aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-01-15 08:54:25 -0600
committerTed Gould <ted@gould.cx>2010-01-15 08:54:25 -0600
commita75c3deda04f2529dd2db287829c191580fa2446 (patch)
treec373321c649cd64668aafe7ef848ffe08e00c412 /src
parentbd7118f59345fbf9c7a22fdfb7a65e7f97dfa6c8 (diff)
parentb447c26d5dab577f46ad32d6191bc623be9aaf25 (diff)
downloadayatana-indicator-application-a75c3deda04f2529dd2db287829c191580fa2446.tar.gz
ayatana-indicator-application-a75c3deda04f2529dd2db287829c191580fa2446.tar.bz2
ayatana-indicator-application-a75c3deda04f2529dd2db287829c191580fa2446.zip
* Upstream update
* Support getting the app list from a running service.
Diffstat (limited to 'src')
-rw-r--r--src/application-service-appstore.c49
-rw-r--r--src/application-service.xml2
-rw-r--r--src/indicator-application.c37
3 files changed, 84 insertions, 4 deletions
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c
index fa1b9d2..df4213a 100644
--- a/src/application-service-appstore.c
+++ b/src/application-service-appstore.c
@@ -31,7 +31,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dbus-shared.h"
/* DBus Prototypes */
-static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GArray ** apps);
+static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error);
#include "application-service-server.h"
@@ -624,9 +624,52 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap
/* DBus Interface */
static gboolean
-_application_service_server_get_applications (ApplicationServiceAppstore * appstore, GArray ** apps)
+_application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error)
{
+ ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
+
+ *apps = g_ptr_array_new();
+ GList * listpntr;
+ gint position = 0;
+
+ for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) {
+ GValueArray * values = g_value_array_new(5);
+
+ GValue value = {0};
+
+ /* Icon name */
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, ((Application *)listpntr->data)->icon);
+ g_value_array_append(values, &value);
+ g_value_unset(&value);
+
+ /* Position */
+ g_value_init(&value, G_TYPE_INT);
+ g_value_set_int(&value, position++);
+ g_value_array_append(values, &value);
+ g_value_unset(&value);
+
+ /* DBus Address */
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, ((Application *)listpntr->data)->dbus_name);
+ g_value_array_append(values, &value);
+ g_value_unset(&value);
+
+ /* DBus Object */
+ g_value_init(&value, DBUS_TYPE_G_OBJECT_PATH);
+ g_value_set_static_boxed(&value, ((Application *)listpntr->data)->dbus_object);
+ g_value_array_append(values, &value);
+ g_value_unset(&value);
+
+ /* Icon path */
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, ((Application *)listpntr->data)->icon_path);
+ g_value_array_append(values, &value);
+ g_value_unset(&value);
+
+ g_ptr_array_add(*apps, values);
+ }
- return FALSE;
+ return TRUE;
}
diff --git a/src/application-service.xml b/src/application-service.xml
index d74aaa9..0b2e959 100644
--- a/src/application-service.xml
+++ b/src/application-service.xml
@@ -26,7 +26,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
<!-- Methods -->
<method name="GetApplications">
- <arg type="a(siso)" name="applications" direction="out" />
+ <arg type="a(sisos)" name="applications" direction="out" />
</method>
<!-- Signals -->
diff --git a/src/indicator-application.c b/src/indicator-application.c
index c330645..c6b962a 100644
--- a/src/indicator-application.c
+++ b/src/indicator-application.c
@@ -96,6 +96,7 @@ static void application_added (DBusGProxy * proxy, const gchar * iconname, gint
static void application_removed (DBusGProxy * proxy, gint position , IndicatorApplication * application);
static void application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application);
static void get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata);
+static void get_applications_helper (gpointer data, gpointer user_data);
G_DEFINE_TYPE (IndicatorApplication, indicator_application, INDICATOR_OBJECT_TYPE);
@@ -368,6 +369,42 @@ application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconn
static void
get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata)
{
+ if (error != NULL) {
+ g_warning("Unable to get application list: %s", error->message);
+ return;
+ }
+ g_ptr_array_foreach(OUT_applications, get_applications_helper, proxy);
return;
}
+
+/* A little helper that takes apart the DBus structure and calls
+ application_added on every entry in the list. */
+static void
+get_applications_helper (gpointer data, gpointer user_data)
+{
+ GType structype = dbus_g_type_get_struct("GValueArray",
+ G_TYPE_STRING,
+ G_TYPE_INT,
+ G_TYPE_STRING,
+ DBUS_TYPE_G_OBJECT_PATH,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ g_return_if_fail(G_VALUE_HOLDS(data, structype));
+
+ gchar * icon_name;
+ gint position;
+ gchar * dbus_address;
+ gchar * dbus_object;
+ gchar * icon_path;
+
+ dbus_g_type_struct_get(data,
+ 0, &icon_name,
+ 1, &position,
+ 2, &dbus_address,
+ 3, &dbus_object,
+ 4, &icon_path,
+ G_MAXUINT);
+
+ return application_added(user_data, icon_name, position, dbus_address, dbus_object, icon_path, NULL);
+}