From be432c9acb542263f6a16da9e40e31ba59f9315c Mon Sep 17 00:00:00 2001 From: Bill Haneman Date: Fri, 6 Jun 2003 23:20:37 +0000 Subject: [PATCH] Use a peditor for the visual bell instead. Fri Jun 6 19:16:43 2003 Jonathan Blandford * sound-properties-capplet.c (bell_flash_to_widget), (bell_flash_from_widget): Use a peditor for the visual bell instead. 2003-06-06 Bill Haneman * sound-properties.glade: Added page tab and UI from "visual bell" capplet (UI originally from Calum, except for ugly icon) * visual-bell.png: Ugly new icon which needs TLC from Calum. * sound-properties-capplet.c: Added gconf keys for visual bell feature and control of audio bell. (visual_bell_type_changed): New, called when visual bell radiobuttons are toggled. (create_dialog): Set the image on the "System Bell" notebook tab. (setup_dialog): Added peditors for visual-bell and audio-bell checkboxes/gconf keys. Added guards for the visual-bell type buttons, controlled by the visual-bell-enabling checkbox. Connected visual_bell_type_changed to "toggled" signal on radiobuttons. --- capplets/sound/ChangeLog | 28 +++ capplets/sound/Makefile.am | 6 +- capplets/sound/sound-properties-capplet.c | 84 ++++++++- capplets/sound/sound-properties.glade | 209 +++++++++++++++++++++- 4 files changed, 311 insertions(+), 16 deletions(-) diff --git a/capplets/sound/ChangeLog b/capplets/sound/ChangeLog index 8d60cfd0d..38a13c629 100644 --- a/capplets/sound/ChangeLog +++ b/capplets/sound/ChangeLog @@ -1,3 +1,31 @@ +Fri Jun 6 19:16:43 2003 Jonathan Blandford + + * sound-properties-capplet.c (bell_flash_to_widget), + (bell_flash_from_widget): Use a peditor for the visual bell + instead. + +2003-06-06 Bill Haneman + + * sound-properties.glade: + Added page tab and UI from "visual bell" capplet + (UI originally from Calum, except for ugly icon) + + * visual-bell.png: + Ugly new icon which needs TLC from Calum. + + * sound-properties-capplet.c: + Added gconf keys for visual bell feature and control of + audio bell. + (visual_bell_type_changed): New, called when visual bell radiobuttons + are toggled. + (create_dialog): + Set the image on the "System Bell" notebook tab. + (setup_dialog): + Added peditors for visual-bell and audio-bell checkboxes/gconf keys. + Added guards for the visual-bell type buttons, controlled by + the visual-bell-enabling checkbox. + Connected visual_bell_type_changed to "toggled" signal on radiobuttons. + 2003-05-07 Jody Goldberg * Release 2.3.1 diff --git a/capplets/sound/Makefile.am b/capplets/sound/Makefile.am index 9d615d475..a892489f2 100644 --- a/capplets/sound/Makefile.am +++ b/capplets/sound/Makefile.am @@ -11,8 +11,8 @@ Glade_DATA = sound-properties.glade iconsdir = $(GNOMECC_ICONS_DIR) icons_DATA = sound-capplet.png -desktop_iconsdir = $(datadir)/pixmaps -desktop_icons_DATA = sound-capplet.png +desktop_iconsdir = $(GNOMECC_PIXMAPS_DIR) +desktop_icons_DATA = sound-capplet.png visual-bell.png desktopdir = $(GNOMECC_DESKTOP_DIR) Desktop_in_files = sound.desktop.in @@ -20,5 +20,5 @@ desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) $(SOUND_CAPPLET_CFLAGS) CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) -EXTRA_DIST = $(Glade_DATA) $(icons_DATA) $(Desktop_in_files) +EXTRA_DIST = $(Glade_DATA) $(desktop_icons_DATA) $(Desktop_in_files) diff --git a/capplets/sound/sound-properties-capplet.c b/capplets/sound/sound-properties-capplet.c index c03b39839..e756bdd31 100644 --- a/capplets/sound/sound-properties-capplet.c +++ b/capplets/sound/sound-properties-capplet.c @@ -41,6 +41,12 @@ #include "activate-settings-daemon.h" +#define ENABLE_ESD_KEY "/desktop/gnome/sound/enable_esd" +#define EVENT_SOUNDS_KEY "/desktop/gnome/sound/event_sounds" +#define VISUAL_BELL_KEY "/apps/metacity/general/visual_bell" +#define AUDIO_BELL_KEY "/apps/metacity/general/audible_bell" +#define VISUAL_BELL_TYPE_KEY "/apps/metacity/general/visual_bell_type" + /* Capplet-specific prototypes */ static SoundProperties *props = NULL; @@ -51,6 +57,46 @@ props_changed_cb (SoundProperties *p, SoundEvent *event, gpointer data) sound_properties_user_save (p); } + + +static GConfEnumStringPair bell_flash_enums[] = { + { 0, "frame_flash" }, + { 1, "fullscreen_flash" }, + { -1, NULL } +}; + +static GConfValue * +bell_flash_from_widget (GConfPropertyEditor *peditor, const GConfValue *value) +{ + GConfValue *new_value; + + new_value = gconf_value_new (GCONF_VALUE_STRING); + gconf_value_set_string (new_value, + gconf_enum_to_string (bell_flash_enums, gconf_value_get_int (value))); + + return new_value; +} + +static GConfValue * +bell_flash_to_widget (GConfPropertyEditor *peditor, const GConfValue *value) +{ + GConfValue *new_value; + const gchar *str; + gint val = 2; + + str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL; + + new_value = gconf_value_new (GCONF_VALUE_INT); + if (value->type == GCONF_VALUE_STRING) { + gconf_string_to_enum (bell_flash_enums, + str, + &val); + } + gconf_value_set_int (new_value, val); + + return new_value; +} + /* create_dialog * * Create the dialog box and return it as a GtkWidget @@ -59,27 +105,30 @@ props_changed_cb (SoundProperties *p, SoundEvent *event, gpointer data) static GladeXML * create_dialog (void) { - GladeXML *data; + GladeXML *dialog; GtkWidget *widget, *box; - data = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/sound-properties.glade", "prefs_widget", NULL); - widget = glade_xml_get_widget (data, "prefs_widget"); - g_object_set_data (G_OBJECT (widget), "glade-data", data); + dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/sound-properties.glade", "prefs_widget", NULL); + widget = glade_xml_get_widget (dialog, "prefs_widget"); + g_object_set_data (G_OBJECT (widget), "glade-data", dialog); props = sound_properties_new (); sound_properties_add_defaults (props, NULL); g_signal_connect (G_OBJECT (props), "event_changed", (GCallback) props_changed_cb, NULL); - box = glade_xml_get_widget (data, "events_vbox"); + box = glade_xml_get_widget (dialog, "events_vbox"); gtk_box_pack_start (GTK_BOX (box), sound_view_new (props), TRUE, TRUE, 0); g_signal_connect_swapped (G_OBJECT (widget), "destroy", (GCallback) gtk_object_destroy, props); - gtk_widget_set_size_request (widget, -1, 250); + gtk_image_set_from_file (GTK_IMAGE (WID ("bell_image")), + GNOMECC_DATA_DIR "/pixmaps/visual-bell.png"); - return data; + gtk_widget_set_size_request (widget, -1, 250); /* Can this be right? Seems broken for large fonts. */ + + return dialog; } /* setup_dialog @@ -91,11 +140,27 @@ static void setup_dialog (GladeXML *dialog, GConfChangeSet *changeset) { GObject *peditor; + gchar *visual_type; + GtkWidget *flash_titlebar_widget, *flash_screen_widget; - peditor = gconf_peditor_new_boolean (NULL, "/desktop/gnome/sound/enable_esd", WID ("enable_toggle"), NULL); + peditor = gconf_peditor_new_boolean (NULL, ENABLE_ESD_KEY, WID ("enable_toggle"), NULL); gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("events_toggle")); gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("events_vbox")); - peditor = gconf_peditor_new_boolean (NULL, "/desktop/gnome/sound/event_sounds", WID ("events_toggle"), NULL); + + gconf_peditor_new_boolean (NULL, EVENT_SOUNDS_KEY, WID ("events_toggle"), NULL); + + gconf_peditor_new_boolean (NULL, AUDIO_BELL_KEY, WID ("bell_audible_toggle"), NULL); + + peditor = gconf_peditor_new_boolean (NULL, VISUAL_BELL_KEY, WID ("bell_visual_toggle"), NULL); + gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("bell_flash_vbox")); + + /* peditor not so convenient for the radiobuttons */ + gconf_peditor_new_select_radio (NULL, + VISUAL_BELL_TYPE_KEY, + gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("bell_flash_window_radio"))), + "conv-to-widget-cb", bell_flash_to_widget, + "conv-from-widget-cb", bell_flash_from_widget, + NULL); } /* get_legacy_settings @@ -163,6 +228,7 @@ main (int argc, char **argv) client = gconf_client_get_default (); gconf_client_add_dir (client, "/desktop/gnome/sound", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_add_dir (client, "/apps/metacity/general", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); if (get_legacy) { get_legacy_settings (); diff --git a/capplets/sound/sound-properties.glade b/capplets/sound/sound-properties.glade index 370e93888..d980c8079 100644 --- a/capplets/sound/sound-properties.glade +++ b/capplets/sound/sound-properties.glade @@ -20,15 +20,14 @@ True GTK_POS_TOP False - 2 - 2 False + 8 True False - 5 + 8 @@ -95,6 +94,7 @@ + 8 True False 0 @@ -106,9 +106,210 @@ - + True Sound Events + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + False + 0 + + + + 8 + True + False + 8 + + + + True + 0.5 + 0 + 0 + 0 + + + 0 + False + True + + + + + + True + False + 3 + + + + True + True + _Sound an audible bell + True + GTK_RELIEF_NORMAL + True + False + True + + + 0 + False + False + + + + + + True + True + _Visual feedback: + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + + True + False + 0 + + + + True + 0.5 + 0.5 + 0 + 1 + + + + 20 + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + + + + + + 0 + False + True + + + + + + True + False + 3 + + + + True + True + Flash _window titlebar + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + + True + True + Flash entire _screen + True + GTK_RELIEF_NORMAL + False + False + True + bell_flash_window_radio + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + False + True + + + + + + True + System Bell True False GTK_JUSTIFY_CENTER