diff options
author | Ted Gould <ted@gould.cx> | 2010-08-05 16:10:11 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-05 16:10:11 -0500 |
commit | e4c14f7872697049acc56baa6865f55c2355e505 (patch) | |
tree | 13b9efda40a5c4d871e0b8b551e49befe5810776 /src | |
parent | 3f326bdebf4052e5ae620caf2cf1e17909c2f8f8 (diff) | |
parent | 9291697e3e6d4270a7f6200c0dc3d85743feb6d2 (diff) | |
download | libayatana-appindicator-e4c14f7872697049acc56baa6865f55c2355e505.tar.gz libayatana-appindicator-e4c14f7872697049acc56baa6865f55c2355e505.tar.bz2 libayatana-appindicator-e4c14f7872697049acc56baa6865f55c2355e505.zip |
* Upstream Merge
* Allow the icon theme path to be changed dynamically (LP: #607831)
Diffstat (limited to 'src')
-rw-r--r-- | src/app-indicator.c | 88 | ||||
-rw-r--r-- | src/app-indicator.h | 27 | ||||
-rw-r--r-- | src/application-service-appstore.c | 70 | ||||
-rw-r--r-- | src/application-service-appstore.h | 3 | ||||
-rw-r--r-- | src/application-service.xml | 4 | ||||
-rw-r--r-- | src/indicator-application.c | 79 | ||||
-rw-r--r-- | src/notification-item.xml | 3 |
7 files changed, 221 insertions, 53 deletions
diff --git a/src/app-indicator.c b/src/app-indicator.c index 32f512f..fdfcc23 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -69,7 +69,7 @@ struct _AppIndicatorPrivate { AppIndicatorStatus status; gchar *icon_name; gchar *attention_icon_name; - gchar * icon_path; + gchar *icon_theme_path; DbusmenuServer *menuservice; GtkWidget *menu; @@ -88,6 +88,7 @@ enum { NEW_ATTENTION_ICON, NEW_STATUS, CONNECTION_CHANGED, + NEW_ICON_THEME_PATH, LAST_SIGNAL }; @@ -229,7 +230,7 @@ app_indicator_class_init (AppIndicatorClass *klass) "An icon for the indicator", "The default icon that is shown for the indicator.", NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); /** AppIndicator:attention-icon-name: @@ -256,7 +257,7 @@ app_indicator_class_init (AppIndicatorClass *klass) "An additional path for custom icons.", "An additional place to look for icon names that may be installed by the application.", NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); /** AppIndicator:menu: @@ -347,6 +348,21 @@ app_indicator_class_init (AppIndicatorClass *klass) g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE); + /** + AppIndicator::new-icon-theme-path: + @arg0: The #AppIndicator object + + Signaled when there is a new icon set for the + object. + */ + signals[NEW_ICON_THEME_PATH] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppIndicatorClass, new_icon_theme_path), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + /* Initialize the object as a DBus type */ dbus_g_object_type_install_info(APP_INDICATOR_TYPE, &dbus_glib__notification_item_server_object_info); @@ -365,7 +381,7 @@ app_indicator_init (AppIndicator *self) priv->status = APP_INDICATOR_STATUS_PASSIVE; priv->icon_name = NULL; priv->attention_icon_name = NULL; - priv->icon_path = NULL; + priv->icon_theme_path = NULL; priv->menu = NULL; priv->menuservice = NULL; @@ -487,9 +503,9 @@ app_indicator_finalize (GObject *object) priv->attention_icon_name = NULL; } - if (priv->icon_path != NULL) { - g_free(priv->icon_path); - priv->icon_path = NULL; + if (priv->icon_theme_path != NULL) { + g_free(priv->icon_theme_path); + priv->icon_theme_path = NULL; } G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); @@ -557,10 +573,9 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu break; case PROP_ICON_THEME_PATH: - if (priv->icon_path != NULL) { - g_free(priv->icon_path); - } - priv->icon_path = g_value_dup_string(value); + app_indicator_set_icon_theme_path (APP_INDICATOR (object), + g_value_get_string (value)); + check_connect (self); break; default: @@ -603,7 +618,7 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa break; case PROP_ICON_THEME_PATH: - g_value_set_string (value, priv->icon_path); + g_value_set_string (value, priv->icon_theme_path); break; case PROP_MENU: @@ -1025,12 +1040,12 @@ app_indicator_new (const gchar *id, @id: The unique id of the indicator to create. @icon_name: The icon name for this indicator @category: The category of indicator. - @icon_path: A custom path for finding icons. + @icon_theme_path: A custom path for finding icons. Creates a new #AppIndicator setting the properties: #AppIndicator:id with @id, #AppIndicator:category with @category, #AppIndicator:icon-name with - @icon_name and #AppIndicator:icon-theme-path with @icon_path. + @icon_name and #AppIndicator:icon-theme-path with @icon_theme_path. Return value: A pointer to a new #AppIndicator object. */ @@ -1038,13 +1053,13 @@ AppIndicator * app_indicator_new_with_path (const gchar *id, const gchar *icon_name, AppIndicatorCategory category, - const gchar *icon_path) + const gchar *icon_theme_path) { AppIndicator *indicator = g_object_new (APP_INDICATOR_TYPE, PROP_ID_S, id, PROP_CATEGORY_S, category_from_enum (category), PROP_ICON_NAME_S, icon_name, - PROP_ICON_THEME_PATH_S, icon_path, + PROP_ICON_THEME_PATH_S, icon_theme_path, NULL); return indicator; @@ -1134,6 +1149,31 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) return; } +/** + app_indicator_set_icon_theme_path: + @self: The #AppIndicator object to use + @icon_theme_path: The icon theme path to set. + + Sets the path to use when searching for icons. +**/ +void +app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_path) +{ + g_return_if_fail (IS_APP_INDICATOR (self)); + + if (g_strcmp0 (self->priv->icon_theme_path, icon_theme_path) != 0) + { + if (self->priv->icon_theme_path != NULL) + g_free(self->priv->icon_theme_path); + + self->priv->icon_theme_path = g_strdup(icon_theme_path); + + g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, g_strdup(self->priv->icon_theme_path)); + } + + return; +} + static void activate_menuitem (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) { @@ -1626,6 +1666,22 @@ app_indicator_get_icon (AppIndicator *self) } /** + app_indicator_get_icon_theme_path: + @self: The #AppIndicator object to use + + Wrapper function for property #AppIndicator:icon-theme-path. + + Return value: The current icon theme path. +*/ +const gchar * +app_indicator_get_icon_theme_path (AppIndicator *self) +{ + g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); + + return self->priv->icon_theme_path; +} + +/** app_indicator_get_attention_icon: @self: The #AppIndicator object to use diff --git a/src/app-indicator.h b/src/app-indicator.h index e37abd4..b17f023 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -69,6 +69,7 @@ G_BEGIN_DECLS Gets a pointer to the #AppIndicatorClass for the object @obj. */ + #define APP_INDICATOR_TYPE (app_indicator_get_type ()) #define APP_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APP_INDICATOR_TYPE, AppIndicator)) #define APP_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APP_INDICATOR_TYPE, AppIndicatorClass)) @@ -96,10 +97,16 @@ G_BEGIN_DECLS String identifier for the #AppIndicator::connection-changed signal. */ +/** + APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH: + + String identifier for the #AppIndicator::new-icon-theme-path signal. +*/ #define APP_INDICATOR_SIGNAL_NEW_ICON "new-icon" #define APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON "new-attention-icon" #define APP_INDICATOR_SIGNAL_NEW_STATUS "new-status" #define APP_INDICATOR_SIGNAL_CONNECTION_CHANGED "connection-changed" +#define APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH "new-icon-theme-path" /** AppIndicatorCategory: @@ -147,12 +154,12 @@ typedef struct _AppIndicatorPrivate AppIndicatorPrivate; @new_icon: Slot for #AppIndicator::new-icon. @new_attention_icon: Slot for #AppIndicator::new-attention-icon. @new_status: Slot for #AppIndicator::new-status. + @new_icon_theme_path: Slot for #AppIndicator::new-icon-theme-path @connection_changed: Slot for #AppIndicator::connection-changed. @fallback: Function that gets called to make a #GtkStatusIcon when there is no Application Indicator area available. @unfallback: The function that gets called if an Application Indicator area appears after the fallback has been created. - @app_indicator_reserved_1: Reserved for future use. @app_indicator_reserved_2: Reserved for future use. The signals and external functions that make up the #AppIndicator @@ -163,12 +170,12 @@ struct _AppIndicatorClass { GObjectClass parent_class; /* DBus Signals */ - void (* new_icon) (AppIndicator *indicator, + void (* new_icon) (AppIndicator *indicator, gpointer user_data); - void (* new_attention_icon) (AppIndicator *indicator, + void (* new_attention_icon) (AppIndicator *indicator, gpointer user_data); - void (* new_status) (AppIndicator *indicator, - const gchar *status, + void (* new_status) (AppIndicator *indicator, + const gchar *status, gpointer user_data); /* Local Signals */ @@ -181,8 +188,11 @@ struct _AppIndicatorClass { void (*unfallback) (AppIndicator * indicator, GtkStatusIcon * status_icon); + void (* new_icon_theme_path) (AppIndicator *indicator, + const gchar *icon_theme_path, + gpointer user_data); + /* Reserved */ - void (*app_indicator_reserved_1)(void); void (*app_indicator_reserved_2)(void); }; @@ -215,7 +225,7 @@ AppIndicator *app_indicator_new (const gchar AppIndicator *app_indicator_new_with_path (const gchar *id, const gchar *icon_name, AppIndicatorCategory category, - const gchar *icon_path); + const gchar *icon_theme_path); /* Set properties */ void app_indicator_set_status (AppIndicator *self, @@ -226,12 +236,15 @@ void app_indicator_set_menu (AppIndicator GtkMenu *menu); void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name); +void app_indicator_set_icon_theme_path(AppIndicator *self, + const gchar *icon_theme_path); /* Get properties */ const gchar * app_indicator_get_id (AppIndicator *self); AppIndicatorCategory app_indicator_get_category (AppIndicator *self); AppIndicatorStatus app_indicator_get_status (AppIndicator *self); const gchar * app_indicator_get_icon (AppIndicator *self); +const gchar * app_indicator_get_icon_theme_path(AppIndicator *self); const gchar * app_indicator_get_attention_icon (AppIndicator *self); GtkMenu * app_indicator_get_menu (AppIndicator *self); diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 311fcb1..f18a89e 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -43,12 +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_THEME_PATH "NewIconThemePath" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { @@ -77,7 +78,7 @@ struct _Application { gchar * icon; gchar * aicon; gchar * menu; - gchar * icon_path; + gchar * icon_theme_path; gboolean currently_free; }; @@ -89,6 +90,7 @@ enum { APPLICATION_ADDED, APPLICATION_REMOVED, APPLICATION_ICON_CHANGED, + APPLICATION_ICON_THEME_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_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_theme_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); @@ -246,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. */ @@ -346,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); @@ -445,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 { @@ -586,6 +595,32 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) return; } +/* Called when the Notification Item signals that it + has a new icon theme path. */ +static void +new_icon_theme_path (DBusGProxy * proxy, const gchar * icon_theme_path, gpointer data) +{ + Application * app = (Application *)data; + if (!app->validated) return; + + 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; +} + /* Adding a new NotificationItem object from DBus in to the appstore. First, we need to get the information on it though. */ @@ -612,7 +647,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 */ @@ -659,7 +694,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_ICON_THEME_PATH, + G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(app->dbus_proxy, NOTIFICATION_ITEM_SIG_NEW_ICON, G_CALLBACK(new_icon), @@ -675,7 +714,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_THEME_PATH, + G_CALLBACK(new_icon_theme_path), + app, + NULL); + /* Get all the propertiees */ org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy, NOTIFICATION_ITEM_DBUS_IFACE, @@ -764,7 +808,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); diff --git a/src/application-service-appstore.h b/src/application-service-appstore.h index e8ba8c1..422b0fd 100644 --- a/src/application-service-appstore.h +++ b/src/application-service-appstore.h @@ -45,7 +45,8 @@ 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_icon_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer); + void (*application_icon_theme_path_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer); }; struct _ApplicationServiceAppstore { diff --git a/src/application-service.xml b/src/application-service.xml index 0b2e959..dcccfa4 100644 --- a/src/application-service.xml +++ b/src/application-service.xml @@ -44,6 +44,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>. <arg type="i" name="position" direction="out" /> <arg type="s" name="icon_name" direction="out" /> </signal> + <signal name="ApplicationIconThemePathChanged"> + <arg type="i" name="position" direction="out" /> + <arg type="s" name="icon_theme_path" direction="out" /> + </signal> </interface> </node> diff --git a/src/indicator-application.c b/src/indicator-application.c index 16c3a9f..066ea63 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -84,7 +84,8 @@ struct _IndicatorApplicationPrivate { typedef struct _ApplicationEntry ApplicationEntry; struct _ApplicationEntry { IndicatorObjectEntry entry; - gchar * icon_path; + gchar * icon_theme_path; + gchar * icon_name; gboolean old_service; gchar * dbusobject; gchar * dbusaddress; @@ -105,9 +106,10 @@ 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_theme_path, 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 application_icon_theme_path_changed (DBusGProxy * proxy, gint position, const gchar * icon_theme_path, 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); static void theme_dir_unref(IndicatorApplication * ia, const gchar * dir); @@ -280,6 +282,11 @@ connected (IndicatorApplication * application) G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal(priv->service_proxy, + "ApplicationIconThemePathChanged", + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_INVALID); /* Connect to them */ g_debug("Connect to them."); @@ -298,6 +305,11 @@ connected (IndicatorApplication * application) G_CALLBACK(application_icon_changed), application, NULL /* Disconnection Signal */); + dbus_g_proxy_connect_signal(priv->service_proxy, + "ApplicationIconThemePathChanged", + G_CALLBACK(application_icon_theme_path_changed), + application, + NULL /* Disconnection Signal */); } /* Query it for existing applications */ @@ -413,7 +425,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_theme_path, IndicatorApplication * application) { g_return_if_fail(IS_INDICATOR_APPLICATION(application)); g_debug("Building new application entry: %s with icon: %s", dbusaddress, iconname); @@ -435,15 +447,16 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co ApplicationEntry * app = g_new(ApplicationEntry, 1); app->old_service = FALSE; - app->icon_path = NULL; - if (icon_path != NULL && icon_path[0] != '\0') { - app->icon_path = g_strdup(icon_path); - theme_dir_ref(application, icon_path); + app->icon_theme_path = NULL; + if (icon_theme_path != NULL && icon_theme_path[0] != '\0') { + app->icon_theme_path = g_strdup(icon_theme_path); + theme_dir_ref(application, icon_theme_path); } app->dbusaddress = g_strdup(dbusaddress); app->dbusobject = g_strdup(dbusobject); + app->icon_name = g_strdup(iconname); /* 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. */ @@ -489,9 +502,9 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a priv->applications = g_list_remove(priv->applications, app); g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); - if (app->icon_path != NULL) { - theme_dir_unref(application, app->icon_path); - g_free(app->icon_path); + if (app->icon_theme_path != NULL) { + theme_dir_unref(application, app->icon_theme_path); + g_free(app->icon_theme_path); } if (app->dbusaddress != NULL) { g_free(app->dbusaddress); @@ -499,6 +512,9 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a if (app->dbusobject != NULL) { g_free(app->dbusobject); } + if (app->icon_name != NULL) { + g_free(app->icon_name); + } if (app->entry.image != NULL) { g_object_unref(G_OBJECT(app->entry.image)); } @@ -533,6 +549,37 @@ application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconn gchar * longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); indicator_image_helper_update(app->entry.image, longname); g_free(longname); + + app->icon_name = g_strdup(iconname); + + return; +} + +/* The callback for the signal that the icon theme path for an application + has changed. */ +static void +application_icon_theme_path_changed (DBusGProxy * proxy, gint position, const gchar * icon_theme_path, 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; + } + + if (g_strcmp0(icon_theme_path, app->icon_theme_path) != 0) { + if(app->icon_theme_path != NULL) { + theme_dir_unref(application, app->icon_theme_path); + g_free(app->icon_theme_path); + app->icon_theme_path = NULL; + } + if (icon_theme_path != NULL && icon_theme_path[0] != '\0') { + app->icon_theme_path = g_strdup(icon_theme_path); + theme_dir_ref(application, app->icon_theme_path); + } + indicator_image_helper_update(app->entry.image, app->icon_name); + } return; } @@ -564,13 +611,13 @@ get_applications_helper (gpointer data, gpointer user_data) gint position = g_value_get_int(g_value_array_get_nth(array, 1)); 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 * icon_theme_path = g_value_get_string(g_value_array_get_nth(array, 4)); - 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_theme_path, user_data); } -/* Refs a theme directory, and it may add it to the search - path */ +/* Unrefs a theme directory. This may involve removing it from + the search path. */ static void theme_dir_unref(IndicatorApplication * ia, const gchar * dir) { @@ -629,8 +676,8 @@ theme_dir_unref(IndicatorApplication * ia, const gchar * dir) return; } -/* Unrefs a theme directory. This may involve removing it from - the search path. */ +/* Refs a theme directory, and it may add it to the search + path */ static void theme_dir_ref(IndicatorApplication * ia, const gchar * dir) { diff --git a/src/notification-item.xml b/src/notification-item.xml index a0141c3..dc755c9 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -19,6 +19,9 @@ <!-- Signals --> <signal name="NewIcon"> </signal> + <signal name="NewIconThemePath"> + <arg type="s" name="icon_theme_path" direction="out" /> + </signal> <signal name="NewAttentionIcon"> </signal> <signal name="NewStatus"> |