aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2011-07-10 05:18:08 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2011-07-10 05:18:08 +0200
commit1a569c2f0cda67071400682be92b01b4c2641ec5 (patch)
tree51489e2673706d8e47abedbbbb71a3e47c76fc11 /src
parent81714fdde37c70d298f65dba56ebb3c069e6d139 (diff)
downloadayatana-indicator-application-1a569c2f0cda67071400682be92b01b4c2641ec5.tar.gz
ayatana-indicator-application-1a569c2f0cda67071400682be92b01b4c2641ec5.tar.bz2
ayatana-indicator-application-1a569c2f0cda67071400682be92b01b4c2641ec5.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/application-service-appstore.c61
-rw-r--r--src/application-service.xml7
-rw-r--r--src/indicator-application.c37
3 files changed, 84 insertions, 21 deletions
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
diff --git a/src/application-service.xml b/src/application-service.xml
index 1cffbc7..cd26d47 100644
--- a/src/application-service.xml
+++ b/src/application-service.xml
@@ -34,6 +34,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
<arg type="i" name="delta" direction="in" />
<arg type="u" name="direction" direction="in" />
</method>
+ <method name="ApplicationSecondaryActivateEvent">
+ <arg type="s" name="dbusaddress" direction="in" />
+ <arg type="s" name="dbusobject" direction="in" />
+ <arg type="u" name="time" direction="in" />
+ <arg type="i" name="x" direction="in" />
+ <arg type="i" name="y" direction="in" />
+ </method>
<!-- Signals -->
<signal name="ApplicationAdded">
diff --git a/src/indicator-application.c b/src/indicator-application.c
index dc810f4..281e397 100644
--- a/src/indicator-application.c
+++ b/src/indicator-application.c
@@ -110,6 +110,7 @@ static void indicator_application_finalize (GObject *object);
static GList * get_entries (IndicatorObject * io);
static guint get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction);
+static void entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint time, gint x, gint y, gpointer data);
void connection_changed (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application);
static void connected (IndicatorApplication * application);
static void disconnected (IndicatorApplication * application);
@@ -144,6 +145,7 @@ indicator_application_class_init (IndicatorApplicationClass *klass)
io_class->get_entries = get_entries;
io_class->get_location = get_location;
+ io_class->secondary_activate = entry_secondary_activate;
io_class->entry_scrolled = entry_scrolled;
return;
@@ -402,9 +404,34 @@ get_location (IndicatorObject * io, IndicatorObjectEntry * entry)
return g_list_index(priv->applications, entry);
}
+/* Redirect the secondary activate to the Application Item */
+static void
+entry_secondary_activate (IndicatorObject * io, IndicatorObjectEntry * entry,
+ guint time, gint x, gint y, gpointer data)
+{
+ g_return_if_fail(IS_INDICATOR_APPLICATION(io));
+
+ IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io);
+ g_return_if_fail(priv->service_proxy);
+
+ GList *l = g_list_find(priv->applications, entry);
+ if (l == NULL)
+ return;
+
+ ApplicationEntry *app = l->data;
+
+ if (app && app->dbusaddress && app->dbusobject && priv->service_proxy) {
+ g_dbus_proxy_call(priv->service_proxy, "ApplicationSecondaryActivateEvent",
+ g_variant_new("(ssuii)", app->dbusaddress,
+ app->dbusobject,
+ time, x, y),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ }
+}
+
/* Redirect the scroll event to the Application Item */
-static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction) {
-
+static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction)
+{
g_return_if_fail(IS_INDICATOR_APPLICATION(io));
IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io);
@@ -418,9 +445,9 @@ static void entry_scrolled (IndicatorObject * io, IndicatorObjectEntry * entry,
if (app && app->dbusaddress && app->dbusobject && priv->service_proxy) {
g_dbus_proxy_call(priv->service_proxy, "ApplicationScrollEvent",
- g_variant_new("(ssiu)", app->dbusaddress,
- app->dbusobject,
- delta, direction),
+ g_variant_new("(ssiu)", app->dbusaddress,
+ app->dbusobject,
+ delta, direction),
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
}
}