From 3443f5573f31271aeb6859ee9497d681943e019c Mon Sep 17 00:00:00 2001 From: "Bradford Hovinen (Gdict maintainer)" Date: Sun, 24 Sep 2000 05:12:08 +0000 Subject: [PATCH] Added new ui properties capplet Fixed typos in the screensaver properties Makefile.am --- ChangeLog | 5 + capplets/Makefile.am | 2 +- capplets/ui-properties/Makefile.am | 42 + capplets/ui-properties/application.desktop | 58 ++ capplets/ui-properties/dialogs.desktop | 29 + capplets/ui-properties/main.c | 208 +++++ capplets/ui-properties/mdi.desktop | 26 + capplets/ui-properties/preferences.c | 855 ++++++++++++++++++ capplets/ui-properties/preferences.h | 128 +++ capplets/ui-properties/prefs-widget-app.c | 113 +++ capplets/ui-properties/prefs-widget-app.h | 54 ++ capplets/ui-properties/prefs-widget-dialogs.c | 111 +++ capplets/ui-properties/prefs-widget-dialogs.h | 54 ++ capplets/ui-properties/prefs-widget-mdi.c | 105 +++ capplets/ui-properties/prefs-widget-mdi.h | 54 ++ capplets/ui-properties/prefs-widget.c | 429 +++++++++ capplets/ui-properties/prefs-widget.h | 97 ++ capplets/ui-properties/ui-properties.glade | 747 +++++++++++++++ 18 files changed, 3116 insertions(+), 1 deletion(-) create mode 100644 capplets/ui-properties/Makefile.am create mode 100644 capplets/ui-properties/application.desktop create mode 100644 capplets/ui-properties/dialogs.desktop create mode 100644 capplets/ui-properties/main.c create mode 100644 capplets/ui-properties/mdi.desktop create mode 100644 capplets/ui-properties/preferences.c create mode 100644 capplets/ui-properties/preferences.h create mode 100644 capplets/ui-properties/prefs-widget-app.c create mode 100644 capplets/ui-properties/prefs-widget-app.h create mode 100644 capplets/ui-properties/prefs-widget-dialogs.c create mode 100644 capplets/ui-properties/prefs-widget-dialogs.h create mode 100644 capplets/ui-properties/prefs-widget-mdi.c create mode 100644 capplets/ui-properties/prefs-widget-mdi.h create mode 100644 capplets/ui-properties/prefs-widget.c create mode 100644 capplets/ui-properties/prefs-widget.h create mode 100644 capplets/ui-properties/ui-properties.glade diff --git a/ChangeLog b/ChangeLog index 96e0aea30..90240cd04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-09-24 Bradford Hovinen + + * capplets/Makefile.am (always_built_SUBDIRS): Change + ui-properties to new-ui-properties + 2000-09-12 Bradford Hovinen * configure.in (CFLAGS): Set CFLAGS to -O2 -g -Wall by default diff --git a/capplets/Makefile.am b/capplets/Makefile.am index d0c804087..94f9cf570 100644 --- a/capplets/Makefile.am +++ b/capplets/Makefile.am @@ -1,7 +1,7 @@ always_built_SUBDIRS = desktop-links new-mouse-properties \ new-screensaver-properties new-background-properties \ theme-switcher sound-properties new-bell-properties \ - ui-properties url-properties gnome-edit-properties \ + new-ui-properties url-properties gnome-edit-properties \ session-properties wm-properties new-keyboard-properties \ mime-type diff --git a/capplets/ui-properties/Makefile.am b/capplets/ui-properties/Makefile.am new file mode 100644 index 000000000..e9e6f4bad --- /dev/null +++ b/capplets/ui-properties/Makefile.am @@ -0,0 +1,42 @@ +Applicationsdir = $(datadir)/control-center/Desktop +Applications_DATA = \ + application.desktop + dialogs.desktop + mdi.desktop + +Gladedir = $(datadir)/control-center-data +Glade_DATA = \ + ui-properties.glade + +EXTRA_DIST = ChangeLog $(Applications_DATA) $(Glade_DATA) + +INCLUDES = \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + -DGNOME_ICONDIR=\""${prefix}/share/pixmaps"\" \ + -DG_LOG_DOMAIN=\"ui-properties\" \ + -DGLADE_DATADIR=\""$(Gladedir)"\" \ + $(GNOME_INCLUDEDIR) \ + $(XML_CFLAGS) \ + $(LIBGLADE_CFLAGS) \ + -I$(top_srcdir)/ \ + -I$(top_srcdir)/intl \ + -I$(top_srcdir)/libcapplet + +bin_PROGRAMS = ui-properties-capplet + +ui_properties_capplet_SOURCES = \ + prefs-widget.c prefs-widget.h \ + prefs-widget-app.c prefs-widget-app.h \ + prefs-widget-dialogs.c prefs-widget-dialogs.h \ + prefs-widget-mdi.c prefs-widget-mdi.h \ + preferences.c preferences.h \ + main.c + +ui_properties_capplet_LDADD = \ + $(GNOME_LIBDIR) \ + $(GNOMEUI_LIBS) \ + $(ORBIT_LIBS) \ + $(GNOME_XML_LIB) \ + $(LIBGLADE_LIBS) \ + -lgdk_pixbuf \ + ../../libcapplet/libcapplet.la diff --git a/capplets/ui-properties/application.desktop b/capplets/ui-properties/application.desktop new file mode 100644 index 000000000..3aed47051 --- /dev/null +++ b/capplets/ui-properties/application.desktop @@ -0,0 +1,58 @@ +[Desktop Entry] +Name=Applications +Name[ca]=Aplicacions +Name[cs]=Vzhled aplikací +Name[da]=Applikationer +Name[de]=Anwendungen +Name[el]=ÅöáñìïãÝò +Name[es]=Aplicación +Name[et]=Rakendused +Name[fi]=Sovellusoletukset +Name[fr]=Applications +Name[gl]=Aplicación +Name[ga]=Fograiocht +Name[hu]=Alkalmazások +Name[it]=Applicazioni +Name[ja]=¥¢¥×¥ê¥±¡¼¥·¥ç¥ó +Name[ko]=ÀÀ¿ë ÇÁ·Î±×·¥ ±âº»»çÇ× +Name[lt]=Programos +Name[no]=Applikasjoner +Name[pl]=Aplikacje +Name[pt]=Aplicações +Name[ru]=ðÒÉÌÏÖÅÎÉÑ +Name[sl]=Aplikacije +Name[sv]=Applikation +Name[uk]=ðÒÏÇÒÁÍÉ +Name[wa]=Programes +Name[zh_TW.Big5]=À³¥Îµ{¦¡ªº¹w³]­È +Name[zh_CN.GB2312]=Ó¦ÓóÌʽµÄÔ¤ÉèÖµ +Comment=Sets the default feel of GNOME applications. +Comment[ca]=Establir el comportament de les aplicacions de GNOME. +Comment[cs]=Zmìny standardního vzhledu aplikací Gnome. +Comment[da]=Indstil hvordan Gnome-programmer føles at bruge. +Comment[de]=Richtet das normale Verhalten von GNOME-Anwendungen ein. +Comment[el]=ÈÝôåé ôï åî' ïñéóìïý áßóèçìá ôùí åöáñìïãþí ôïõ GNOME +Comment[es]=Configuración del comportamiento de las aplicaciones Gnome. +Comment[et]=Määrab GNOME rakendusprogrammide väljanägemise +Comment[fi]=Asettaa GNOME-sovellusten oletustoiminnallisuutta. +Comment[fr]=Configuration du comportement des applications GNOME +Comment[gl]=Configurar o aspecto por defecto das aplicacións de GNOME. +Comment[hu]=Alkalmazások megjelenésének meghatározása +Comment[it]=Imposta il comportamento di default delle applicazioni GNOME +Comment[ja]=GNOME¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Îɸ½àŪ¤ÊÁàºî·Ï¤òÀßÄꤷ¤Þ¤¹¡£ +Comment[ko]=±×³ð ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ±âº» »çÇ× °áÁ¤ +Comment[lt]=Nustato áprastà GNOME programø pojûtá +Comment[no]=Setter standard oppførsel for GNOME applikasjoner. +Comment[pl]=Ustawia domy¶lne zachowanie siê aplikacji GNOME +Comment[pt]=Configurar o comportamento por omissão das aplicações GNOME. +Comment[ru]=ïÐÒÅÄÅÌÉÔØ ×ÎÅÛÎÉÊ ×ÉÄ ÐÒÉÌÏÖÅÎÉÊ GNOME. +Comment[sl]=Nastavi privzet izgled in obna¹anje GNOME aplikacij. +Comment[sv]=Konfigurera hur GNOME-applikationer uppför sig. +Comment[uk]=÷ÓÔÁÎÏ×ÌÅÎÎÑ ÔÉÐÏ×ÏÇÏ ×ÉÇÌÑÄÕ ÐÒÏÇÒÁÍ GNOME. +Comment[wa]=Apontyî kmint les programes GNOME vont ovrer +Comment[zh_TW.Big5]=³]©w GNOME À³¥Îµ{¦¡ªº¹w³]¥~Æ[¡C +Comment[zh_CN.GB2312]=É趨 GNOME Ó¦ÓóÌʽµÄÔ¤ÉèÍâ¹Û¡£ +Exec=ui-properties --cap-id=1 +Icon=gnome-applications.png +Terminal=0 +Type=Application diff --git a/capplets/ui-properties/dialogs.desktop b/capplets/ui-properties/dialogs.desktop new file mode 100644 index 000000000..dc60b7a79 --- /dev/null +++ b/capplets/ui-properties/dialogs.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Name=Dialogs +Name[ca]=Quadres de diàleg +Name[da]=Dialogbokse +Name[de]=Dialogfelder +Name[el]=ÄéÜëïãïé +Name[es]=Diálogos +Name[et]=Dialoogid +Name[fi]=Valintaikkunat +Name[fr]=Dialogues +Name[gl]=Diálogos +Name[hu]=Párbeszédablakok +Name[it]=Finestre di dialogo +Name[ja]=¥À¥¤¥¢¥í¥° +Name[ko]=´ëÈ­»óÀÚ +Name[no]=Dialoger +Name[pl]=Okna dialogowe +Name[pt]=Diálogos +Name[ru]=äÉÁÌÏÇÉ +Name[sl]=Dialogi +Name[sv]=Dialogrutor +Name[tr]=Diyaloklar +Name[uk]=ä¦ÁÌÏÇÉ +Name[wa]=Purneas di dialogue +Comment[fr]=Configuration du comportement des boites de dialogues GNOME +Exec=ui-properties --cap-id=0 +Icon=gnome-ccdialog.png +Terminal=0 +Type=Application diff --git a/capplets/ui-properties/main.c b/capplets/ui-properties/main.c new file mode 100644 index 000000000..1429c99ea --- /dev/null +++ b/capplets/ui-properties/main.c @@ -0,0 +1,208 @@ +/* -*- mode: c; style: linux -*- */ + +/* main.c + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen (hovinen@helixcode.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include + +#include + +#include + +#include "preferences.h" +#include "prefs-widget.h" +#include "prefs-widget-app.h" +#include "prefs-widget-dialogs.h" +#include "prefs-widget-mdi.h" + +static Preferences *prefs; +static Preferences *old_prefs; +static PrefsWidget *prefs_widget; + +static void +ok_cb (GtkWidget *widget) +{ + preferences_save (prefs); +} + +static void +cancel_cb (GtkWidget *widget) +{ + preferences_save (old_prefs); +} + +static void +setup_capplet_widget (void) +{ + preferences_freeze (prefs); + + switch (capplet_widget_class_get_capid ()) { + case 0: + prefs_widget = PREFS_WIDGET (prefs_widget_dialogs_new (prefs)); + break; + case 1: + prefs_widget = PREFS_WIDGET (prefs_widget_app_new (prefs)); + break; + case 2: + prefs_widget = PREFS_WIDGET (prefs_widget_mdi_new (prefs)); + break; + } + + gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok", + GTK_SIGNAL_FUNC (ok_cb), NULL); + gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel", + GTK_SIGNAL_FUNC (cancel_cb), NULL); + + gtk_widget_show_all (GTK_WIDGET (prefs_widget)); + + preferences_thaw (prefs); +} + +static void +do_get_xml (void) +{ + Preferences *prefs; + xmlDocPtr doc; + + prefs = PREFERENCES (preferences_new ()); + preferences_load (prefs); + doc = preferences_write_xml (prefs); + xmlDocDump (stdout, doc); + gtk_object_destroy (GTK_OBJECT (prefs)); +} + +static void +do_set_xml (void) +{ + Preferences *prefs; + xmlDocPtr doc; + char *buffer = NULL; + int len = 0; + + while (!feof (stdin)) { + if (!len) buffer = g_new (char, 16384); + else buffer = g_renew (char, buffer, len + 16384); + fread (buffer + len, 1, 16384, stdin); + len += 16384; + } + + doc = xmlParseMemory (buffer, strlen (buffer)); + + prefs = preferences_read_xml (doc); + + if (prefs) + preferences_save (prefs); + else + g_warning ("Error while reading the screensaver config file"); +} + +int +main (int argc, char **argv) +{ + GnomeClient *client; + GnomeClientFlags flags; + gint token, res; + gchar *restart_args[3]; + + bindtextdomain (PACKAGE, GNOMELOCALEDIR); + textdomain (PACKAGE); + + glade_gnome_init (); + res = gnome_capplet_init ("ui-properties", + VERSION, argc, argv, NULL, + 0, NULL); + + if (res < 0) { + g_error ("Could not initialize the capplet."); + } + else if (res == 3) { + do_get_xml (); + return 0; + } + else if (res == 4) { + do_set_xml (); + return 0; + } + + client = gnome_master_client (); + flags = gnome_client_get_flags (client); + + if (flags & GNOME_CLIENT_IS_CONNECTED) { + token = gnome_startup_acquire_token + ("GNOME_UI_PROPERTIES", + gnome_client_get_id (client)); + + if (token) { + gnome_client_set_priority (client, 20); + gnome_client_set_restart_style (client, + GNOME_RESTART_ANYWAY); + restart_args[0] = argv[0]; + restart_args[1] = "--init-session-settings"; + restart_args[2] = NULL; + gnome_client_set_restart_command (client, 2, + restart_args); + } else { + gnome_client_set_restart_style (client, + GNOME_RESTART_NEVER); + } + } else { + token = 1; + } + + switch (capplet_widget_class_get_capid ()) { + case 0: + gnome_window_icon_set_default_from_file + (GNOME_ICONDIR"/gnome-ccdialog.png"); + break; + case 1: + gnome_window_icon_set_default_from_file + (GNOME_ICONDIR"/gnome-applications.png"); + break; + case 2: + gnome_window_icon_set_default_from_file + (GNOME_ICONDIR"/gnome-mdi.png"); + break; + } + + prefs = PREFERENCES (preferences_new ()); + preferences_load (prefs); + + if (token) { + preferences_apply_now (prefs); + } + + if (!res) { + old_prefs = PREFERENCES (preferences_clone (prefs)); + setup_capplet_widget (); + + capplet_gtk_main (); + } + + return 0; +} diff --git a/capplets/ui-properties/mdi.desktop b/capplets/ui-properties/mdi.desktop new file mode 100644 index 000000000..479444af8 --- /dev/null +++ b/capplets/ui-properties/mdi.desktop @@ -0,0 +1,26 @@ +[Desktop Entry] +Name=MDI +Name[ca]=Multidocument +Name[da]=Multidokument +Name[de]=Multi-Dokument-Interface +Name[el]=Ðïëý-ÍôïêïõìÝíôï +Name[es]=Multidocumento +Name[et]=Multidokument +Name[fi]=Usean asiakirjan käyttö +Name[fr]=Multidocument +Name[gl]=Multi-Documento +Name[ja]=MDI +Name[ko]=¿©·¯¹®¼­ +Name[no]=MDI +Name[pl]=MDI +Name[pt]=MDI +Name[sl]=MDI (Veèdokumentni vmesnik) +Name[sv]=MDI +Name[tr]=ÇDY +Name[uk]=MDI +Name[wa]=Eterface multi-documints (MDI) +Comment[fr]=Configuration du comportement des applications multidocument GNOME +Exec=ui-properties --cap-id=2 +Icon=gnome-mdi.png +Terminal=0 +Type=Application diff --git a/capplets/ui-properties/preferences.c b/capplets/ui-properties/preferences.c new file mode 100644 index 000000000..8cefe00f5 --- /dev/null +++ b/capplets/ui-properties/preferences.c @@ -0,0 +1,855 @@ +/* -*- mode: c; style: linux -*- */ + +/* preferences.c + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include + +#include "preferences.h" + +static GtkObjectClass *parent_class; + +static void preferences_init (Preferences *prefs); +static void preferences_class_init (PreferencesClass *class); + +static gint xml_read_int (xmlNodePtr node, + gchar *propname); +static xmlNodePtr xml_write_int (gchar *name, + gchar *propname, + gint number); + +static gint apply_timeout_cb (Preferences *prefs); + +guint +preferences_get_type (void) +{ + static guint preferences_type = 0; + + if (!preferences_type) { + GtkTypeInfo preferences_info = { + "Preferences", + sizeof (Preferences), + sizeof (PreferencesClass), + (GtkClassInitFunc) preferences_class_init, + (GtkObjectInitFunc) preferences_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + preferences_type = + gtk_type_unique (gtk_object_get_type (), + &preferences_info); + } + + return preferences_type; +} + +static void +preferences_init (Preferences *prefs) +{ + prefs->frozen = FALSE; + prefs->gnome_prefs = g_new0 (GnomePreferences, 1); +} + +static void +preferences_class_init (PreferencesClass *class) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass *) class; + object_class->destroy = preferences_destroy; + + parent_class = + GTK_OBJECT_CLASS (gtk_type_class (gtk_object_get_type ())); +} + +GtkObject * +preferences_new (void) +{ + GtkObject *object; + + object = gtk_type_new (preferences_get_type ()); + + return object; +} + +GtkObject * +preferences_clone (Preferences *prefs) +{ + GtkObject *object; + Preferences *new_prefs; + + g_return_val_if_fail (prefs != NULL, NULL); + g_return_val_if_fail (IS_PREFERENCES (prefs), NULL); + g_return_val_if_fail (prefs->gnome_prefs != NULL, NULL); + + object = preferences_new (); + + new_prefs = PREFERENCES (object); + memcpy (new_prefs->gnome_prefs, prefs->gnome_prefs, + sizeof (GnomePreferences)); + + return object; +} + +void +preferences_destroy (GtkObject *object) +{ + Preferences *prefs; + + g_return_if_fail (object != NULL); + g_return_if_fail (IS_PREFERENCES (object)); + + prefs = PREFERENCES (object); + + if (prefs->gnome_prefs) g_free (prefs->gnome_prefs); + + parent_class->destroy (object); +} + +void +preferences_load (Preferences *prefs) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + gnome_preferences_load_custom (prefs->gnome_prefs); + + prefs->dialog_use_icons = + gnome_config_get_bool ("/Gnome/Icons/ButtonUseIcons=true"); +} + +void +preferences_save (Preferences *prefs) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + gnome_preferences_save_custom (prefs->gnome_prefs); + + gnome_config_set_bool ("/Gnome/Icons/ButtonUseIcons", + prefs->dialog_use_icons); + gnome_config_sync (); +} + +void +preferences_changed (Preferences *prefs) +{ + if (prefs->frozen) return; + + if (prefs->timeout_id) + gtk_timeout_remove (prefs->timeout_id); +} + +void +preferences_apply_now (Preferences *prefs) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + + if (prefs->timeout_id) + gtk_timeout_remove (prefs->timeout_id); + + prefs->timeout_id = 0; + + preferences_save (prefs); +} + +void +preferences_freeze (Preferences *prefs) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + + prefs->frozen = TRUE; +} + +void +preferences_thaw (Preferences *prefs) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + + prefs->frozen = FALSE; +} + +Preferences * +preferences_read_xml (xmlDocPtr xml_doc) +{ + Preferences *prefs; + xmlNodePtr root_node, node; + + prefs = PREFERENCES (preferences_new ()); + + root_node = xmlDocGetRootElement (xml_doc); + + if (strcmp (root_node->name, "ui-properties")) + return NULL; + + for (node = root_node->childs; node; node = node->next) { + if (!strcmp (node->name, "dialog-buttons-style")) + prefs->gnome_prefs->dialog_buttons_style = + xml_read_int (node, "style"); + else if (!strcmp (node->name, "property-box-buttons-ok")) + prefs->gnome_prefs->property_box_buttons_ok = TRUE; + else if (!strcmp (node->name, "property-box-buttons-apply")) + prefs->gnome_prefs->property_box_buttons_apply = TRUE; + else if (!strcmp (node->name, "property-box-buttons-close")) + prefs->gnome_prefs->property_box_buttons_close = TRUE; + else if (!strcmp (node->name, "property-box-buttons-help")) + prefs->gnome_prefs->property_box_buttons_help = TRUE; + else if (!strcmp (node->name, "statusbar-not-dialog")) + prefs->gnome_prefs->statusbar_not_dialog = TRUE; + else if (!strcmp (node->name, "statusbar-is-interactive")) + prefs->gnome_prefs->statusbar_is_interactive = TRUE; + else if (!strcmp (node->name, "statusbar-meter-on-right")) + prefs->gnome_prefs->statusbar_meter_on_right = TRUE; + else if (!strcmp (node->name, "menubar-detachable")) + prefs->gnome_prefs->menubar_detachable = TRUE; + else if (!strcmp (node->name, "menubar-relief")) + prefs->gnome_prefs->menubar_relief = TRUE; + else if (!strcmp (node->name, "toolbar-detachable")) + prefs->gnome_prefs->toolbar_detachable = TRUE; + else if (!strcmp (node->name, "toolbar-relief")) + prefs->gnome_prefs->toolbar_relief = TRUE; + else if (!strcmp (node->name, "toolbar-relief-btn")) + prefs->gnome_prefs->toolbar_relief_btn = TRUE; + else if (!strcmp (node->name, "toolbar-lines")) + prefs->gnome_prefs->toolbar_lines = TRUE; + else if (!strcmp (node->name, "toolbar-labels")) + prefs->gnome_prefs->toolbar_labels = TRUE; + else if (!strcmp (node->name, "dialog-centered")) + prefs->gnome_prefs->dialog_centered = TRUE; + else if (!strcmp (node->name, "menus-have-tearoff")) + prefs->gnome_prefs->menus_have_tearoff = TRUE; + else if (!strcmp (node->name, "menus-have-icons")) + prefs->gnome_prefs->menus_have_icons = TRUE; + else if (!strcmp (node->name, "disable-imlib-cache")) + prefs->gnome_prefs->disable_imlib_cache = TRUE; + else if (!strcmp (node->name, "dialog-type")) + prefs->gnome_prefs->dialog_type = + xml_read_int (node, "type"); + else if (!strcmp (node->name, "dialog-position")) + prefs->gnome_prefs->dialog_position = + xml_read_int (node, "position"); + else if (!strcmp (node->name, "mdi-mode")) + prefs->gnome_prefs->mdi_mode = + xml_read_int (node, "mode"); + else if (!strcmp (node->name, "mdi-tab-pos")) + prefs->gnome_prefs->mdi_tab_pos = + xml_read_int (node, "pos"); + else if (!strcmp (node->name, "dialog-use-icons")) + prefs->dialog_use_icons = TRUE; + } + + return prefs; +} + +xmlDocPtr +preferences_write_xml (Preferences *prefs) +{ + xmlDocPtr doc; + xmlNodePtr node; + + doc = xmlNewDoc ("1.0"); + + node = xmlNewDocNode (doc, NULL, "ui-properties", NULL); + + xmlAddChild (node, + xml_write_int ("dialog-buttons-style", "style", + prefs->gnome_prefs->dialog_buttons_style)); + + if (prefs->gnome_prefs->property_box_buttons_ok) + xmlNewChild (node, NULL, "property-box-buttons-ok", NULL); + if (prefs->gnome_prefs->property_box_buttons_apply) + xmlNewChild (node, NULL, "property-box-buttons-apply", NULL); + if (prefs->gnome_prefs->property_box_buttons_close) + xmlNewChild (node, NULL, "property-box-buttons-close", NULL); + if (prefs->gnome_prefs->property_box_buttons_help) + xmlNewChild (node, NULL, "property-box-buttons-help", NULL); + if (prefs->gnome_prefs->statusbar_not_dialog) + xmlNewChild (node, NULL, "statusbar-not-dialog", NULL); + if (prefs->gnome_prefs->statusbar_is_interactive) + xmlNewChild (node, NULL, "statusbar-is-interactive", NULL); + if (prefs->gnome_prefs->statusbar_meter_on_right) + xmlNewChild (node, NULL, "statusbar-meter-on-right", NULL); + if (prefs->gnome_prefs->menubar_detachable) + xmlNewChild (node, NULL, "menubar-detachable", NULL); + if (prefs->gnome_prefs->menubar_relief) + xmlNewChild (node, NULL, "menubar-relief", NULL); + if (prefs->gnome_prefs->toolbar_detachable) + xmlNewChild (node, NULL, "toolbar-detachable", NULL); + if (prefs->gnome_prefs->toolbar_relief) + xmlNewChild (node, NULL, "toolbar-relief", NULL); + if (prefs->gnome_prefs->toolbar_relief_btn) + xmlNewChild (node, NULL, "toolbar-relief-btn", NULL); + if (prefs->gnome_prefs->toolbar_lines) + xmlNewChild (node, NULL, "toolbar-lines", NULL); + if (prefs->gnome_prefs->toolbar_labels) + xmlNewChild (node, NULL, "toolbar-labels", NULL); + if (prefs->gnome_prefs->dialog_centered) + xmlNewChild (node, NULL, "dialog-centered", NULL); + if (prefs->gnome_prefs->menus_have_tearoff) + xmlNewChild (node, NULL, "menus-have-tearoff", NULL); + if (prefs->gnome_prefs->menus_have_icons) + xmlNewChild (node, NULL, "menus-have-icons", NULL); + if (prefs->gnome_prefs->disable_imlib_cache) + xmlNewChild (node, NULL, "disable-imlib-cache", NULL); + + xmlAddChild (node, + xml_write_int ("dialog-type", "type", + prefs->gnome_prefs->dialog_type)); + xmlAddChild (node, + xml_write_int ("dialog-position", "position", + prefs->gnome_prefs->dialog_position)); + xmlAddChild (node, + xml_write_int ("mdi-mode", "mode", + prefs->gnome_prefs->mdi_mode)); + xmlAddChild (node, + xml_write_int ("mdi-tab-pos", "pos", + prefs->gnome_prefs->mdi_tab_pos)); + + if (prefs->dialog_use_icons) + xmlNewChild (node, NULL, "dialog-use-icons", NULL); + + xmlDocSetRootElement (doc, node); + + return doc; +} + +/* Read a numeric value from a node */ + +static gint +xml_read_int (xmlNodePtr node, char *propname) +{ + char *text; + + if (propname == NULL) + text = xmlNodeGetContent (node); + else + text = xmlGetProp (node, propname); + + if (text == NULL) + return 0; + else + return atoi (text); +} + +/* Write out a numeric value in a node */ + +static xmlNodePtr +xml_write_int (gchar *name, gchar *propname, gint number) +{ + xmlNodePtr node; + gchar *str; + + g_return_val_if_fail (name != NULL, NULL); + + str = g_strdup_printf ("%d", number); + + node = xmlNewNode (NULL, name); + + if (propname == NULL) + xmlNodeSetContent (node, str); + else + xmlSetProp (node, propname, str); + + g_free (str); + + return node; +} + +static gint +apply_timeout_cb (Preferences *prefs) +{ + preferences_apply_now (prefs); + + return TRUE; +} + +GtkButtonBoxStyle +preferences_get_dialog_buttons_style (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->dialog_buttons_style; +} + +int +preferences_get_property_box_buttons_ok (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->property_box_buttons_ok; +} + +int +preferences_get_property_box_buttons_apply (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->property_box_buttons_apply; +} + +int +preferences_get_property_box_buttons_close (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->property_box_buttons_close; +} + +int +preferences_get_property_box_buttons_help (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->property_box_buttons_help; +} + +int +preferences_get_statusbar_not_dialog (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->statusbar_not_dialog; +} + +int +preferences_get_statusbar_is_interactive (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->statusbar_is_interactive; +} + +int +preferences_get_statusbar_meter_on_right (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->statusbar_meter_on_right; +} + +int +preferences_get_menubar_detachable (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->menubar_detachable; +} + +int +preferences_get_menubar_relief (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->menubar_relief; +} + +int +preferences_get_toolbar_detachable (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->toolbar_detachable; +} + +int +preferences_get_toolbar_relief (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->toolbar_relief; +} + +int +preferences_get_toolbar_relief_btn (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->toolbar_relief_btn; +} + +int +preferences_get_toolbar_lines (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->toolbar_lines; +} + +int +preferences_get_toolbar_labels (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->toolbar_labels; +} + +int +preferences_get_dialog_centered (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->dialog_centered; +} + +int +preferences_get_menus_have_tearoff (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->menus_have_tearoff; +} + +int +preferences_get_menus_have_icons (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->menus_have_icons; +} + +int +preferences_get_disable_imlib_cache (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->disable_imlib_cache; +} + +GtkWindowType +preferences_get_dialog_type (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->dialog_type; +} + +GtkWindowPosition +preferences_get_dialog_position (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->dialog_position; +} + +GnomeMDIMode +preferences_get_mdi_mode (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->mdi_mode; +} + +GtkPositionType +preferences_get_mdi_tab_pos (Preferences *prefs) +{ + g_return_val_if_fail (prefs != NULL, 0); + g_return_val_if_fail (IS_PREFERENCES (prefs), 0); + g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); + + return prefs->gnome_prefs->mdi_tab_pos; +} + +void +preferences_set_dialog_buttons_style (Preferences *prefs, + GtkButtonBoxStyle style) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->dialog_buttons_style = style; +} + +void +preferences_set_property_box_buttons_ok (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->property_box_buttons_ok = s; +} + +void +set_property_set_property_box_buttons_apply (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->property_box_buttons_apply = s; +} + +void +preferences_set_property_box_buttons_close (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->property_box_buttons_close = s; +} + +void +preferences_set_property_box_buttons_help (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->property_box_buttons_help = s; +} + +void +preferences_set_statusbar_not_dialog (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->statusbar_not_dialog = s; +} + +void +preferences_set_statusbar_is_interactive (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->statusbar_is_interactive = s; +} + +void +preferences_set_statusbar_meter_on_right (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->statusbar_meter_on_right = s; +} + +void +preferences_set_menubar_detachable (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->menubar_detachable = s; +} + +void +preferences_set_menubar_relief (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->menubar_relief = s; +} + +void +preferences_set_toolbar_detachable (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->toolbar_detachable = s; +} + +void +preferences_set_toolbar_relief (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->toolbar_relief = s; +} + +void +preferences_set_toolbar_relief_btn (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->toolbar_relief_btn = s; +} + +void +preferences_set_toolbar_lines (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->toolbar_lines = s; +} + +void +preferences_set_toolbar_labels (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->toolbar_labels = s; +} + +void +preferences_set_dialog_centered (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->dialog_centered = s; +} + +void +preferences_set_menus_have_tearoff (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->menus_have_tearoff = s; +} + +void +preferences_set_menus_have_icons (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->menus_have_icons = s; +} + +void +preferences_set_disable_imlib_cache (Preferences *prefs, int s) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->disable_imlib_cache = s; +} + +void +preferences_set_dialog_type (Preferences *prefs, GtkWindowType type) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->dialog_type = type; +} + +void +preferences_set_dialog_position (Preferences *prefs, GtkWindowPosition pos) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->dialog_position = pos; +} + +void +preferences_set_mdi_mode (Preferences *prefs, GnomeMDIMode mode) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->mdi_mode = mode; +} + +void +preferences_set_mdi_tab_pos (Preferences *prefs, GtkPositionType type) +{ + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + g_return_if_fail (prefs->gnome_prefs != NULL); + + prefs->gnome_prefs->mdi_tab_pos = type; +} diff --git a/capplets/ui-properties/preferences.h b/capplets/ui-properties/preferences.h new file mode 100644 index 000000000..2c56c097d --- /dev/null +++ b/capplets/ui-properties/preferences.h @@ -0,0 +1,128 @@ +/* -*- mode: c; style: linux -*- */ + +/* preferences.h + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef __PREFERENCES_H +#define __PREFERENCES_H + +#include +#include + +#include + +#define PREFERENCES(obj) GTK_CHECK_CAST (obj, preferences_get_type (), Preferences) +#define PREFERENCES_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, preferences_get_type (), PreferencesClass) +#define IS_PREFERENCES(obj) GTK_CHECK_TYPE (obj, preferences_get_type ()) + +typedef struct _Preferences Preferences; +typedef struct _PreferencesClass PreferencesClass; + +struct _Preferences +{ + GtkObject object; + + gboolean frozen; + guint timeout_id; + + GnomePreferences *gnome_prefs; + + gboolean dialog_use_icons; +}; + +struct _PreferencesClass +{ + GtkObjectClass klass; +}; + +guint preferences_get_type (void); + +GtkObject *preferences_new (void); +GtkObject *preferences_clone (Preferences *prefs); +void preferences_destroy (GtkObject *object); + +void preferences_load (Preferences *prefs); +void preferences_save (Preferences *prefs); +void preferences_changed (Preferences *prefs); +void preferences_apply_now (Preferences *prefs); + +void preferences_freeze (Preferences *prefs); +void preferences_thaw (Preferences *prefs); + +Preferences *preferences_read_xml (xmlDocPtr xml_doc); +xmlDocPtr preferences_write_xml (Preferences *prefs); + +/* get/set functions. It's really stupid that we need these */ + +GtkButtonBoxStyle preferences_get_dialog_buttons_style (Preferences *prefs); +int preferences_get_property_box_buttons_ok (Preferences *prefs); +int preferences_get_property_box_buttons_apply (Preferences *prefs); +int preferences_get_property_box_buttons_close (Preferences *prefs); +int preferences_get_property_box_buttons_help (Preferences *prefs); +int preferences_get_statusbar_not_dialog (Preferences *prefs); +int preferences_get_statusbar_is_interactive (Preferences *prefs); +int preferences_get_statusbar_meter_on_right (Preferences *prefs); +int preferences_get_menubar_detachable (Preferences *prefs); +int preferences_get_menubar_relief (Preferences *prefs); +int preferences_get_toolbar_detachable (Preferences *prefs); +int preferences_get_toolbar_relief (Preferences *prefs); +int preferences_get_toolbar_relief_btn (Preferences *prefs); +int preferences_get_toolbar_lines (Preferences *prefs); +int preferences_get_toolbar_labels (Preferences *prefs); +int preferences_get_dialog_centered (Preferences *prefs); +int preferences_get_menus_have_tearoff (Preferences *prefs); +int preferences_get_menus_have_icons (Preferences *prefs); +int preferences_get_disable_imlib_cache (Preferences *prefs); +GtkWindowType preferences_get_dialog_type (Preferences *prefs); +GtkWindowPosition preferences_get_dialog_position (Preferences *prefs); +GnomeMDIMode preferences_get_mdi_mode (Preferences *prefs); +GtkPositionType preferences_get_mdi_tab_pos (Preferences *prefs); + +void preferences_set_dialog_buttons_style (Preferences *prefs, + GtkButtonBoxStyle); +void preferences_set_property_box_buttons_ok (Preferences *prefs, int); +void preferences_set_property_box_buttons_apply (Preferences *prefs, int); +void preferences_set_property_box_buttons_close (Preferences *prefs, int); +void preferences_set_property_box_buttons_help (Preferences *prefs, int); +void preferences_set_statusbar_not_dialog (Preferences *prefs, int); +void preferences_set_statusbar_is_interactive (Preferences *prefs, int); +void preferences_set_statusbar_meter_on_right (Preferences *prefs, int); +void preferences_set_menubar_detachable (Preferences *prefs, int); +void preferences_set_menubar_relief (Preferences *prefs, int); +void preferences_set_toolbar_detachable (Preferences *prefs, int); +void preferences_set_toolbar_relief (Preferences *prefs, int); +void preferences_set_toolbar_relief_btn (Preferences *prefs, int); +void preferences_set_toolbar_lines (Preferences *prefs, int); +void preferences_set_toolbar_labels (Preferences *prefs, int); +void preferences_set_dialog_centered (Preferences *prefs, int); +void preferences_set_menus_have_tearoff (Preferences *prefs, int); +void preferences_set_menus_have_icons (Preferences *prefs, int); +void preferences_set_disable_imlib_cache (Preferences *prefs, int); +void preferences_set_dialog_type (Preferences *prefs, + GtkWindowType); +void preferences_set_dialog_position (Preferences *prefs, + GtkWindowPosition); +void preferences_set_mdi_mode (Preferences *prefs, + GnomeMDIMode); +void preferences_set_mdi_tab_pos (Preferences *prefs, + GtkPositionType); + +#endif /* __PREFERENCES_H */ diff --git a/capplets/ui-properties/prefs-widget-app.c b/capplets/ui-properties/prefs-widget-app.c new file mode 100644 index 000000000..099b8eb83 --- /dev/null +++ b/capplets/ui-properties/prefs-widget-app.c @@ -0,0 +1,113 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget-app.c + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "prefs-widget-app.h" + +#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) + +static PrefsWidgetClass *parent_class; + +static widget_desc_t widget_desc[] = { + WD_CHECK (menubar_detachable, "menubar_detachable"), + WD_CHECK (menubar_relief, "menubar_relief"), + WD_CHECK (menus_have_tearoff, "menus_have_tearoff"), + WD_CHECK (menus_have_icons, "menus_have_icons"), + WD_CHECK (statusbar_is_interactive, "statusbar_is_interactive"), + WD_CHECK (statusbar_meter_on_right, "statusbar_meter_on_right"), + WD_CHECK (toolbar_detachable, "toolbar_detachable"), + WD_CHECK (toolbar_relief, "toolbar_relief"), + WD_CHECK (toolbar_relief_btn, "toolbar_relief_btn"), + WD_CHECK (toolbar_lines, "toolbar_lines"), + WD_CHECK (toolbar_labels, "toolbar_labels"), + WD_END +}; + +static void prefs_widget_app_init (PrefsWidgetApp *prefs_widget_app); +static void prefs_widget_app_class_init (PrefsWidgetAppClass *class); + +guint +prefs_widget_app_get_type (void) +{ + static guint prefs_widget_app_type = 0; + + if (!prefs_widget_app_type) { + GtkTypeInfo prefs_widget_app_info = { + "PrefsWidgetApp", + sizeof (PrefsWidgetApp), + sizeof (PrefsWidgetAppClass), + (GtkClassInitFunc) prefs_widget_app_class_init, + (GtkObjectInitFunc) prefs_widget_app_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + prefs_widget_app_type = + gtk_type_unique (prefs_widget_get_type (), + &prefs_widget_app_info); + } + + return prefs_widget_app_type; +} + +static void +prefs_widget_app_init (PrefsWidgetApp *prefs_widget_app) +{ +} + +static void +prefs_widget_app_class_init (PrefsWidgetAppClass *class) +{ + PrefsWidgetClass *prefs_widget_class; + + prefs_widget_class = PREFS_WIDGET_CLASS (class); + prefs_widget_class->widget_desc = widget_desc; + + parent_class = PREFS_WIDGET_CLASS + (gtk_type_class (prefs_widget_get_type ())); +} + +GtkWidget * +prefs_widget_app_new (Preferences *prefs) +{ + GtkWidget *widget, *dlg_widget; + GladeXML *dialog_data; + + g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); + + dialog_data = glade_xml_new (GLADE_DATADIR "/ui-properties.glade", + "prefs_widget_app"); + + widget = gtk_widget_new (prefs_widget_app_get_type (), + "dialog_data", dialog_data, + "preferences", prefs, + NULL); + + dlg_widget = glade_xml_get_widget (dialog_data, "prefs_widget_app"); + gtk_container_add (GTK_CONTAINER (widget), dlg_widget); + + return widget; +} diff --git a/capplets/ui-properties/prefs-widget-app.h b/capplets/ui-properties/prefs-widget-app.h new file mode 100644 index 000000000..4a71318c1 --- /dev/null +++ b/capplets/ui-properties/prefs-widget-app.h @@ -0,0 +1,54 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget-app.h + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef __PREFS_WIDGET_APP_H +#define __PREFS_WIDGET_APP_H + +#include +#include + +#include "preferences.h" +#include "prefs-widget.h" + +#define PREFS_WIDGET_APP(obj) GTK_CHECK_CAST (obj, prefs_widget_app_get_type (), PrefsWidgetApp) +#define PREFS_WIDGET_APP_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_app_get_type (), PrefsWidgetAppClass) +#define IS_PREFS_WIDGET_APP(obj) GTK_CHECK_TYPE (obj, prefs_widget_app_get_type ()) + +typedef struct _PrefsWidgetApp PrefsWidgetApp; +typedef struct _PrefsWidgetAppClass PrefsWidgetAppClass; + +struct _PrefsWidgetApp +{ + PrefsWidget prefs_widget; +}; + +struct _PrefsWidgetAppClass +{ + PrefsWidgetClass parent_class; +}; + +guint prefs_widget_app_get_type (void); + +GtkWidget *prefs_widget_app_new (Preferences *prefs); + +#endif /* __PREFS_WIDGET_APP_H */ diff --git a/capplets/ui-properties/prefs-widget-dialogs.c b/capplets/ui-properties/prefs-widget-dialogs.c new file mode 100644 index 000000000..b7632b5c0 --- /dev/null +++ b/capplets/ui-properties/prefs-widget-dialogs.c @@ -0,0 +1,111 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget-dialogs.c + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "prefs-widget-dialogs.h" + +#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) + +static PrefsWidgetClass *parent_class; + +static widget_desc_t widget_desc[] = { + WD_OPTION (dialog_buttons_style, "dialog_buttons_style"), + WD_CHECK (statusbar_not_dialog, "statusbar_not_dialog"), + WD_OPTION (dialog_position, "dialog_position"), + WD_OPTION (dialog_type, "dialog_type"), + WD_CHECK (dialog_centered, "dialog_centered"), + { WDTYPE_CHECK, "dialog_icons_toggle", NULL, NULL, + GTK_STRUCT_OFFSET (Preferences, dialog_use_icons) }, + WD_END +}; + +static void prefs_widget_dialogs_init (PrefsWidgetDialogs *prefs_widget_dlgs); +static void prefs_widget_dialogs_class_init (PrefsWidgetDialogsClass *class); + +guint +prefs_widget_dialogs_get_type (void) +{ + static guint prefs_widget_dialogs_type = 0; + + if (!prefs_widget_dialogs_type) { + GtkTypeInfo prefs_widget_dialogs_info = { + "PrefsWidgetDialogs", + sizeof (PrefsWidgetDialogs), + sizeof (PrefsWidgetDialogsClass), + (GtkClassInitFunc) prefs_widget_dialogs_class_init, + (GtkObjectInitFunc) prefs_widget_dialogs_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + prefs_widget_dialogs_type = + gtk_type_unique (prefs_widget_get_type (), + &prefs_widget_dialogs_info); + } + + return prefs_widget_dialogs_type; +} + +static void +prefs_widget_dialogs_init (PrefsWidgetDialogs *prefs_widget_dialogs) +{ +} + +static void +prefs_widget_dialogs_class_init (PrefsWidgetDialogsClass *class) +{ + PrefsWidgetClass *prefs_widget_class; + + prefs_widget_class = PREFS_WIDGET_CLASS (class); + prefs_widget_class->widget_desc = widget_desc; + + parent_class = PREFS_WIDGET_CLASS + (gtk_type_class (prefs_widget_get_type ())); +} + +GtkWidget * +prefs_widget_dialogs_new (Preferences *prefs) +{ + GtkWidget *widget, *dlg_widget; + GladeXML *dialog_data; + + g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); + + dialog_data = + glade_xml_new (GLADE_DATADIR "/ui-properties.glade", + "prefs_widget_dialogs"); + + widget = gtk_widget_new (prefs_widget_dialogs_get_type (), + "dialog_data", dialog_data, + "preferences", prefs, + NULL); + + dlg_widget = glade_xml_get_widget (dialog_data, + "prefs_widget_dialogs"); + gtk_container_add (GTK_CONTAINER (widget), dlg_widget); + + return widget; +} diff --git a/capplets/ui-properties/prefs-widget-dialogs.h b/capplets/ui-properties/prefs-widget-dialogs.h new file mode 100644 index 000000000..e7e2d587d --- /dev/null +++ b/capplets/ui-properties/prefs-widget-dialogs.h @@ -0,0 +1,54 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget-dialogs.h + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef __PREFS_WIDGET_DIALOGS_H +#define __PREFS_WIDGET_DIALOGS_H + +#include +#include + +#include "preferences.h" +#include "prefs-widget.h" + +#define PREFS_WIDGET_DIALOGS(obj) GTK_CHECK_CAST (obj, prefs_widget_dialogs_get_type (), PrefsWidget) +#define PREFS_WIDGET_DIALOGS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_dialogs_get_type (), PrefsWidgetClass) +#define IS_PREFS_WIDGET_DIALOGS(obj) GTK_CHECK_TYPE (obj, prefs_widget_dialogs_get_type ()) + +typedef struct _PrefsWidgetDialogs PrefsWidgetDialogs; +typedef struct _PrefsWidgetDialogsClass PrefsWidgetDialogsClass; + +struct _PrefsWidgetDialogs +{ + PrefsWidget prefs_widget; +}; + +struct _PrefsWidgetDialogsClass +{ + PrefsWidgetClass parent_class; +}; + +guint prefs_widget_dialogs_get_type (void); + +GtkWidget *prefs_widget_dialogs_new (Preferences *prefs); + +#endif /* __PREFS_WIDGET_DIALOGS_H */ diff --git a/capplets/ui-properties/prefs-widget-mdi.c b/capplets/ui-properties/prefs-widget-mdi.c new file mode 100644 index 000000000..da7300a73 --- /dev/null +++ b/capplets/ui-properties/prefs-widget-mdi.c @@ -0,0 +1,105 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget-mdi.c + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "prefs-widget-mdi.h" + +#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) + +static PrefsWidgetClass *parent_class; + +static widget_desc_t widget_desc[] = { + WD_OPTION (mdi_mode, "mdi_mode"), + WD_OPTION (mdi_tab_pos, "mdi_tab_pos"), + WD_END +}; + +static void prefs_widget_mdi_init (PrefsWidgetMDI *prefs_widget_mdi); +static void prefs_widget_mdi_class_init (PrefsWidgetMDIClass *class); + +guint +prefs_widget_mdi_get_type (void) +{ + static guint prefs_widget_mdi_type = 0; + + if (!prefs_widget_mdi_type) { + GtkTypeInfo prefs_widget_mdi_info = { + "PrefsWidgetMDI", + sizeof (PrefsWidgetMDI), + sizeof (PrefsWidgetMDIClass), + (GtkClassInitFunc) prefs_widget_mdi_class_init, + (GtkObjectInitFunc) prefs_widget_mdi_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + prefs_widget_mdi_type = + gtk_type_unique (prefs_widget_get_type (), + &prefs_widget_mdi_info); + } + + return prefs_widget_mdi_type; +} + +static void +prefs_widget_mdi_init (PrefsWidgetMDI *prefs_widget_mdi) +{ +} + +static void +prefs_widget_mdi_class_init (PrefsWidgetMDIClass *class) +{ + PrefsWidgetClass *prefs_widget_class; + + prefs_widget_class = PREFS_WIDGET_CLASS (class); + prefs_widget_class->widget_desc = widget_desc; + + parent_class = PREFS_WIDGET_CLASS + (gtk_type_class (prefs_widget_get_type ())); +} + +GtkWidget * +prefs_widget_mdi_new (Preferences *prefs) +{ + GtkWidget *widget, *dlg_widget; + GladeXML *dialog_data; + + g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); + + dialog_data = + glade_xml_new (GLADE_DATADIR "/ui-properties.glade", + "prefs_widget_mdi"); + + widget = gtk_widget_new (prefs_widget_mdi_get_type (), + "dialog_data", dialog_data, + "preferences", prefs, + NULL); + + dlg_widget = glade_xml_get_widget (dialog_data, "prefs_widget_mdi"); + gtk_container_add (GTK_CONTAINER (widget), dlg_widget); + + return widget; +} diff --git a/capplets/ui-properties/prefs-widget-mdi.h b/capplets/ui-properties/prefs-widget-mdi.h new file mode 100644 index 000000000..84063c2cf --- /dev/null +++ b/capplets/ui-properties/prefs-widget-mdi.h @@ -0,0 +1,54 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget-mdi.h + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef __PREFS_WIDGET_MDI_H +#define __PREFS_WIDGET_MDI_H + +#include +#include + +#include "preferences.h" +#include "prefs-widget.h" + +#define PREFS_WIDGET_MDI(obj) GTK_CHECK_CAST (obj, prefs_widget_mdi_get_type (), PrefsWidgetMDI) +#define PREFS_WIDGET_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_mdi_get_type (), PrefsWidgetMDIClass) +#define IS_PREFS_WIDGET_MDI(obj) GTK_CHECK_TYPE (obj, prefs_widget_mdi_get_type ()) + +typedef struct _PrefsWidgetMDI PrefsWidgetMDI; +typedef struct _PrefsWidgetMDIClass PrefsWidgetMDIClass; + +struct _PrefsWidgetMDI +{ + PrefsWidget prefs_widget; +}; + +struct _PrefsWidgetMDIClass +{ + PrefsWidgetClass parent_class; +}; + +guint prefs_widget_mdi_get_type (void); + +GtkWidget *prefs_widget_mdi_new (Preferences *prefs); + +#endif /* __PREFS_WIDGET_MDI_H */ diff --git a/capplets/ui-properties/prefs-widget.c b/capplets/ui-properties/prefs-widget.c new file mode 100644 index 000000000..83e2d1bb3 --- /dev/null +++ b/capplets/ui-properties/prefs-widget.c @@ -0,0 +1,429 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget.c + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include "prefs-widget.h" + +#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) + +#define VALUE_AT_OFFSET(st, offset) \ + (*((int *) (((char *) st) + offset))) + +enum { + ARG_0, + ARG_PREFERENCES, + ARG_DIALOG_DATA +}; + +enum { + READ_PREFERENCES, + LAST_SIGNAL +}; + +static guint prefs_widget_signals[LAST_SIGNAL] = { 0 }; + +static CappletWidgetClass *parent_class; + +static void prefs_widget_init (PrefsWidget *prefs_widget); +static void prefs_widget_class_init (PrefsWidgetClass *class); + +static void prefs_widget_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void prefs_widget_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); + +static void read_preferences (PrefsWidget *prefs_widget, + Preferences *prefs); + +static void register_callbacks (PrefsWidget *prefs_widget, + GladeXML *dialog_data); + +static widget_desc_t * const find_widget_desc_with_name + (PrefsWidget *prefs_widget, + const char *name); + +static void toggled_cb (GtkToggleButton *tb, + PrefsWidget *prefs_widget); +static void selected_cb (GtkMenuItem *mi, + PrefsWidget *prefs_widget); + +guint +prefs_widget_get_type (void) +{ + static guint prefs_widget_type = 0; + + if (!prefs_widget_type) { + GtkTypeInfo prefs_widget_info = { + "PrefsWidget", + sizeof (PrefsWidget), + sizeof (PrefsWidgetClass), + (GtkClassInitFunc) prefs_widget_class_init, + (GtkObjectInitFunc) prefs_widget_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + prefs_widget_type = + gtk_type_unique (capplet_widget_get_type (), + &prefs_widget_info); + } + + return prefs_widget_type; +} + +static void +prefs_widget_init (PrefsWidget *prefs_widget) +{ +} + +static void +prefs_widget_class_init (PrefsWidgetClass *class) +{ + GtkObjectClass *object_class; + + gtk_object_add_arg_type ("PrefsWidget::preferences", + GTK_TYPE_POINTER, + GTK_ARG_READWRITE, + ARG_PREFERENCES); + gtk_object_add_arg_type ("PrefsWidget::dialog_data", + GTK_TYPE_POINTER, + GTK_ARG_READWRITE, + ARG_DIALOG_DATA); + + object_class = GTK_OBJECT_CLASS (class); + object_class->set_arg = prefs_widget_set_arg; + object_class->get_arg = prefs_widget_get_arg; + + prefs_widget_signals[READ_PREFERENCES] = + gtk_signal_new ("read-preferences", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (PrefsWidgetClass, + read_preferences), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + + gtk_object_class_add_signals (object_class, prefs_widget_signals, + LAST_SIGNAL); + + class->read_preferences = read_preferences; + + parent_class = CAPPLET_WIDGET_CLASS + (gtk_type_class (capplet_widget_get_type ())); +} + +static void +prefs_widget_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + PrefsWidget *prefs_widget; + + g_return_if_fail (object != NULL); + g_return_if_fail (IS_PREFS_WIDGET (object)); + + prefs_widget = PREFS_WIDGET (object); + + switch (arg_id) { + case ARG_PREFERENCES: + if (prefs_widget->prefs) + gtk_object_unref (GTK_OBJECT (prefs_widget->prefs)); + + prefs_widget->prefs = GTK_VALUE_POINTER (*arg); + + if (prefs_widget->prefs) { + gtk_object_ref (GTK_OBJECT (prefs_widget->prefs)); + if (prefs_widget->dialog_data) + gtk_signal_emit + (GTK_OBJECT (prefs_widget), + prefs_widget_signals + [READ_PREFERENCES], + prefs_widget->prefs, NULL); + } + + break; + + case ARG_DIALOG_DATA: + if (prefs_widget->dialog_data) + gtk_object_unref + (GTK_OBJECT (prefs_widget->dialog_data)); + + prefs_widget->dialog_data = GTK_VALUE_POINTER (*arg); + + if (prefs_widget->dialog_data) { + gtk_object_ref + (GTK_OBJECT (prefs_widget->dialog_data)); + register_callbacks (prefs_widget, + prefs_widget->dialog_data); + if (prefs_widget->prefs) + gtk_signal_emit + (GTK_OBJECT (prefs_widget), + prefs_widget_signals + [READ_PREFERENCES], + prefs_widget->prefs, NULL); + } + + break; + + default: + g_warning ("Bad argument set"); + break; + } +} + +static void +prefs_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + PrefsWidget *prefs_widget; + + g_return_if_fail (object != NULL); + g_return_if_fail (IS_PREFS_WIDGET (object)); + + prefs_widget = PREFS_WIDGET (object); + + switch (arg_id) { + case ARG_PREFERENCES: + GTK_VALUE_POINTER (*arg) = prefs_widget->prefs; + break; + + case ARG_DIALOG_DATA: + GTK_VALUE_POINTER (*arg) = prefs_widget->dialog_data; + break; + + default: + g_warning ("Bad argument get"); + break; + } +} + +GtkWidget * +prefs_widget_new (Preferences *prefs) +{ + g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); + + return gtk_widget_new (prefs_widget_get_type (), + "preferences", prefs, + NULL); +} + +void +prefs_widget_set_preferences (PrefsWidget *prefs_widget, Preferences *prefs) +{ + g_return_if_fail (prefs_widget != NULL); + g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + + gtk_object_set (GTK_OBJECT (prefs_widget), "preferences", prefs, NULL); +} + +static void +read_preferences (PrefsWidget *prefs_widget, Preferences *prefs) +{ + widget_desc_t *widget_desc; + int i, value; + + g_return_if_fail (prefs_widget != NULL); + g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); + g_return_if_fail (prefs != NULL); + g_return_if_fail (IS_PREFERENCES (prefs)); + + widget_desc = + PREFS_WIDGET_CLASS (GTK_OBJECT + (prefs_widget)->klass)->widget_desc; + + g_return_if_fail (widget_desc != NULL); + + for (i = 0; widget_desc[i].type != WDTYPE_NONE; i++) { + g_return_if_fail (widget_desc[i].name != NULL); + + if (widget_desc[i].get_func) + value = widget_desc[i].get_func (prefs); + else if (widget_desc[i].prefs_offset) + value = VALUE_AT_OFFSET (prefs, + widget_desc[i].prefs_offset); + else + continue; + + switch (widget_desc[i].type) { + case WDTYPE_CHECK: + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (WID (widget_desc[i].name)), + value); + + break; + + case WDTYPE_OPTION: + gtk_option_menu_set_history + (GTK_OPTION_MENU (WID (widget_desc[i].name)), + value); + break; + + case WDTYPE_NONE: + g_assert_not_reached (); + break; + } + } +} + +static void +register_callbacks (PrefsWidget *prefs_widget, GladeXML *dialog_data) +{ + widget_desc_t *widget_desc; + int i, j; + GtkWidget *menu; + GList *node; + + g_return_if_fail (prefs_widget != NULL); + g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); + g_return_if_fail (dialog_data != NULL); + g_return_if_fail (GLADE_IS_XML (dialog_data)); + + widget_desc = PREFS_WIDGET_CLASS (GTK_OBJECT + (prefs_widget)->klass)->widget_desc; + + if (widget_desc == NULL) + return; + + glade_xml_signal_connect_data (dialog_data, "toggled_cb", + GTK_SIGNAL_FUNC (toggled_cb), + prefs_widget); + + for (i = 0; widget_desc[i].type != WDTYPE_NONE; i++) { + g_return_if_fail (widget_desc[i].name != NULL); + + if (widget_desc[i].type == WDTYPE_OPTION) { + menu = glade_xml_get_widget (dialog_data, + widget_desc[i].name); + + g_return_if_fail (menu != NULL); + g_return_if_fail (GTK_IS_OPTION_MENU (menu)); + + node = GTK_MENU_SHELL (gtk_option_menu_get_menu + (GTK_OPTION_MENU + (menu)))->children; + + j = 0; + + while (node != NULL) { + gtk_signal_connect (GTK_OBJECT (node->data), + "activate", + GTK_SIGNAL_FUNC + (selected_cb), + prefs_widget); + gtk_object_set_data (GTK_OBJECT (node->data), + "index", (gpointer) j); + gtk_object_set_data (GTK_OBJECT (node->data), + "name", + widget_desc[i].name); + j++; + node = node->next; + } + } + } +} + +static widget_desc_t * const +find_widget_desc_with_name (PrefsWidget *prefs_widget, const char *name) +{ + widget_desc_t *widget_desc; + int i; + + g_return_val_if_fail (prefs_widget != NULL, NULL); + g_return_val_if_fail (IS_PREFS_WIDGET (prefs_widget), NULL); + g_return_val_if_fail (name != NULL, NULL); + + widget_desc = + PREFS_WIDGET_CLASS (GTK_OBJECT + (prefs_widget)->klass)->widget_desc; + + g_return_val_if_fail (widget_desc != NULL, NULL); + + for (i = 0; widget_desc[i].type != WDTYPE_NONE; i++) { + if (!strcmp (widget_desc[i].name, name)) + return &(widget_desc[i]); + } + + return NULL; +} + +static void +toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget) +{ + const char *widget_name; + widget_desc_t *widget_desc; + + g_return_if_fail (tb != NULL); + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (tb)); + g_return_if_fail (prefs_widget != NULL); + g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); + + widget_name = glade_get_widget_name (GTK_WIDGET (tb)); + g_return_if_fail (widget_name != NULL); + widget_desc = find_widget_desc_with_name (prefs_widget, widget_name); + g_return_if_fail (widget_desc != NULL); + + if (widget_desc->set_func) + widget_desc->set_func (prefs_widget->prefs, + gtk_toggle_button_get_active (tb)); + else if (widget_desc->prefs_offset) + VALUE_AT_OFFSET (prefs_widget->prefs, + widget_desc->prefs_offset) = + gtk_toggle_button_get_active (tb); + + preferences_changed (prefs_widget->prefs); + capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE); +} + +static void +selected_cb (GtkMenuItem *mi, PrefsWidget *prefs_widget) +{ + const char *widget_name; + widget_desc_t *widget_desc; + gint index = 0; + + g_return_if_fail (mi != NULL); + g_return_if_fail (GTK_IS_MENU_ITEM (mi)); + g_return_if_fail (prefs_widget != NULL); + g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); + + index = (gint) gtk_object_get_data (GTK_OBJECT (mi), "index"); + widget_name = gtk_object_get_data (GTK_OBJECT (mi), "name"); + g_return_if_fail (widget_name != NULL); + widget_desc = find_widget_desc_with_name (prefs_widget, widget_name); + g_return_if_fail (widget_desc != NULL); + + if (widget_desc->set_func) + widget_desc->set_func (prefs_widget->prefs, index); + else if (widget_desc->prefs_offset) + VALUE_AT_OFFSET (prefs_widget->prefs, + widget_desc->prefs_offset) = index; + + preferences_changed (prefs_widget->prefs); + capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE); +} diff --git a/capplets/ui-properties/prefs-widget.h b/capplets/ui-properties/prefs-widget.h new file mode 100644 index 000000000..b67a1df9a --- /dev/null +++ b/capplets/ui-properties/prefs-widget.h @@ -0,0 +1,97 @@ +/* -*- mode: c; style: linux -*- */ + +/* prefs-widget.h + * Copyright (C) 2000 Helix Code, Inc. + * + * Written by Bradford Hovinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef __PREFS_WIDGET_H +#define __PREFS_WIDGET_H + +#include +#include +#include + +#include "preferences.h" + +/* Generic widget descriptors to make maintenance easier */ + +typedef enum _widget_desc_type_t { + WDTYPE_NONE, WDTYPE_CHECK, WDTYPE_OPTION +} widget_desc_type_t; + +struct _widget_desc_t +{ + widget_desc_type_t type; + char *name; + gint (*get_func) (Preferences *); + void (*set_func) (Preferences *, gint); + gint prefs_offset; +}; + +typedef struct _widget_desc_t widget_desc_t; + +#define WD_CHECK(name, namestr) \ + { WDTYPE_CHECK, namestr "_toggle", \ + (gint (*) (Preferences *)) preferences_get_##name, \ + (void (*) (Preferences *, gint)) preferences_set_##name, \ + 0} +#define WD_OPTION(name, namestr) \ + { WDTYPE_OPTION, namestr "_select", \ + (gint (*) (Preferences *)) preferences_get_##name, \ + (void (*) (Preferences *, gint)) preferences_set_##name, \ + 0} +#define WD_END \ + { WDTYPE_NONE, NULL, NULL, NULL, 0 } + +/* Preferences widget class proper */ + +#define PREFS_WIDGET(obj) GTK_CHECK_CAST (obj, prefs_widget_get_type (), PrefsWidget) +#define PREFS_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_get_type (), PrefsWidgetClass) +#define IS_PREFS_WIDGET(obj) GTK_CHECK_TYPE (obj, prefs_widget_get_type ()) + +typedef struct _PrefsWidget PrefsWidget; +typedef struct _PrefsWidgetClass PrefsWidgetClass; + +struct _PrefsWidget +{ + CappletWidget capplet_widget; + + Preferences *prefs; + GladeXML *dialog_data; +}; + +struct _PrefsWidgetClass +{ + CappletWidgetClass parent_class; + + void (*read_preferences) (PrefsWidget *prefs_widget, + Preferences *prefs); + + widget_desc_t *widget_desc; +}; + +guint prefs_widget_get_type (void); + +GtkWidget *prefs_widget_new (Preferences *prefs); + +void prefs_widget_set_preferences (PrefsWidget *prefs_widget, + Preferences *prefs); + +#endif /* __PREFS_WIDGET_H */ diff --git a/capplets/ui-properties/ui-properties.glade b/capplets/ui-properties/ui-properties.glade new file mode 100644 index 000000000..5c2ee856f --- /dev/null +++ b/capplets/ui-properties/ui-properties.glade @@ -0,0 +1,747 @@ + + + + + New-ui-properties + new-ui-properties + + src + pixmaps + C + True + True + + + + GtkWindow + window1 + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkHBox + prefs_widget_app + 5 + False + 0 + + + GtkVBox + vbox1 + 5 + False + 5 + + 0 + True + True + + + + GtkFrame + frame1 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + False + True + + + + GtkVBox + vbox2 + 5 + False + 5 + + + GtkCheckButton + menubar_detachable_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:48:47 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + menubar_relief_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:48:53 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + menus_have_tearoff_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:03 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + menus_have_icons_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:11 GMT + + + False + True + + 0 + False + False + + + + + + + GtkFrame + frame2 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + False + True + + + + GtkVBox + vbox3 + 5 + False + 5 + + + GtkCheckButton + statusbar_is_interactive_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:20 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + statusbar_meter_on_right_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:29 GMT + + + False + True + + 0 + False + False + + + + + + + + GtkVBox + vbox4 + 5 + False + 5 + + 0 + True + True + + + + GtkFrame + frame3 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + False + False + + + + GtkVBox + vbox5 + 5 + False + 5 + + + GtkCheckButton + toolbar_detachable_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:38 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + toolbar_relief_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:42 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + toolbar_relief_btn_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:48 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + toolbar_lines_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:53 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + toolbar_labels_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 02:49:57 GMT + + + False + True + + 0 + False + False + + + + + + + + + + GtkWindow + window2 + window2 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkVBox + prefs_widget_dialogs + 5 + False + 5 + + + GtkFrame + frame4 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + False + True + + + + GtkVBox + vbox7 + 5 + False + 5 + + + GtkHBox + hbox2 + False + 5 + + 0 + False + True + + + + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkOptionMenu + dialog_buttons_style_select + True + Default value +Spread buttons out +Put buttons on edges +Left-justify buttons +Right-justify buttons + + 0 + + 0 + False + False + + + + + + GtkCheckButton + dialog_icons_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 05:08:48 GMT + + + False + True + + 0 + False + False + + + + + GtkCheckButton + statusbar_not_dialog_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 05:09:02 GMT + + + False + True + + 0 + False + False + + + + + + + GtkFrame + frame5 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + False + True + + + + GtkTable + table1 + 5 + 3 + 2 + False + 5 + 5 + + + GtkLabel + label2 + + GTK_JUSTIFY_RIGHT + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label3 + + GTK_JUSTIFY_RIGHT + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkOptionMenu + dialog_position_select + True + Let window manager decide +Center of the screen +At the mouse pointer + + 0 + + 1 + 2 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkOptionMenu + dialog_type_select + True + Dialogs are like other windows +Dialogs are treated specially by the window manager + + 0 + + 1 + 2 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkCheckButton + dialog_centered_toggle + True + + toggled + toggled_cb + Sun, 24 Sep 2000 05:09:12 GMT + + + False + True + + 0 + 2 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + + + + + + + + + GtkWindow + window3 + window3 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkFrame + prefs_widget_mdi + 5 + + 0 + GTK_SHADOW_ETCHED_IN + + + GtkTable + table2 + 5 + 2 + 2 + False + 5 + 5 + + + GtkLabel + label4 + + GTK_JUSTIFY_RIGHT + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label5 + + GTK_JUSTIFY_RIGHT + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkOptionMenu + mdi_mode_select + True + Notebook +Toplevel +Modal + + 0 + + 1 + 2 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkOptionMenu + mdi_tab_pos_select + True + Left +Right +Top +Bottom + + 0 + + 1 + 2 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + + +