From 4189a76c67f80a8c6a8e80142e7cfeffab1039e9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 11:55:52 -0500 Subject: Adding defines for the new properties and signal. --- src/application-service-appstore.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 311fcb1..17bb987 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -45,10 +45,13 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" #define NOTIFICATION_ITEM_PROP_ICON_PATH "IconThemePath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" +#define NOTIFICATION_ITEM_PROP_LABEL "Label" +#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" #define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" #define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" #define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" +#define NOTIFICATION_ITEM_SIG_NEW_LABEL "NewLabel" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { -- cgit v1.2.3 From d58186ab8edd420512df29e05005f7722b7bb619 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 12:07:36 -0500 Subject: Updating signal emition to match new API --- src/application-service-appstore.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 17bb987..235ed4a 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -125,8 +125,8 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_added), NULL, NULL, - _application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING, - G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); + _application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING_STRING_STRING, + G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); signals[APPLICATION_REMOVED] = g_signal_new ("application-removed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, @@ -449,6 +449,8 @@ apply_status (Application * app, AppIndicatorStatus status) app->dbus_name, app->menu, app->icon_path, + "", + "", TRUE); } } else { -- cgit v1.2.3 From e33d50bdee8e3e04277f4c3c3f45ff60d3bbbb45 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 12:08:42 -0500 Subject: Adding the new entries to the list of the get_apps function. --- src/application-service-appstore.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 235ed4a..2f53ecf 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -773,6 +773,18 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst g_value_array_append(values, &value); g_value_unset(&value); + /* Label */ + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, ""); + g_value_array_append(values, &value); + g_value_unset(&value); + + /* Guide */ + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, ""); + g_value_array_append(values, &value); + g_value_unset(&value); + g_ptr_array_add(*apps, values); } -- cgit v1.2.3 From 4dea77d518cd6b1106452735f265ff2366c4dc9c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 12:46:49 -0500 Subject: Adding signal for label changing. --- src/application-service-appstore.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 2f53ecf..d25c022 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -92,6 +92,7 @@ enum { APPLICATION_ADDED, APPLICATION_REMOVED, APPLICATION_ICON_CHANGED, + APPLICATION_LABEL_CHANGED, LAST_SIGNAL }; @@ -141,6 +142,13 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) NULL, NULL, _application_service_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE); + signals[APPLICATION_LABEL_CHANGED] = g_signal_new ("application-label-changed", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_label_changed), + NULL, NULL, + _application_service_marshal_VOID__INT_STRING_STRING, + G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, &dbus_glib__application_service_server_object_info); -- cgit v1.2.3 From ff9b7b426a720d3d7489d007ae273baf6243cb47 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 13:25:14 -0500 Subject: Whitespace fix --- src/application-service-appstore.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index d25c022..5694596 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -38,20 +38,20 @@ static gboolean _application_service_server_get_applications (ApplicationService #include "application-service-server.h" -#define NOTIFICATION_ITEM_PROP_ID "Id" -#define NOTIFICATION_ITEM_PROP_CATEGORY "Category" -#define NOTIFICATION_ITEM_PROP_STATUS "Status" -#define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName" -#define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" -#define NOTIFICATION_ITEM_PROP_ICON_PATH "IconThemePath" -#define NOTIFICATION_ITEM_PROP_MENU "Menu" -#define NOTIFICATION_ITEM_PROP_LABEL "Label" -#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" - -#define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" -#define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" -#define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" -#define NOTIFICATION_ITEM_SIG_NEW_LABEL "NewLabel" +#define NOTIFICATION_ITEM_PROP_ID "Id" +#define NOTIFICATION_ITEM_PROP_CATEGORY "Category" +#define NOTIFICATION_ITEM_PROP_STATUS "Status" +#define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName" +#define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" +#define NOTIFICATION_ITEM_PROP_ICON_PATH "IconThemePath" +#define NOTIFICATION_ITEM_PROP_MENU "Menu" +#define NOTIFICATION_ITEM_PROP_LABEL "Label" +#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" + +#define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" +#define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" +#define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" +#define NOTIFICATION_ITEM_SIG_NEW_LABEL "NewLabel" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { -- cgit v1.2.3 From 0d11bf650fcaa20dfbc5d53ea1c08334b2bf63a0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 13:52:28 -0500 Subject: Start tracking the label and the label guide allong with the other application properties. --- src/application-service-appstore.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 5694596..a05c725 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -81,6 +81,8 @@ struct _Application { gchar * aicon; gchar * menu; gchar * icon_path; + gchar * label; + gchar * guide; gboolean currently_free; }; @@ -264,6 +266,20 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->icon_path = g_strdup(""); } + gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); + if (label_data != NULL) { + app->label = g_value_dup_string((GValue *)label_data); + } else { + app->label = g_strdup(""); + } + + gpointer guide_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL_GUIDE); + if (guide_data != NULL) { + app->guide = g_value_dup_string((GValue *)guide_data); + } else { + app->guide = g_strdup(""); + } + /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ g_list_foreach(priv->approvers, check_with_old_approver, app); @@ -360,6 +376,12 @@ application_free (Application * app) if (app->icon_path != NULL) { g_free(app->icon_path); } + if (app->label != NULL) { + g_free(app->label); + } + if (app->guide != NULL) { + g_free(app->guide); + } g_free(app); return; @@ -626,6 +648,8 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->aicon = NULL; app->menu = NULL; app->icon_path = NULL; + app->label = NULL; + app->guide = NULL; app->currently_free = FALSE; /* Get the DBus proxy for the NotificationItem interface */ -- cgit v1.2.3 From 788b0dbc0a2f61eb427796c7f0588490de071a4f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 13:58:23 -0500 Subject: Sending the label and the guide over dbus if we have them. --- src/application-service-appstore.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index a05c725..453c25c 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -479,8 +479,8 @@ apply_status (Application * app, AppIndicatorStatus status) app->dbus_name, app->menu, app->icon_path, - "", - "", + app->label, + app->guide, TRUE); } } else { @@ -807,13 +807,13 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst /* Label */ g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, ""); + g_value_set_string(&value, ((Application *)listpntr->data)->label); g_value_array_append(values, &value); g_value_unset(&value); /* Guide */ g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, ""); + g_value_set_string(&value, ((Application *)listpntr->data)->guide); g_value_array_append(values, &value); g_value_unset(&value); -- cgit v1.2.3 From 04fd1193ad19940766870eb094992a3d8f1f9583 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 14:05:21 -0500 Subject: Cast once, be happy --- src/application-service-appstore.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 453c25c..8c59432 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -771,13 +771,14 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst gint position = 0; for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { + Application * app = (Application *)listpntr->data; 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_set_string(&value, app->icon); g_value_array_append(values, &value); g_value_unset(&value); @@ -789,31 +790,31 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst /* DBus Address */ g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, ((Application *)listpntr->data)->dbus_name); + g_value_set_string(&value, app->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)->menu); + g_value_set_static_boxed(&value, app->menu); 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_set_string(&value, app->icon_path); g_value_array_append(values, &value); g_value_unset(&value); /* Label */ g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, ((Application *)listpntr->data)->label); + g_value_set_string(&value, app->label); g_value_array_append(values, &value); g_value_unset(&value); /* Guide */ g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, ((Application *)listpntr->data)->guide); + g_value_set_string(&value, app->guide); g_value_array_append(values, &value); g_value_unset(&value); -- cgit v1.2.3 From 83f563433d1456da5383529f4be2813e162c6978 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 14:18:15 -0500 Subject: Connecting to the application signal for new label and handling it appropriately. --- src/application-service-appstore.c | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 8c59432..8d9206f 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -152,6 +152,12 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) _application_service_marshal_VOID__INT_STRING_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); + dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_STRING, + G_TYPE_NONE, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, &dbus_glib__application_service_server_object_info); @@ -621,6 +627,41 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) return; } +/* Called when the Notification Item signals that it + has a new label. */ +static void +new_label (DBusGProxy * proxy, const gchar * label, const gchar * guide, gpointer data) +{ + Application * app = (Application *)data; + if (!app->validated) return; + + gboolean changed = FALSE; + + if (g_strcmp0(app->label, label) != 0) { + changed = TRUE; + if (app->label != NULL) { + g_free(app->label); + app->label = NULL; + } + app->label = g_strdup(label); + } + + if (g_strcmp0(app->guide, guide) != 0) { + changed = TRUE; + if (app->guide != NULL) { + g_free(app->guide); + app->guide = NULL; + } + app->guide = g_strdup(guide); + } + + if (changed) { + g_signal_emit(app->appstore, signals[APPLICATION_LABEL_CHANGED], 0, app->label, app->guide, TRUE); + } + + return; +} + /* Adding a new NotificationItem object from DBus in to the appstore. First, we need to get the information on it though. */ @@ -696,6 +737,11 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst NOTIFICATION_ITEM_SIG_NEW_STATUS, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal(app->dbus_proxy, + NOTIFICATION_ITEM_SIG_NEW_LABEL, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INVALID); dbus_g_proxy_connect_signal(app->dbus_proxy, NOTIFICATION_ITEM_SIG_NEW_ICON, @@ -712,6 +758,11 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst G_CALLBACK(new_status), app, NULL); + dbus_g_proxy_connect_signal(app->dbus_proxy, + NOTIFICATION_ITEM_SIG_NEW_LABEL, + G_CALLBACK(new_label), + app, + NULL); /* Get all the propertiees */ org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy, -- cgit v1.2.3 From 208fc0000cc6101d1ebd8ed774f05ec371b1bcaa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 20:18:39 -0500 Subject: Fixing the prototype for the label changed signal. --- src/application-service-appstore.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 8d9206f..7f77a78 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -150,7 +150,7 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_label_changed), NULL, NULL, _application_service_marshal_VOID__INT_STRING_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); + G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, @@ -656,7 +656,14 @@ new_label (DBusGProxy * proxy, const gchar * label, const gchar * guide, gpointe } if (changed) { - g_signal_emit(app->appstore, signals[APPLICATION_LABEL_CHANGED], 0, app->label, app->guide, TRUE); + gint position = get_position(app); + if (position == -1) return; + + g_signal_emit(app->appstore, signals[APPLICATION_LABEL_CHANGED], 0, + position, + app->label != NULL ? app->label : "", + app->guide != NULL ? app->guide : "", + TRUE); } return; -- cgit v1.2.3