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 +++++++++++++++++++++++++++++++++++++- src/application-service-appstore.h | 3 +- src/application-service.xml | 4 ++ src/indicator-application.c | 34 +++++++++++++++++ 4 files changed, 113 insertions(+), 3 deletions(-) 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, diff --git a/src/application-service-appstore.h b/src/application-service-appstore.h index e8ba8c1..066dfbc 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_path_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer); }; struct _ApplicationServiceAppstore { diff --git a/src/application-service.xml b/src/application-service.xml index 0b2e959..9a559d2 100644 --- a/src/application-service.xml +++ b/src/application-service.xml @@ -44,6 +44,10 @@ with this program. If not, see . + + + + diff --git a/src/indicator-application.c b/src/indicator-application.c index 16c3a9f..66913df 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -108,6 +108,7 @@ 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_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_path_changed (DBusGProxy * proxy, gint position, const gchar * iconpath, 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 +281,11 @@ connected (IndicatorApplication * application) G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal(priv->service_proxy, + "ApplicationIconPathChanged", + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_INVALID); /* Connect to them */ g_debug("Connect to them."); @@ -298,6 +304,11 @@ connected (IndicatorApplication * application) G_CALLBACK(application_icon_changed), application, NULL /* Disconnection Signal */); + dbus_g_proxy_connect_signal(priv->service_proxy, + "ApplicationIconPathChanged", + G_CALLBACK(application_icon_path_changed), + application, + NULL /* Disconnection Signal */); } /* Query it for existing applications */ @@ -537,6 +548,29 @@ application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconn return; } +/* The callback for the signal that the icon path for an application + has changed. */ +static void +application_icon_path_changed (DBusGProxy * proxy, gint position, const gchar * iconpath, 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; + } + + g_free(app->icon_path); + app->icon_path = NULL; + if (iconpath != NULL && iconpath[0] != '\0') { + app->icon_path = g_strdup(iconpath); + theme_dir_ref(application, iconpath); + } + + return; +} + /* This repsonds to the list of applications that the service has and calls application_added on each one of them. */ static void -- cgit v1.2.3 From 3fb0e1143677f16976fa991098dc009a0a7b1a79 Mon Sep 17 00:00:00 2001 From: C10uD Date: Thu, 22 Jul 2010 15:04:52 +0200 Subject: forgot some files --- bindings/python/appindicator.defs | 9 +++++++ src/app-indicator.c | 49 +++++++++++++++++++++++++++++++++++---- src/app-indicator.h | 11 +++++++++ 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/bindings/python/appindicator.defs b/bindings/python/appindicator.defs index 98abe4c..b4740ce 100644 --- a/bindings/python/appindicator.defs +++ b/bindings/python/appindicator.defs @@ -89,6 +89,15 @@ ) ) +(define-method set_icon_path + (of-object "AppIndicator") + (c-name "app_indicator_set_icon_path") + (return-type "none") + (parameters + '("const-gchar*" "icon_path") + ) +) + (define-method get_id (of-object "AppIndicator") (c-name "app_indicator_get_id") diff --git a/src/app-indicator.c b/src/app-indicator.c index 32f512f..137c4c4 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -88,6 +88,7 @@ enum { NEW_ATTENTION_ICON, NEW_STATUS, CONNECTION_CHANGED, + NEW_PATH, LAST_SIGNAL }; @@ -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: + @arg0: The #AppIndicator object + + Signaled when there is a new icon set for the + object. + */ + signals[NEW_PATH] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_PATH, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppIndicatorClass, new_path), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); + /* Initialize the object as a DBus type */ dbus_g_object_type_install_info(APP_INDICATOR_TYPE, &dbus_glib__notification_item_server_object_info); @@ -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_path (APP_INDICATOR (object), + g_value_get_string (value)); + check_connect (self); break; default: @@ -1134,6 +1149,32 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) return; } +/** + app_indicator_set_icon_theme: + @self: The #AppIndicator object to use + @icon_path: The icon theme path to set. + + Sets the path to use when searching for icons. +**/ +void +app_indicator_set_icon_path (AppIndicator *self, const gchar *icon_path) +{ + g_return_if_fail (IS_APP_INDICATOR (self)); + g_return_if_fail (icon_path != NULL); + + if (g_strcmp0 (self->priv->icon_path, icon_path) != 0) + { + if (self->priv->icon_path != NULL) + g_free(self->priv->icon_path); + + self->priv->icon_path = g_strdup(icon_path); + + g_signal_emit (self, signals[NEW_PATH], 0, TRUE); + } + + return; +} + static void activate_menuitem (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) { diff --git a/src/app-indicator.h b/src/app-indicator.h index e37abd4..a5ee4d6 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_PATH: + + String identifier for the #AppIndicator::new-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_PATH "new-path" /** AppIndicatorCategory: @@ -170,6 +177,8 @@ struct _AppIndicatorClass { void (* new_status) (AppIndicator *indicator, const gchar *status, gpointer user_data); + void (* new_path) (AppIndicator *indicator, + gpointer user_data); /* Local Signals */ void (* connection_changed) (AppIndicator * indicator, @@ -226,6 +235,8 @@ void app_indicator_set_menu (AppIndicator GtkMenu *menu); void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name); +void app_indicator_set_icon_path (AppIndicator *self, + const gchar *icon_path); /* Get properties */ const gchar * app_indicator_get_id (AppIndicator *self); -- 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. --- bindings/mono/libappindicator-api.metadata | 6 ++- bindings/python/appindicator.defs | 14 ++++-- src/app-indicator.c | 63 +++++++++++++++++---------- src/app-indicator.h | 16 ++++--- src/application-service-appstore.c | 70 ++++++++++++++---------------- src/application-service-appstore.h | 2 +- src/application-service.xml | 4 +- src/indicator-application.c | 67 ++++++++++++++++------------ src/notification-item.xml | 2 + 9 files changed, 141 insertions(+), 103 deletions(-) diff --git a/bindings/mono/libappindicator-api.metadata b/bindings/mono/libappindicator-api.metadata index 8f9df53..718c500 100644 --- a/bindings/mono/libappindicator-api.metadata +++ b/bindings/mono/libappindicator-api.metadata @@ -9,6 +9,8 @@ connection-changed NewIcon new-icon + NewIconThemePath + new-icon-theme-path ID true true @@ -26,16 +28,18 @@ id icon-name category - icon-theme-path + icon-theme-path + + diff --git a/bindings/python/appindicator.defs b/bindings/python/appindicator.defs index b4740ce..b6c7402 100644 --- a/bindings/python/appindicator.defs +++ b/bindings/python/appindicator.defs @@ -49,7 +49,7 @@ '("const-gchar*" "id") '("const-gchar*" "icon_name") '("AppIndicatorCategory" "category") - '("const-gchar*" "icon_path" (null-ok) (default "NULL")) + '("const-gchar*" "icon_theme_path" (null-ok) (default "NULL")) ) ) @@ -89,12 +89,12 @@ ) ) -(define-method set_icon_path +(define-method set_icon_theme_path (of-object "AppIndicator") - (c-name "app_indicator_set_icon_path") + (c-name "app_indicator_set_icon_theme_path") (return-type "none") (parameters - '("const-gchar*" "icon_path") + '("const-gchar*" "icon_theme_path" (null-ok)) ) ) @@ -122,6 +122,12 @@ (return-type "const-gchar*") ) +(define-method get_icon_theme_path + (of-object "AppIndicator") + (c-name "app_indicator_get_icon_theme_path") + (return-type "const-gchar*") +) + (define-method get_attention_icon (of-object "AppIndicator") (c-name "app_indicator_get_attention_icon") diff --git a/src/app-indicator.c b/src/app-indicator.c index 137c4c4..91b0ecd 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,7 +88,7 @@ enum { NEW_ATTENTION_ICON, NEW_STATUS, CONNECTION_CHANGED, - NEW_PATH, + NEW_ICON_THEME_PATH, LAST_SIGNAL }; @@ -349,16 +349,16 @@ app_indicator_class_init (AppIndicatorClass *klass) G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE); /** - AppIndicator::new-icon: + AppIndicator::new-icon-theme-path: @arg0: The #AppIndicator object Signaled when there is a new icon set for the object. */ - signals[NEW_PATH] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_PATH, + 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_path), + G_STRUCT_OFFSET (AppIndicatorClass, new_icon_theme_path), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE); @@ -381,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; @@ -503,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); @@ -573,7 +573,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu break; case PROP_ICON_THEME_PATH: - app_indicator_set_icon_path (APP_INDICATOR (object), + app_indicator_set_icon_theme_path (APP_INDICATOR (object), g_value_get_string (value)); check_connect (self); break; @@ -618,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: @@ -1040,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. */ @@ -1053,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; @@ -1150,26 +1150,25 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) } /** - app_indicator_set_icon_theme: + app_indicator_set_icon_theme_path: @self: The #AppIndicator object to use - @icon_path: The icon theme path to set. + @icon_theme_path: The icon theme path to set. Sets the path to use when searching for icons. **/ void -app_indicator_set_icon_path (AppIndicator *self, const gchar *icon_path) +app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_path) { g_return_if_fail (IS_APP_INDICATOR (self)); - g_return_if_fail (icon_path != NULL); - if (g_strcmp0 (self->priv->icon_path, icon_path) != 0) + if (g_strcmp0 (self->priv->icon_theme_path, icon_theme_path) != 0) { - if (self->priv->icon_path != NULL) - g_free(self->priv->icon_path); + if (self->priv->icon_theme_path != NULL) + g_free(self->priv->icon_theme_path); - self->priv->icon_path = g_strdup(icon_path); + self->priv->icon_theme_path = g_strdup(icon_theme_path); - g_signal_emit (self, signals[NEW_PATH], 0, TRUE); + g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, TRUE); } return; @@ -1666,6 +1665,22 @@ app_indicator_get_icon (AppIndicator *self) return self->priv->icon_name; } +/** + 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 a5ee4d6..3a17ba1 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -98,15 +98,15 @@ G_BEGIN_DECLS String identifier for the #AppIndicator::connection-changed signal. */ /** - APP_INDICATOR_SIGNAL_NEW_PATH: + APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH: - String identifier for the #AppIndicator::new-path signal. + 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_PATH "new-path" +#define APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH "new-icon-theme-path" /** AppIndicatorCategory: @@ -154,6 +154,7 @@ 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. @@ -177,7 +178,7 @@ struct _AppIndicatorClass { void (* new_status) (AppIndicator *indicator, const gchar *status, gpointer user_data); - void (* new_path) (AppIndicator *indicator, + void (* new_icon_theme_path) (AppIndicator *indicator, gpointer user_data); /* Local Signals */ @@ -224,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, @@ -235,14 +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_path (AppIndicator *self, - const gchar *icon_path); +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 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); diff --git a/src/application-service-appstore.h b/src/application-service-appstore.h index 066dfbc..422b0fd 100644 --- a/src/application-service-appstore.h +++ b/src/application-service-appstore.h @@ -46,7 +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_icon_path_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 9a559d2..dcccfa4 100644 --- a/src/application-service.xml +++ b/src/application-service.xml @@ -44,9 +44,9 @@ with this program. If not, see . - + - + diff --git a/src/indicator-application.c b/src/indicator-application.c index 66913df..1a7467d 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,10 +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_path_changed (DBusGProxy * proxy, gint position, const gchar * iconpath, 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); @@ -282,7 +283,7 @@ connected (IndicatorApplication * application) G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal(priv->service_proxy, - "ApplicationIconPathChanged", + "ApplicationIconThemePathChanged", G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); @@ -305,8 +306,8 @@ connected (IndicatorApplication * application) application, NULL /* Disconnection Signal */); dbus_g_proxy_connect_signal(priv->service_proxy, - "ApplicationIconPathChanged", - G_CALLBACK(application_icon_path_changed), + "ApplicationIconThemePathChanged", + G_CALLBACK(application_icon_theme_path_changed), application, NULL /* Disconnection Signal */); } @@ -424,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); @@ -446,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. */ @@ -500,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); @@ -510,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)); } @@ -544,14 +549,16 @@ 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 path for an application +/* The callback for the signal that the icon theme path for an application has changed. */ static void -application_icon_path_changed (DBusGProxy * proxy, gint position, const gchar * iconpath, IndicatorApplication * application) +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); @@ -561,11 +568,17 @@ application_icon_path_changed (DBusGProxy * proxy, gint position, const gchar * return; } - g_free(app->icon_path); - app->icon_path = NULL; - if (iconpath != NULL && iconpath[0] != '\0') { - app->icon_path = g_strdup(iconpath); - theme_dir_ref(application, iconpath); + if (icon_theme_path[0] != '\0' && 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 ) { + 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; @@ -598,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) { @@ -663,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..b25eb74 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -19,6 +19,8 @@ + + -- 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(-) 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 0a8c09e4f8ce284788845f465dcc826a67602cd0 Mon Sep 17 00:00:00 2001 From: Sense Hofstede Date: Thu, 22 Jul 2010 17:36:12 +0200 Subject: Fixed two G_PARAM_SPECS and made it even more possible to remove the custom icon theme path. --- src/app-indicator.c | 4 ++-- src/indicator-application.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 91b0ecd..7b74495 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -230,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: @@ -257,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: diff --git a/src/indicator-application.c b/src/indicator-application.c index 1a7467d..066ea63 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -568,13 +568,13 @@ application_icon_theme_path_changed (DBusGProxy * proxy, gint position, const gc return; } - if (icon_theme_path[0] != '\0' && g_strcmp0(icon_theme_path, app->icon_theme_path) != 0) { + 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 ) { + 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); } -- 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/app-indicator.c | 6 ++-- src/app-indicator.h | 11 ++++---- src/application-service-appstore.c | 57 ++++++++++++-------------------------- src/notification-item.xml | 1 + 4 files changed, 27 insertions(+), 48 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 7b74495..fdfcc23 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -360,8 +360,8 @@ app_indicator_class_init (AppIndicatorClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_icon_theme_path), NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, G_TYPE_NONE); + 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, @@ -1168,7 +1168,7 @@ app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_p self->priv->icon_theme_path = g_strdup(icon_theme_path); - g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, TRUE); + g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, g_strdup(self->priv->icon_theme_path)); } return; diff --git a/src/app-indicator.h b/src/app-indicator.h index 3a17ba1..31b7a4a 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -171,14 +171,15 @@ 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); - void (* new_icon_theme_path) (AppIndicator *indicator, + void (* new_icon_theme_path) (AppIndicator *indicator, + const gchar *icon_theme_path, gpointer user_data); /* Local Signals */ 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, diff --git a/src/notification-item.xml b/src/notification-item.xml index b25eb74..dc755c9 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -20,6 +20,7 @@ + -- cgit v1.2.3