From 1a569c2f0cda67071400682be92b01b4c2641ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sun, 10 Jul 2011 05:18:08 +0200 Subject: Add support to the "SecondaryActivate" method Added support for the missing StatusNotifierItem SecondaryActivate signal. The indicator-application receives the "secondary-activate" signal from libindicator and redirects it via dbus to the proper watcher using the "SecondaryActivate" method, sending the X and Y pointer position as parameters (as defined by the StatusNotifierItem specs). --- src/application-service-appstore.c | 61 ++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 16 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 9cd65b4..4353728 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -142,6 +142,7 @@ static void approver_free (gpointer papprover, gpointer user_data); static void check_with_new_approver (gpointer papp, gpointer papprove); static void check_with_old_approver (gpointer papprove, gpointer papp); static Application * find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object); +static Application * find_application_by_menu (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * menuobject); static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void dbus_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); @@ -263,31 +264,20 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, { ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data); GVariant * retval = NULL; + Application *app = NULL; + const gchar *dbusaddress; + const gchar *dbusmenuobject; if (g_strcmp0(method, "GetApplications") == 0) { retval = get_applications(service); } else if (g_strcmp0(method, "ApplicationScrollEvent") == 0) { - Application *app = NULL; - const gchar *dbusaddress; - const gchar *dbusobject; gchar *orientation = NULL; gint delta; guint direction; - g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusobject, + g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusmenuobject, &delta, &direction); - GList *l; - for (l = service->priv->applications; l != NULL; l = l->next) { - Application *a = l->data; - - if (g_strcmp0(a->dbus_name, dbusaddress) == 0 && - g_strcmp0(a->menu, dbusobject) == 0) { - app = a; - break; - } - } - switch (direction) { case INDICATOR_OBJECT_SCROLL_UP: delta = -delta; @@ -301,11 +291,28 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, orientation = "horizontal"; } + app = find_application_by_menu(service, dbusaddress, dbusmenuobject); + if (app != NULL && app->dbus_proxy != NULL && orientation != NULL) { g_dbus_proxy_call(app->dbus_proxy, "Scroll", - g_variant_new("(is)", delta, orientation), + g_variant_new("(is)", delta, orientation), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); } + } else if (g_strcmp0(method, "ApplicationSecondaryActivateEvent") == 0) { + guint time; + gint x; + gint y; + + g_variant_get (params, "(&s&suii)", &dbusaddress, &dbusmenuobject, + &time, &x, &y); + + app = find_application_by_menu(service, dbusaddress, dbusmenuobject); + + if (app != NULL && app->dbus_proxy != NULL) { + g_dbus_proxy_call(app->dbus_proxy, "SecondaryActivate", + g_variant_new("(ii)", x, y), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } } else { g_warning("Calling method '%s' on the indicator service and it's unknown", method); } @@ -1199,6 +1206,28 @@ find_application (ApplicationServiceAppstore * appstore, const gchar * address, return NULL; } +/* Looks for an application in the list of applications with the matching menu */ +static Application * +find_application_by_menu (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * menuobject) +{ + g_return_val_if_fail(appstore, NULL); + g_return_val_if_fail(address, NULL); + g_return_val_if_fail(menuobject, NULL); + + ApplicationServiceAppstorePrivate * priv = appstore->priv; + GList *l; + + for (l = priv->applications; l != NULL; l = l->next) { + Application *a = l->data; + if (g_strcmp0(a->dbus_name, address) == 0 && + g_strcmp0(a->menu, menuobject) == 0) { + return a; + } + } + + return NULL; +} + /* Removes an application. Currently only works for the apps that are shown. */ void -- cgit v1.2.3 From 7cd70567cf7c2f1423416513777b85c2efc93c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 21 Jul 2011 18:28:23 +0200 Subject: 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). --- src/application-service-appstore.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4353728..09c2a99 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -300,18 +300,14 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, } } else if (g_strcmp0(method, "ApplicationSecondaryActivateEvent") == 0) { guint time; - gint x; - gint y; - - g_variant_get (params, "(&s&suii)", &dbusaddress, &dbusmenuobject, - &time, &x, &y); + g_variant_get (params, "(&s&su)", &dbusaddress, &dbusmenuobject, &time); app = find_application_by_menu(service, dbusaddress, dbusmenuobject); if (app != NULL && app->dbus_proxy != NULL) { - g_dbus_proxy_call(app->dbus_proxy, "SecondaryActivate", - g_variant_new("(ii)", x, y), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + g_dbus_proxy_call(app->dbus_proxy, "XAyatanaSecondaryActivate", + g_variant_new("(u)", time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); } } else { g_warning("Calling method '%s' on the indicator service and it's unknown", method); -- cgit v1.2.3