From 6c14ce6ac83759bba2575d13705541352dad6441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sun, 17 Jul 2011 16:13:15 +0200 Subject: indicator-sound: handle the mute-menu-item and toggle it Handle the mute menu item with a mute widget, then associate the secondary_activate libindicator signal to a function that toggles the status of mute_widget, to apply the change in all the indicator-sound framework. --- src/indicator-sound.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src/indicator-sound.c') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 76bf710..a7ba95c 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -39,6 +39,7 @@ with this program. If not, see . #include "voip-input-widget.h" #include "dbus-shared-names.h" #include "sound-state-manager.h" +#include "mute-widget.h" #include "gen-sound-service.xml.h" #include "common-defs.h" @@ -49,6 +50,7 @@ struct _IndicatorSoundPrivate { GtkWidget* volume_widget; GtkWidget* voip_widget; + MuteWidget *mute_widget; GList* transport_widgets_list; GDBusProxy *dbus_proxy; SoundStateManager* state_manager; @@ -75,6 +77,10 @@ static const gchar * get_accessible_desc (IndicatorObject * io); static void indicator_sound_scroll (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction); +static void indicator_sound_middle_click (IndicatorObject * io, + IndicatorObjectEntry * entry, + guint time, gint x, gint y, + gpointer data); //key/moust event handlers static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); @@ -97,6 +103,10 @@ static gboolean new_metadata_widget (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +static gboolean new_mute_widget (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data); // DBUS communication static GDBusNodeInfo *node_info = NULL; @@ -125,6 +135,7 @@ indicator_sound_class_init (IndicatorSoundClass *klass) io_class->get_menu = get_menu; io_class->get_accessible_desc = get_accessible_desc; io_class->entry_scrolled = indicator_sound_scroll; + io_class->secondary_activate = indicator_sound_middle_click; } static void @@ -137,6 +148,7 @@ indicator_sound_init (IndicatorSound *self) IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); priv->volume_widget = NULL; priv->voip_widget = NULL; + priv->mute_widget = NULL; priv->dbus_proxy = NULL; GList* t_list = NULL; priv->transport_widgets_list = t_list; @@ -207,6 +219,9 @@ get_menu (IndicatorObject * io) dbusmenu_client_add_type_handler (DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget); + dbusmenu_client_add_type_handler (DBUSMENU_CLIENT(client), + DBUSMENU_MUTE_MENUITEM_TYPE, + new_mute_widget); // Note: Not ideal but all key handling needs to be managed here and then // delegated to the appropriate widget. g_signal_connect (menu, "key-press-event", G_CALLBACK(key_press_cb), io); @@ -459,6 +474,36 @@ new_voip_slider_widget (DbusmenuMenuitem * newitem, return TRUE; } +static gboolean +new_mute_widget(DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data) +{ + 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"); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); + + if (priv->mute_widget != NULL){ + g_object_unref (priv->mute_widget); + priv->mute_widget = NULL; + } + + priv->mute_widget = mute_widget_new(newitem); + GtkMenuItem *item = mute_widget_get_menu_item (priv->mute_widget); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), + newitem, + item, + parent); + + return TRUE; +} + /*******************************************************************/ //UI callbacks /******************************************************************/ @@ -677,6 +722,16 @@ indicator_sound_scroll (IndicatorObject * io, IndicatorObjectEntry * entry, sound_state_manager_show_notification (priv->state_manager, value); } +static void +indicator_sound_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, + guint time, gint x, gint y, gpointer data) +{ + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); + g_return_if_fail (priv); + + mute_widget_toggle(priv->mute_widget); +} + void update_accessible_desc (IndicatorObject * io) { -- cgit v1.2.3 From a2871b1b51c2f26a5778a6f15c5cae6650cc8fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 21 Jul 2011 18:12:12 +0200 Subject: X and Y pointer position aren't exported anymore by libindicator Dropping them! --- src/indicator-sound.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/indicator-sound.c') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index a7ba95c..7c72900 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -79,8 +79,7 @@ static void indicator_sound_scroll (IndicatorObject * io, IndicatorScrollDirection direction); static void indicator_sound_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, - guint time, gint x, gint y, - gpointer data); + guint time, gpointer data); //key/moust event handlers static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); @@ -724,7 +723,7 @@ indicator_sound_scroll (IndicatorObject * io, IndicatorObjectEntry * entry, static void indicator_sound_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, - guint time, gint x, gint y, gpointer data) + guint time, gpointer data) { IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); g_return_if_fail (priv); -- cgit v1.2.3