diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.in | 2 | ||||
-rw-r--r-- | src/dbus-menu-manager.c | 6 | ||||
-rw-r--r-- | src/indicator-sound.c | 63 |
4 files changed, 50 insertions, 23 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index b7de930..062d993 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,7 @@ libsoundmenu_la_SOURCES = \ dbus-shared-names.h \ sound-service-client.h -libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror +libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) libsoundmenu_la_LDFLAGS = -module -avoid-version diff --git a/src/Makefile.in b/src/Makefile.in index 7f2b8dc..d4506f7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -296,7 +296,7 @@ libsoundmenu_la_SOURCES = \ dbus-shared-names.h \ sound-service-client.h -libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror +libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) libsoundmenu_la_LDFLAGS = -module -avoid-version diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 38ed727..1628a59 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -117,7 +117,7 @@ void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value) b_all_muted = incoming_mute_value; dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, - _(b_all_muted == FALSE ? "Mute All" : "Unmute")); + b_all_muted == FALSE ? _("Mute All") : _("Unmute")); } @@ -191,7 +191,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service { // Mute button mute_all_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute")); + dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, b_all_muted == FALSE ? _("Mute All") : _("Unmute")); g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL); dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available); @@ -230,7 +230,7 @@ static void set_global_mute_from_ui() toggle_global_mute(b_all_muted); dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, - _(b_all_muted == FALSE ? "Mute All" : "Unmute")); + b_all_muted == FALSE ? _("Mute All") : _("Unmute")); } diff --git a/src/indicator-sound.c b/src/indicator-sound.c index aa87410..a1a531a 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -7,6 +7,7 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran <conor.curran@canonical.com> Ted Gould <ted@canonical.com> + Cody Russell <cody.russell@canonical.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -60,6 +61,7 @@ struct _IndicatorSoundClass { //GObject instance struct struct _IndicatorSound { IndicatorObject parent; + GtkWidget *slider; IndicatorServiceManager *service; }; // GObject Boiler plate @@ -77,7 +79,8 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE); //GTK+ items static GtkLabel * get_label (IndicatorObject * io); static GtkImage * get_icon (IndicatorObject * io); -static GtkMenu * get_menu (IndicatorObject * io); +static GtkMenu * get_menu (IndicatorObject * io); +static void scroll (IndicatorObject*io, gint delta, IndicatorScrollDirection direction); //Slider related static GtkWidget *volume_slider = NULL; @@ -140,9 +143,10 @@ indicator_sound_class_init (IndicatorSoundClass *klass) IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass); io_class->get_label = get_label; io_class->get_image = get_icon; - io_class->get_menu = get_menu; + io_class->get_menu = get_menu; + io_class->scroll = scroll; - design_team_size = gtk_icon_size_register("design-team-size", 22, 22); + design_team_size = gtk_icon_size_register("design-team-size", 22, 22); return; } @@ -172,7 +176,7 @@ indicator_sound_dispose (GObject *object) self->service = NULL; } g_hash_table_destroy(volume_states); - + if(blocked_animation_list != NULL){ g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); g_list_free(blocked_animation_list); @@ -212,7 +216,10 @@ static GtkMenu * get_menu (IndicatorObject * io) { DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT); - DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); + DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); + + g_object_set_data (G_OBJECT (client), + "indicator", io); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); // register Key-press listening on the menu widget as the slider does not allow this. @@ -235,10 +242,14 @@ Create a new dBusMenu Slider item. **/ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + IndicatorObject *io = NULL; + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 0.5); + io = g_object_get_data (G_OBJECT (client), "indicator"); + + volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 1); g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); g_signal_connect (volume_slider, @@ -252,6 +263,8 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p // register slider changes listening on the range GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + INDICATOR_SOUND (io)->slider = slider; + g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); g_signal_connect(volume_slider, "slider-grabbed", G_CALLBACK(slider_grabbed), NULL); g_signal_connect(volume_slider, "slider-released", G_CALLBACK(slider_released), NULL); @@ -343,18 +356,18 @@ static void prepare_blocked_animation() { gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)); - - GtkImage* temp_image = indicator_image_helper(muted_name); - GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image); - temp_image = indicator_image_helper(blocked_name); + GtkImage* temp_image = indicator_image_helper(muted_name); + GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image); + + temp_image = indicator_image_helper(blocked_name); GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); int i; if(mute_buf == NULL || blocked_buf == NULL){ g_debug("Don bother with the animation, the theme aint got the goods"); - return; + return; } // sample 22 snapshots - range : 0-256 @@ -400,9 +413,7 @@ static void update_state(const gint state) current_state = state; gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); - GtkImage * tempimage = indicator_image_helper(image_name); - gtk_image_set_from_pixbuf(speaker_image, gtk_image_get_pixbuf(tempimage)); - g_object_ref_sink(tempimage); + indicator_image_helper_update(speaker_image, image_name); } @@ -493,13 +504,11 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean blo g_debug("signal caught - sink input while muted with value %i", block_value); if (block_value == 1 && animation_id == 0 && blocked_animation_list != NULL) { gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); - GtkImage * tempimage = indicator_image_helper(image_name); - gtk_image_set_from_pixbuf(speaker_image, gtk_image_get_pixbuf(tempimage)); - g_object_ref_sink(tempimage); + indicator_image_helper_update(speaker_image, image_name); blocked_iter = blocked_animation_list; animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL); - } + } } static gboolean fade_back_to_mute_image() @@ -659,3 +668,21 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat } +static void +scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction) +{ + if (device_available == FALSE || current_state == STATE_MUTED) + return; + + IndicatorSound *sound = INDICATOR_SOUND (io); + GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (sound->slider)); + gdouble value = gtk_range_get_value (GTK_RANGE (sound->slider)); + + if (direction == INDICATOR_OBJECT_SCROLL_UP) + value += adj->step_increment; + else + value -= adj->step_increment; + + gtk_range_set_value (GTK_RANGE (sound->slider), + value); +} |