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(+) 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 faf285937e744afd680703ee4cae14fac02276ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 11:58:49 -0500 Subject: Adding labels to the service interface --- src/application-service.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/application-service.xml b/src/application-service.xml index 0b2e959..df49516 100644 --- a/src/application-service.xml +++ b/src/application-service.xml @@ -26,7 +26,7 @@ with this program. If not, see . - + @@ -36,6 +36,8 @@ with this program. If not, see . + + @@ -44,6 +46,11 @@ with this program. If not, see . + + + + + -- cgit v1.2.3 From 1f1bb2ca74ccdbbbeaf0600b13ab12342d276b77 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 12:02:57 -0500 Subject: Changing prototypes to match DBus API change. --- src/indicator-application.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 16c3a9f..72f2110 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -105,7 +105,7 @@ static void disconnected (IndicatorApplication * application); static void disconnected_helper (gpointer data, gpointer user_data); static gboolean disconnected_kill (gpointer user_data); static void disconnected_kill_helper (gpointer data, gpointer user_data); -static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, IndicatorApplication * application); +static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, const gchar * label, const gchar * guide, IndicatorApplication * application); static void application_removed (DBusGProxy * proxy, gint position , IndicatorApplication * application); static void application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application); static void get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata); @@ -413,7 +413,7 @@ application_added_search (gconstpointer a, gconstpointer b) ApplicationEntry and signaling the indicator host that we've got a new indicator. */ static void -application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, IndicatorApplication * application) +application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, const gchar * label, const gchar * guide, IndicatorApplication * application) { g_return_if_fail(IS_INDICATOR_APPLICATION(application)); g_debug("Building new application entry: %s with icon: %s", dbusaddress, iconname); @@ -565,8 +565,10 @@ get_applications_helper (gpointer data, gpointer user_data) const gchar * dbus_address = g_value_get_string(g_value_array_get_nth(array, 2)); const gchar * dbus_object = g_value_get_boxed(g_value_array_get_nth(array, 3)); const gchar * icon_path = g_value_get_string(g_value_array_get_nth(array, 4)); + const gchar * label = g_value_get_string(g_value_array_get_nth(array, 5)); + const gchar * guide = g_value_get_string(g_value_array_get_nth(array, 6)); - return application_added(NULL, icon_name, position, dbus_address, dbus_object, icon_path, user_data); + return application_added(NULL, icon_name, position, dbus_address, dbus_object, icon_path, label, guide, user_data); } /* Refs a theme directory, and it may add it to the search -- 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 ++++-- src/application-service-marshal.list | 2 +- src/indicator-application.c | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) 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 { diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index 4ac8398..506bb00 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -16,5 +16,5 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see . -VOID: STRING, INT, STRING, STRING, STRING +VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING VOID: INT, STRING diff --git a/src/indicator-application.c b/src/indicator-application.c index 72f2110..32284d3 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -130,13 +130,15 @@ indicator_application_class_init (IndicatorApplicationClass *klass) io_class->get_entries = get_entries; io_class->get_location = get_location; - dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING, + dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING_STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); dbus_g_object_register_marshaller(_application_service_marshal_VOID__INT_STRING, G_TYPE_NONE, -- 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(+) 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 ++++++++ src/application-service-appstore.h | 1 + src/application-service-marshal.list | 1 + 3 files changed, 10 insertions(+) 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); diff --git a/src/application-service-appstore.h b/src/application-service-appstore.h index e8ba8c1..34c7b1c 100644 --- a/src/application-service-appstore.h +++ b/src/application-service-appstore.h @@ -46,6 +46,7 @@ struct _ApplicationServiceAppstoreClass { void (*application_added) (ApplicationServiceAppstore * appstore, gchar *, gint, gchar *, gchar *, gpointer); void (*application_removed) (ApplicationServiceAppstore * appstore, gint, gpointer); void (*application_icon_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer); + void (*application_label_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, const gchar *, gpointer); }; struct _ApplicationServiceAppstore { diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index 506bb00..90bd64e 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -17,4 +17,5 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see . VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING +VOID: INT, STRING, STRING VOID: INT, STRING -- cgit v1.2.3 From d06c1026db12ff8da45a2f16e81768aaca90c1c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 12:49:54 -0500 Subject: Adding in a base signal handler for the label change --- src/indicator-application.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/indicator-application.c b/src/indicator-application.c index 32284d3..be47be6 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -107,6 +107,7 @@ static gboolean disconnected_kill (gpointer user_data); static void disconnected_kill_helper (gpointer data, gpointer user_data); static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, const gchar * label, const gchar * guide, IndicatorApplication * application); static void application_removed (DBusGProxy * proxy, gint position , IndicatorApplication * application); +static void application_label_changed (DBusGProxy * proxy, gint position, const gchar * label, const gchar * guide, IndicatorApplication * application); static void application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application); static void get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata); static void get_applications_helper (gpointer data, gpointer user_data); @@ -145,6 +146,12 @@ indicator_application_class_init (IndicatorApplicationClass *klass) G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_application_service_marshal_VOID__INT_STRING_STRING, + G_TYPE_NONE, + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INVALID); return; } @@ -282,6 +289,12 @@ connected (IndicatorApplication * application) G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal(priv->service_proxy, + "ApplicationLabelChanged", + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INVALID); /* Connect to them */ g_debug("Connect to them."); @@ -300,6 +313,11 @@ connected (IndicatorApplication * application) G_CALLBACK(application_icon_changed), application, NULL /* Disconnection Signal */); + dbus_g_proxy_connect_signal(priv->service_proxy, + "ApplicationLabelChanged", + G_CALLBACK(application_label_changed), + application, + NULL /* Disconnection Signal */); } /* Query it for existing applications */ @@ -516,6 +534,22 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a return; } +/* The callback for the signal that the label for an application + has changed. */ +static void +application_label_changed (DBusGProxy * proxy, gint position, const gchar * label, const gchar * guide, IndicatorApplication * application) +{ + IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); + ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position); + + if (app == NULL) { + g_warning("Unable to find application at position: %d", position); + return; + } + + return; +} + /* The callback for the signal that the icon for an application has changed. */ static void -- 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(-) 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(+) 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(-) 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(-) 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 ++++++++++++++++++++++++++++++++++++ src/application-service-marshal.list | 1 + 2 files changed, 52 insertions(+) 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, diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index 90bd64e..f432028 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -19,3 +19,4 @@ VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING VOID: INT, STRING, STRING VOID: INT, STRING +VOID: STRING, STRING -- cgit v1.2.3 From 91c8b42fb87ae1919dddc1384ba1e3fc18e3d5e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 14:27:42 -0500 Subject: If we get passed a label let's make a GTK one for fun. --- src/indicator-application.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index be47be6..2597973 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -476,7 +476,15 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co app->entry.image = indicator_image_helper(longname); g_free(longname); - app->entry.label = NULL; + if (label == NULL || label[0] == '\0') { + app->entry.label = NULL; + } else { + app->entry.label = GTK_LABEL(gtk_label_new(label)); + gtk_widget_show(GTK_WIDGET(app->entry.label)); + + /* TODO: Use guide to size the label better */ + } + app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject)); /* Keep copies of these for ourself, just in case. */ -- cgit v1.2.3 From c25bb3c4bd3bf3b5c2d79db028d6db016eaa2c5b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 14:31:55 -0500 Subject: If it changes, let's update. --- src/indicator-application.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/indicator-application.c b/src/indicator-application.c index 2597973..9c12474 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -555,6 +555,12 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe return; } + if (app->entry.label != NULL) { + gtk_label_set_text(app->entry.label, label); + } else { + /* TODO: Handle the case where we didn't have a label */ + } + return; } -- cgit v1.2.3 From b83a74cd18522241f70efc98a285a363c55b91f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 15:19:09 -0500 Subject: Fix the check for the updated function signature. --- src/indicator-application.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 9c12474..9b06213 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -608,7 +608,7 @@ get_applications_helper (gpointer data, gpointer user_data) { GValueArray * array = (GValueArray *)data; - g_return_if_fail(array->n_values == 5); + g_return_if_fail(array->n_values == 7); const gchar * icon_name = g_value_get_string(g_value_array_get_nth(array, 0)); gint position = g_value_get_int(g_value_array_get_nth(array, 1)); -- 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(-) 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 fff357c14dce6e0ec08294d56c86756f5bede59a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 08:40:24 -0500 Subject: Changing the prototype of the added function. --- src/indicator-application.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/indicator-application.c b/src/indicator-application.c index 9b06213..5a6bfaf 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -279,6 +279,8 @@ connected (IndicatorApplication * application) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal(priv->service_proxy, "ApplicationRemoved", -- cgit v1.2.3 From 9c46c111666900bc30bf3a5062148f3f6dfc0e37 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 11:18:07 -0500 Subject: Storing the guide and using it to bound the size of the label. --- src/indicator-application.c | 56 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 5a6bfaf..1fd043d 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -88,6 +88,7 @@ struct _ApplicationEntry { gboolean old_service; gchar * dbusobject; gchar * dbusaddress; + gchar * guide; }; #define INDICATOR_APPLICATION_GET_PRIVATE(o) \ @@ -431,6 +432,46 @@ application_added_search (gconstpointer a, gconstpointer b) return -1; } +/* Does a quick meausre of how big the string is in + pixels with a Pango layout */ +static gint +measure_string (GtkStyle * style, PangoContext * context, const gchar * string) +{ + PangoLayout * layout = pango_layout_new(context); + pango_layout_set_text(layout, string, -1); + pango_layout_set_font_description(layout, style->font_desc); + + gint width; + pango_layout_get_pixel_size(layout, &width, NULL); + g_object_unref(layout); + return width; +} + +/* Try to get a good guess at what a maximum width of the entire + string would be. */ +static void +guess_label_size (ApplicationEntry * app) +{ + /* This is during startup. */ + if (app->entry.label == NULL) return; + + GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(app->entry.label)); + PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(app->entry.label)); + + gint length = measure_string(style, context, gtk_label_get_text(app->entry.label)); + + if (app->guide != NULL) { + gint guidelen = measure_string(style, context, app->guide); + if (guidelen > length) { + length = guidelen; + } + } + + gtk_widget_set_size_request(GTK_WIDGET(app->entry.label), length, -1); + + return; +} + /* Here we respond to new applications by building up the ApplicationEntry and signaling the indicator host that we've got a new indicator. */ @@ -465,6 +506,7 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co app->dbusaddress = g_strdup(dbusaddress); app->dbusobject = g_strdup(dbusobject); + app->guide = NULL; /* We make a long name using the suffix, and if that icon is available we want to use it. Otherwise we'll @@ -484,7 +526,16 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co app->entry.label = GTK_LABEL(gtk_label_new(label)); gtk_widget_show(GTK_WIDGET(app->entry.label)); - /* TODO: Use guide to size the label better */ + if (app->guide != NULL) { + g_free(app->guide); + app->guide = NULL; + } + + if (guide != NULL) { + app->guide = g_strdup(guide); + } + + guess_label_size(app); } app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject)); @@ -529,6 +580,9 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a if (app->dbusobject != NULL) { g_free(app->dbusobject); } + if (app->guide != NULL) { + g_free(app->guide); + } if (app->entry.image != NULL) { g_object_unref(G_OBJECT(app->entry.image)); } -- cgit v1.2.3 From 62a5f41b117ec2f8a2c5258522951fe94acfffea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 11:25:25 -0500 Subject: Adding updating the guide and label size to the label update signal --- src/indicator-application.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/indicator-application.c b/src/indicator-application.c index 1fd043d..461d32e 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -617,6 +617,17 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe /* TODO: Handle the case where we didn't have a label */ } + if (app->guide != NULL) { + g_free(app->guide); + app->guide = NULL; + } + + if (guide != NULL) { + app->guide = g_strdup(guide); + } + + guess_label_size(app); + return; } -- cgit v1.2.3 From a644617fdbc2257a9e6219532a5a6bfaf6decc90 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 12:08:51 -0500 Subject: Building a label in the case that we don't have one already. --- src/indicator-application.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 461d32e..788c5e9 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -587,7 +587,6 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a g_object_unref(G_OBJECT(app->entry.image)); } if (app->entry.label != NULL) { - g_warning("Odd, an application indicator with a label?"); g_object_unref(G_OBJECT(app->entry.label)); } if (app->entry.menu != NULL) { @@ -610,11 +609,19 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe g_warning("Unable to find application at position: %d", position); return; } + + /* TODO: Be able to remove labels */ if (app->entry.label != NULL) { gtk_label_set_text(app->entry.label, label); } else { - /* TODO: Handle the case where we didn't have a label */ + app->entry.label = GTK_LABEL(gtk_label_new(label)); + gtk_widget_show(GTK_WIDGET(app->entry.label)); + + /* We tell listeners that it got removed and readded so + that we can get them to re-look at the new label. */ + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); } if (app->guide != NULL) { @@ -622,7 +629,7 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe app->guide = NULL; } - if (guide != NULL) { + if (guide != NULL && guide[0] != '\0') { app->guide = g_strdup(guide); } -- cgit v1.2.3 From 08a2c880e92c9ac143e83c862853c07068661fb9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 12:20:25 -0500 Subject: Some slight refactoring and comments along with the ability to remove the entries and recreate them. --- src/indicator-application.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 788c5e9..a4933ac 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -610,20 +610,34 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe return; } - /* TODO: Be able to remove labels */ - - if (app->entry.label != NULL) { - gtk_label_set_text(app->entry.label, label); + if (label == NULL || label[0] == '\0') { + /* No label, let's see if we need to delete the old one */ + if (app->entry.label != NULL) { + g_object_unref(G_OBJECT(app->entry.label)); + app->entry.label = NULL; + + /* We tell listeners that it got removed and readded so + that we can get them to remove the old label. */ + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + } } else { - app->entry.label = GTK_LABEL(gtk_label_new(label)); - gtk_widget_show(GTK_WIDGET(app->entry.label)); + /* We've got a label, is this just an update or is + it a new thing. */ + if (app->entry.label != NULL) { + gtk_label_set_text(app->entry.label, label); + } else { + app->entry.label = GTK_LABEL(gtk_label_new(label)); + gtk_widget_show(GTK_WIDGET(app->entry.label)); - /* We tell listeners that it got removed and readded so - that we can get them to re-look at the new label. */ - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + /* We tell listeners that it got removed and readded so + that we can get them to re-look at the new label. */ + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + } } + /* Copy the guide if we have one */ if (app->guide != NULL) { g_free(app->guide); app->guide = NULL; @@ -633,6 +647,7 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe app->guide = g_strdup(guide); } + /* Protected against not having a label */ guess_label_size(app); return; -- cgit v1.2.3 From 38074f5f2b53b969b9bdd1759ac6c94cfec68956 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 12:20:56 -0500 Subject: Not really sure what this TODO meant, so I'm removing it. --- src/indicator-application.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index a4933ac..939537e 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -548,7 +548,6 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co priv->applications = g_list_insert(priv->applications, app, position); - /* TODO: Need to deal with position here somehow */ g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); return; } -- cgit v1.2.3 From b17e62540f4ac630d7af7386409779271f3a2a57 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 13:23:12 -0500 Subject: Reshuffling the signaling and making sure to ref the label. --- src/indicator-application.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 939537e..2b32a1b 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -524,6 +524,7 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co app->entry.label = NULL; } else { app->entry.label = GTK_LABEL(gtk_label_new(label)); + g_object_ref(G_OBJECT(app->entry.label)); gtk_widget_show(GTK_WIDGET(app->entry.label)); if (app->guide != NULL) { @@ -603,6 +604,7 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe { IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position); + gboolean signal_reload = FALSE; if (app == NULL) { g_warning("Unable to find application at position: %d", position); @@ -615,10 +617,7 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe g_object_unref(G_OBJECT(app->entry.label)); app->entry.label = NULL; - /* We tell listeners that it got removed and readded so - that we can get them to remove the old label. */ - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + signal_reload = TRUE; } } else { /* We've got a label, is this just an update or is @@ -627,12 +626,10 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe gtk_label_set_text(app->entry.label, label); } else { app->entry.label = GTK_LABEL(gtk_label_new(label)); + g_object_ref(G_OBJECT(app->entry.label)); gtk_widget_show(GTK_WIDGET(app->entry.label)); - /* We tell listeners that it got removed and readded so - that we can get them to re-look at the new label. */ - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + signal_reload = TRUE; } } @@ -649,6 +646,13 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe /* Protected against not having a label */ guess_label_size(app); + if (signal_reload) { + /* Telling the listener that this has been removed, and then + readded to make it reparse the entry. */ + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + } + return; } -- cgit v1.2.3 From 54c6103dc570dbbee0ba8402d3c7156ac40dc5a4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 13:56:56 -0500 Subject: Showing and hiding the entries with removal. --- src/indicator-application.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/indicator-application.c b/src/indicator-application.c index 2b32a1b..31c3aa9 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -649,7 +649,28 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe if (signal_reload) { /* Telling the listener that this has been removed, and then readded to make it reparse the entry. */ + if (app->entry.label != NULL) { + gtk_widget_hide(GTK_WIDGET(app->entry.label)); + } + + if (app->entry.image != NULL) { + gtk_widget_hide(GTK_WIDGET(app->entry.image)); + } + + if (app->entry.menu != NULL) { + gtk_menu_detach(app->entry.menu); + } + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + + if (app->entry.label != NULL) { + gtk_widget_show(GTK_WIDGET(app->entry.label)); + } + + if (app->entry.image != NULL) { + gtk_widget_show(GTK_WIDGET(app->entry.image)); + } + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); } -- cgit v1.2.3 From 593c6b8c70d347a0109b96e968fc6a4eab7f5fb8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 15:02:17 -0500 Subject: Check for suffix when updating icon as well! --- src/indicator-application.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 31c3aa9..9abfbe6 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -693,7 +693,12 @@ application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconn /* We make a long name using the suffix, and if that icon is available we want to use it. Otherwise we'll just use the name we were given. */ - gchar * longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); + gchar * longname = NULL; + if (!g_str_has_suffix(iconname, PANEL_ICON_SUFFIX)) { + longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); + } else { + longname = g_strdup(iconname); + } indicator_image_helper_update(app->entry.image, longname); g_free(longname); -- cgit v1.2.3 From 225167d17161ec59efac14648841b5a36b20f3c1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 15:04:34 -0500 Subject: Tracking the long name along with the application entry. --- src/indicator-application.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/indicator-application.c b/src/indicator-application.c index 9abfbe6..a3aabb2 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -89,6 +89,7 @@ struct _ApplicationEntry { gchar * dbusobject; gchar * dbusaddress; gchar * guide; + gchar * longname; }; #define INDICATOR_APPLICATION_GET_PRIVATE(o) \ @@ -511,14 +512,13 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co /* We make a long name using the suffix, and if that icon is available we want to use it. Otherwise we'll just use the name we were given. */ - gchar * longname = NULL; + app->longname = NULL; if (!g_str_has_suffix(iconname, PANEL_ICON_SUFFIX)) { - longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); + app->longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); } else { - longname = g_strdup(iconname); + app->longname = g_strdup(iconname); } - app->entry.image = indicator_image_helper(longname); - g_free(longname); + app->entry.image = indicator_image_helper(app->longname); if (label == NULL || label[0] == '\0') { app->entry.label = NULL; @@ -583,6 +583,9 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a if (app->guide != NULL) { g_free(app->guide); } + if (app->longname != NULL) { + g_free(app->longname); + } if (app->entry.image != NULL) { g_object_unref(G_OBJECT(app->entry.image)); } @@ -693,14 +696,16 @@ application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconn /* We make a long name using the suffix, and if that icon is available we want to use it. Otherwise we'll just use the name we were given. */ - gchar * longname = NULL; + if (app->longname != NULL) { + g_free(app->longname); + app->longname = NULL; + } if (!g_str_has_suffix(iconname, PANEL_ICON_SUFFIX)) { - longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); + app->longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); } else { - longname = g_strdup(iconname); + app->longname = g_strdup(iconname); } - indicator_image_helper_update(app->entry.image, longname); - g_free(longname); + indicator_image_helper_update(app->entry.image, app->longname); return; } -- cgit v1.2.3 From c1aaada70bc0a55e99e1ef7e13e477ddf553f386 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 15:06:49 -0500 Subject: Updating with helper when rebuilding. --- src/indicator-application.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/indicator-application.c b/src/indicator-application.c index a3aabb2..eb3de3c 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -671,6 +671,7 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe } if (app->entry.image != NULL) { + indicator_image_helper_update(app->entry.image, app->longname); gtk_widget_show(GTK_WIDGET(app->entry.image)); } -- cgit v1.2.3