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