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
=== modified file 'src/application-service-appstore.c'
--- src/application-service-appstore.c 2011-07-07 15:16:51 +0000
+++ src/application-service-appstore.c 2011-07-21 20:16:40 +0000
@@ -142,6 +142,7 @@
142static void check_with_new_approver (gpointer papp, gpointer papprove);142static void check_with_new_approver (gpointer papp, gpointer papprove);
143static void check_with_old_approver (gpointer papprove, gpointer papp);143static void check_with_old_approver (gpointer papprove, gpointer papp);
144static Application * find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object);144static Application * find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object);
145static Application * find_application_by_menu (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * menuobject);
145static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);146static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
146static void dbus_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);147static void dbus_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
147static void app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);148static void app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
@@ -263,31 +264,20 @@
263{264{
264 ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data);265 ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data);
265 GVariant * retval = NULL;266 GVariant * retval = NULL;
267 Application *app = NULL;
268 const gchar *dbusaddress;
269 const gchar *dbusmenuobject;
266270
267 if (g_strcmp0(method, "GetApplications") == 0) {271 if (g_strcmp0(method, "GetApplications") == 0) {
268 retval = get_applications(service);272 retval = get_applications(service);
269 } else if (g_strcmp0(method, "ApplicationScrollEvent") == 0) {273 } else if (g_strcmp0(method, "ApplicationScrollEvent") == 0) {
270 Application *app = NULL;
271 const gchar *dbusaddress;
272 const gchar *dbusobject;
273 gchar *orientation = NULL;274 gchar *orientation = NULL;
274 gint delta;275 gint delta;
275 guint direction;276 guint direction;
276277
277 g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusobject,278 g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusmenuobject,
278 &delta, &direction);279 &delta, &direction);
279280
280 GList *l;
281 for (l = service->priv->applications; l != NULL; l = l->next) {
282 Application *a = l->data;
283
284 if (g_strcmp0(a->dbus_name, dbusaddress) == 0 &&
285 g_strcmp0(a->menu, dbusobject) == 0) {
286 app = a;
287 break;
288 }
289 }
290
291 switch (direction) {281 switch (direction) {
292 case INDICATOR_OBJECT_SCROLL_UP:282 case INDICATOR_OBJECT_SCROLL_UP:
293 delta = -delta;283 delta = -delta;
@@ -301,9 +291,22 @@
301 orientation = "horizontal";291 orientation = "horizontal";
302 }292 }
303293
294 app = find_application_by_menu(service, dbusaddress, dbusmenuobject);
295
304 if (app != NULL && app->dbus_proxy != NULL && orientation != NULL) {296 if (app != NULL && app->dbus_proxy != NULL && orientation != NULL) {
305 g_dbus_proxy_call(app->dbus_proxy, "Scroll",297 g_dbus_proxy_call(app->dbus_proxy, "Scroll",
306 g_variant_new("(is)", delta, orientation),298 g_variant_new("(is)", delta, orientation),
299 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
300 }
301 } else if (g_strcmp0(method, "ApplicationSecondaryActivateEvent") == 0) {
302 guint time;
303
304 g_variant_get (params, "(&s&su)", &dbusaddress, &dbusmenuobject, &time);
305 app = find_application_by_menu(service, dbusaddress, dbusmenuobject);
306
307 if (app != NULL && app->dbus_proxy != NULL) {
308 g_dbus_proxy_call(app->dbus_proxy, "XAyatanaSecondaryActivate",
309 g_variant_new("(u)", time),
307 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);310 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
308 }311 }
309 } else {312 } else {
@@ -1199,6 +1202,28 @@
1199 return NULL;1202 return NULL;
1200}1203}
12011204
1205/* Looks for an application in the list of applications with the matching menu */
1206static Application *
1207find_application_by_menu (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * menuobject)
1208{
1209 g_return_val_if_fail(appstore, NULL);
1210 g_return_val_if_fail(address, NULL);
1211 g_return_val_if_fail(menuobject, NULL);
1212
1213 ApplicationServiceAppstorePrivate * priv = appstore->priv;
1214 GList *l;
1215
1216 for (l = priv->applications; l != NULL; l = l->next) {
1217 Application *a = l->data;
1218 if (g_strcmp0(a->dbus_name, address) == 0 &&
1219 g_strcmp0(a->menu, menuobject) == 0) {
1220 return a;
1221 }
1222 }
1223
1224 return NULL;
1225}
1226
1202/* Removes an application. Currently only works for the apps1227/* Removes an application. Currently only works for the apps
1203 that are shown. */1228 that are shown. */
1204void1229void
12051230
=== modified file 'src/application-service.xml'
--- src/application-service.xml 2011-07-07 15:16:51 +0000
+++ src/application-service.xml 2011-07-21 20:16:40 +0000
@@ -34,6 +34,11 @@
34 <arg type="i" name="delta" direction="in" />34 <arg type="i" name="delta" direction="in" />
35 <arg type="u" name="direction" direction="in" />35 <arg type="u" name="direction" direction="in" />
36 </method>36 </method>
37 <method name="ApplicationSecondaryActivateEvent">
38 <arg type="s" name="dbusaddress" direction="in" />
39 <arg type="s" name="dbusobject" direction="in" />
40 <arg type="u" name="time" direction="in" />
41 </method>
3742
38<!-- Signals -->43<!-- Signals -->
39 <signal name="ApplicationAdded">44 <signal name="ApplicationAdded">
4045
=== modified file 'src/indicator-application.c'
--- src/indicator-application.c 2011-07-07 15:39:10 +0000
+++ src/indicator-application.c 2011-07-21 20:16:40 +0000
@@ -110,6 +110,7 @@
110static GList * get_entries (IndicatorObject * io);110static GList * get_entries (IndicatorObject * io);
111static guint get_location (IndicatorObject * io, IndicatorObjectEntry * entry);111static guint get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
112static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction);112static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction);
113static void entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint time, gpointer data);
113void connection_changed (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application);114void connection_changed (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application);
114static void connected (IndicatorApplication * application);115static void connected (IndicatorApplication * application);
115static void disconnected (IndicatorApplication * application);116static void disconnected (IndicatorApplication * application);
@@ -144,6 +145,7 @@
144145
145 io_class->get_entries = get_entries;146 io_class->get_entries = get_entries;
146 io_class->get_location = get_location;147 io_class->get_location = get_location;
148 io_class->secondary_activate = entry_secondary_activate;
147 io_class->entry_scrolled = entry_scrolled;149 io_class->entry_scrolled = entry_scrolled;
148150
149 return;151 return;
@@ -402,9 +404,34 @@
402 return g_list_index(priv->applications, entry);404 return g_list_index(priv->applications, entry);
403}405}
404406
407/* Redirect the secondary activate to the Application Item */
408static void
409entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry,
410 guint time, gpointer data)
411{
412 g_return_if_fail(IS_INDICATOR_APPLICATION(io));
413
414 IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io);
415 g_return_if_fail(priv->service_proxy);
416
417 GList *l = g_list_find(priv->applications, entry);
418 if (l == NULL)
419 return;
420
421 ApplicationEntry *app = l->data;
422
423 if (app && app->dbusaddress && app->dbusobject && priv->service_proxy) {
424 g_dbus_proxy_call(priv->service_proxy, "ApplicationSecondaryActivateEvent",
425 g_variant_new("(ssu)", app->dbusaddress,
426 app->dbusobject,
427 time),
428 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
429 }
430}
431
405/* Redirect the scroll event to the Application Item */432/* Redirect the scroll event to the Application Item */
406static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction) {433static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction)
407 434{
408 g_return_if_fail(IS_INDICATOR_APPLICATION(io));435 g_return_if_fail(IS_INDICATOR_APPLICATION(io));
409436
410 IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io);437 IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io);
@@ -418,9 +445,9 @@
418445
419 if (app && app->dbusaddress && app->dbusobject && priv->service_proxy) {446 if (app && app->dbusaddress && app->dbusobject && priv->service_proxy) {
420 g_dbus_proxy_call(priv->service_proxy, "ApplicationScrollEvent",447 g_dbus_proxy_call(priv->service_proxy, "ApplicationScrollEvent",
421 g_variant_new("(ssiu)", app->dbusaddress,448 g_variant_new("(ssiu)", app->dbusaddress,
422 app->dbusobject,449 app->dbusobject,
423 delta, direction),450 delta, direction),
424 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);451 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
425 }452 }
426}453}

Subscribers

People subscribed via source and target branches