From 11f1982a7b23d55be2306ab6da80879d2f9d8e03 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 26 Feb 2010 12:29:16 +0000 Subject: handles pulseaudio flapping without memory leaks - solid --- src/pulse-manager.c | 43 +++++++++++++++++++++++++++++++++------ src/sound-service.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 88 insertions(+), 13 deletions(-) diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 9b9d7cd..4436561 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -31,7 +31,6 @@ with this program. If not, see . static GHashTable *sink_hash = NULL; static SoundServiceDbus *dbus_service = NULL; -// Until we find a satisfactory default sink this index should remain < 0 static gint DEFAULT_SINK_INDEX = -1; static gboolean pa_server_available = FALSE; // PA related @@ -46,6 +45,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v static void pulse_source_info_callback(pa_context *c, const pa_source_info *i, int eol, void *userdata); static void destroy_sink_info(void *value); static gboolean determine_sink_availability(); +static void reconnect_to_pulse(); /** @@ -65,14 +65,19 @@ void establish_pulse_activities(SoundServiceDbus *service) g_assert(pulse_context); sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info); + // Establish event callback registration pa_context_set_state_callback(pulse_context, context_state_callback, NULL); - pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL); + // BUILD MENU ANYWHO - it will be updated + update_pa_state(FALSE, FALSE, FALSE, 0); + + pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL); } void close_pulse_activites() { - if (pulse_context){ + if (pulse_context != NULL){ + g_debug("freeing the pulse context"); pa_context_unref(pulse_context); pulse_context = NULL; } @@ -82,6 +87,30 @@ void close_pulse_activites() g_debug("I just closed communication with Pulse"); } +/** +reconnect_to_pulse() +In the event of Pulseaudio flapping in the wind handle gracefully without +memory leaks ! +*/ +static void reconnect_to_pulse() +{ + // reset + if (pulse_context != NULL){ + g_debug("freeing the pulse context"); + pa_context_unref(pulse_context); + pulse_context = NULL; + } + g_hash_table_destroy(sink_hash); + + // reconnect + pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound"); + g_assert(pulse_context); + sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info); + // Establish event callback registration + pa_context_set_state_callback(pulse_context, context_state_callback, NULL); + update_pa_state(FALSE, FALSE, FALSE, 0); + pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL); +} static void destroy_sink_info(void *value) { @@ -186,6 +215,8 @@ Use the base volume stored in the sink struct to calculate actual linear volumes */ void set_sink_volume(gdouble percent) { + if(pa_server_available == FALSE) + return; g_debug("in the pulse manager:set_sink_volume with percent %f", percent); if(DEFAULT_SINK_INDEX < 0) { @@ -474,7 +505,7 @@ static void context_state_callback(pa_context *c, void *userdata) { g_debug("unconnected"); break; case PA_CONTEXT_CONNECTING: - g_debug("connecting"); + g_debug("connecting - waiting for the server to become available"); break; case PA_CONTEXT_AUTHORIZING: g_debug("authorizing"); @@ -484,8 +515,8 @@ static void context_state_callback(pa_context *c, void *userdata) { break; case PA_CONTEXT_FAILED: g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?"); - //Update the indicator to show PA either is not ready or has no available sink - update_pa_state(FALSE, FALSE, TRUE, 0); + pa_server_available = FALSE; + reconnect_to_pulse(); break; case PA_CONTEXT_TERMINATED: g_debug("context terminated"); diff --git a/src/sound-service.c b/src/sound-service.c index 62f6bc6..e3153e9 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -37,12 +37,13 @@ static SoundServiceDbus *dbus_interface = NULL; static gboolean b_sink_available = FALSE; static gboolean b_all_muted = FALSE; static gboolean b_pulse_ready = FALSE; +static gboolean b_startup = TRUE; static gdouble volume_percent = 0.0; static void set_global_mute_from_ui(); static gboolean idle_routine (gpointer data); static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service); - +static void refresh_menu(); /**********************************************************************************************************************/ // Init functions (GTK and DBUS) @@ -70,6 +71,7 @@ Build the DBus menu items. For now Mute all/Unmute is the only available option **/ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service) { + g_debug("rebuilding the sound menu - should i be doing this - it only should happen once !"); // 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")); @@ -80,10 +82,20 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent); dbusmenu_menuitem_child_append(root, mute_all_menuitem); dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem)); - + // Enable/Disable, show/hide slider depending on sink availability + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_ENABLED, + b_sink_available); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_VISIBLE, + b_sink_available); + + // Separator DbusmenuMenuitem *separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); + + // Sound preferences dialog DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences...")); @@ -127,8 +139,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); +/* close_pulse_activites();*/ +/* g_main_loop_quit(mainloop);*/ } return; } @@ -140,12 +152,44 @@ void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_m b_pulse_ready = pa_state; volume_percent = percent; g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent); + // Only rebuild the menu on start up... + if(b_startup == TRUE){ + rebuild_sound_menu(root_menuitem, dbus_interface); + b_startup = FALSE; + } + else{ + refresh_menu(); + } + // Emit the signals after the menus are setup/torn down sound_service_dbus_update_sink_volume(dbus_interface, percent); sound_service_dbus_update_sink_mute(dbus_interface, sink_muted); - // Only rebuild the menu on start up... - if(volume_slider_menuitem == NULL) - rebuild_sound_menu(root_menuitem, dbus_interface); +} + +static void refresh_menu() +{ + if(b_sink_available == FALSE || b_pulse_ready == FALSE) + { + + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_ENABLED, + FALSE); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); + dbusmenu_menuitem_property_set_bool(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_ENABLED, + FALSE); + + } + else if(b_sink_available == TRUE && b_pulse_ready == TRUE){ + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_VISIBLE, + TRUE); + dbusmenu_menuitem_property_set_bool(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_ENABLED, + TRUE); + } } -- cgit v1.2.3 From 8ab71867cb6d028ade4e72ee6efeb563fba07c9a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 26 Feb 2010 14:40:28 +0000 Subject: new sink inserts are now cached in our hash --- src/pulse-manager.c | 20 ++++++++++++++------ src/sound-service.c | 17 ++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 4436561..d5377bf 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -397,12 +397,20 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v } else { - // TODO ADD new sink - part of big refactor - g_debug("attempting to add new sink with name %s", info->name); - //sink_info *s; - //s = g_new0(sink_info, 1); - //update the sinks hash with new sink. - } + sink_info *value; + value = g_new0(sink_info, 1); + value->index = value->device_index = info->index; + value->name = g_strdup(info->name); + value->description = g_strdup(info->description); + value->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME)); + value->active_port = (info->active_port != NULL); + value->mute = !!info->mute; + value->volume = info->volume; + value->base_volume = info->base_volume; + value->channel_map = info->channel_map; + g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value); + g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash"); + } } diff --git a/src/sound-service.c b/src/sound-service.c index e3153e9..af1f1e9 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -67,11 +67,11 @@ static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data } } /** -Build the DBus menu items. For now Mute all/Unmute is the only available option +rebuild_sound_menu: +Build the DBus menu items, mute/unmute, slider, separator and sound preferences 'link' **/ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service) { - g_debug("rebuilding the sound menu - should i be doing this - it only should happen once !"); // 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")); @@ -82,14 +82,12 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent); dbusmenu_menuitem_child_append(root, mute_all_menuitem); dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem)); - // Enable/Disable, show/hide slider depending on sink availability dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_ENABLED, - b_sink_available); + b_sink_available); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), - DBUSMENU_MENUITEM_PROP_VISIBLE, - b_sink_available); - + DBUSMENU_MENUITEM_PROP_VISIBLE, + b_sink_available); // Separator DbusmenuMenuitem *separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); @@ -168,6 +166,7 @@ void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_m static void refresh_menu() { + g_debug("in the refresh menu method"); if(b_sink_available == FALSE || b_pulse_ready == FALSE) { @@ -183,6 +182,10 @@ static void refresh_menu() } else if(b_sink_available == TRUE && b_pulse_ready == TRUE){ + + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_ENABLED, + TRUE); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); -- cgit v1.2.3 From 259f58ec21be89f22f478243f4c8acf9a44231f9 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Mar 2010 15:05:08 +0000 Subject: tests compiling --- src/dbus-menu-manager.c | 1 - src/indicator-sound.c | 1 + src/sound-service-dbus.c | 10 ++--- tests/Makefile.am | 70 +++++++++++++++----------------- tests/test-indicator-sound-dbus-client.c | 9 ++-- 5 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 652e6b2..3e33932 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -113,7 +113,6 @@ void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value) 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"))); } diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 3aca517..4bdfbb7 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -238,6 +238,7 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata) { + // TODO: This could be safer. if (connected) { if (sound_dbus_proxy == NULL) { GError * error = NULL; diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 99a9d34..952a2d3 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -29,8 +29,7 @@ #include "sound-service-marshal.h" #include "pulse-manager.h" -// DBUS methods - -// TODO - other should be static and moved from the header to here +// DBUS methods static gboolean sound_service_dbus_get_sink_volume(SoundServiceDbus* service, gdouble* volume_percent_input, GError** gerror); static gboolean sound_service_dbus_get_sink_mute(SoundServiceDbus* service, gboolean* mute_input, GError** gerror); static void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror); @@ -41,7 +40,6 @@ typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; struct _SoundServiceDbusPrivate { - DBusGConnection *system_bus; DBusGConnection *connection; gdouble volume_percent; gboolean mute; @@ -116,13 +114,10 @@ sound_service_dbus_init (SoundServiceDbus *self) GError *error = NULL; SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); - priv->system_bus = NULL; priv->connection = NULL; priv->volume_percent = 0; - /* Get the system bus */ - priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - /* Put the object on DBus */ + /* Fetch the session bus */ priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { @@ -130,6 +125,7 @@ sound_service_dbus_init (SoundServiceDbus *self) g_error_free(error); return; } + /* register the service on it */ dbus_g_connection_register_g_object(priv->connection, "/org/ayatana/indicator/sound/service", G_OBJECT(self)); diff --git a/tests/Makefile.am b/tests/Makefile.am index ad985f4..a0b990b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,8 +1,8 @@ check_PROGRAMS = \ test-indicator-sound \ - test-indicator-sound-dbus-client -# test-indicator-sound-dbus-server + test-indicator-sound-dbus-client \ + test-indicator-sound-dbus-server TESTS = DISTCLEANFILES = $(TESTS) @@ -27,53 +27,49 @@ test_indicator_sound_LDADD = \ ######################################### ## test-indicator-sound-dbus-client ######################################### - test_indicator_sound_dbus_client_SOURCES = \ test-defines.h \ - test-indicator-sound-dbus-client.c + test-indicator-sound-dbus-client.c test_indicator_sound_dbus_client_CFLAGS = \ $(SOUNDSERVICE_CFLAGS) \ -Wall -Werror \ - -I$(srcdir) \ - -I$(SOUNDSERVICE_CFLAGS) + -I$(srcdir) test_indicator_sound_dbus_client_LDADD = \ $(SOUNDSERVICE_LIBS) -######################################### -## test-indicator-sound-dbus-server -######################################### -#test_indicator_sound_dbus_server_SOURCES = \ -# test-defines.h - -#test_indicator_sound_dbus_server_CFLAGS = \ -# $(SOUNDSERVICE_CFLAGS) \ -# -Wall -Werror \ -# -I$(srcdir) \ -# -I$(SOUNDSERVICE_CFLAGS) - -#test_indicator_sound_dbus_server_LDADD = \ -# $(SOUNDSERVICE_LIBS) \ -# $(top_builddir)/src/indicator_sound_service-sound-service.o \ -# $(top_builddir)/src/indicator_sound_service-pulse-manager.o \ -# $(top_builddir)/src/indicator_sound_service-slider-menu-item.o \ -# $(top_builddir)/src/indicator_sound_service-sound-service-dbus.o - +######################################## +# test-indicator-sound-dbus-server +######################################## +test_indicator_sound_dbus_server_SOURCES = \ + test-defines.h \ + test-indicator-sound-dbus-server.c \ + $(top_builddir)/src/sound-service-dbus.c \ + $(top_builddir)/src/pulse-manager.c \ + $(top_builddir)/src/slider-menu-item.c \ + $(top_builddir)/src/dbus-menu-manager.c + +test_indicator_sound_dbus_server_CFLAGS = \ + $(SOUNDSERVICE_CFLAGS) \ + -Wall -Werror \ + -I$(srcdir) +test_indicator_sound_dbus_server_LDADD = \ + $(SOUNDSERVICE_LIBS) ######################################### ## Actual tests ######################################### -#XML_REPORT = indicator-sound-check-results.xml -#HTML_REPORT = indicator-sound-check-results.html +XML_REPORT = indicator-sound-check-results.xml +HTML_REPORT = indicator-sound-check-results.html -#indicator-sound-tests: indicator-sound-tests-gtester Makefile.am -# @echo "#!/bin/sh" > $@ -# @echo $(DBUS_RUNNER) --task ./indicator-sound-tests-gtester >> $@ -# @chmod +x $@ +indicator-sound-tests: indicator-sound-tests-gtester Makefile.am + @echo "#!/bin/sh" > $@ + @echo $(DBUS_RUNNER) --task ./indicator-sound-tests-gtester >> $@ + @chmod +x $@ indicator-sound-tests-gtester: test-indicator-sound Makefile.am @echo "#!/bin/sh" > $@ @@ -84,14 +80,14 @@ TESTS += indicator-sound-tests DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) indicator-sound-tests-gtester -#DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf +DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -#test-indicator-sound-dbus: test-indicator-sound-dbus-client test-indicator-sound-dbus-server Makefile.am -# @echo "#!/bin/sh" > test-indicator-sound-dbus -# @echo $(DBUS_RUNNER) --task ./test-indicator-sound-dbus-client --task-name Client --task ./test-indicator-sound-dbus-server --task-name Server --ignore-return >> test-indicator-sound-dbus -# @chmod +x test-indicator-sound-dbus +test-indicator-sound-dbus: test-indicator-sound-dbus-client test-indicator-sound-dbus-server Makefile.am + @echo "#!/bin/sh" > test-indicator-sound-dbus + @echo $(DBUS_RUNNER) --task ./test-indicator-sound-dbus-client --task-name Client --task ./test-indicator-sound-dbus-server --task-name Server --ignore-return >> test-indicator-sound-dbus + @chmod +x test-indicator-sound-dbus -#TESTS += test-indicator-sound-dbus +TESTS += test-indicator-sound-dbus diff --git a/tests/test-indicator-sound-dbus-client.c b/tests/test-indicator-sound-dbus-client.c index dc36ae3..08ce93e 100644 --- a/tests/test-indicator-sound-dbus-client.c +++ b/tests/test-indicator-sound-dbus-client.c @@ -25,7 +25,6 @@ with this program. If not, see . #include #include #include "../src/dbus-shared-names.h" -/*#include "../src/indicator-sound.c"*/ #include "test-defines.h" static GMainLoop * mainloop = NULL; @@ -78,10 +77,14 @@ main (gint argc, gchar * argv[]) } DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, - INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_SERVICE_DBUS_OBJECT, INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, - &error); + &error); +/* ":1.0",*/ +/* "/need/a/path",*/ +/* DBUS_INTERFACE_PROPERTIES,*/ +/* &error);*/ if (error != NULL) { g_error("Unable to get property proxy: %s", error->message); return 1; -- cgit v1.2.3 From 87478982de012b8322090f40a747ab42f7dd838c Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Wed, 3 Mar 2010 16:46:30 +0000 Subject: Test menuitem name. --- src/indicator-sound.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index acacddc..49c02fa 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -439,6 +439,10 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat gdouble current_value = gtk_range_get_value(range); gdouble new_value = current_value; const gdouble five_percent = 5; + GtkWidget *menuitem; + + menuitem = gtk_menu_get_active (GTK_MENU (widget)); + g_print (g_type_name (menuitem)); switch(event->keyval) { -- cgit v1.2.3 From 90f724e9890f4631eecab0eb46275558a28111bc Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Mar 2010 17:00:03 +0000 Subject: uncomment close down code --- src/sound-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound-service.c b/src/sound-service.c index af1f1e9..91b5af3 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -137,8 +137,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! -/* close_pulse_activites();*/ -/* g_main_loop_quit(mainloop);*/ + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From eb3df565591fb7474aa5290db83ca601a7edd1ee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Mar 2010 17:23:08 +0000 Subject: fixes the key listener problems --- src/indicator-sound.c | 86 ++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 49c02fa..63d48aa 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -441,51 +441,53 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat const gdouble five_percent = 5; GtkWidget *menuitem; - menuitem = gtk_menu_get_active (GTK_MENU (widget)); - g_print (g_type_name (menuitem)); - - switch(event->keyval) - { - case GDK_Right: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 100; - } - else - { - new_value = current_value + five_percent; - } - break; - case GDK_Left: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 0; - } - else + menuitem = GTK_MENU_SHELL (widget)->active_menu_item; +/* g_print ("object (%p) name should be %s", menuitem, G_OBJECT_TYPE_NAME(menuitem));*/ + if(IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) + { + switch(event->keyval) { + case GDK_Right: + digested = TRUE; + if(event->state & GDK_CONTROL_MASK) + { + new_value = 100; + } + else + { + new_value = current_value + five_percent; + } + break; + case GDK_Left: + digested = TRUE; + if(event->state & GDK_CONTROL_MASK) + { + new_value = 0; + } + else + { + new_value = current_value - five_percent; + } + break; + case GDK_plus: + digested = TRUE; + new_value = current_value + five_percent; + break; + case GDK_minus: + digested = TRUE; new_value = current_value - five_percent; + break; + default: + break; + } + + new_value = CLAMP(new_value, 0, 100); + if(new_value != current_value && current_state != STATE_MUTED) + { + g_debug("Attempting to set the range from the key listener to %f", new_value); + gtk_range_set_value(range, new_value); } - break; - case GDK_plus: - digested = TRUE; - new_value = current_value + five_percent; - break; - case GDK_minus: - digested = TRUE; - new_value = current_value - five_percent; - break; - default: - break; - } - - new_value = CLAMP(new_value, 0, 100); - if(new_value != current_value && current_state != STATE_MUTED) - { - g_debug("Attempting to set the range from the key listener to %f", new_value); - gtk_range_set_value(range, new_value); - } + } return digested; } -- cgit v1.2.3 From 55fe3e5a44992862735b4ef2208300dbfccacebb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Mar 2010 17:33:28 +0000 Subject: removed trace and made sure the service closes down probably --- src/indicator-sound.c | 1 - src/sound-service.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 63d48aa..1301916 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -442,7 +442,6 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat GtkWidget *menuitem; menuitem = GTK_MENU_SHELL (widget)->active_menu_item; -/* g_print ("object (%p) name should be %s", menuitem, G_OBJECT_TYPE_NAME(menuitem));*/ if(IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) { switch(event->keyval) diff --git a/src/sound-service.c b/src/sound-service.c index af1f1e9..91b5af3 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -137,8 +137,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! -/* close_pulse_activites();*/ -/* g_main_loop_quit(mainloop);*/ + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From e2a152628f20271f5373702ad88fda483e0403ca Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Mar 2010 21:57:43 +0000 Subject: debug trace was incorrect --- src/sound-service-dbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 952a2d3..72337fd 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -48,7 +48,7 @@ struct _SoundServiceDbusPrivate /* Signals */ enum { - SINK_INPUT_WHILE_MUTED, + SINK_INPUT_WHILE_MUTED, SINK_VOLUME_UPDATE, SINK_MUTE_UPDATE, LAST_SIGNAL @@ -121,7 +121,7 @@ sound_service_dbus_init (SoundServiceDbus *self) priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { - g_error("Unable to connect to the session bus when creating application indicator: %s", error->message); + g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message); g_error_free(error); return; } -- cgit v1.2.3 From cb864e17102163154fa313d5f9344e9c6c2cbe16 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Mar 2010 10:56:49 +0000 Subject: updated the revision number for todays release --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 48022e2..157e650 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-sound.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.1.1) +AM_INIT_AUTOMAKE(indicator-sound, 0.1.2) AM_MAINTAINER_MODE -- cgit v1.2.3 From 633b514efeaf1c4086e1b2e5fbef185b199517c8 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Mar 2010 16:19:54 +0000 Subject: internationalisation reinstated whoops --- src/dbus-menu-manager.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 3e33932..17003df 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -18,6 +18,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + +#include +#include + #include #include @@ -112,7 +116,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")); } @@ -185,7 +189,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); @@ -207,7 +211,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service // Sound preferences dialog DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, - ("Sound Preferences...")); + _("Sound Preferences...")); dbusmenu_menuitem_child_append(root, settings_mi); g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_sound_settings_dialog), NULL); @@ -223,7 +227,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")); } -- cgit v1.2.3 From 6b706a64c5bdcc4b33adfa94b5fa71dbda928399 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Mar 2010 18:02:45 +0000 Subject: slider stretching in place --- src/dbus-menu-manager.c | 5 ++--- src/indicator-sound.c | 47 +++++++++++++++++++++-------------------------- src/slider-menu-item.c | 1 + src/sound-service.c | 4 ++-- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 17003df..d2102ef 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #include #include @@ -210,8 +209,8 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service // Sound preferences dialog DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, - _("Sound Preferences...")); + dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences...")); +//_("Sound Preferences...")); dbusmenu_menuitem_child_append(root, settings_mi); g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_sound_settings_dialog), NULL); diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 3a6ae30..098b24f 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -78,14 +78,14 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE); static GtkLabel * get_label (IndicatorObject * io); static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); + //Slider related static GtkWidget *volume_slider = NULL; static gboolean new_slider_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); -// Alternative callback mechanism, may use this again once ido is updated. -/*static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data);*/ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); +static void slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data); // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; @@ -96,6 +96,7 @@ static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value static void fetch_volume_percent_from_dbus(); static void fetch_mute_value_from_dbus(); + /****Volume States 'members' ***/ static void update_state(const gint state); @@ -201,6 +202,7 @@ get_menu (IndicatorObject * io) return GTK_MENU(menu); } + /** new_slider_item: Create a new dBusMenu Slider item. @@ -220,10 +222,9 @@ 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); + g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); - // alternative callback mechanism which i could use again at some point. -/* g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); */ - + g_signal_connect(slider, "size-allocate", G_CALLBACK(slider_size_allocate), NULL); // Set images on the ido primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU); @@ -277,9 +278,6 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u return; } - - - /* Prepare states Array. */ @@ -451,6 +449,21 @@ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) return FALSE; } +/** +slider_size_allocate: +Callback on the size-allocate event on the slider item. +**/ +static void slider_size_allocate(GtkWidget *widget, + GtkAllocation *allocation, + gpointer user_data) +{ + g_print("size allocate on slider (%dx%d)\n", allocation->width, allocation->height); + if(allocation->width < 200) + { + gtk_widget_set_size_request(widget, 200, -1); + } +} + /** key_press_cb: **/ @@ -514,22 +527,4 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat return digested; } -/** -This callback should only be called when the user actually drags the slider. -Turned off for now in favour of the non descriminating value-changed call back. -Once the grabbing listener is implemented on the slider may revert to using this. -Its another tool for filtering unwanted volume change updates. -**/ -/*static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data)*/ -/*{*/ -/* DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data;*/ -/* gdouble clamped_input = CLAMP(input_value, 0, 100);*/ -/* GValue value = {0};*/ -/* g_debug("User input on SLIDER - = %f", clamped_input);*/ -/* g_value_init(&value, G_TYPE_DOUBLE);*/ -/* g_value_set_double(&value, clamped_input);*/ -/* dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0);*/ -/* return FALSE; */ -/*} */ - diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index ef3b1fa..a14f4f9 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -92,6 +92,7 @@ SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_vol SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_SLIDER_MENUITEM_TYPE); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, sinks_available); return self; } diff --git a/src/sound-service.c b/src/sound-service.c index 403b2b0..9e967c2 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -44,8 +44,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); +/* close_pulse_activites();*/ +/* g_main_loop_quit(mainloop);*/ } return; } -- cgit v1.2.3 From 378c3c3f79aae564090593af6c6ce6abdb3c541a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Mar 2010 18:34:15 +0000 Subject: correct size now being used for the icons - design_team_size --- src/indicator-sound.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 098b24f..28f85b8 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -116,6 +116,9 @@ static gint previous_state = 0; static gdouble initial_volume_percent = 0; static gboolean initial_mute = FALSE; +#define DESIGN_TEAM_SIZE design_team_size +static GtkIconSize design_team_size; + // Construction static void indicator_sound_class_init (IndicatorSoundClass *klass) @@ -129,6 +132,8 @@ indicator_sound_class_init (IndicatorSoundClass *klass) io_class->get_label = get_label; io_class->get_image = get_icon; io_class->get_menu = get_menu; + + design_team_size = gtk_icon_size_register("design-team-size", 22, 22); /* dbus_g_object_register_marshaller (_sound_service_marshal_VOID__INT_BOOLEAN,*/ /* G_TYPE_NONE,*/ @@ -181,7 +186,7 @@ get_icon (IndicatorObject * io) { gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); //g_debug("At start-up attempting to set the image to %s", current_name); - speaker_image = GTK_IMAGE(gtk_image_new_from_icon_name(current_name, GTK_ICON_SIZE_MENU)); + speaker_image = GTK_IMAGE(gtk_image_new_from_icon_name(current_name, DESIGN_TEAM_SIZE)); gtk_widget_show(GTK_WIDGET(speaker_image)); return speaker_image; } @@ -227,9 +232,9 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p g_signal_connect(slider, "size-allocate", G_CALLBACK(slider_size_allocate), NULL); // Set images on the ido primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); - gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), DESIGN_TEAM_SIZE); GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); - gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), DESIGN_TEAM_SIZE); gtk_widget_show_all(volume_slider); @@ -325,7 +330,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)); - gtk_image_set_from_icon_name(speaker_image, image_name, GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name(speaker_image, image_name, DESIGN_TEAM_SIZE); } -- cgit v1.2.3 From 8d392c8f315f18c1ebc52850141b103897e2eea2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 5 Mar 2010 10:38:57 +0000 Subject: blocking event now being registered, removed unneccessary marshaller --- src/Makefile.am | 18 ++---------------- src/dbus-menu-manager.c | 3 ++- src/indicator-sound.c | 17 ++++++----------- src/sound-service-dbus.h | 4 ---- 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 40a8fdd..73bb259 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,9 +11,7 @@ libsoundmenu_la_SOURCES = \ indicator-sound.h \ indicator-sound.c \ dbus-shared-names.h \ - sound-service-client.h \ - sound-service-marshal.c \ - sound-service-marshal.h + sound-service-client.h libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror libsoundmenu_la_LIBADD = $(APPLET_LIBS) @@ -30,16 +28,6 @@ sound-service-client.h: $(srcdir)/sound-service.xml --output=sound-service-client.h \ $(srcdir)/sound-service.xml -sound-service-marshal.h: $(srcdir)/sound-service.list - glib-genmarshal --header \ - --prefix=_sound_service_marshal $(srcdir)/sound-service.list \ - > sound-service-marshal.h - -sound-service-marshal.c: $(srcdir)/sound-service.list - glib-genmarshal --body \ - --prefix=_sound_service_marshal $(srcdir)/sound-service.list \ - > sound-service-marshal.c - ################# # Session Stuff @@ -74,9 +62,7 @@ sound-service-server.h: $(srcdir)/sound-service.xml ############### BUILT_SOURCES = \ sound-service-client.h \ - sound-service-server.h \ - sound-service-marshal.h \ - sound-service-marshal.c + sound-service-server.h EXTRA_DIST = \ sound-service.xml \ diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index d2102ef..243a3a7 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -157,7 +157,8 @@ static void refresh_menu() /** - +idle_routine: +Something for glip mainloop to do when idle **/ static gboolean idle_routine (gpointer data) { diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 28f85b8..1fb8090 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -90,7 +90,7 @@ static void slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation, // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata); -/*static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean value, gpointer userdata);*/ +static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean value, gpointer userdata); static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata); static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata); static void fetch_volume_percent_from_dbus(); @@ -135,11 +135,6 @@ indicator_sound_class_init (IndicatorSoundClass *klass) design_team_size = gtk_icon_size_register("design-team-size", 22, 22); -/* dbus_g_object_register_marshaller (_sound_service_marshal_VOID__INT_BOOLEAN,*/ -/* G_TYPE_NONE,*/ -/* G_TYPE_INT,*/ -/* G_TYPE_BOOLEAN,*/ -/* G_TYPE_INVALID);*/ return; } @@ -264,7 +259,7 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u g_debug("about to connect to the signals"); dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_BOOLEAN, G_TYPE_INVALID); -/* dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL);*/ + dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL); dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_TYPE_DOUBLE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL); dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); @@ -393,10 +388,10 @@ static void fetch_mute_value_from_dbus() g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute); } -/*static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata)*/ -/*{*/ -/* g_debug("signal caught - sink input while muted with value %i", block_value);*/ -/*}*/ +static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) +{ + g_debug("signal caught - sink input while muted with value %i", block_value); +} static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) { diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index ef0d7dd..1a06117 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -49,10 +49,6 @@ struct _SoundServiceDbus { struct _SoundServiceDbusClass { GObjectClass parent_class; - /* Signals -> outward messages to the DBUS and beyond*/ - // TODO - ARE THESE NECESSARY ? - //void (* sink_input_while_muted) (SoundServiceDbus *self, gboolean block_value, gpointer sound_data); - //void (* sink_volume_update) (SoundServiceDbus *self, gdouble sink_volume, gpointer sound_data); }; GType sound_service_dbus_get_type (void) G_GNUC_CONST; -- cgit v1.2.3 From c462eb03f66d00a39562d00238f5dce35f371df6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 8 Mar 2010 19:12:18 +0000 Subject: no sink available dynamically being handled --- src/common-defs.h | 1 + src/dbus-menu-manager.c | 5 +++- src/indicator-sound.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++-- src/pulse-manager.c | 15 ++++++---- src/sound-service-dbus.c | 37 ++++++++++++++++++++++-- src/sound-service-dbus.h | 1 + src/sound-service.xml | 10 +++++++ 7 files changed, 134 insertions(+), 10 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index 942e269..9be1da5 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -22,6 +22,7 @@ with this program. If not, see . #define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted" #define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate" #define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate" +#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" // DBUS items #define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 243a3a7..38ed727 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -101,6 +101,8 @@ void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_availabl refresh_menu(); } // Emit the signals after the menus are setup/torn down + // preserve ordering ! + sound_service_dbus_update_sink_availability(dbus_interface, sink_available); sound_service_dbus_update_sink_volume(dbus_interface, percent); sound_service_dbus_update_sink_mute(dbus_interface, sink_muted); dbus_menu_manager_update_mute_ui(b_all_muted); @@ -199,7 +201,8 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem)); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_ENABLED, - b_sink_available); + b_sink_available && !b_all_muted); + g_debug("!!!!!!**in the rebuild sound menu - slider active = %i", b_sink_available && !b_all_muted); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, b_sink_available); diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 1fb8090..c10b549 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -93,8 +93,10 @@ static void connection_changed (IndicatorServiceManager * sm, gboolean connected static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean value, gpointer userdata); static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata); static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata); +static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata); static void fetch_volume_percent_from_dbus(); static void fetch_mute_value_from_dbus(); +static void fetch_sink_availability_from_dbus(); /****Volume States 'members' ***/ @@ -110,11 +112,13 @@ static const gint STATE_SINKS_NONE = 6; static GHashTable *volume_states = NULL; static GtkImage *speaker_image = NULL; +static GtkImage *blocking_image = NULL; static GtkWidget* primary_image = NULL; static gint current_state = 0; static gint previous_state = 0; static gdouble initial_volume_percent = 0; static gboolean initial_mute = FALSE; +static gboolean device_available = TRUE; #define DESIGN_TEAM_SIZE design_team_size static GtkIconSize design_team_size; @@ -182,6 +186,8 @@ get_icon (IndicatorObject * io) gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); //g_debug("At start-up attempting to set the image to %s", current_name); speaker_image = GTK_IMAGE(gtk_image_new_from_icon_name(current_name, DESIGN_TEAM_SIZE)); + gchar* blocking_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + blocking_image = GTK_IMAGE(gtk_image_new_from_icon_name(blocking_name, DESIGN_TEAM_SIZE)); gtk_widget_show(GTK_WIDGET(speaker_image)); return speaker_image; } @@ -264,11 +270,14 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL); dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), NULL, NULL); + dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL); // Ensure we are in a coherent state with the service at start up. // Preserve ordering! fetch_volume_percent_from_dbus(); fetch_mute_value_from_dbus(); + fetch_sink_availability_from_dbus(); } } else { @@ -332,7 +341,8 @@ static void update_state(const gint state) void determine_state_from_volume(gdouble volume_percent) { /* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/ - + if (device_available == FALSE) + return; gint state = previous_state; if (volume_percent < 30.0 && volume_percent > 0){ state = STATE_LOW; @@ -350,6 +360,25 @@ void determine_state_from_volume(gdouble volume_percent) } +static void fetch_sink_availability_from_dbus() +{ + GError * error = NULL; + gboolean *available_input; + available_input = g_new0(gboolean, 1); + org_ayatana_indicator_sound_get_sink_availability(sound_dbus_proxy, available_input, &error); + if (error != NULL) { + g_warning("Unable to fetch AVAILABILITY at indicator start up: %s", error->message); + g_error_free(error); + g_free(available_input); + return; + } + device_available = *available_input; + if (device_available == FALSE) + update_state(STATE_SINKS_NONE); + g_free(available_input); + g_debug("IndicatorSound::fetch_sink_availability_from_dbus -> AVAILABILTY returned from dbus method is %i", device_available); + +} static void fetch_volume_percent_from_dbus() { @@ -391,6 +420,38 @@ static void fetch_mute_value_from_dbus() static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) { g_debug("signal caught - sink input while muted with value %i", block_value); + if (block_value == 1) { + GError* error= NULL; + // We can assume we are in the muted state ! + GtkIconTheme* theme = gtk_icon_theme_get_default(); + GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, + g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)), + 22, + GTK_ICON_LOOKUP_GENERIC_FALLBACK, + &error); + if(error != NULL){ + g_error("indicator-sound : catch_signal_sink_input_while_muted - %s", error->message); + g_error_free(error); + return; + } + gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + GdkPixbuf* blocked_buf = gtk_icon_theme_load_icon(theme, blocked_name, + 22, + GTK_ICON_LOOKUP_GENERIC_FALLBACK, + &error); + if(error != NULL){ + g_error("indicator-sound : catch_signal_sink_input_while_muted - %s", error->message); + g_error_free(error); + return; + } + g_debug("gdk_pixbuf_get_width returns %i", gdk_pixbuf_get_width(blocked_buf)); + gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, + gdk_pixbuf_get_width(blocked_buf), + gdk_pixbuf_get_height(blocked_buf), + 0, 0, 1, 1, GDK_INTERP_BILINEAR, 128); + //gtk_image_set_from_icon_name(speaker_image, blocked_name, DESIGN_TEAM_SIZE); + //gtk_image_set_from_pixbuf(speaker_image, blocked_buf); + } } static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) @@ -409,13 +470,23 @@ static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value { //We can be sure the service won't send a mute signal unless it has changed ! //UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here. - if(mute_value == TRUE) + if(mute_value == TRUE && device_available != FALSE) { update_state(STATE_MUTED); } g_debug("signal caught - sink mute update with mute value: %i", mute_value); gtk_widget_set_sensitive(volume_slider, !mute_value); } + +static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata) +{ + device_available = available_value; + if (device_available == FALSE){ + update_state(STATE_SINKS_NONE); + } + g_debug("signal caught - sink availability update with value: %i", available_value); +} + /** slider_prop_change_cb: Whenever we have a property change on a DbusmenuMenuitem this will be called. diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 36e6351..40add4e 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -282,7 +282,7 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in else{ //Update the indicator to show PA either is not ready or has no available sink g_warning("Cannot find a suitable default sink ..."); - dbus_menu_manager_update_pa_state(FALSE, device_available, TRUE, 0); + dbus_menu_manager_update_pa_state(FALSE, device_available, default_sink_is_muted(), get_default_sink_volume()); } } else{ @@ -398,6 +398,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v } else { + sink_info *value; value = g_new0(sink_info, 1); value->index = value->device_index = info->index; @@ -411,7 +412,8 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v value->channel_map = info->channel_map; g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value); g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash"); - } + sound_service_dbus_update_sink_availability(dbus_service, TRUE); + } } @@ -460,8 +462,11 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event g_debug("PA_SUBSCRIPTION_EVENT_SINK event triggered"); if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - //TODO handle the remove event => if its our default sink - update date pa state - } else + if(index == DEFAULT_SINK_INDEX) + g_debug("PA_SUBSCRIPTION_EVENT_SINK REMOVAL event triggered"); + sound_service_dbus_update_sink_availability(dbus_service, FALSE); + } + else { pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata)); } @@ -470,7 +475,7 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event g_debug("PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!"); if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { - //TODO handle the remove event + //handle the remove event - not relevant for current design } else { diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 72337fd..1cc5f0d 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -32,6 +32,7 @@ // DBUS methods static gboolean sound_service_dbus_get_sink_volume(SoundServiceDbus* service, gdouble* volume_percent_input, GError** gerror); static gboolean sound_service_dbus_get_sink_mute(SoundServiceDbus* service, gboolean* mute_input, GError** gerror); +static gboolean sound_service_dbus_get_sink_availability(SoundServiceDbus* service, gboolean* availability_input, GError** gerror); static void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror); #include "sound-service-server.h" @@ -43,6 +44,7 @@ struct _SoundServiceDbusPrivate DBusGConnection *connection; gdouble volume_percent; gboolean mute; + gboolean sink_availability; }; @@ -51,6 +53,7 @@ enum { SINK_INPUT_WHILE_MUTED, SINK_VOLUME_UPDATE, SINK_MUTE_UPDATE, + SINK_AVAILABLE_UPDATE, LAST_SIGNAL }; @@ -105,6 +108,15 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + signals[SINK_AVAILABLE_UPDATE] = g_signal_new("sink-available-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + } @@ -116,6 +128,8 @@ sound_service_dbus_init (SoundServiceDbus *self) priv->connection = NULL; priv->volume_percent = 0; + priv->mute = FALSE; + priv->sink_availability = FALSE; /* Fetch the session bus */ priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); @@ -129,8 +143,6 @@ sound_service_dbus_init (SoundServiceDbus *self) dbus_g_connection_register_g_object(priv->connection, "/org/ayatana/indicator/sound/service", G_OBJECT(self)); - - return; } @@ -174,6 +186,14 @@ static gboolean sound_service_dbus_get_sink_mute (SoundServiceDbus *self, gboole return TRUE; } +static gboolean sound_service_dbus_get_sink_availability (SoundServiceDbus *self, gboolean *availability_input, GError** gerror) +{ + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); + g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability); + *availability_input = priv->sink_availability; + return TRUE; +} + /** SIGNALS Utility methods to emit signals from the service into the ether. @@ -212,5 +232,18 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mu priv->mute); } +void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availability) +{ + g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability); + + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); + priv->sink_availability = sink_availability; + + g_signal_emit(obj, + signals[SINK_AVAILABLE_UPDATE], + 0, + priv->sink_availability); +} + diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index 1a06117..ae4953e 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -56,6 +56,7 @@ GType sound_service_dbus_get_type (void) G_GNUC_CONST; void sound_service_dbus_sink_input_while_muted (SoundServiceDbus* obj, gboolean block_value); void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume); void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute); +void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availibity); G_END_DECLS diff --git a/src/sound-service.xml b/src/sound-service.xml index 580f0e1..12ed03e 100644 --- a/src/sound-service.xml +++ b/src/sound-service.xml @@ -5,6 +5,7 @@ + @@ -15,6 +16,11 @@ + + + + + @@ -30,6 +36,10 @@ Our respective UI element should listen to this and therefore will be updated wi + + + + -- cgit v1.2.3 From ea8064d34d73a1b242cc571fbfd9f0f39128178a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 9 Mar 2010 18:10:09 +0000 Subject: smoother slider actions due ido grabbing update and pixbuf icon loading problems --- src/dbus-menu-manager.c | 5 ++ src/indicator-sound.c | 124 ++++++++++++++++++++++++++++++------------------ 2 files changed, 83 insertions(+), 46 deletions(-) diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 38ed727..64f7108 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -154,6 +154,11 @@ static void refresh_menu() DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); } +/* if(b_all_muted == TRUE){*/ +/* dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), */ +/* DBUSMENU_MENUITEM_PROP_ENABLED,*/ +/* FALSE); */ +/* }*/ } diff --git a/src/indicator-sound.c b/src/indicator-sound.c index c10b549..5fd68b2 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -5,7 +5,7 @@ into the gnome-panel using it's applet interface. Copyright 2010 Canonical Ltd. Authors: - Conor Curran + Conor Curran Ted Gould This program is free software: you can redistribute it and/or modify it @@ -82,10 +82,12 @@ static GtkMenu * get_menu (IndicatorObject * io); //Slider related static GtkWidget *volume_slider = NULL; static gboolean new_slider_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); -static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); +/*static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget);*/ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); static void slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data); +static void slider_grabbed(GtkWidget *widget, gpointer user_data); +static void slider_released(GtkWidget *widget, gpointer user_data); // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; @@ -98,7 +100,6 @@ static void fetch_volume_percent_from_dbus(); static void fetch_mute_value_from_dbus(); static void fetch_sink_availability_from_dbus(); - /****Volume States 'members' ***/ static void update_state(const gint state); @@ -112,13 +113,13 @@ static const gint STATE_SINKS_NONE = 6; static GHashTable *volume_states = NULL; static GtkImage *speaker_image = NULL; -static GtkImage *blocking_image = NULL; -static GtkWidget* primary_image = NULL; static gint current_state = 0; static gint previous_state = 0; + static gdouble initial_volume_percent = 0; static gboolean initial_mute = FALSE; static gboolean device_available = TRUE; +static gboolean slider_in_direct_use = FALSE; #define DESIGN_TEAM_SIZE design_team_size static GtkIconSize design_team_size; @@ -184,10 +185,8 @@ static GtkImage * get_icon (IndicatorObject * io) { gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); - //g_debug("At start-up attempting to set the image to %s", current_name); + g_debug("At start-up attempting to set the image to %s", current_name); speaker_image = GTK_IMAGE(gtk_image_new_from_icon_name(current_name, DESIGN_TEAM_SIZE)); - gchar* blocking_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); - blocking_image = GTK_IMAGE(gtk_image_new_from_icon_name(blocking_name, DESIGN_TEAM_SIZE)); gtk_widget_show(GTK_WIDGET(speaker_image)); return speaker_image; } @@ -204,7 +203,6 @@ get_menu (IndicatorObject * io) // register Key-press listening on the menu widget as the slider does not allow this. g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); - return GTK_MENU(menu); } @@ -224,15 +222,16 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); - g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider); +/* g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider);*/ // register slider changes listening on the range GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - - g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); - g_signal_connect(slider, "size-allocate", G_CALLBACK(slider_size_allocate), NULL); + 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); + g_signal_connect(slider, "size-allocate", G_CALLBACK(slider_size_allocate), NULL); // Set images on the ido - primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); + GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), DESIGN_TEAM_SIZE); GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), DESIGN_TEAM_SIZE); @@ -413,6 +412,9 @@ static void fetch_mute_value_from_dbus() initial_mute = *mute_input; if (initial_mute == TRUE) update_state(STATE_MUTED); +// TODO bug down below - VIRTUALLY IMPOSSIBLE TO SETUP SLIDER WITH ANY ALTERNATIVE STARTUP STATE +/* GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);*/ +/* gtk_widget_set_sensitive(slider, !initial_mute);*/ g_free(mute_input); g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute); } @@ -423,18 +425,25 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean blo if (block_value == 1) { GError* error= NULL; // We can assume we are in the muted state ! + gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); GtkIconTheme* theme = gtk_icon_theme_get_default(); - GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, - g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)), - 22, - GTK_ICON_LOOKUP_GENERIC_FALLBACK, - &error); + g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name)); +/* GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, */ +/* blocked_name,*/ +/* 22,*/ +/* GTK_ICON_LOOKUP_GENERIC_FALLBACK,*/ +/* &error);*/ if(error != NULL){ g_error("indicator-sound : catch_signal_sink_input_while_muted - %s", error->message); g_error_free(error); return; } - gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + + GtkIconInfo* buffer_icon_info = gtk_icon_theme_lookup_icon(theme, blocked_name, + 22, + GTK_ICON_LOOKUP_GENERIC_FALLBACK); + g_debug("The icon name of the buffer icon %s", gtk_icon_info_get_filename(buffer_icon_info)); + GdkPixbuf* blocked_buf = gtk_icon_theme_load_icon(theme, blocked_name, 22, GTK_ICON_LOOKUP_GENERIC_FALLBACK, @@ -445,25 +454,34 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean blo return; } g_debug("gdk_pixbuf_get_width returns %i", gdk_pixbuf_get_width(blocked_buf)); - gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, - gdk_pixbuf_get_width(blocked_buf), - gdk_pixbuf_get_height(blocked_buf), - 0, 0, 1, 1, GDK_INTERP_BILINEAR, 128); +/* gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0,*/ +/* gdk_pixbuf_get_width(blocked_buf),*/ +/* gdk_pixbuf_get_height(blocked_buf), */ +/* 0, 0, 1, 1, GDK_INTERP_BILINEAR, 128);*/ //gtk_image_set_from_icon_name(speaker_image, blocked_name, DESIGN_TEAM_SIZE); - //gtk_image_set_from_pixbuf(speaker_image, blocked_buf); + + g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name)); + gchar ** theme_path; + gint nelements = 1; + + gtk_icon_theme_get_search_path(theme, &theme_path, &nelements); + g_debug("icon theme path is %s ", *theme_path); + gtk_image_set_from_pixbuf(speaker_image, blocked_buf); } } static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) { - GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - GtkRange *range = (GtkRange*)slider; - - // DEBUG - gdouble current_value = gtk_range_get_value(range); - g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); - gtk_range_set_value(range, volume_percent); - determine_state_from_volume(volume_percent); + if (slider_in_direct_use != TRUE){ + GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + GtkRange *range = (GtkRange*)slider; + + // DEBUG + gdouble current_value = gtk_range_get_value(range); + g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); + gtk_range_set_value(range, volume_percent); + determine_state_from_volume(volume_percent); + } } static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata) @@ -491,15 +509,15 @@ static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean av slider_prop_change_cb: Whenever we have a property change on a DbusmenuMenuitem this will be called. **/ -static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget) -{ - g_debug("slider_prop_change_cb - dodgy updater "); - g_debug("about to set the slider to %f", g_value_get_double(value)); - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - GtkRange* range = (GtkRange*)slider; - gtk_range_set_value(range, g_value_get_double(value)); - return; -} +/*static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget)*/ +/*{*/ +/* g_debug("slider_prop_change_cb - dodgy updater ");*/ +/* g_debug("about to set the slider to %f", g_value_get_double(value));*/ +/* GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);*/ +/* GtkRange* range = (GtkRange*)slider; */ +/* gtk_range_set_value(range, g_value_get_double(value)); */ +/* return;*/ +/*}*/ /** value_changed_event_cb: @@ -520,6 +538,20 @@ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) return FALSE; } + +static void slider_grabbed (GtkWidget *widget, gpointer user_data) +{ + slider_in_direct_use = TRUE; + g_debug ("!!!!!! grabbed\n"); +} + +static void slider_released (GtkWidget *widget, gpointer user_data) +{ + slider_in_direct_use = FALSE; + g_debug ("!!!!!! released\n"); +} + + /** slider_size_allocate: Callback on the size-allocate event on the slider item. @@ -528,10 +560,10 @@ static void slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data) { - g_print("size allocate on slider (%dx%d)\n", allocation->width, allocation->height); - if(allocation->width < 200) - { - gtk_widget_set_size_request(widget, 200, -1); + g_print("Size allocate on slider (%dx%d)\n", allocation->width, allocation->height); + if(allocation->width < 200){ + g_print("Attempting to resize the slider"); + gtk_widget_set_size_request(widget, 200, -1); } } -- cgit v1.2.3 From 16021586200c0e7746ce787e43a8721dfe23ae48 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Mar 2010 10:53:23 +0000 Subject: fixed that annoying startup in mute state allowing slider to move - race conditions on start up are pretty hairy --- src/indicator-sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 5fd68b2..1876e69 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -235,6 +235,9 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), DESIGN_TEAM_SIZE); GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), DESIGN_TEAM_SIZE); + + // the race conditions at start up are like a west waterford greyhound dart. god knows who wins, who breaks a leg. + gtk_widget_set_sensitive(volume_slider, !initial_mute); gtk_widget_show_all(volume_slider); @@ -412,9 +415,6 @@ static void fetch_mute_value_from_dbus() initial_mute = *mute_input; if (initial_mute == TRUE) update_state(STATE_MUTED); -// TODO bug down below - VIRTUALLY IMPOSSIBLE TO SETUP SLIDER WITH ANY ALTERNATIVE STARTUP STATE -/* GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);*/ -/* gtk_widget_set_sensitive(slider, !initial_mute);*/ g_free(mute_input); g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute); } -- cgit v1.2.3 From 59eb14451f0635c286d482e8b35cad622882aa35 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Mar 2010 18:10:40 +0000 Subject: fade animation in place --- src/indicator-sound.c | 181 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 136 insertions(+), 45 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 1876e69..ebd4306 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -123,6 +123,13 @@ static gboolean slider_in_direct_use = FALSE; #define DESIGN_TEAM_SIZE design_team_size static GtkIconSize design_team_size; +static gint timeout_id; +static gint animation_id; +static GList * blocked_animation_list = NULL; +static GList * blocked_iter = NULL; +static void prepare_blocked_animation(); +static gboolean fade_back_to_mute_image(); +static gboolean commence_animation(); // Construction static void @@ -151,6 +158,9 @@ static void indicator_sound_init (IndicatorSound *self) self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); prepare_state_machine(); + prepare_blocked_animation(); + timeout_id = 0; + animation_id = 0; return; } @@ -164,6 +174,8 @@ indicator_sound_dispose (GObject *object) self->service = NULL; } g_hash_table_destroy(volume_states); + // TODO delete all pointers in the list; + g_list_free(blocked_animation_list); G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object); return; } @@ -305,6 +317,51 @@ void prepare_state_machine() g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel")); } +/* +prepare_blocked_animation: +Prepares the array of images to be used in the blocked animation. +Only called at startup. +*/ +static void prepare_blocked_animation() +{ + GError* error= NULL; + int i; + + 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)); + GtkIconTheme* theme = gtk_icon_theme_get_default(); + GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, + muted_name, + 22, + GTK_ICON_LOOKUP_GENERIC_FALLBACK, + &error); + if(error != NULL){ + g_error("indicator-sound : prepare_blocked_animation - %s", error->message); + g_error_free(error); + return; + } + + GdkPixbuf* blocked_buf = gtk_icon_theme_load_icon(theme, blocked_name, + 22, + GTK_ICON_LOOKUP_GENERIC_FALLBACK, + &error); + if(error != NULL){ + g_error("indicator-sound : prepare_blocked_animation - %s", error->message); + g_error_free(error); + return; + } + + for(i = 0; i < 256; i++) + { + gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, + gdk_pixbuf_get_width(mute_buf), + gdk_pixbuf_get_height(mute_buf), + 0, 0, 1, 1, GDK_INTERP_BILINEAR, i); + g_debug("creating animation - alpha value = %i", i); + blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); + } +} + gint get_state() { return current_state; @@ -365,7 +422,7 @@ void determine_state_from_volume(gdouble volume_percent) static void fetch_sink_availability_from_dbus() { GError * error = NULL; - gboolean *available_input; + gboolean * available_input; available_input = g_new0(gboolean, 1); org_ayatana_indicator_sound_get_sink_availability(sound_dbus_proxy, available_input, &error); if (error != NULL) { @@ -422,53 +479,75 @@ static void fetch_mute_value_from_dbus() static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) { g_debug("signal caught - sink input while muted with value %i", block_value); - if (block_value == 1) { - GError* error= NULL; + if (block_value == 1 && timeout_id == 0 ) { // We can assume we are in the muted state ! - gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); - GtkIconTheme* theme = gtk_icon_theme_get_default(); - g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name)); -/* GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, */ -/* blocked_name,*/ -/* 22,*/ -/* GTK_ICON_LOOKUP_GENERIC_FALLBACK,*/ -/* &error);*/ - if(error != NULL){ - g_error("indicator-sound : catch_signal_sink_input_while_muted - %s", error->message); - g_error_free(error); - return; - } - - GtkIconInfo* buffer_icon_info = gtk_icon_theme_lookup_icon(theme, blocked_name, - 22, - GTK_ICON_LOOKUP_GENERIC_FALLBACK); - g_debug("The icon name of the buffer icon %s", gtk_icon_info_get_filename(buffer_icon_info)); - - GdkPixbuf* blocked_buf = gtk_icon_theme_load_icon(theme, blocked_name, - 22, - GTK_ICON_LOOKUP_GENERIC_FALLBACK, - &error); - if(error != NULL){ - g_error("indicator-sound : catch_signal_sink_input_while_muted - %s", error->message); - g_error_free(error); - return; - } - g_debug("gdk_pixbuf_get_width returns %i", gdk_pixbuf_get_width(blocked_buf)); -/* gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0,*/ -/* gdk_pixbuf_get_width(blocked_buf),*/ -/* gdk_pixbuf_get_height(blocked_buf), */ -/* 0, 0, 1, 1, GDK_INTERP_BILINEAR, 128);*/ - //gtk_image_set_from_icon_name(speaker_image, blocked_name, DESIGN_TEAM_SIZE); - - g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name)); - gchar ** theme_path; - gint nelements = 1; + gtk_image_set_from_icon_name(speaker_image, + g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)), + DESIGN_TEAM_SIZE); + blocked_iter = blocked_animation_list; + timeout_id = g_timeout_add_seconds(3, commence_animation, NULL); + } +} - gtk_icon_theme_get_search_path(theme, &theme_path, &nelements); - g_debug("icon theme path is %s ", *theme_path); - gtk_image_set_from_pixbuf(speaker_image, blocked_buf); - } +static gboolean commence_animation() +{ + animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL); + timeout_id = 0; + g_debug("out of there\n"); + return FALSE; +} + +static gboolean fade_back_to_mute_image() +{ + g_debug("fade me entry\n"); + if(blocked_iter != NULL) + { + g_debug("in there\n"); + gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data); + blocked_iter = blocked_iter->next; + return TRUE; + } + else{ + animation_id = 0; + g_debug("out of there\n"); + return FALSE; + } } +/* int i;*/ +/* GList * anim_iter;*/ +/* anim_iter = blocked_animation_list;*/ +/* for(i=0; i < 2560000; i++)*/ +/* { */ +/* if(i % 100000 == 0)*/ +/* {*/ +/* if (anim_iter != NULL)*/ +/* {*/ +/* gtk_image_set_from_pixbuf(speaker_image, anim_iter->data); */ +/* anim_iter = anim_iter->next; */ +/* g_debug("should now be setting each image");*/ +/* }*/ +/* }*/ +/* }*/ +/* gtk_image_set_from_icon_name(speaker_image,*/ +/* g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)),*/ +/* DESIGN_TEAM_SIZE);*/ + //fade_id = g_timeout_add_seconds(0.2, fade_each_frame, NULL); + + + + +/* g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name));*/ +/* GtkIconInfo* buffer_icon_info = gtk_icon_theme_lookup_icon(theme, blocked_name,*/ +/* 22,*/ +/* GTK_ICON_LOOKUP_GENERIC_FALLBACK);*/ +/* g_debug("The icon name of the buffer icon %s", gtk_icon_info_get_filename(buffer_icon_info));*/ +/* g_debug("gdk_pixbuf_get_width returns %i", gdk_pixbuf_get_width(blocked_buf));*/ +/* g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name));*/ +/* gchar ** theme_path; */ +/* gint nelements = 1;*/ +/* gtk_icon_theme_get_search_path(theme, &theme_path, &nelements);*/ +/* gtk_image_set_from_icon_name(speaker_image, blocked_name, DESIGN_TEAM_SIZE);*/ +/* g_debug("icon theme path is %s ", *theme_path);*/ static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) { @@ -492,6 +571,18 @@ static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value { update_state(STATE_MUTED); } + else{ + if(timeout_id != 0){ + g_debug("about to remove the timeout_id callback from the mainloop!!**"); + g_source_remove(timeout_id); + timeout_id = 0; + } + if(animation_id != 0){ + g_debug("about to remove the animation_id callback from the mainloop!!**"); + g_source_remove(animation_id); + animation_id = 0; + } + } g_debug("signal caught - sink mute update with mute value: %i", mute_value); gtk_widget_set_sensitive(volume_slider, !mute_value); } -- cgit v1.2.3 From c67c7ac2effb7ee425370ee33e6b5449e04b98c6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 11 Mar 2010 00:23:59 +0000 Subject: animation working much better now --- src/indicator-sound.c | 85 +++++---------------------------------------------- 1 file changed, 8 insertions(+), 77 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index ebd4306..d9c5aa6 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -123,13 +123,11 @@ static gboolean slider_in_direct_use = FALSE; #define DESIGN_TEAM_SIZE design_team_size static GtkIconSize design_team_size; -static gint timeout_id; static gint animation_id; static GList * blocked_animation_list = NULL; static GList * blocked_iter = NULL; static void prepare_blocked_animation(); static gboolean fade_back_to_mute_image(); -static gboolean commence_animation(); // Construction static void @@ -152,14 +150,11 @@ indicator_sound_class_init (IndicatorSoundClass *klass) static void indicator_sound_init (IndicatorSound *self) { - /* Set good defaults */ self->service = NULL; - /* Now let's fire these guys up. */ self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); prepare_state_machine(); prepare_blocked_animation(); - timeout_id = 0; animation_id = 0; return; } @@ -234,7 +229,6 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); -/* g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider);*/ // register slider changes listening on the range GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); @@ -306,7 +300,6 @@ Prepare states Array. */ void prepare_state_machine() { - // TODO we need three more images volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel")); g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-low-zero-panel")); @@ -350,14 +343,14 @@ static void prepare_blocked_animation() g_error_free(error); return; } - - for(i = 0; i < 256; i++) + // sample 22 snapshots - range : 0-256 + for(i = 0; i < 23; i++) { gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, gdk_pixbuf_get_width(mute_buf), gdk_pixbuf_get_height(mute_buf), - 0, 0, 1, 1, GDK_INTERP_BILINEAR, i); - g_debug("creating animation - alpha value = %i", i); + 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 11)); + g_debug("creating blocking animation - alpha value = %i", MIN(255, i * 11)); blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); } } @@ -479,75 +472,31 @@ static void fetch_mute_value_from_dbus() static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) { g_debug("signal caught - sink input while muted with value %i", block_value); - if (block_value == 1 && timeout_id == 0 ) { + if (block_value == 1 && animation_id == 0 ) { // We can assume we are in the muted state ! gtk_image_set_from_icon_name(speaker_image, g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)), DESIGN_TEAM_SIZE); blocked_iter = blocked_animation_list; - timeout_id = g_timeout_add_seconds(3, commence_animation, NULL); + animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL); } } - -static gboolean commence_animation() -{ - animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL); - timeout_id = 0; - g_debug("out of there\n"); - return FALSE; -} static gboolean fade_back_to_mute_image() { - g_debug("fade me entry\n"); if(blocked_iter != NULL) { - g_debug("in there\n"); + g_debug("in animation 'loop'\n"); gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data); blocked_iter = blocked_iter->next; return TRUE; } else{ animation_id = 0; - g_debug("out of there\n"); + g_debug("exit from animation\n"); return FALSE; } } -/* int i;*/ -/* GList * anim_iter;*/ -/* anim_iter = blocked_animation_list;*/ -/* for(i=0; i < 2560000; i++)*/ -/* { */ -/* if(i % 100000 == 0)*/ -/* {*/ -/* if (anim_iter != NULL)*/ -/* {*/ -/* gtk_image_set_from_pixbuf(speaker_image, anim_iter->data); */ -/* anim_iter = anim_iter->next; */ -/* g_debug("should now be setting each image");*/ -/* }*/ -/* }*/ -/* }*/ -/* gtk_image_set_from_icon_name(speaker_image,*/ -/* g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)),*/ -/* DESIGN_TEAM_SIZE);*/ - //fade_id = g_timeout_add_seconds(0.2, fade_each_frame, NULL); - - - - -/* g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name));*/ -/* GtkIconInfo* buffer_icon_info = gtk_icon_theme_lookup_icon(theme, blocked_name,*/ -/* 22,*/ -/* GTK_ICON_LOOKUP_GENERIC_FALLBACK);*/ -/* g_debug("The icon name of the buffer icon %s", gtk_icon_info_get_filename(buffer_icon_info));*/ -/* g_debug("gdk_pixbuf_get_width returns %i", gdk_pixbuf_get_width(blocked_buf));*/ -/* g_debug("DOES the ICON THEME Have the Blocked image = %i", gtk_icon_theme_has_icon(theme, blocked_name));*/ -/* gchar ** theme_path; */ -/* gint nelements = 1;*/ -/* gtk_icon_theme_get_search_path(theme, &theme_path, &nelements);*/ -/* gtk_image_set_from_icon_name(speaker_image, blocked_name, DESIGN_TEAM_SIZE);*/ -/* g_debug("icon theme path is %s ", *theme_path);*/ static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) { @@ -572,11 +521,6 @@ static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value update_state(STATE_MUTED); } else{ - if(timeout_id != 0){ - g_debug("about to remove the timeout_id callback from the mainloop!!**"); - g_source_remove(timeout_id); - timeout_id = 0; - } if(animation_id != 0){ g_debug("about to remove the animation_id callback from the mainloop!!**"); g_source_remove(animation_id); @@ -596,19 +540,6 @@ static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean av g_debug("signal caught - sink availability update with value: %i", available_value); } -/** -slider_prop_change_cb: -Whenever we have a property change on a DbusmenuMenuitem this will be called. -**/ -/*static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget)*/ -/*{*/ -/* g_debug("slider_prop_change_cb - dodgy updater ");*/ -/* g_debug("about to set the slider to %f", g_value_get_double(value));*/ -/* GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);*/ -/* GtkRange* range = (GtkRange*)slider; */ -/* gtk_range_set_value(range, g_value_get_double(value)); */ -/* return;*/ -/*}*/ /** value_changed_event_cb: -- cgit v1.2.3 From 69c96d7e7fa903569073bd87069b2d9f6aeb3fa4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Mar 2010 22:59:35 -0600 Subject: Update to use new icon helper from libindicator --- src/indicator-sound.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 3a6ae30..0b92af8 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -34,6 +34,7 @@ with this program. If not, see . #include #include #include +#include #include "indicator-sound.h" #include "dbus-shared-names.h" @@ -180,7 +181,7 @@ get_icon (IndicatorObject * io) { gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); //g_debug("At start-up attempting to set the image to %s", current_name); - speaker_image = GTK_IMAGE(gtk_image_new_from_icon_name(current_name, GTK_ICON_SIZE_MENU)); + speaker_image = indicator_image_helper(current_name); gtk_widget_show(GTK_WIDGET(speaker_image)); return speaker_image; } @@ -327,7 +328,9 @@ static void update_state(const gint state) current_state = state; gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); - gtk_image_set_from_icon_name(speaker_image, image_name, GTK_ICON_SIZE_MENU); + GtkImage * tempimage = indicator_image_helper(image_name); + gtk_image_set_from_pixbuf(speaker_image, gtk_image_get_pixbuf(tempimage)); + g_object_ref_sink(tempimage); } -- cgit v1.2.3 From 21d52b5ed3206791d5a0b4adc907be75a9e5f668 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Mar 2010 23:07:22 -0600 Subject: Using GIcon for setting the icons on the IDO slider. --- src/indicator-sound.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 0b92af8..2dc6bf3 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -225,12 +225,23 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p // alternative callback mechanism which i could use again at some point. /* g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); */ - // Set images on the ido + /* Get the primary Image */ primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); - gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU); + + /* Build a GIcon for the theme fallbacks */ + GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO))); + gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU); + g_object_unref(primary_gicon); + + /* Get the secondary image */ GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); - gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), GTK_ICON_SIZE_MENU); + /* Build a GIcon for fallbacks */ + GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH))); + gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU); + g_object_unref(secondary_gicon); + + /* Make the widget visible to users */ gtk_widget_show_all(volume_slider); return TRUE; -- cgit v1.2.3 From 2431bde2e07bab60b949e79931d236aeb972bfcf Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 11 Mar 2010 18:27:38 +0000 Subject: updated ido version --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 080303c..52e6577 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,7 @@ INDICATOR_REQUIRED_VERSION=0.3.0 DBUSMENUGTK_REQUIRED_VERSION=0.2.2 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 -INDICATOR_DISPLAY_OBJECTS=0.1.2 +INDICATOR_DISPLAY_OBJECTS=0.1.4 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION -- cgit v1.2.3 From 0c3a25b1a354d68c5e07bf898cd983983e84206f Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 11 Mar 2010 16:58:43 -0600 Subject: Set size request to [ 200, -1 ] when the parent changes. --- src/indicator-sound.c | 122 +++++++++++++++++++++++++++----------------------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index aecbe7a..b57cd43 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -8,16 +8,16 @@ Authors: Conor Curran Ted Gould -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 +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 by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, 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 +You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include @@ -94,7 +94,7 @@ static void slider_released(GtkWidget *widget, gpointer user_data); static DBusGProxy *sound_dbus_proxy = NULL; static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata); static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean value, gpointer userdata); -static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata); +static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata); static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata); static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata); static void fetch_volume_percent_from_dbus(); @@ -143,7 +143,7 @@ indicator_sound_class_init (IndicatorSoundClass *klass) io_class->get_label = get_label; io_class->get_image = get_icon; io_class->get_menu = get_menu; - + design_team_size = gtk_icon_size_register("design-team-size", 22, 22); return; @@ -205,15 +205,21 @@ get_icon (IndicatorObject * io) 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); + DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT); + DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); 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. - g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); + g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); return GTK_MENU(menu); } +static void +slider_parent_changed (GtkWidget *widget, + gpointer user_data) +{ + gtk_widget_set_size_request (widget, 200, -1); +} /** new_slider_item: @@ -221,39 +227,43 @@ Create a new dBusMenu Slider item. **/ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); - g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - + 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); - g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); + g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); + + g_signal_connect (volume_slider, + "notify::parent", G_CALLBACK (slider_parent_changed), + NULL); GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); - + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); + // register slider changes listening on the range - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_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); + g_signal_connect(volume_slider, "slider-released", G_CALLBACK(slider_released), NULL); /* g_signal_connect(slider, "size-allocate", G_CALLBACK(slider_size_allocate), NULL);*/ // Set images on the ido - GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); - GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO))); + GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); + GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO))); gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU); - g_object_unref(primary_gicon); + g_object_unref(primary_gicon); - GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); - GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH))); + GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); + GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH))); gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU); - g_object_unref(secondary_gicon); + g_object_unref(secondary_gicon); gtk_widget_set_sensitive(volume_slider, !initial_mute); gtk_widget_show_all(volume_slider); - return TRUE; + return TRUE; } static void @@ -328,8 +338,8 @@ 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)); - GtkIconTheme* theme = gtk_icon_theme_get_default(); - GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, + GtkIconTheme* theme = gtk_icon_theme_get_default(); + GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, muted_name, 22, GTK_ICON_LOOKUP_GENERIC_FALLBACK, @@ -338,7 +348,7 @@ static void prepare_blocked_animation() g_error("indicator-sound : prepare_blocked_animation - %s", error->message); g_error_free(error); return; - } + } GdkPixbuf* blocked_buf = gtk_icon_theme_load_icon(theme, blocked_name, 22, @@ -348,17 +358,17 @@ static void prepare_blocked_animation() g_error("indicator-sound : prepare_blocked_animation - %s", error->message); g_error_free(error); return; - } + } // sample 22 snapshots - range : 0-256 for(i = 0; i < 23; i++) - { + { gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, gdk_pixbuf_get_width(mute_buf), - gdk_pixbuf_get_height(mute_buf), + gdk_pixbuf_get_height(mute_buf), 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 11)); g_debug("creating blocking animation - alpha value = %i", MIN(255, i * 11)); blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); - } + } } @@ -416,15 +426,15 @@ void determine_state_from_volume(gdouble volume_percent) } else if(volume_percent == 0.0){ state = STATE_ZERO; - } - update_state(state); + } + update_state(state); } - + static void fetch_sink_availability_from_dbus() { GError * error = NULL; - gboolean * available_input; + gboolean * available_input; available_input = g_new0(gboolean, 1); org_ayatana_indicator_sound_get_sink_availability(sound_dbus_proxy, available_input, &error); if (error != NULL) { @@ -444,7 +454,7 @@ static void fetch_sink_availability_from_dbus() static void fetch_volume_percent_from_dbus() { GError * error = NULL; - gdouble *volume_percent_input; + gdouble *volume_percent_input; volume_percent_input = g_new0(gdouble, 1); org_ayatana_indicator_sound_get_sink_volume(sound_dbus_proxy, volume_percent_input, &error); if (error != NULL) { @@ -462,7 +472,7 @@ static void fetch_volume_percent_from_dbus() static void fetch_mute_value_from_dbus() { GError * error = NULL; - gboolean *mute_input; + gboolean *mute_input; mute_input = g_new0(gboolean, 1); org_ayatana_indicator_sound_get_sink_mute(sound_dbus_proxy, mute_input, &error); if (error != NULL) { @@ -490,16 +500,16 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean blo 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() { if(blocked_iter != NULL) { g_debug("in animation 'loop'\n"); gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data); - blocked_iter = blocked_iter->next; + blocked_iter = blocked_iter->next; return TRUE; } else{ @@ -513,12 +523,12 @@ static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_pe { if (slider_in_direct_use != TRUE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - GtkRange *range = (GtkRange*)slider; - + GtkRange *range = (GtkRange*)slider; + // DEBUG gdouble current_value = gtk_range_get_value(range); g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); - gtk_range_set_value(range, volume_percent); + gtk_range_set_value(range, volume_percent); determine_state_from_volume(volume_percent); } } @@ -558,13 +568,13 @@ This callback will get triggered irregardless of whether its a user change or a **/ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) { - gdouble current_value = CLAMP(gtk_range_get_value(range), 0, 100); + gdouble current_value = CLAMP(gtk_range_get_value(range), 0, 100); DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; GValue value = {0}; g_value_init(&value, G_TYPE_DOUBLE); g_value_set_double(&value, current_value); g_debug("Value changed callback - = %f", current_value); - dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); + dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); // This is not ideal in that the icon ui will update on ui actions and not on actual service feedback. // but necessary for now as the server does not send volume update information if the source of change was this ui. determine_state_from_volume(current_value); @@ -608,8 +618,8 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat gboolean digested = FALSE; GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - GtkRange* range = (GtkRange*)slider; - gdouble current_value = gtk_range_get_value(range); + GtkRange* range = (GtkRange*)slider; + gdouble current_value = gtk_range_get_value(range); gdouble new_value = current_value; const gdouble five_percent = 5; GtkWidget *menuitem; @@ -638,26 +648,26 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat } else { - new_value = current_value - five_percent; + new_value = current_value - five_percent; } break; case GDK_plus: digested = TRUE; - new_value = current_value + five_percent; + new_value = current_value + five_percent; break; case GDK_minus: digested = TRUE; - new_value = current_value - five_percent; + new_value = current_value - five_percent; break; default: break; - } - + } + new_value = CLAMP(new_value, 0, 100); if(new_value != current_value && current_state != STATE_MUTED) { - g_debug("Attempting to set the range from the key listener to %f", new_value); - gtk_range_set_value(range, new_value); + g_debug("Attempting to set the range from the key listener to %f", new_value); + gtk_range_set_value(range, new_value); } } return digested; -- cgit v1.2.3 From 8de1359af1cf50acdd5a9b8a6f470d5f00d332c5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Mar 2010 10:56:56 +0000 Subject: properly cleaned up the makefile and includes, fixed seg-fault on clearlooks --- src/Makefile.am | 2 -- src/indicator-sound.c | 36 ++++++++++-------------------------- src/sound-service-dbus.c | 1 - src/sound-service.c | 4 ++-- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 73bb259..b7de930 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,8 +43,6 @@ indicator_sound_service_SOURCES = \ sound-service-dbus.h \ sound-service-dbus.c \ sound-service-server.h \ - sound-service-marshal.c \ - sound-service-marshal.h \ slider-menu-item.h \ slider-menu-item.c indicator_sound_service_CFLAGS = $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror diff --git a/src/indicator-sound.c b/src/indicator-sound.c index aecbe7a..1490d7c 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -40,7 +40,6 @@ with this program. If not, see . #include "dbus-shared-names.h" #include "sound-service-client.h" #include "common-defs.h" -#include "sound-service-marshal.h" // GObject Boiler plate #define INDICATOR_SOUND_TYPE (indicator_sound_get_type ()) @@ -323,32 +322,18 @@ Only called at startup. */ static void prepare_blocked_animation() { - GError* error= NULL; - int i; - 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)); - GtkIconTheme* theme = gtk_icon_theme_get_default(); - GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, - muted_name, - 22, - GTK_ICON_LOOKUP_GENERIC_FALLBACK, - &error); - if(error != NULL){ - g_error("indicator-sound : prepare_blocked_animation - %s", error->message); - g_error_free(error); - return; - } - - GdkPixbuf* blocked_buf = gtk_icon_theme_load_icon(theme, blocked_name, - 22, - GTK_ICON_LOOKUP_GENERIC_FALLBACK, - &error); - if(error != NULL){ - g_error("indicator-sound : prepare_blocked_animation - %s", error->message); - g_error_free(error); - return; - } + + 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; + // sample 22 snapshots - range : 0-256 for(i = 0; i < 23; i++) { @@ -356,7 +341,6 @@ static void prepare_blocked_animation() gdk_pixbuf_get_width(mute_buf), gdk_pixbuf_get_height(mute_buf), 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 11)); - g_debug("creating blocking animation - alpha value = %i", MIN(255, i * 11)); blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); } } diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 1cc5f0d..260e064 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -26,7 +26,6 @@ #include "dbus-shared-names.h" #include "sound-service-dbus.h" #include "common-defs.h" -#include "sound-service-marshal.h" #include "pulse-manager.h" // DBUS methods diff --git a/src/sound-service.c b/src/sound-service.c index 403b2b0..9e967c2 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -44,8 +44,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); +/* close_pulse_activites();*/ +/* g_main_loop_quit(mainloop);*/ } return; } -- cgit v1.2.3 From 6f8f32d31dca2ac480e3b8536b4fa57a18abe2d2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Mar 2010 10:59:12 +0000 Subject: uncomment exit service code --- src/sound-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound-service.c b/src/sound-service.c index 9e967c2..403b2b0 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -44,8 +44,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! -/* close_pulse_activites();*/ -/* g_main_loop_quit(mainloop);*/ + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From 9ac1b1a6ecac11d811b453adc75213bf01c21389 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Mar 2010 11:36:00 +0000 Subject: animation will not be used if the theme does not manage to fall back gracefully for mute-blocking icon loading - this should not happen but if it does there is no chance of the nasty seg fault seen with 0.1.3 and clearlooks --- src/indicator-sound.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 1490d7c..4b9fbc3 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -169,8 +169,12 @@ indicator_sound_dispose (GObject *object) self->service = NULL; } g_hash_table_destroy(volume_states); - g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); - g_list_free(blocked_animation_list); + + if(blocked_animation_list != NULL){ + g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); + g_list_free(blocked_animation_list); + } + G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object); return; } @@ -322,18 +326,23 @@ Only called at startup. */ static void prepare_blocked_animation() { - gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + //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); + temp_image = indicator_image_helper("wrong_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; + } + // sample 22 snapshots - range : 0-256 for(i = 0; i < 23; i++) { @@ -466,14 +475,16 @@ 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 ) { - // We can assume we are in the muted state ! - 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); - - blocked_iter = blocked_animation_list; - animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL); + if(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); + + blocked_iter = blocked_animation_list; + animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL); + } } } -- cgit v1.2.3 From 60f21441622d5b5c6d504cfc95872f4f12633593 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Mar 2010 11:49:34 +0000 Subject: removed test case --- src/indicator-sound.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 4b9fbc3..105f00b 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -326,14 +326,13 @@ Only called at startup. */ static void prepare_blocked_animation() { - //gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + 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("wrong_name"); - + temp_image = indicator_image_helper(blocked_name); GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); int i; -- cgit v1.2.3 From 5dc32749af6b8281efcf94970fcb9f4863d93163 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Mar 2010 18:07:48 +0000 Subject: this race condition is tricky one --- src/dbus-menu-manager.c | 5 ----- src/indicator-sound.c | 37 ++++++++++++++++--------------------- src/pulse-manager.c | 4 ++-- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 64f7108..38ed727 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -154,11 +154,6 @@ static void refresh_menu() DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); } -/* if(b_all_muted == TRUE){*/ -/* dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), */ -/* DBUSMENU_MENUITEM_PROP_ENABLED,*/ -/* FALSE); */ -/* }*/ } diff --git a/src/indicator-sound.c b/src/indicator-sound.c index d59d300..aa87410 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -117,9 +117,9 @@ static gint current_state = 0; static gint previous_state = 0; static gdouble initial_volume_percent = 0; -static gboolean initial_mute = FALSE; -static gboolean device_available = TRUE; -static gboolean slider_in_direct_use = FALSE; +static gboolean initial_mute ; +static gboolean device_available; +static gboolean slider_in_direct_use; static GtkIconSize design_team_size; static gint animation_id; @@ -151,10 +151,14 @@ static void indicator_sound_init (IndicatorSound *self) { self->service = NULL; self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); - g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); prepare_state_machine(); prepare_blocked_animation(); animation_id = 0; + initial_mute = FALSE; + device_available = TRUE; + slider_in_direct_use = FALSE; + + g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); return; } @@ -195,7 +199,7 @@ static GtkImage * get_icon (IndicatorObject * io) { gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); - //g_debug("At start-up attempting to set the image to %s", current_name); + g_debug("At start-up attempting to set the image to %s", current_name); speaker_image = indicator_image_helper(current_name); gtk_widget_show(GTK_WIDGET(speaker_image)); return speaker_image; @@ -221,6 +225,8 @@ slider_parent_changed (GtkWidget *widget, gpointer user_data) { gtk_widget_set_size_request (widget, 200, -1); + g_debug("slider parent changed"); + //fetch_volume_percent_from_dbus(); } /** @@ -437,6 +443,9 @@ static void fetch_sink_availability_from_dbus() device_available = *available_input; if (device_available == FALSE) update_state(STATE_SINKS_NONE); + g_debug("NO DEVICE AVAILABLE"); + + gtk_widget_set_sensitive(volume_slider, device_available); g_free(available_input); g_debug("IndicatorSound::fetch_sink_availability_from_dbus -> AVAILABILTY returned from dbus method is %i", device_available); @@ -511,7 +520,7 @@ static gboolean fade_back_to_mute_image() static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) { - if (slider_in_direct_use != TRUE){ + if (slider_in_direct_use == FALSE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); GtkRange *range = (GtkRange*)slider; @@ -527,7 +536,7 @@ static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value { //We can be sure the service won't send a mute signal unless it has changed ! //UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here. - if(mute_value == TRUE && device_available != FALSE) + if(mute_value == TRUE && device_available == TRUE) { update_state(STATE_MUTED); } @@ -585,20 +594,6 @@ static void slider_released (GtkWidget *widget, gpointer user_data) } -/** -slider_size_allocate: -Callback on the size-allocate event on the slider item. -**/ -/*static void slider_size_allocate(GtkWidget *widget,*/ -/* GtkAllocation *allocation, */ -/* gpointer user_data)*/ -/*{*/ -/* g_print("Size allocate on slider (%dx%d)\n", allocation->width, allocation->height);*/ -/* if(allocation->width < 200){*/ -/* g_print("Attempting to resize the slider");*/ -/* gtk_widget_set_size_request(widget, 200, -1); */ -/* }*/ -/*}*/ /** key_press_cb: diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 40add4e..e1634a9 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -67,8 +67,8 @@ void establish_pulse_activities(SoundServiceDbus *service) // Establish event callback registration pa_context_set_state_callback(pulse_context, context_state_callback, NULL); - // BUILD MENU ANYWHO - it will be updated - dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0); + // Broadcast init state (assume we have a device - if not the signals will handle it) + dbus_menu_manager_update_pa_state(FALSE, TRUE, FALSE, 0); pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL); } -- cgit v1.2.3 From 1e4f7e51d59456dac5c8d3e0a99b843b27c4cd63 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Mar 2010 18:13:55 +0000 Subject: update the configure.ac with 0.1.3.1 release number and incremented indicator dependency version to 0.3.5 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 52e6577..770245a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.1.3, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.1.3.1, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.1.3) +AM_INIT_AUTOMAKE(indicator-sound, 0.1.3.1) AM_MAINTAINER_MODE @@ -26,7 +26,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) ########################### GTK_REQUIRED_VERSION=2.12 -INDICATOR_REQUIRED_VERSION=0.3.0 +INDICATOR_REQUIRED_VERSION=0.3.5 DBUSMENUGTK_REQUIRED_VERSION=0.2.2 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 -- cgit v1.2.3 From a328ac78b812c6ff782aac701975ceded0ea2f4f Mon Sep 17 00:00:00 2001 From: David Barth Date: Mon, 15 Mar 2010 14:29:31 +0100 Subject: applying i18n fix from Luca Ferretti --- po/POTFILES.in | 3 +-- src/dbus-menu-manager.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 6cb8472..423ff8e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,4 +1,3 @@ [encoding: UTF-8] data/indicator-sound.schemas.in -src/indicator-sound.c -src/sound-service.c +src/dbus-menu-manager.c 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")); } -- cgit v1.2.3 From 911af759c760cbbe8b8631bcfb2749a9f72b40ab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 08:42:17 -0500 Subject: Use the libindicator update helper to reset the base image for theme updates. --- src/indicator-sound.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index aa87410..3b2b426 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -400,9 +400,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,9 +491,7 @@ 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); -- cgit v1.2.3 From c20b69cf13582bf738c0dc3a76b8065fbd32665b Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Tue, 16 Mar 2010 16:31:32 -0500 Subject: Implement scroll method. --- src/indicator-sound.c | 56 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 3b2b426..6dcc56b 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -7,6 +7,7 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran Ted Gould + Cody Russell 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); @@ -211,8 +215,13 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { + g_print ("get_menu(): %s\n", G_OBJECT_TYPE_NAME (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,9 +244,15 @@ 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); + io = g_object_get_data (G_OBJECT (client), "indicator"); + + g_print ("new_slider_item(): %s\n", G_OBJECT_TYPE_NAME (io)); + volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 0.5); g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); @@ -252,6 +267,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 +360,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 @@ -495,7 +512,7 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean blo 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() @@ -655,3 +672,20 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat } +static void +scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction) +{ + 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); + + g_print ("scroll %d!!\n", (gint)direction); +} -- cgit v1.2.3 From 6e407358a9f48bcf24c6224b35cd2845fdf56004 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Wed, 17 Mar 2010 01:23:33 -0500 Subject: Remove some debugging output. --- src/indicator-sound.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 6dcc56b..e9a8e73 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -215,8 +215,6 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { - g_print ("get_menu(): %s\n", G_OBJECT_TYPE_NAME (io)); - DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT); DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); @@ -251,8 +249,6 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p io = g_object_get_data (G_OBJECT (client), "indicator"); - g_print ("new_slider_item(): %s\n", G_OBJECT_TYPE_NAME (io)); - volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 0.5); g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); @@ -686,6 +682,4 @@ scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction) gtk_range_set_value (GTK_RANGE (sound->slider), value); - - g_print ("scroll %d!!\n", (gint)direction); } -- cgit v1.2.3 From da7146ab578829c406c4d3ccde8b89443ba634c9 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 18 Mar 2010 15:38:40 +0000 Subject: intermediate test removal --- tests/Makefile.am | 88 +++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a0b990b..4767f76 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,8 +1,8 @@ check_PROGRAMS = \ - test-indicator-sound \ - test-indicator-sound-dbus-client \ - test-indicator-sound-dbus-server + test-indicator-sound +# test-indicator-sound-dbus-client \ +# test-indicator-sound-dbus-server TESTS = DISTCLEANFILES = $(TESTS) @@ -27,67 +27,67 @@ test_indicator_sound_LDADD = \ ######################################### ## test-indicator-sound-dbus-client ######################################### -test_indicator_sound_dbus_client_SOURCES = \ - test-defines.h \ - test-indicator-sound-dbus-client.c +#test_indicator_sound_dbus_client_SOURCES = \ +# test-defines.h \ +# test-indicator-sound-dbus-client.c -test_indicator_sound_dbus_client_CFLAGS = \ - $(SOUNDSERVICE_CFLAGS) \ - -Wall -Werror \ - -I$(srcdir) +#test_indicator_sound_dbus_client_CFLAGS = \ +# $(SOUNDSERVICE_CFLAGS) \ +# -Wall -Werror \ +# -I$(srcdir) -test_indicator_sound_dbus_client_LDADD = \ - $(SOUNDSERVICE_LIBS) +#test_indicator_sound_dbus_client_LDADD = \ +# $(SOUNDSERVICE_LIBS) ######################################## # test-indicator-sound-dbus-server ######################################## -test_indicator_sound_dbus_server_SOURCES = \ - test-defines.h \ - test-indicator-sound-dbus-server.c \ - $(top_builddir)/src/sound-service-dbus.c \ - $(top_builddir)/src/pulse-manager.c \ - $(top_builddir)/src/slider-menu-item.c \ - $(top_builddir)/src/dbus-menu-manager.c - -test_indicator_sound_dbus_server_CFLAGS = \ - $(SOUNDSERVICE_CFLAGS) \ - -Wall -Werror \ - -I$(srcdir) +#test_indicator_sound_dbus_server_SOURCES = \ +# test-defines.h \ +# test-indicator-sound-dbus-server.c \ +# $(top_builddir)/src/sound-service-dbus.c \ +# $(top_builddir)/src/pulse-manager.c \ +# $(top_builddir)/src/slider-menu-item.c \ +# $(top_builddir)/src/dbus-menu-manager.c + +#test_indicator_sound_dbus_server_CFLAGS = \ +# $(SOUNDSERVICE_CFLAGS) \ +# -Wall -Werror \ +# -I$(srcdir) -test_indicator_sound_dbus_server_LDADD = \ - $(SOUNDSERVICE_LIBS) +#test_indicator_sound_dbus_server_LDADD = \ +# $(SOUNDSERVICE_LIBS) ######################################### ## Actual tests ######################################### -XML_REPORT = indicator-sound-check-results.xml -HTML_REPORT = indicator-sound-check-results.html +#XML_REPORT = indicator-sound-check-results.xml +#HTML_REPORT = indicator-sound-check-results.html -indicator-sound-tests: indicator-sound-tests-gtester Makefile.am - @echo "#!/bin/sh" > $@ - @echo $(DBUS_RUNNER) --task ./indicator-sound-tests-gtester >> $@ - @chmod +x $@ +#indicator-sound-tests: indicator-sound-tests-gtester Makefile.am +# @echo "#!/bin/sh" > $@ +# @echo $(DBUS_RUNNER) --task ./indicator-sound-tests-gtester >> $@ +# @chmod +x $@ -indicator-sound-tests-gtester: test-indicator-sound Makefile.am - @echo "#!/bin/sh" > $@ - @echo gtester -k --verbose -o=$(XML_REPORT) ./test-indicator-sound >> $@ - @chmod +x $@ +#indicator-sound-tests-gtester: test-indicator-sound Makefile.am +# @echo "#!/bin/sh" > $@ +# @echo gtester -k --verbose -o=$(XML_REPORT) ./test-indicator-sound >> $@ +# @chmod +x $@ -TESTS += indicator-sound-tests +#TESTS += indicator-sound-tests -DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) indicator-sound-tests-gtester +#DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) indicator-sound-tests-gtester -DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf +#DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -test-indicator-sound-dbus: test-indicator-sound-dbus-client test-indicator-sound-dbus-server Makefile.am - @echo "#!/bin/sh" > test-indicator-sound-dbus - @echo $(DBUS_RUNNER) --task ./test-indicator-sound-dbus-client --task-name Client --task ./test-indicator-sound-dbus-server --task-name Server --ignore-return >> test-indicator-sound-dbus - @chmod +x test-indicator-sound-dbus +#test-indicator-sound-dbus: test-indicator-sound-dbus-client test-indicator-sound-dbus-server Makefile.am +# @echo "#!/bin/sh" > test-indicator-sound-dbus +# @echo $(DBUS_RUNNER) --task ./test-indicator-sound-dbus-client --task-name Client --task ./test-indicator-sound-dbus-server --task-name Server --ignore-return >> test-indicator-sound-dbus +# @chmod +x test-indicator-sound-dbus -TESTS += test-indicator-sound-dbus +#TESTS += test-indicator-sound-dbus -- cgit v1.2.3