From 6db28ce9134db40a0808a3c67df5f9dd223303b5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 12 Jan 2011 17:55:05 -0600 Subject: stage one of the refactor on the server side complete --- src/slider-menu-item.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'src/slider-menu-item.c') diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 0f2f07b..d41ff85 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -29,7 +29,6 @@ with this program. If not, see . typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate; struct _SliderMenuItemPrivate { - gdouble slider_value; }; #define SLIDER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SLIDER_MENU_ITEM_TYPE, SliderMenuItemPrivate)) @@ -76,14 +75,12 @@ slider_menu_item_finalize (GObject *object) G_OBJECT_CLASS (slider_menu_item_parent_class)->finalize (object); } - static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp) { - gdouble volume_input = 0; /*g_debug ( "handle-event in the slider at the backend, input is of type %s", g_variant_get_type_string(value));*/ @@ -96,25 +93,41 @@ handle_event (DbusmenuMenuitem * mi, input = g_variant_get_variant(value); } - volume_input = g_variant_get_double(input); + gboolean volume_input = g_variant_get_double(input); if (value != NULL){ set_sink_volume(volume_input); } g_variant_unref (input); } +void slider_menu_item_update (SliderMenuItem* item, + gdouble update) +{ + // TODO + // Check if that variant below will leak !!! + GVariant* new_volume = g_variant_new_double(update); + dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(item), + DBUSMENU_VOLUME_MENUITEM_LEVEL, + new_volume); +} +void slider_menu_item_enable (SliderMenuItem* item, + gboolean active) +{ + dbusmenu_menuitem_property_set_bool( DBUSMENU_MENUITEM(item), + DBUSMENU_MENUITEM_PROP_ENABLED, + active ); +} -SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_volume) +SliderMenuItem* slider_menu_item_new (gboolean sinks_available, + gdouble start_volume) { SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_VOLUME_MENUITEM_TYPE); + dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self), + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_VOLUME_MENUITEM_TYPE ); + slider_menu_item_update (self, start_volume); + slider_menu_item_enable (self, sinks_available); - 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; -} - - - - +} \ No newline at end of file -- cgit v1.2.3 From b21fd65d6bc0dee49a39fb18f585cbe75acc5e52 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 26 Jan 2011 20:27:23 -0600 Subject: applied fixes --- src/slider-menu-item.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/slider-menu-item.c') diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index d41ff85..64db277 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -86,8 +86,6 @@ handle_event (DbusmenuMenuitem * mi, GVariant* input = NULL; input = value; - g_variant_ref (input); - // Please note: Subject to change in future DBusmenu revisions if (g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT) == TRUE) { input = g_variant_get_variant(value); @@ -97,7 +95,6 @@ handle_event (DbusmenuMenuitem * mi, if (value != NULL){ set_sink_volume(volume_input); } - g_variant_unref (input); } void slider_menu_item_update (SliderMenuItem* item, -- cgit v1.2.3