diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-09-09 14:00:06 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-09-09 14:00:06 +0000 |
commit | 5878e6b03deeacda2293ff733faaa436932dda95 (patch) | |
tree | 9dab360b74ba642606d9562edbddb8ee4caa4761 /libindicator/indicator-ng.c | |
parent | 86f3d9e211daa64c99047734cd81f7d75ad7ed09 (diff) | |
parent | 9e857c3e55be6a7f2bb30f1edbdf94f3f97c8ba7 (diff) | |
download | libayatana-indicator-5878e6b03deeacda2293ff733faaa436932dda95.tar.gz libayatana-indicator-5878e6b03deeacda2293ff733faaa436932dda95.tar.bz2 libayatana-indicator-5878e6b03deeacda2293ff733faaa436932dda95.zip |
Expose scrolling and middle clicking to fix bug #1221242 and #1204036 (make scrolling and middle clicking work on the sound indicator). Fixes: https://bugs.launchpad.net/bugs/1204036, https://bugs.launchpad.net/bugs/1221242.
Approved by Charles Kerr, PS Jenkins bot.
Diffstat (limited to 'libindicator/indicator-ng.c')
-rw-r--r-- | libindicator/indicator-ng.c | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/libindicator/indicator-ng.c b/libindicator/indicator-ng.c index d8ac840..8d3304b 100644 --- a/libindicator/indicator-ng.c +++ b/libindicator/indicator-ng.c @@ -33,6 +33,8 @@ struct _IndicatorNg gchar *bus_name; gchar *profile; gchar *header_action; + gchar *scroll_action; + gchar *secondary_action; gint position; guint name_watch_id; @@ -158,6 +160,8 @@ indicator_ng_finalize (GObject *object) g_free (self->bus_name); g_free (self->accessible_desc); g_free (self->header_action); + g_free (self->scroll_action); + g_free (self->secondary_action); G_OBJECT_CLASS (indicator_ng_parent_class)->finalize (object); } @@ -179,6 +183,37 @@ indicator_ng_get_position (IndicatorObject *io) } static void +indicator_ng_entry_scrolled (IndicatorObject *io, + IndicatorObjectEntry *entry, + gint delta, + IndicatorScrollDirection direction) +{ + IndicatorNg *self = INDICATOR_NG (io); + + if (self->actions && self->scroll_action) + { + if (direction == INDICATOR_OBJECT_SCROLL_DOWN) + delta *= -1; + g_action_group_activate_action (self->actions, self->scroll_action, + g_variant_new_int32 (delta)); + } +} + +void +indicator_ng_secondary_activate (IndicatorObject *io, + IndicatorObjectEntry *entry, + guint timestamp, + gpointer user_data) +{ + IndicatorNg *self = INDICATOR_NG (io); + + if (self->actions && self->secondary_action) + { + g_action_group_activate_action (self->actions, self->secondary_action, NULL); + } +} + +static void indicator_ng_set_accessible_desc (IndicatorNg *self, const gchar *accessible_desc) { @@ -332,16 +367,33 @@ indicator_ng_menu_changed (GMenuModel *menu, if (added) { g_clear_pointer (&self->header_action, g_free); + g_clear_pointer (&self->scroll_action, g_free); + g_clear_pointer (&self->secondary_action, g_free); if (indicator_ng_menu_item_is_of_type (self->menu, 0, "com.canonical.indicator.root")) { GMenuModel *popup; gchar *action; - if (g_menu_model_get_item_attribute (self->menu, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action) && - g_str_has_prefix (action, "indicator.")) + if (g_menu_model_get_item_attribute (self->menu, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action)) { - self->header_action = g_strdup (action + strlen ("indicator.")); + if (g_str_has_prefix (action, "indicator.")) + self->header_action = g_strdup (action + strlen ("indicator.")); + g_free (action); + } + + if (g_menu_model_get_item_attribute (self->menu, 0, "x-canonical-scroll-action", "s", &action)) + { + if (g_str_has_prefix (action, "indicator.")) + self->scroll_action = g_strdup (action + strlen ("indicator.")); + g_free (action); + } + + if (g_menu_model_get_item_attribute (self->menu, 0, "x-canonical-secondary-action", "s", &action)) + { + if (g_str_has_prefix (action, "indicator.")) + self->secondary_action = g_strdup (action + strlen ("indicator.")); + g_free (action); } popup = g_menu_model_get_item_link (self->menu, 0, G_MENU_LINK_SUBMENU); @@ -352,8 +404,6 @@ indicator_ng_menu_changed (GMenuModel *menu, } indicator_ng_update_entry (self); - - g_free (action); } else g_warning ("indicator menu item must be of type 'com.canonical.indicator.root'"); @@ -570,6 +620,8 @@ indicator_ng_class_init (IndicatorNgClass *class) io_class->get_entries = indicator_ng_get_entries; io_class->get_position = indicator_ng_get_position; + io_class->entry_scrolled = indicator_ng_entry_scrolled; + io_class->secondary_activate = indicator_ng_secondary_activate; properties[PROP_SERVICE_FILE] = g_param_spec_string ("service-file", "Service file", |