diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-01-26 21:30:55 -0600 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-01-26 21:30:55 -0600 |
commit | f5aba239f02110c6f0ba2a6c88349c6e59771f65 (patch) | |
tree | 7ede9ec6731b75a310d0bcaad311ce9450a0e865 /src/slider-menu-item.c | |
parent | e832a5fd618e30ea15029d4c029f8796eeb66078 (diff) | |
parent | 2015246e5146a5a03b6b0497aa8ce18a705bd724 (diff) | |
download | ayatana-indicator-sound-f5aba239f02110c6f0ba2a6c88349c6e59771f65.tar.gz ayatana-indicator-sound-f5aba239f02110c6f0ba2a6c88349c6e59771f65.tar.bz2 ayatana-indicator-sound-f5aba239f02110c6f0ba2a6c88349c6e59771f65.zip |
merged big refactor
Diffstat (limited to 'src/slider-menu-item.c')
-rw-r--r-- | src/slider-menu-item.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 0f2f07b..64db277 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -29,7 +29,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. 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,45 +75,56 @@ 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));*/ 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); } - 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 |