From 47806177db55300ada6d5f6bf543eb77d765f0f3 Mon Sep 17 00:00:00 2001 From: C10uD Date: Thu, 22 Jul 2010 14:57:14 +0200 Subject: trying to implement runtime theme-path changing --- src/application-service-appstore.c | 75 +++++++++++++++++++++++++++++++++++++- 1 file changed, 73 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 311fcb1..6c11b7f 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -49,6 +49,7 @@ static gboolean _application_service_server_get_applications (ApplicationService #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_ICON_PATH "NewIconPath" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { @@ -89,6 +90,7 @@ enum { APPLICATION_ADDED, APPLICATION_REMOVED, APPLICATION_ICON_CHANGED, + APPLICATION_ICON_PATH_CHANGED, LAST_SIGNAL }; @@ -138,6 +140,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_ICON_PATH_CHANGED] = g_signal_new ("application-icon-path-changed", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_icon_path_changed), + NULL, NULL, + _application_service_marshal_VOID__INT_STRING, + G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE); dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, &dbus_glib__application_service_server_object_info); @@ -540,6 +549,44 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat return; } +/* Gets the data back on an updated icon signal. Hopefully + a new fun icon. */ +static void +new_path_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata) +{ + /* Check for errors */ + if (error != NULL) { + g_warning("Unable to get updated icon name: %s", error->message); + return; + } + + /* Grab the icon and make sure we have one */ + const gchar * newpath = g_value_get_string(&value); + if (newpath == NULL) { + g_warning("Bad new path :("); + return; + } + + Application * app = (Application *) userdata; + + if (g_strcmp0(newpath, app->icon_path)) { + /* If the new path is actually a new path */ + if (app->icon_path != NULL) g_free(app->icon_path); + app->icon_path = g_strdup(newpath); + + if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + gint position = get_position(app); + if (position == -1) return; + + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ICON_PATH_CHANGED], 0, + position, newpath, TRUE); + } + } + + return; +} + /* Called when the Notification Item signals that it has a new icon. */ static void @@ -586,6 +633,22 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) return; } +/* Called when the Notification Item signals that it + has a new icon. */ +static void +new_path (DBusGProxy * proxy, gpointer data) +{ + Application * app = (Application *)data; + if (!app->validated) return; + + org_freedesktop_DBus_Properties_get_async(app->prop_proxy, + NOTIFICATION_ITEM_DBUS_IFACE, + NOTIFICATION_ITEM_PROP_ICON_PATH, + new_path_cb, + app); + return; +} + /* Adding a new NotificationItem object from DBus in to the appstore. First, we need to get the information on it though. */ @@ -659,7 +722,10 @@ 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_ICON_PATH, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(app->dbus_proxy, NOTIFICATION_ITEM_SIG_NEW_ICON, G_CALLBACK(new_icon), @@ -675,7 +741,12 @@ 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_ICON_PATH, + G_CALLBACK(new_path), + app, + NULL); + /* Get all the propertiees */ org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy, NOTIFICATION_ITEM_DBUS_IFACE, -- cgit v1.2.3 From 0bbee36d1c080b247d14c5131666c7436761ece6 Mon Sep 17 00:00:00 2001 From: Sense Hofstede Date: Thu, 22 Jul 2010 16:51:10 +0200 Subject: Clean-up and renaming variables and functions everywhere to use icon_theme_path for the sake of consistency. Doesn't seem to do antyhing, though. --- src/application-service-appstore.c | 70 ++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 37 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 6c11b7f..b75d11d 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -43,13 +43,13 @@ static gboolean _application_service_server_get_applications (ApplicationService #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_ICON_THEME_PATH "IconThemePath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" #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_ICON_PATH "NewIconPath" +#define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconPath" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { @@ -78,7 +78,7 @@ struct _Application { gchar * icon; gchar * aicon; gchar * menu; - gchar * icon_path; + gchar * icon_theme_path; gboolean currently_free; }; @@ -90,7 +90,7 @@ enum { APPLICATION_ADDED, APPLICATION_REMOVED, APPLICATION_ICON_CHANGED, - APPLICATION_ICON_PATH_CHANGED, + APPLICATION_ICON_THEME_PATH_CHANGED, LAST_SIGNAL }; @@ -140,10 +140,10 @@ 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_ICON_PATH_CHANGED] = g_signal_new ("application-icon-path-changed", + signals[APPLICATION_ICON_THEME_PATH_CHANGED] = g_signal_new ("application-icon-theme-path-changed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_icon_path_changed), + G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_icon_theme_path_changed), NULL, NULL, _application_service_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE); @@ -255,11 +255,11 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->aicon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_AICON_NAME)); } - gpointer icon_path_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_PATH); - if (icon_path_data != NULL) { - app->icon_path = g_value_dup_string((GValue *)icon_path_data); + gpointer icon_theme_path_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_THEME_PATH); + if (icon_theme_path_data != NULL) { + app->icon_theme_path = g_value_dup_string((GValue *)icon_theme_path_data); } else { - app->icon_path = g_strdup(""); + app->icon_theme_path = g_strdup(""); } /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ @@ -355,8 +355,8 @@ application_free (Application * app) if (app->menu != NULL) { g_free(app->menu); } - if (app->icon_path != NULL) { - g_free(app->icon_path); + if (app->icon_theme_path != NULL) { + g_free(app->icon_theme_path); } g_free(app); @@ -454,7 +454,7 @@ apply_status (Application * app, AppIndicatorStatus status) g_list_index(priv->applications, app), /* Position */ app->dbus_name, app->menu, - app->icon_path, + app->icon_theme_path, TRUE); } } else { @@ -549,38 +549,34 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat return; } -/* Gets the data back on an updated icon signal. Hopefully - a new fun icon. */ +/* Gets the data back on an updated icon theme path. + Maybe a new icon */ static void -new_path_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata) +new_icon_theme_path_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata) { /* Check for errors */ if (error != NULL) { - g_warning("Unable to get updated icon name: %s", error->message); + g_warning("Unable to get updated icon theme path: %s", error->message); return; } /* Grab the icon and make sure we have one */ - const gchar * newpath = g_value_get_string(&value); - if (newpath == NULL) { - g_warning("Bad new path :("); - return; - } + const gchar * new_icon_theme_path = g_value_get_string(&value); Application * app = (Application *) userdata; - if (g_strcmp0(newpath, app->icon_path)) { - /* If the new path is actually a new path */ - if (app->icon_path != NULL) g_free(app->icon_path); - app->icon_path = g_strdup(newpath); + if (g_strcmp0(new_icon_theme_path, app->icon_theme_path)) { + /* If the new icon theme path is actually a new icon theme path */ + if (app->icon_theme_path != NULL) g_free(app->icon_theme_path); + app->icon_theme_path = g_strdup(new_icon_theme_path); if (app->status == APP_INDICATOR_STATUS_ACTIVE) { gint position = get_position(app); if (position == -1) return; g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ICON_PATH_CHANGED], 0, - position, newpath, TRUE); + signals[APPLICATION_ICON_THEME_PATH_CHANGED], 0, + position, new_icon_theme_path, TRUE); } } @@ -634,17 +630,17 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) } /* Called when the Notification Item signals that it - has a new icon. */ + has a new icon theme path. */ static void -new_path (DBusGProxy * proxy, gpointer data) +new_icon_theme_path (DBusGProxy * proxy, gpointer data) { Application * app = (Application *)data; if (!app->validated) return; org_freedesktop_DBus_Properties_get_async(app->prop_proxy, NOTIFICATION_ITEM_DBUS_IFACE, - NOTIFICATION_ITEM_PROP_ICON_PATH, - new_path_cb, + NOTIFICATION_ITEM_PROP_ICON_THEME_PATH, + new_icon_theme_path_cb, app); return; } @@ -675,7 +671,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->icon = NULL; app->aicon = NULL; app->menu = NULL; - app->icon_path = NULL; + app->icon_theme_path = NULL; app->currently_free = FALSE; /* Get the DBus proxy for the NotificationItem interface */ @@ -723,7 +719,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal(app->dbus_proxy, - NOTIFICATION_ITEM_SIG_NEW_ICON_PATH, + NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal(app->dbus_proxy, @@ -742,8 +738,8 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app, NULL); dbus_g_proxy_connect_signal(app->dbus_proxy, - NOTIFICATION_ITEM_SIG_NEW_ICON_PATH, - G_CALLBACK(new_path), + NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH, + G_CALLBACK(new_icon_theme_path), app, NULL); @@ -835,7 +831,7 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst /* Icon path */ g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, ((Application *)listpntr->data)->icon_path); + g_value_set_string(&value, ((Application *)listpntr->data)->icon_theme_path); g_value_array_append(values, &value); g_value_unset(&value); -- cgit v1.2.3 From 0dbf34a46c0c39f4e4bcd6ac1de72523cb7e3b63 Mon Sep 17 00:00:00 2001 From: Sense Hofstede Date: Thu, 22 Jul 2010 16:57:29 +0200 Subject: Fix wrong naming that caused the signal to be missed --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index b75d11d..c5997e9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -49,7 +49,7 @@ static gboolean _application_service_server_get_applications (ApplicationService #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_ICON_THEME_PATH "NewIconPath" +#define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { -- cgit v1.2.3 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 From 247e5a1ac3f714f831bea27fa87170b0ac7fec64 Mon Sep 17 00:00:00 2001 From: Sense Egbert Hofstede Date: Thu, 5 Aug 2010 15:51:53 +0200 Subject: Passing the updated icon theme path along with the DBus signal, saving a DBus call. --- src/application-service-appstore.c | 57 ++++++++++++-------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index c5997e9..f18a89e 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -549,40 +549,6 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat return; } -/* Gets the data back on an updated icon theme path. - Maybe a new icon */ -static void -new_icon_theme_path_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata) -{ - /* Check for errors */ - if (error != NULL) { - g_warning("Unable to get updated icon theme path: %s", error->message); - return; - } - - /* Grab the icon and make sure we have one */ - const gchar * new_icon_theme_path = g_value_get_string(&value); - - Application * app = (Application *) userdata; - - if (g_strcmp0(new_icon_theme_path, app->icon_theme_path)) { - /* If the new icon theme path is actually a new icon theme path */ - if (app->icon_theme_path != NULL) g_free(app->icon_theme_path); - app->icon_theme_path = g_strdup(new_icon_theme_path); - - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { - gint position = get_position(app); - if (position == -1) return; - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ICON_THEME_PATH_CHANGED], 0, - position, new_icon_theme_path, TRUE); - } - } - - return; -} - /* Called when the Notification Item signals that it has a new icon. */ static void @@ -632,16 +598,26 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) /* Called when the Notification Item signals that it has a new icon theme path. */ static void -new_icon_theme_path (DBusGProxy * proxy, gpointer data) +new_icon_theme_path (DBusGProxy * proxy, const gchar * icon_theme_path, gpointer data) { Application * app = (Application *)data; if (!app->validated) return; - org_freedesktop_DBus_Properties_get_async(app->prop_proxy, - NOTIFICATION_ITEM_DBUS_IFACE, - NOTIFICATION_ITEM_PROP_ICON_THEME_PATH, - new_icon_theme_path_cb, - app); + if (g_strcmp0(icon_theme_path, app->icon_theme_path)) { + /* If the new icon theme path is actually a new icon theme path */ + if (app->icon_theme_path != NULL) g_free(app->icon_theme_path); + app->icon_theme_path = g_strdup(icon_theme_path); + + if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + gint position = get_position(app); + if (position == -1) return; + + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ICON_THEME_PATH_CHANGED], 0, + position, app->icon_theme_path, TRUE); + } + } + return; } @@ -720,6 +696,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst G_TYPE_INVALID); dbus_g_proxy_add_signal(app->dbus_proxy, NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH, + G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal(app->dbus_proxy, -- cgit v1.2.3 From 1cac2ea0d1e60053a733a99ebc77b5ef46d52850 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:13:44 -0500 Subject: Adding 'OrderingIndex' and realigning. --- src/application-service-appstore.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index f18a89e..0d9396b 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -38,17 +38,18 @@ 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_THEME_PATH "IconThemePath" -#define NOTIFICATION_ITEM_PROP_MENU "Menu" - -#define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" -#define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" -#define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" +#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_THEME_PATH "IconThemePath" +#define NOTIFICATION_ITEM_PROP_MENU "Menu" +#define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "OrderingIndex" + +#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_ICON_THEME_PATH "NewIconThemePath" /* Private Stuff */ -- cgit v1.2.3 From 09e6c21971ee0c93b72ed8386911875c3f630a1c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:37:44 -0500 Subject: Adding in an ordering index for application structures --- src/application-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0d9396b..cd827d3 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -81,6 +81,7 @@ struct _Application { gchar * menu; gchar * icon_theme_path; gboolean currently_free; + guint ordering_index; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -650,6 +651,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->menu = NULL; app->icon_theme_path = NULL; app->currently_free = FALSE; + app->ordering_index = 0; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From c27a7a980337e5216abe0ba0e77c94cf83d2fe43 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:41:53 -0500 Subject: Setting the ordering ID. --- 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 cd827d3..4ae316c 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -32,6 +32,7 @@ with this program. If not, see . #include "dbus-properties-client.h" #include "dbus-shared.h" #include "notification-approver-client.h" +#include "generate-id.h" /* DBus Prototypes */ static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error); @@ -264,6 +265,13 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->icon_theme_path = g_strdup(""); } + gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); + if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { + app->ordering_index = generate_id(string_to_status(app->category), app->id); + } else { + app->ordering_index = g_value_get_uint(ordering_index_data); + } + /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ g_list_foreach(priv->approvers, check_with_old_approver, app); -- cgit v1.2.3 From bf3f4c6eb3affcf8e66b67ed61666c93a97ca47b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:47:23 -0500 Subject: Removing the LRU file --- src/application-service-appstore.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4ae316c..2aa418a 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -58,7 +58,6 @@ struct _ApplicationServiceAppstorePrivate { DBusGConnection * bus; GList * applications; GList * approvers; - AppLruFile * lrufile; }; typedef struct _Approver Approver; @@ -165,7 +164,6 @@ application_service_appstore_init (ApplicationServiceAppstore *self) priv->applications = NULL; priv->approvers = NULL; - priv->lrufile = NULL; GError * error = NULL; priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); @@ -241,7 +239,6 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->id = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID)); app->category = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY)); ApplicationServiceAppstorePrivate * priv = app->appstore->priv; - app_lru_file_touch(priv->lrufile, app->id, app->category); app->icon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); @@ -411,15 +408,13 @@ can_add_application (GList *applications, Application *app) } /* This function takes two Application structure - pointers and uses the lrufile to compare them. */ + pointers and uses their ordering index to compare them. */ static gint app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) { Application * appa = (Application *)a; Application * appb = (Application *)b; - AppLruFile * lrufile = (AppLruFile *)userdata; - - return app_lru_file_sort(lrufile, appa->id, appb->id); + return appa->ordering_index - appb->ordering_index; } /* Change the status of the application. If we're going passive @@ -456,7 +451,7 @@ apply_status (Application * app, AppIndicatorStatus status) if (app->status == APP_INDICATOR_STATUS_PASSIVE) { if (can_add_application (priv->applications, app)) { /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, NULL); g_signal_emit(G_OBJECT(app->appstore), signals[APPLICATION_ADDED], 0, @@ -769,12 +764,9 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap /* Creates a basic appstore object and attaches the LRU file object to it. */ ApplicationServiceAppstore * -application_service_appstore_new (AppLruFile * lrufile) +application_service_appstore_new (void) { - g_return_val_if_fail(IS_APP_LRU_FILE(lrufile), NULL); ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(g_object_new(APPLICATION_SERVICE_APPSTORE_TYPE, NULL)); - ApplicationServiceAppstorePrivate * priv = appstore->priv; - priv->lrufile = lrufile; return appstore; } -- cgit v1.2.3 From dad491a83573507401805d9782a02dec2bad743a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 16:50:54 -0500 Subject: Adding an override hash table --- src/application-service-appstore.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 5fc4f9b..47396bb 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -56,11 +56,14 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_SIG_NEW_LABEL "NewLabel" #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" +#define OVERRIDE_GROUP_NAME "Ordering Index Overrides" + /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { DBusGConnection * bus; GList * applications; GList * approvers; + GHashTable * ordering_overrides; }; typedef struct _Approver Approver; @@ -183,6 +186,8 @@ application_service_appstore_init (ApplicationServiceAppstore *self) priv->applications = NULL; priv->approvers = NULL; + + priv->ordering_overrides = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); GError * error = NULL; priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); @@ -225,6 +230,12 @@ application_service_appstore_dispose (GObject *object) static void application_service_appstore_finalize (GObject *object) { + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE(object)->priv; + + if (priv->ordering_overrides != NULL) { + g_hash_table_destroy(priv->ordering_overrides); + priv->ordering_overrides = NULL; + } G_OBJECT_CLASS (application_service_appstore_parent_class)->finalize (object); return; -- cgit v1.2.3 From f4b22a7fa52695acc7e1e5abd20859f320e3895f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 16:59:25 -0500 Subject: Putting together the pieces to look for override files --- src/application-service-appstore.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 47396bb..0df4dd5 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -57,6 +57,7 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" #define OVERRIDE_GROUP_NAME "Ordering Index Overrides" +#define OVERRIDE_FILE_NAME "ordering-override.keyfile" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { @@ -112,6 +113,7 @@ static void application_service_appstore_class_init (ApplicationServiceAppstoreC static void application_service_appstore_init (ApplicationServiceAppstore *self); static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); +static void load_override_file (GHashTable * hash, const gchar * filename); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app, AppIndicatorStatus status); static void approver_free (gpointer papprover, gpointer user_data); @@ -188,6 +190,11 @@ application_service_appstore_init (ApplicationServiceAppstore *self) priv->approvers = NULL; priv->ordering_overrides = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + + load_override_file(priv->ordering_overrides, DATADIR "/" OVERRIDE_FILE_NAME); + gchar * userfile = g_build_filename(g_get_user_data_dir(), "indicators", "application", OVERRIDE_FILE_NAME, NULL); + load_override_file(priv->ordering_overrides, userfile); + g_free(userfile); GError * error = NULL; priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); @@ -241,6 +248,15 @@ application_service_appstore_finalize (GObject *object) return; } +/* Loads the file and adds the override entries to the table + of overrides */ +static void +load_override_file (GHashTable * hash, const gchar * filename) +{ + + +} + /* Return from getting the properties from the item. We're looking at those and making sure we have everythign that we need. If we do, then we'll move on up to sending this onto the indicator. */ -- cgit v1.2.3 From de6c40d873a317a98d025cb094e7d89a646b4000 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 17:13:22 -0500 Subject: Fleshing out the loading overrides function. --- src/application-service-appstore.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0df4dd5..4d21291 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -253,8 +253,46 @@ application_service_appstore_finalize (GObject *object) static void load_override_file (GHashTable * hash, const gchar * filename) { + g_return_if_fail(hash != NULL); + g_return_if_fail(filename != NULL); + if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { + return; + } + + g_debug("Loading overrides from: '%s'", filename); + + GError * error = NULL; + GKeyFile * keyfile = g_key_file_new(); + g_key_file_load_from_file(keyfile, filename, G_KEY_FILE_NONE, &error); + if (error != NULL) { + g_warning("Unable to load keyfile '%s' because: %s", filename, error->message); + g_error_free(error); + g_key_file_free(keyfile); + return; + } + + gchar ** keys = g_key_file_get_keys(keyfile, OVERRIDE_GROUP_NAME, NULL, NULL); + gchar * key = keys[0]; + gint i; + + for (i = 0; (key = keys[i]) != NULL; i++) { + GError * valerror = NULL; + gint val = g_key_file_get_integer(keyfile, OVERRIDE_GROUP_NAME, key, &valerror); + + if (valerror != NULL) { + g_warning("Unable to get key '%s' out of file '%s' because: %s", key, filename, valerror->message); + g_error_free(valerror); + continue; + } + g_debug("%s: override '%s' with value '%d'", filename, key, val); + + g_hash_table_insert(hash, g_strdup(key), GINT_TO_POINTER(val)); + } + g_key_file_free(keyfile); + + return; } /* Return from getting the properties from the item. We're looking at those -- cgit v1.2.3 From 51de4ced42e132fa3a66a2739e8a3ba861842467 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 21:19:31 -0500 Subject: Checking for an override and applying it. --- src/application-service-appstore.c | 13 +++++++++---- 1 file changed, 9 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 4d21291..d632456 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -346,11 +346,16 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->icon_theme_path = g_strdup(""); } - gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); - if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { - app->ordering_index = generate_id(string_to_status(app->category), app->id); + gpointer ordering_index_over = g_hash_table_lookup(priv->ordering_overrides, app->id); + if (ordering_index_over == NULL) { + gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); + if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { + app->ordering_index = generate_id(string_to_status(app->category), app->id); + } else { + app->ordering_index = g_value_get_uint(ordering_index_data); + } } else { - app->ordering_index = g_value_get_uint(ordering_index_data); + app->ordering_index = GPOINTER_TO_UINT(ordering_index_over); } gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); -- cgit v1.2.3 From bdd9c8541f5df134ad5460ef192c7dc019e893eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 09:05:07 -0500 Subject: Ensuring that we got a list of keys so we don't crash --- src/application-service-appstore.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index d632456..2306230 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -273,7 +273,14 @@ load_override_file (GHashTable * hash, const gchar * filename) return; } - gchar ** keys = g_key_file_get_keys(keyfile, OVERRIDE_GROUP_NAME, NULL, NULL); + gchar ** keys = g_key_file_get_keys(keyfile, OVERRIDE_GROUP_NAME, NULL, &error); + if (error != NULL) { + g_warning("Unable to get keys from keyfile '%s' because: %s", filename, error->message); + g_error_free(error); + g_key_file_free(keyfile); + return; + } + gchar * key = keys[0]; gint i; -- cgit v1.2.3 From fd956d9ac1489d8dc12827df67e9a201da43bc9d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 09:50:14 -0500 Subject: Flipping the order --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 2306230..57f8871 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -530,7 +530,7 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) { Application * appa = (Application *)a; Application * appb = (Application *)b; - return appa->ordering_index - appb->ordering_index; + return appb->ordering_index - appa->ordering_index; } /* Change the status of the application. If we're going passive -- cgit v1.2.3 From 818f7c466b1a06cea9a70e11abcfc0fba13a37c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:02:20 -0500 Subject: Putting the ordering index into the 'x' domain. --- src/application-service-appstore.c | 4 ++-- 1 file changed, 2 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 57f8871..e067b90 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -47,8 +47,8 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" #define NOTIFICATION_ITEM_PROP_LABEL "Label" -#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" -#define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "OrderingIndex" +#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" +#define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "XAyatanaOrderingIndex" #define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" #define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" -- cgit v1.2.3 From 2a0f0b9f099c2714556099fc7ddf1ceca5378fa2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:04:52 -0500 Subject: Changing the app store --- src/application-service-appstore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 55906ff..cf74efc 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -45,13 +45,13 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" #define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" -#define NOTIFICATION_ITEM_PROP_LABEL "Label" -#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" +#define NOTIFICATION_ITEM_PROP_LABEL "XAyatanaLabel" +#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "XAyatanaLabelGuide" #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_SIG_NEW_LABEL "XAyatanaNewLabel" #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" /* Private Stuff */ -- cgit v1.2.3 From a0c8fb032b4eb3fb534367832d43207cfdf31309 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 15:28:26 -0500 Subject: We were using the wrong function, we want categories not statuses! --- src/application-service-appstore.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index e067b90..e7231fe 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -115,6 +115,7 @@ static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); static void load_override_file (GHashTable * hash, const gchar * filename); static AppIndicatorStatus string_to_status(const gchar * status_string); +static AppIndicatorCategory string_to_cat(const gchar * cat_string); static void apply_status (Application * app, AppIndicatorStatus status); static void approver_free (gpointer papprover, gpointer user_data); static void check_with_new_approver (gpointer papp, gpointer papprove); @@ -357,13 +358,14 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err if (ordering_index_over == NULL) { gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { - app->ordering_index = generate_id(string_to_status(app->category), app->id); + app->ordering_index = generate_id(string_to_cat(app->category), app->id); } else { app->ordering_index = g_value_get_uint(ordering_index_data); } } else { app->ordering_index = GPOINTER_TO_UINT(ordering_index_over); } + g_debug("'%s' ordering index is '%d'", app->id, app->ordering_index); gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); if (label_data != NULL) { @@ -417,6 +419,28 @@ string_to_status(const gchar * status_string) return retval; } +/* Simple translation function -- could be optimized */ +static AppIndicatorCategory +string_to_cat(const gchar * cat_string) +{ + GEnumClass * klass = G_ENUM_CLASS(g_type_class_ref(APP_INDICATOR_TYPE_INDICATOR_CATEGORY)); + g_return_val_if_fail(klass != NULL, APP_INDICATOR_CATEGORY_OTHER); + + AppIndicatorCategory retval = APP_INDICATOR_CATEGORY_OTHER; + + GEnumValue * val = g_enum_get_value_by_nick(klass, cat_string); + if (val == NULL) { + g_warning("Unrecognized status '%s' assuming other.", cat_string); + } else { + retval = (AppIndicatorCategory)val->value; + } + + g_type_class_unref(klass); + + return retval; +} + + /* A small helper function to get the position of an application in the app list. */ static gint -- cgit v1.2.3 From d678c3504b773d726573d50f2456ae83fc2b0bb0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 15:42:56 -0500 Subject: Better debug printing. --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index e7231fe..f28c2af 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -365,7 +365,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err } else { app->ordering_index = GPOINTER_TO_UINT(ordering_index_over); } - g_debug("'%s' ordering index is '%d'", app->id, app->ordering_index); + g_debug("'%s' ordering index is '%X'", app->id, app->ordering_index); gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); if (label_data != NULL) { -- cgit v1.2.3 From f34b5e562004795cfb4e09a7daa1d3cbb21f89f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 15:45:09 -0500 Subject: Fighting wrap around --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index f28c2af..d3dc4a9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -554,7 +554,7 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) { Application * appa = (Application *)a; Application * appb = (Application *)b; - return appb->ordering_index - appa->ordering_index; + return (appb->ordering_index/2) - (appa->ordering_index/2); } /* Change the status of the application. If we're going passive -- cgit v1.2.3 From efd7be1cf7c80abc13c6d3bb3bc99cef18b8db7b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 19:59:38 -0500 Subject: Adding a count for the number of approvers that have approved the application. --- src/application-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 55906ff..83b64f3 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -85,6 +85,7 @@ struct _Application { gchar * label; gchar * guide; gboolean currently_free; + gint approved_by; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -734,6 +735,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->label = NULL; app->guide = NULL; app->currently_free = FALSE; + app->approved_by = 0; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From e8b76a6a10b53e0cc4d34895fb396a5bc9ab4c54 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:04:06 -0500 Subject: Changing to a list, we're going to need to track who so when they disconnect we can know the state change. --- src/application-service-appstore.c | 4 ++-- 1 file changed, 2 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 83b64f3..9c34a79 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -85,7 +85,7 @@ struct _Application { gchar * label; gchar * guide; gboolean currently_free; - gint approved_by; + GList * approved_by; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -735,7 +735,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->label = NULL; app->guide = NULL; app->currently_free = FALSE; - app->approved_by = 0; + app->approved_by = NULL; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From fbdf4bfec6dad26c7b3ffdedd9f1616abf20f196 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:26:08 -0500 Subject: Managing the list with the approver returns. --- src/application-service-appstore.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 9c34a79..b2c18d4 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -949,6 +949,15 @@ static void approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) { g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + Application * app = (Application *)userdata; + + if (OUT_approved) { + app->approved_by = g_list_prepend(app->approved_by, proxy); + } else { + app->approved_by = g_list_remove(app->approved_by, proxy); + } + + /* TODO: Apply status */ return; } -- cgit v1.2.3 From a635d68dff58440961c12f1db6f998836b1c556f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:31:30 -0500 Subject: Adding a visible state entry to the application structure --- 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 b2c18d4..c32cd5e 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -62,6 +62,12 @@ struct _ApplicationServiceAppstorePrivate { AppLruFile * lrufile; }; +typedef enum { + VISIBLE_STATE_HIDDEN, + VISIBLE_STATE_NORMAL, + VISIBLE_STATE_ATTENTION +} visible_state_t; + typedef struct _Approver Approver; struct _Approver { DBusGProxy * proxy; @@ -86,6 +92,7 @@ struct _Application { gchar * guide; gboolean currently_free; GList * approved_by; + visible_state_t visible_state; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -736,6 +743,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->guide = NULL; app->currently_free = FALSE; app->approved_by = NULL; + app->visible_state = VISIBLE_STATE_HIDDEN; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From ddd87466241652a8f889e7c27f6e6b6b31797450 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:33:01 -0500 Subject: Making sure to clean up the approved by list --- 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 c32cd5e..d0723b9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -405,6 +405,9 @@ application_free (Application * app) if (app->guide != NULL) { g_free(app->guide); } + if (app->approved_by != NULL) { + g_list_free(app->approved_by); + } g_free(app); return; -- cgit v1.2.3 From b7419c3d3e23ddc3be51f1d3c182360ffe76bf8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:58:36 -0500 Subject: Changing the apply_status function to be less about applying the status and more about trying to apply a visual state that can be determined by things like approvers. This means that it doesn't get passed the status. --- src/application-service-appstore.c | 77 +++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 30 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index d0723b9..bff4c77 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -116,7 +116,7 @@ static void application_service_appstore_init (ApplicationServiceAppstore static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); static AppIndicatorStatus string_to_status(const gchar * status_string); -static void apply_status (Application * app, AppIndicatorStatus status); +static void apply_status (Application * app); 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); @@ -264,6 +264,8 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->id = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID)); app->category = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY)); + app->status = string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS))); + ApplicationServiceAppstorePrivate * priv = app->appstore->priv; app_lru_file_touch(priv->lrufile, app->id, app->category); @@ -306,7 +308,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ g_list_foreach(priv->approvers, check_with_old_approver, app); - apply_status(app, string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS)))); + apply_status(app); return; } @@ -421,13 +423,16 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) Application * app = (Application *)userdata; /* Remove from the panel */ - apply_status(app, APP_INDICATOR_STATUS_PASSIVE); + app->status = APP_INDICATOR_STATUS_PASSIVE; + apply_status(app); /* Destroy the data */ application_free(app); return; } +/* Look and see if an application exists in the application + list already */ static gboolean can_add_application (GList *applications, Application *app) { @@ -466,49 +471,60 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) it removes it from the panel. If we're coming online, then it add it to the panel. Otherwise it changes the icon. */ static void -apply_status (Application * app, AppIndicatorStatus status) +apply_status (Application * app) { - if (app->status == status) { - return; - } - g_debug("Changing app status to: %d", status); - ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; + visible_state_t goal_state = VISIBLE_STATE_HIDDEN; + + if (app->status != APP_INDICATOR_STATUS_PASSIVE && + g_list_length(app->approved_by) == g_list_length(priv->approvers)) { + if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + goal_state = VISIBLE_STATE_NORMAL; + } else if (app->status == APP_INDICATOR_STATUS_ATTENTION) { + goal_state = VISIBLE_STATE_ATTENTION; + } + } + + /* Nothing needs to change, we're good */ + if (app->visible_state == goal_state) { + return; + } + /* This means we're going off line */ - if (status == APP_INDICATOR_STATUS_PASSIVE) { + if (goal_state == VISIBLE_STATE_HIDDEN) { gint position = get_position(app); if (position == -1) return; g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); - priv->applications = g_list_remove(priv->applications, app); + priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; - if (status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { + if (goal_state == VISIBLE_STATE_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { newicon = app->aicon; } /* Determine whether we're already shown or not */ - if (app->status == APP_INDICATOR_STATUS_PASSIVE) { - if (can_add_application (priv->applications, app)) { - /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ADDED], 0, - newicon, - g_list_index(priv->applications, app), /* Position */ - app->dbus_name, - app->menu, - app->icon_theme_path, - app->label, - app->guide, - TRUE); - } + if (app->visible_state == VISIBLE_STATE_HIDDEN) { + if (can_add_application (priv->applications, app)) { + /* Put on panel */ + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + newicon, + g_list_index(priv->applications, app), /* Position */ + app->dbus_name, + app->menu, + app->icon_theme_path, + app->label, + app->guide, + TRUE); + } } else { /* Icon update */ gint position = get_position(app); @@ -520,7 +536,7 @@ apply_status (Application * app, AppIndicatorStatus status) } } - app->status = status; + app->visible_state = goal_state; return; } @@ -642,7 +658,8 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) Application * app = (Application *)data; if (!app->validated) return; - apply_status(app, string_to_status(status)); + app->status = string_to_status(status); + apply_status(app); return; } -- cgit v1.2.3 From ba6904978575157936f0fb3ce9fd4aa78ac740ee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:15:58 -0500 Subject: Moving some TODOs --- src/application-service-appstore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index bff4c77..6ee2c47 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -305,7 +305,6 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err 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); apply_status(app); @@ -985,7 +984,7 @@ approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gp app->approved_by = g_list_remove(app->approved_by, proxy); } - /* TODO: Apply status */ + apply_status(app); return; } -- cgit v1.2.3 From 4398a699958b13e6e5739520eb83f9530dd333f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:30:44 -0500 Subject: Make it so that an approver that gets free'd gets removed from the applications list of approval. --- src/application-service-appstore.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 6ee2c47..5467f31 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -220,7 +220,7 @@ application_service_appstore_dispose (GObject *object) } if (priv->approvers != NULL) { - g_list_foreach(priv->approvers, approver_free, NULL); + g_list_foreach(priv->approvers, approver_free, object); g_list_free(priv->approvers); priv->approvers = NULL; } @@ -955,12 +955,27 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst return TRUE; } +/* Removes and approver from our list of approvers and + then sees if that changes our status. Most likely this + could make us visible if this approver rejected us. */ +static void +remove_approver (gpointer papp, gpointer pproxy) +{ + Application * app = (Application *)papp; + app->approved_by = g_list_remove(app->approved_by, pproxy); + apply_status(app); + return; +} + /* Frees the data associated with an approver */ static void approver_free (gpointer papprover, gpointer user_data) { Approver * approver = (Approver *)papprover; g_return_if_fail(approver != NULL); + + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); + g_list_foreach(appstore->priv->applications, remove_approver, approver->proxy); if (approver->proxy != NULL) { g_object_unref(approver->proxy); -- cgit v1.2.3 From 0db4eb579e37326484df53ff9dab3a4a6b6a8b40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:48:54 -0500 Subject: Switching a few status checks to look at the visible state --- src/application-service-appstore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 5467f31..f5b2db4 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -565,7 +565,7 @@ new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata if (app->icon != NULL) g_free(app->icon); app->icon = g_strdup(newicon); - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + if (app->visible_state == VISIBLE_STATE_NORMAL) { gint position = get_position(app); if (position == -1) return; @@ -603,7 +603,7 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat if (app->aicon != NULL) g_free(app->aicon); app->aicon = g_strdup(newicon); - if (app->status == APP_INDICATOR_STATUS_ATTENTION) { + if (app->visible_state == VISIBLE_STATE_ATTENTION) { gint position = get_position(app); if (position == -1) return; @@ -676,7 +676,7 @@ new_icon_theme_path (DBusGProxy * proxy, const gchar * icon_theme_path, gpointer if (app->icon_theme_path != NULL) g_free(app->icon_theme_path); app->icon_theme_path = g_strdup(icon_theme_path); - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + if (app->visible_state != VISIBLE_STATE_HIDDEN) { gint position = get_position(app); if (position == -1) return; -- cgit v1.2.3 From 360e8a40e548f5080193dd60d9c7fd5c2fb50089 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:52:43 -0500 Subject: Simplifying the visual state to just be shown/hidden while letting the status show which icon is shown. --- src/application-service-appstore.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index f5b2db4..0991286 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -64,8 +64,7 @@ struct _ApplicationServiceAppstorePrivate { typedef enum { VISIBLE_STATE_HIDDEN, - VISIBLE_STATE_NORMAL, - VISIBLE_STATE_ATTENTION + VISIBLE_STATE_SHOWN } visible_state_t; typedef struct _Approver Approver; @@ -479,11 +478,7 @@ apply_status (Application * app) if (app->status != APP_INDICATOR_STATUS_PASSIVE && g_list_length(app->approved_by) == g_list_length(priv->approvers)) { - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { - goal_state = VISIBLE_STATE_NORMAL; - } else if (app->status == APP_INDICATOR_STATUS_ATTENTION) { - goal_state = VISIBLE_STATE_ATTENTION; - } + goal_state = VISIBLE_STATE_SHOWN; } /* Nothing needs to change, we're good */ @@ -503,7 +498,7 @@ apply_status (Application * app) } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; - if (goal_state == VISIBLE_STATE_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { + if (app->status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { newicon = app->aicon; } @@ -565,7 +560,7 @@ new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata if (app->icon != NULL) g_free(app->icon); app->icon = g_strdup(newicon); - if (app->visible_state == VISIBLE_STATE_NORMAL) { + if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ACTIVE) { gint position = get_position(app); if (position == -1) return; @@ -603,7 +598,7 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat if (app->aicon != NULL) g_free(app->aicon); app->aicon = g_strdup(newicon); - if (app->visible_state == VISIBLE_STATE_ATTENTION) { + if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ATTENTION) { gint position = get_position(app); if (position == -1) return; -- cgit v1.2.3 From d72265317345f41ea39f306c149fcf098ba1194e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:12:40 -0500 Subject: Handle the proxy being destroyed, and cleaning up the approver. --- src/application-service-appstore.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0991286..00de4b9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1017,6 +1017,42 @@ check_with_new_approver (gpointer papp, gpointer papprove) return; } +/* Look through all the approvers and find the one with a given + proxy. */ +static gint +approver_find_by_proxy (gconstpointer papprover, gconstpointer pproxy) +{ + Approver * approver = (Approver *)papprover; + + if (approver->proxy == pproxy) { + return 0; + } + + return -1; +} + +/* Tracks when a proxy gets destroyed so that we know that the + approver has dropped off the bus. */ +static void +approver_destroyed (gpointer pproxy, gpointer pappstore) +{ + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(pappstore); + + GList * lapprover = g_list_find_custom(appstore->priv->approvers, pproxy, approver_find_by_proxy); + if (lapprover == NULL) { + g_warning("Approver proxy died, but we don't seem to have that approver."); + return; + } + + Approver * approver = (Approver *)lapprover->data; + approver->proxy = NULL; + + appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); + approver_free(approver, appstore); + + return; +} + /* Adds a new approver to the app store */ void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) @@ -1041,6 +1077,8 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore return; } + g_signal_connect(G_OBJECT(approver->proxy), "destroy", G_CALLBACK(approver_destroyed), appstore); + priv->approvers = g_list_prepend(priv->approvers, approver); g_list_foreach(priv->applications, check_with_new_approver, approver); -- cgit v1.2.3 From fa45eaa48e679ddf2c264185e624723a7c1c27ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:22:24 -0500 Subject: Switching the get_position() function to look at the visibility of the applications. --- src/application-service-appstore.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 00de4b9..1b10033 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -342,18 +342,34 @@ string_to_status(const gchar * status_string) } /* A small helper function to get the position of an application - in the app list. */ + in the app list of the applications that are visible. */ static gint get_position (Application * app) { ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; - GList * applistitem = g_list_find(priv->applications, app); - if (applistitem == NULL) { - return -1; + GList * lapp; + gint count; + + /* Go through the list and try to find ours */ + for (lapp = priv->applications, count = 0; lapp != NULL; lapp = g_list_next(lapp), count++) { + if (lapp->data == app) { + break; + } + + /* If the selected app isn't visible let's not + count it's position */ + Application * thisapp = (Application *)(lapp->data); + if (thisapp->visible_state == VISIBLE_STATE_HIDDEN) { + count--; + } } - return g_list_position(priv->applications, applistitem); + if (lapp == NULL) { + return -1; + } + + return count; } /* A simple global function for dealing with freeing the information -- cgit v1.2.3 From 98252b227acb7d969aed26490dab7cba13298a7c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:26:47 -0500 Subject: Making sure to only list the visible applications. --- src/application-service-appstore.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 1b10033..6e666bc 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -914,6 +914,10 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { Application * app = (Application *)listpntr->data; + if (app->visible_state == VISIBLE_STATE_HIDDEN) { + continue; + } + GValueArray * values = g_value_array_new(5); GValue value = {0}; -- cgit v1.2.3 From 7a4bfc9135ea55b0f495513fbd7ad2734b328098 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:31:25 -0500 Subject: Changing it so that the list of applications has all the applications in it, independent of visible state. --- src/application-service-appstore.c | 56 ++++++++++---------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 6e666bc..4ba2aca 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -114,6 +114,7 @@ static void application_service_appstore_class_init (ApplicationServiceAppstoreC static void application_service_appstore_init (ApplicationServiceAppstore *self); static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); +static gint app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app); static void approver_free (gpointer papprover, gpointer user_data); @@ -244,6 +245,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err { if (error != NULL) { g_warning("Unable to get properties: %s", error->message); + /* TODO: We need to free all the application data here */ return; } @@ -304,6 +306,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = g_strdup(""); } + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); g_list_foreach(priv->approvers, check_with_old_approver, app); apply_status(app); @@ -445,30 +448,6 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) return; } -/* Look and see if an application exists in the application - list already */ -static gboolean -can_add_application (GList *applications, Application *app) -{ - if (applications) - { - GList *l = NULL; - - for (l = applications; l != NULL; l = g_list_next (l)) - { - Application *tmp_app = (Application *)l->data; - - if (g_strcmp0 (tmp_app->dbus_name, app->dbus_name) == 0 && - g_strcmp0 (tmp_app->dbus_object, app->dbus_object) == 0) - { - return FALSE; - } - } - } - - return TRUE; -} - /* This function takes two Application structure pointers and uses the lrufile to compare them. */ static gint @@ -510,7 +489,6 @@ apply_status (Application * app) g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); - priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; @@ -520,21 +498,17 @@ apply_status (Application * app) /* Determine whether we're already shown or not */ if (app->visible_state == VISIBLE_STATE_HIDDEN) { - if (can_add_application (priv->applications, app)) { - /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ADDED], 0, - newicon, - g_list_index(priv->applications, app), /* Position */ - app->dbus_name, - app->menu, - app->icon_theme_path, - app->label, - app->guide, - TRUE); - } + /* Put on panel */ + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + newicon, + g_list_index(priv->applications, app), /* Position */ + app->dbus_name, + app->menu, + app->icon_theme_path, + app->label, + app->guide, + TRUE); } else { /* Icon update */ gint position = get_position(app); @@ -867,7 +841,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst } /* Removes an application. Currently only works for the apps - that are shown. /TODO Need to fix that. */ + that are shown. */ void application_service_appstore_application_remove (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { -- cgit v1.2.3 From eadc69dd38700b68d314bc30d9a78e8400c22042 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 09:50:46 -0500 Subject: Freeing the allocated keys. --- src/application-service-appstore.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4ac1576..9764798 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -298,6 +298,7 @@ load_override_file (GHashTable * hash, const gchar * filename) g_hash_table_insert(hash, g_strdup(key), GINT_TO_POINTER(val)); } + g_strfreev(keys); g_key_file_free(keyfile); return; -- cgit v1.2.3 From c04a7cf4f33a7079be7718b72c5408f51f225ca3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 12:24:11 -0500 Subject: Uhg, broken merge. --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 57c4671..771f2af 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -392,7 +392,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = g_strdup(""); } - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, NULL); g_list_foreach(priv->approvers, check_with_old_approver, app); apply_status(app); -- cgit v1.2.3 From a0023d1bfb43aeb51d7b259dfc23c32139c8b14c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 14:01:38 -0500 Subject: Responding to approver errors like they're approval. --- src/application-service-appstore.c | 9 +++++++-- 1 file changed, 7 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 771f2af..056f0e1 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1083,10 +1083,15 @@ approver_free (gpointer papprover, gpointer user_data) static void approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) { - g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + if (error == NULL) { + g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + } else { + g_debug("Approver responded error: %s", error->message); + } + Application * app = (Application *)userdata; - if (OUT_approved) { + if (OUT_approved || error != NULL) { app->approved_by = g_list_prepend(app->approved_by, proxy); } else { app->approved_by = g_list_remove(app->approved_by, proxy); -- cgit v1.2.3 From ba5b85a76a469fb5fa860a723ffd09c939bc7f0e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 14:01:57 -0500 Subject: Making sure to remove our applications from the list as well. --- 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 056f0e1..73fc5d1 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -551,6 +551,9 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) app->status = APP_INDICATOR_STATUS_PASSIVE; apply_status(app); + /* Remove from the application list */ + app->appstore->priv->applications = g_list_remove(app->appstore->priv->applications, app); + /* Destroy the data */ application_free(app); return; -- cgit v1.2.3 From 93f92e8e6a6bda708d227f3ebe9c8dae15694b9e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:41:02 -0500 Subject: Making the list so that if there are errors we handle them well. --- src/application-service-appstore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 73fc5d1..85d72f7 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -578,10 +578,12 @@ apply_status (Application * app) ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; + g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); + visible_state_t goal_state = VISIBLE_STATE_HIDDEN; if (app->status != APP_INDICATOR_STATUS_PASSIVE && - g_list_length(app->approved_by) == g_list_length(priv->approvers)) { + g_list_length(app->approved_by) >= g_list_length(priv->approvers)) { goal_state = VISIBLE_STATE_SHOWN; } -- cgit v1.2.3 From fb1811ef2421e512b49bc5bb5c2796ba669ca29f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:42:41 -0500 Subject: Making it so that we don't set the proxy to null right away. --- src/application-service-appstore.c | 8 ++++++-- 1 file changed, 6 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 85d72f7..9f1920d 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -75,6 +75,7 @@ typedef enum { typedef struct _Approver Approver; struct _Approver { DBusGProxy * proxy; + gboolean destroy_by_proxy; }; typedef struct _Application Application; @@ -1076,7 +1077,9 @@ approver_free (gpointer papprover, gpointer user_data) g_list_foreach(appstore->priv->applications, remove_approver, approver->proxy); if (approver->proxy != NULL) { - g_object_unref(approver->proxy); + if (!approver->destroy_by_proxy) { + g_object_unref(approver->proxy); + } approver->proxy = NULL; } @@ -1153,7 +1156,7 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) } Approver * approver = (Approver *)lapprover->data; - approver->proxy = NULL; + approver->destroy_by_proxy = TRUE; appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); approver_free(approver, appstore); @@ -1171,6 +1174,7 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (appstore); Approver * approver = g_new0(Approver, 1); + approver->destroy_by_proxy = FALSE; GError * error = NULL; approver->proxy = dbus_g_proxy_new_for_name_owner(priv->bus, -- cgit v1.2.3 From 72c93f2c3aea90bc18a694a723915f33701a021b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:43:38 -0500 Subject: Commenting out debug message --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 9f1920d..30af2ea 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -579,7 +579,7 @@ apply_status (Application * app) ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; - g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); + /* g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); */ visible_state_t goal_state = VISIBLE_STATE_HIDDEN; -- cgit v1.2.3 From ca213633c7a98b7d9dd37a5a373f7ef825098eeb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:02:47 -0500 Subject: Connecting into the signal coming from the approver --- src/application-service-appstore.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 30af2ea..789ca48 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -183,6 +183,12 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_application_service_marshal_VOID__BOOLEAN_STRING_OBJECT, + G_TYPE_NONE, + G_TYPE_BOOLEAN, + G_TYPE_STRING, + G_TYPE_OBJECT, + G_TYPE_INVALID); dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, &dbus_glib__application_service_server_object_info); @@ -1164,6 +1170,17 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) return; } +/* A signal when an approver changes the why that it thinks about + a particular indicator. */ +void +approver_revise_judgement (DBusGProxy * proxy, gboolean new_status, gchar * address, DBusGProxy * get_path, gpointer user_data) +{ + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); + appstore = NULL; + + return; +} + /* Adds a new approver to the app store */ void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) @@ -1191,6 +1208,18 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore g_signal_connect(G_OBJECT(approver->proxy), "destroy", G_CALLBACK(approver_destroyed), appstore); + dbus_g_proxy_add_signal(approver->proxy, + "ReviseJudgement", + G_TYPE_BOOLEAN, + G_TYPE_STRING, + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(approver->proxy, + "ReviseJudgement", + G_CALLBACK(approver_revise_judgement), + appstore, + NULL); + priv->approvers = g_list_prepend(priv->approvers, approver); g_list_foreach(priv->applications, check_with_new_approver, approver); -- cgit v1.2.3 From 1865cf3b4e415dcb8b9cf85208ab88596d00b043 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:26:10 -0500 Subject: Refactor so that there is a function to look for applications. --- src/application-service-appstore.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 789ca48..7040b2a 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -959,6 +959,24 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst return; } +/* Looks for an application in the list of applications */ +static Application * +find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object) +{ + ApplicationServiceAppstorePrivate * priv = appstore->priv; + GList * listpntr; + + for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { + Application * app = (Application *)listpntr->data; + + if (!g_strcmp0(app->dbus_name, address) && !g_strcmp0(app->dbus_object, object)) { + return app; + } + } + + return NULL; +} + /* Removes an application. Currently only works for the apps that are shown. */ void @@ -968,16 +986,11 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); - ApplicationServiceAppstorePrivate * priv = appstore->priv; - GList * listpntr; - - for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { - Application * app = (Application *)listpntr->data; - - if (!g_strcmp0(app->dbus_name, dbus_name) && !g_strcmp0(app->dbus_object, dbus_object)) { - application_removed_cb(NULL, app); - break; /* NOTE: Must break as the list will become inconsistent */ - } + Application * app = find_application(appstore, dbus_name, dbus_object); + if (app != NULL) { + application_removed_cb(NULL, app); + } else { + g_warning("Unable to find application %s:%s", dbus_name, dbus_object); } return; -- cgit v1.2.3 From 9fc60ae8675fe81a3c051e5f4de0378ecfd75069 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:26:38 -0500 Subject: Flesh out the revise judgement handler to update the list of approvers. --- src/application-service-appstore.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 7040b2a..2d77d28 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1188,8 +1188,27 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) void approver_revise_judgement (DBusGProxy * proxy, gboolean new_status, gchar * address, DBusGProxy * get_path, gpointer user_data) { + g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(user_data)); + g_return_if_fail(address != NULL && address[0] != '\0'); + g_return_if_fail(get_path != NULL); + const gchar * path = dbus_g_proxy_get_path(get_path); + g_return_if_fail(path != NULL && path[0] != '\0'); + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); - appstore = NULL; + + Application * app = find_application(appstore, address, path); + + if (app == NULL) { + g_warning("Unable to update approver status of application (%s:%s) as it was not found", address, path); + return; + } + + if (new_status) { + app->approved_by = g_list_prepend(app->approved_by, proxy); + } else { + app->approved_by = g_list_remove(app->approved_by, proxy); + } + apply_status(app); return; } -- cgit v1.2.3