~ubuntu-branches/ubuntu/quantal/indicator-application/quantal

« back to all changes in this revision

Viewing changes to src/application-service-appstore.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Ted Gould
  • Date: 2011-08-11 21:48:41 UTC
  • mfrom: (1.1.36 upstream)
  • Revision ID: james.westby@ubuntu.com-20110811214841-tkw1kva0jpvjc7ku
Tags: 0.3.92-0ubuntu1
* debian/rules: 
  - update the translations template

[ Ted Gould ]
* New upstream release.
  * Support middle click actions and send as Ayatana Activates
  * Fix signature for null sets

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
static void check_with_new_approver (gpointer papp, gpointer papprove);
143
143
static void check_with_old_approver (gpointer papprove, gpointer papp);
144
144
static Application * find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object);
 
145
static Application * find_application_by_menu (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * menuobject);
145
146
static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
146
147
static void dbus_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
147
148
static void app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
263
264
{
264
265
        ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data);
265
266
        GVariant * retval = NULL;
 
267
        Application *app = NULL;
 
268
        const gchar *dbusaddress;
 
269
        const gchar *dbusmenuobject;
266
270
 
267
271
        if (g_strcmp0(method, "GetApplications") == 0) {
268
272
                retval = get_applications(service);
269
273
        } else if (g_strcmp0(method, "ApplicationScrollEvent") == 0) {
270
 
                Application *app = NULL;
271
 
                const gchar *dbusaddress;
272
 
                const gchar *dbusobject;
273
274
                gchar *orientation = NULL;
274
275
                gint delta;
275
276
                guint direction;
276
277
 
277
 
                g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusobject,
 
278
                g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusmenuobject,
278
279
                                                   &delta, &direction);
279
280
 
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
281
                switch (direction) {
292
282
                        case INDICATOR_OBJECT_SCROLL_UP:
293
283
                                delta = -delta;
301
291
                                orientation = "horizontal";
302
292
                }
303
293
 
 
294
                app = find_application_by_menu(service, dbusaddress, dbusmenuobject);
 
295
 
304
296
                if (app != NULL && app->dbus_proxy != NULL && orientation != NULL) {
305
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
310
                                          G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
308
311
                }
309
312
        } else {
1199
1202
        return NULL;
1200
1203
}
1201
1204
 
 
1205
/* Looks for an application in the list of applications with the matching menu */
 
1206
static Application *
 
1207
find_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
1227
/* Removes an application.  Currently only works for the apps
1203
1228
   that are shown. */
1204
1229
void