Merge lp:~3v1n0/indicator-application/secondary-activate-support into lp:indicator-application/0.4

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 210
Proposed branch: lp:~3v1n0/indicator-application/secondary-activate-support
Merge into: lp:indicator-application/0.4
Diff against target: 186 lines (+78/-21)
3 files modified
src/application-service-appstore.c (+41/-16)
src/application-service.xml (+5/-0)
src/indicator-application.c (+32/-5)
To merge this branch: bzr merge lp:~3v1n0/indicator-application/secondary-activate-support
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+68405@code.launchpad.net

Description of the change

Add support to "secondary-activate" event support for application indicators, as described in bug #812933.

This needs the merge of lp:~3v1n0/libindicator/secondary-activate-support

To post a comment you must log in.
209. By Marco Trevisan (Treviño)

Don't use "SecondaryActivate" method

Using XAyatanaSecondaryActivate as libindicator doesn't support
the mouse x,y position in secondary_activate signal anymore.

This will drop the middle-click support also for KDE status
notifier items, but this is needed as we can't control
what they would do with this signal (and according to our
policies we can't do anything that isn't doable also using
a menu item).

210. By Marco Trevisan (Treviño)

Up

211. By Marco Trevisan (Treviño)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/application-service-appstore.c'
2--- src/application-service-appstore.c 2011-07-07 15:16:51 +0000
3+++ src/application-service-appstore.c 2011-07-21 20:16:40 +0000
4@@ -142,6 +142,7 @@
5 static void check_with_new_approver (gpointer papp, gpointer papprove);
6 static void check_with_old_approver (gpointer papprove, gpointer papp);
7 static Application * find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object);
8+static Application * find_application_by_menu (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * menuobject);
9 static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
10 static void dbus_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
11 static void app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
12@@ -263,31 +264,20 @@
13 {
14 ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data);
15 GVariant * retval = NULL;
16+ Application *app = NULL;
17+ const gchar *dbusaddress;
18+ const gchar *dbusmenuobject;
19
20 if (g_strcmp0(method, "GetApplications") == 0) {
21 retval = get_applications(service);
22 } else if (g_strcmp0(method, "ApplicationScrollEvent") == 0) {
23- Application *app = NULL;
24- const gchar *dbusaddress;
25- const gchar *dbusobject;
26 gchar *orientation = NULL;
27 gint delta;
28 guint direction;
29
30- g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusobject,
31+ g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusmenuobject,
32 &delta, &direction);
33
34- GList *l;
35- for (l = service->priv->applications; l != NULL; l = l->next) {
36- Application *a = l->data;
37-
38- if (g_strcmp0(a->dbus_name, dbusaddress) == 0 &&
39- g_strcmp0(a->menu, dbusobject) == 0) {
40- app = a;
41- break;
42- }
43- }
44-
45 switch (direction) {
46 case INDICATOR_OBJECT_SCROLL_UP:
47 delta = -delta;
48@@ -301,9 +291,22 @@
49 orientation = "horizontal";
50 }
51
52+ app = find_application_by_menu(service, dbusaddress, dbusmenuobject);
53+
54 if (app != NULL && app->dbus_proxy != NULL && orientation != NULL) {
55 g_dbus_proxy_call(app->dbus_proxy, "Scroll",
56- g_variant_new("(is)", delta, orientation),
57+ g_variant_new("(is)", delta, orientation),
58+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
59+ }
60+ } else if (g_strcmp0(method, "ApplicationSecondaryActivateEvent") == 0) {
61+ guint time;
62+
63+ g_variant_get (params, "(&s&su)", &dbusaddress, &dbusmenuobject, &time);
64+ app = find_application_by_menu(service, dbusaddress, dbusmenuobject);
65+
66+ if (app != NULL && app->dbus_proxy != NULL) {
67+ g_dbus_proxy_call(app->dbus_proxy, "XAyatanaSecondaryActivate",
68+ g_variant_new("(u)", time),
69 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
70 }
71 } else {
72@@ -1199,6 +1202,28 @@
73 return NULL;
74 }
75
76+/* Looks for an application in the list of applications with the matching menu */
77+static Application *
78+find_application_by_menu (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * menuobject)
79+{
80+ g_return_val_if_fail(appstore, NULL);
81+ g_return_val_if_fail(address, NULL);
82+ g_return_val_if_fail(menuobject, NULL);
83+
84+ ApplicationServiceAppstorePrivate * priv = appstore->priv;
85+ GList *l;
86+
87+ for (l = priv->applications; l != NULL; l = l->next) {
88+ Application *a = l->data;
89+ if (g_strcmp0(a->dbus_name, address) == 0 &&
90+ g_strcmp0(a->menu, menuobject) == 0) {
91+ return a;
92+ }
93+ }
94+
95+ return NULL;
96+}
97+
98 /* Removes an application. Currently only works for the apps
99 that are shown. */
100 void
101
102=== modified file 'src/application-service.xml'
103--- src/application-service.xml 2011-07-07 15:16:51 +0000
104+++ src/application-service.xml 2011-07-21 20:16:40 +0000
105@@ -34,6 +34,11 @@
106 <arg type="i" name="delta" direction="in" />
107 <arg type="u" name="direction" direction="in" />
108 </method>
109+ <method name="ApplicationSecondaryActivateEvent">
110+ <arg type="s" name="dbusaddress" direction="in" />
111+ <arg type="s" name="dbusobject" direction="in" />
112+ <arg type="u" name="time" direction="in" />
113+ </method>
114
115 <!-- Signals -->
116 <signal name="ApplicationAdded">
117
118=== modified file 'src/indicator-application.c'
119--- src/indicator-application.c 2011-07-07 15:39:10 +0000
120+++ src/indicator-application.c 2011-07-21 20:16:40 +0000
121@@ -110,6 +110,7 @@
122 static GList * get_entries (IndicatorObject * io);
123 static guint get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
124 static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction);
125+static void entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint time, gpointer data);
126 void connection_changed (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application);
127 static void connected (IndicatorApplication * application);
128 static void disconnected (IndicatorApplication * application);
129@@ -144,6 +145,7 @@
130
131 io_class->get_entries = get_entries;
132 io_class->get_location = get_location;
133+ io_class->secondary_activate = entry_secondary_activate;
134 io_class->entry_scrolled = entry_scrolled;
135
136 return;
137@@ -402,9 +404,34 @@
138 return g_list_index(priv->applications, entry);
139 }
140
141+/* Redirect the secondary activate to the Application Item */
142+static void
143+entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry,
144+ guint time, gpointer data)
145+{
146+ g_return_if_fail(IS_INDICATOR_APPLICATION(io));
147+
148+ IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io);
149+ g_return_if_fail(priv->service_proxy);
150+
151+ GList *l = g_list_find(priv->applications, entry);
152+ if (l == NULL)
153+ return;
154+
155+ ApplicationEntry *app = l->data;
156+
157+ if (app && app->dbusaddress && app->dbusobject && priv->service_proxy) {
158+ g_dbus_proxy_call(priv->service_proxy, "ApplicationSecondaryActivateEvent",
159+ g_variant_new("(ssu)", app->dbusaddress,
160+ app->dbusobject,
161+ time),
162+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
163+ }
164+}
165+
166 /* Redirect the scroll event to the Application Item */
167-static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction) {
168-
169+static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction)
170+{
171 g_return_if_fail(IS_INDICATOR_APPLICATION(io));
172
173 IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io);
174@@ -418,9 +445,9 @@
175
176 if (app && app->dbusaddress && app->dbusobject && priv->service_proxy) {
177 g_dbus_proxy_call(priv->service_proxy, "ApplicationScrollEvent",
178- g_variant_new("(ssiu)", app->dbusaddress,
179- app->dbusobject,
180- delta, direction),
181+ g_variant_new("(ssiu)", app->dbusaddress,
182+ app->dbusobject,
183+ delta, direction),
184 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
185 }
186 }

Subscribers

People subscribed via source and target branches