aboutsummaryrefslogtreecommitdiff
path: root/libindicator/indicator-ng.c
diff options
context:
space:
mode:
Diffstat (limited to 'libindicator/indicator-ng.c')
-rw-r--r--libindicator/indicator-ng.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/libindicator/indicator-ng.c b/libindicator/indicator-ng.c
index d8ac840..3e63dcd 100644
--- a/libindicator/indicator-ng.c
+++ b/libindicator/indicator-ng.c
@@ -33,6 +33,7 @@ struct _IndicatorNg
gchar *bus_name;
gchar *profile;
gchar *header_action;
+ gchar *scroll_action;
gint position;
guint name_watch_id;
@@ -158,6 +159,7 @@ 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_OBJECT_CLASS (indicator_ng_parent_class)->finalize (object);
}
@@ -179,6 +181,23 @@ 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));
+ }
+}
+
+static void
indicator_ng_set_accessible_desc (IndicatorNg *self,
const gchar *accessible_desc)
{
@@ -332,16 +351,25 @@ indicator_ng_menu_changed (GMenuModel *menu,
if (added)
{
g_clear_pointer (&self->header_action, g_free);
+ g_clear_pointer (&self->scroll_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))
+ {
+ 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))
{
- self->header_action = g_strdup (action + strlen ("indicator."));
+ if (g_str_has_prefix (action, "indicator."))
+ self->scroll_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 +380,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 +596,7 @@ 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;
properties[PROP_SERVICE_FILE] = g_param_spec_string ("service-file",
"Service file",