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 456347aada2b1a3466efe6b27bb8ab3541b77f96 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 11:47:45 -0500 Subject: Adding the label property and a signal for it changing. --- src/dbus-properties-client.h | 2 +- src/notification-item.xml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dbus-properties-client.h b/src/dbus-properties-client.h index dc9f299..6f08e78 100644 --- a/src/dbus-properties-client.h +++ b/src/dbus-properties-client.h @@ -39,7 +39,7 @@ org_freedesktop_DBus_Properties_get_async_callback (DBusGProxy *proxy, DBusGProx { DBusGAsyncData *data = (DBusGAsyncData*) user_data; GError *error = NULL; - GValue OUT_Value = {0}; + GValue OUT_Value = { 0, }; dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_VALUE, &OUT_Value, G_TYPE_INVALID); (*(org_freedesktop_DBus_Properties_get_reply)data->cb) (proxy, OUT_Value, error, data->userdata); return; diff --git a/src/notification-item.xml b/src/notification-item.xml index a0141c3..cacc6be 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -12,6 +12,7 @@ to find the icons specified above. --> + @@ -24,6 +25,9 @@ + + + -- cgit v1.2.3 From 9f0e3c6e81e5ee98551c928e846019e46760b6c0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 11:48:27 -0500 Subject: This shouldn't be in Bazaar --- src/dbus-properties-client.h | 139 ------------------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 src/dbus-properties-client.h diff --git a/src/dbus-properties-client.h b/src/dbus-properties-client.h deleted file mode 100644 index 6f08e78..0000000 --- a/src/dbus-properties-client.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Generated by dbus-binding-tool; do not edit! */ - -#include -#include - -G_BEGIN_DECLS - -#ifndef _DBUS_GLIB_ASYNC_DATA_FREE -#define _DBUS_GLIB_ASYNC_DATA_FREE -static -#ifdef G_HAVE_INLINE -inline -#endif -void -_dbus_glib_async_data_free (gpointer stuff) -{ - g_slice_free (DBusGAsyncData, stuff); -} -#endif - -#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Properties -#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Properties - -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -org_freedesktop_DBus_Properties_get (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, GValue* OUT_Value, GError **error) - -{ - return dbus_g_proxy_call (proxy, "Get", error, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_INVALID, G_TYPE_VALUE, OUT_Value, G_TYPE_INVALID); -} - -typedef void (*org_freedesktop_DBus_Properties_get_reply) (DBusGProxy *proxy, GValue OUT_Value, GError *error, gpointer userdata); - -static void -org_freedesktop_DBus_Properties_get_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - GValue OUT_Value = { 0, }; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_VALUE, &OUT_Value, G_TYPE_INVALID); - (*(org_freedesktop_DBus_Properties_get_reply)data->cb) (proxy, OUT_Value, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -org_freedesktop_DBus_Properties_get_async (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, org_freedesktop_DBus_Properties_get_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "Get", org_freedesktop_DBus_Properties_get_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_INVALID); -} -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -org_freedesktop_DBus_Properties_set (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, const GValue* IN_Value, GError **error) - -{ - return dbus_g_proxy_call (proxy, "Set", error, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_VALUE, IN_Value, G_TYPE_INVALID, G_TYPE_INVALID); -} - -typedef void (*org_freedesktop_DBus_Properties_set_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); - -static void -org_freedesktop_DBus_Properties_set_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - (*(org_freedesktop_DBus_Properties_set_reply)data->cb) (proxy, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -org_freedesktop_DBus_Properties_set_async (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, const GValue* IN_Value, org_freedesktop_DBus_Properties_set_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "Set", org_freedesktop_DBus_Properties_set_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_VALUE, IN_Value, G_TYPE_INVALID); -} -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -org_freedesktop_DBus_Properties_get_all (DBusGProxy *proxy, const char * IN_Interface_Name, GHashTable** OUT_Properties, GError **error) - -{ - return dbus_g_proxy_call (proxy, "GetAll", error, G_TYPE_STRING, IN_Interface_Name, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), OUT_Properties, G_TYPE_INVALID); -} - -typedef void (*org_freedesktop_DBus_Properties_get_all_reply) (DBusGProxy *proxy, GHashTable *OUT_Properties, GError *error, gpointer userdata); - -static void -org_freedesktop_DBus_Properties_get_all_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - GHashTable* OUT_Properties; - dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &OUT_Properties, G_TYPE_INVALID); - (*(org_freedesktop_DBus_Properties_get_all_reply)data->cb) (proxy, OUT_Properties, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -org_freedesktop_DBus_Properties_get_all_async (DBusGProxy *proxy, const char * IN_Interface_Name, org_freedesktop_DBus_Properties_get_all_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "GetAll", org_freedesktop_DBus_Properties_get_all_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_Interface_Name, G_TYPE_INVALID); -} -#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Properties */ - -G_END_DECLS -- cgit v1.2.3 From 6de3d6fb8e8551a3a5d39207d1dbaba519325d7a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 13:15:49 -0500 Subject: These have needed to be ignored for a while. --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index cbf5964..94155ae 100644 --- a/.bzrignore +++ b/.bzrignore @@ -111,3 +111,5 @@ src/notification-approver-client.h src/notification-approver-server.h tests/test-approver tests/test-approver-tester +bindings/mono/policy.0.0.appindicator-sharp.config +bindings/mono/policy.0.0.appindicator-sharp.dll -- cgit v1.2.3 From 89a5ffef0d244b250c6cd1a809db68d64bf577ee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 14:10:45 -0500 Subject: Adding a property to guide the size of the label --- src/notification-item.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notification-item.xml b/src/notification-item.xml index cacc6be..b339e7b 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -13,6 +13,7 @@ + @@ -27,6 +28,7 @@ + -- cgit v1.2.3 From 44e84ede3da7d4a7e45c8c5b674a21703811e15c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 14:37:01 -0500 Subject: Setting up the label and lable guide properties. --- src/app-indicator.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 32f512f..98e90ae 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -104,7 +104,9 @@ enum { PROP_ATTENTION_ICON_NAME, PROP_ICON_THEME_PATH, PROP_MENU, - PROP_CONNECTED + PROP_CONNECTED, + PROP_LABEL, + PROP_LABEL_GUIDE }; /* The strings so that they can be slowly looked up. */ @@ -116,6 +118,8 @@ enum { #define PROP_ICON_THEME_PATH_S "icon-theme-path" #define PROP_MENU_S "menu" #define PROP_CONNECTED_S "connected" +#define PROP_LABEL_S "label" +#define PROP_LABEL_GUIDE_S "label-guide" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -284,6 +288,41 @@ app_indicator_class_init (AppIndicatorClass *klass) "Pretty simple, true if we have a reasonable expectation of being displayed through this object. You should hide your TrayIcon if so.", FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:label: + + A label that can be shown next to the string in the application + indicator. The label will not be shown unless there is an icon + as well. The label is useful for numerical and other frequently + updated information. In general, it shouldn't be shown unless a + user requests it as it can take up a significant amount of space + on the user's panel. This may not be shown in all visualizations. + */ + g_object_class_install_property(object_class, + PROP_LABEL, + g_param_spec_string (PROP_LABEL_S, + "A label next to the icon", + "A label to provide dynamic information.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:label-guide: + + An optional string to provide guidance to the panel on how big + the #AppIndicator:label string could get. If this is set correctly + then the panel should never 'jiggle' as the string adjusts through + out the range of options. For instance, if you were providing a + percentage like "54% thrust" in #AppIndicator:label you'd want to + set this string to "100% thrust" to ensure space when Scotty can + get you enough power. + */ + g_object_class_install_property(object_class, + PROP_LABEL_GUIDE, + g_param_spec_string (PROP_LABEL_GUIDE_S, + "A string to size the space available for the label.", + "To ensure that the label does not cause the panel to 'jiggle' this string should provide information on how much space it could take.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ -- cgit v1.2.3 From e541156e92220917a58ff8abce1cfa235dc343f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 14:47:42 -0500 Subject: Adding the label and guide fields to the private struct and tying that into the properties. --- src/app-indicator.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 98e90ae..29149ae 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -72,6 +72,8 @@ struct _AppIndicatorPrivate { gchar * icon_path; DbusmenuServer *menuservice; GtkWidget *menu; + gchar * label; + gchar * label_guide; GtkStatusIcon * status_icon; gint fallback_timer; @@ -407,6 +409,8 @@ app_indicator_init (AppIndicator *self) priv->icon_path = NULL; priv->menu = NULL; priv->menuservice = NULL; + priv->label = NULL; + priv->label_guide = NULL; priv->watcher_proxy = NULL; priv->connection = NULL; @@ -530,6 +534,16 @@ app_indicator_finalize (GObject *object) g_free(priv->icon_path); priv->icon_path = NULL; } + + if (priv->label != NULL) { + g_free(priv->label); + priv->label = NULL; + } + + if (priv->label_guide != NULL) { + g_free(priv->label_guide); + priv->label_guide = NULL; + } G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); return; @@ -602,6 +616,33 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->icon_path = g_value_dup_string(value); break; + case PROP_LABEL: { + gchar * oldlabel = priv->label; + priv->label = g_value_dup_string(value); + + if (g_strcmp0(oldlabel, priv->label) != 0) { + // TODO: signal change + } + + if (oldlabel != NULL) { + g_free(oldlabel); + } + break; + } + case PROP_LABEL_GUIDE: { + gchar * oldguide = priv->label_guide; + priv->label_guide = g_value_dup_string(value); + + if (g_strcmp0(oldguide, priv->label_guide) != 0) { + // TODO: signal change + } + + if (oldguide != NULL) { + g_free(oldguide); + } + break; + } + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -659,6 +700,14 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE); break; + case PROP_LABEL: + g_value_set_string (value, priv->label); + break; + + case PROP_LABEL_GUIDE: + g_value_set_string (value, priv->label_guide); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; -- cgit v1.2.3 From 706a72b9b2a36c39ce274a2508031b4cc0f4bb2e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 15:12:23 -0500 Subject: Adding in the convience wrappers --- src/app-indicator.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/app-indicator.h | 5 +++++ 2 files changed, 63 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 29149ae..ce79165 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1222,6 +1222,31 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) return; } +/** + app_indicator_set_label: + @self: The #AppIndicator object to use + @label: The label to show next to the icon. + @guide: A guide to size the label correctly. + + This is a wrapper function for the #AppIndicator:label and + #AppIndicator:guide properties. This function can take #NULL + as either @label or @guide and will clear the entries. +*/ +void +app_indicator_set_label (AppIndicator *self, const gchar * label, const gchar * guide) +{ + g_return_if_fail (IS_APP_INDICATOR (self)); + /* Note: The label can be NULL, it's okay */ + /* Note: The guide can be NULL, it's okay */ + + g_object_set(G_OBJECT(self), + PROP_LABEL_S, label == NULL ? "" : label, + PROP_LABEL_GUIDE_S, guide == NULL ? "" : guide, + NULL); + + return; +} + static void activate_menuitem (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) { @@ -1749,3 +1774,36 @@ app_indicator_get_menu (AppIndicator *self) return GTK_MENU(priv->menu); } + +/** + app_indicator_get_label: + @self: The #AppIndicator object to use + + Wrapper function for property #AppIndicator:label. + + Return value: The current label. +*/ +const gchar * +app_indicator_get_label (AppIndicator *self) +{ + g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); + + return self->priv->label; +} + +/** + app_indicator_get_label_guide: + @self: The #AppIndicator object to use + + Wrapper function for property #AppIndicator:label-guide. + + Return value: The current label guide. +*/ +const gchar * +app_indicator_get_label_guide (AppIndicator *self) +{ + g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); + + return self->priv->label_guide; +} + diff --git a/src/app-indicator.h b/src/app-indicator.h index e37abd4..767cf72 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -226,6 +226,9 @@ void app_indicator_set_menu (AppIndicator GtkMenu *menu); void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name); +void app_indicator_set_label (AppIndicator *self, + const gchar *label, + const gchar *guide); /* Get properties */ const gchar * app_indicator_get_id (AppIndicator *self); @@ -234,6 +237,8 @@ AppIndicatorStatus app_indicator_get_status (AppIndicator * const gchar * app_indicator_get_icon (AppIndicator *self); const gchar * app_indicator_get_attention_icon (AppIndicator *self); GtkMenu * app_indicator_get_menu (AppIndicator *self); +const gchar * app_indicator_get_label (AppIndicator *self); +const gchar * app_indicator_get_label_guide (AppIndicator *self); G_END_DECLS -- cgit v1.2.3 From e0f472f173a2bb2931f7ddbb1c5bd3d25af5f462 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 15:40:50 -0500 Subject: Adding the label funcs to the documentation. --- docs/reference/libappindicator-sections.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/reference/libappindicator-sections.txt b/docs/reference/libappindicator-sections.txt index 70df0b8..115e0d3 100644 --- a/docs/reference/libappindicator-sections.txt +++ b/docs/reference/libappindicator-sections.txt @@ -23,11 +23,14 @@ app_indicator_set_status app_indicator_set_attention_icon app_indicator_set_menu app_indicator_set_icon +app_indicator_set_label app_indicator_get_id app_indicator_get_category app_indicator_get_status app_indicator_get_icon app_indicator_get_attention_icon app_indicator_get_menu +app_indicator_get_label +app_indicator_get_label_guide -- cgit v1.2.3 From fc9d5d4f762493d0b8378b12ac6c8451e5b9683b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 15:55:21 -0500 Subject: Adding in a signal to tell when the label is updated. --- src/app-indicator.c | 18 ++++++++++++++++++ src/app-indicator.h | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index ce79165..ec153c6 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -89,6 +89,7 @@ enum { NEW_ICON, NEW_ATTENTION_ICON, NEW_STATUS, + NEW_LABEL, CONNECTION_CHANGED, LAST_SIGNAL }; @@ -373,6 +374,23 @@ app_indicator_class_init (AppIndicatorClass *klass) G_TYPE_NONE, 1, G_TYPE_STRING); + /** + AppIndicator::new-label: + @arg0: The #AppIndicator object + @arg1: The string for the label + @arg1: The string for the guide + + Emitted when either #AppIndicator:label or #AppIndicator:label-guide are + changed. + */ + signals[NEW_LABEL] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_LABEL, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppIndicatorClass, new_label), + NULL, NULL, + g_cclosure_marshal_VOID__STRING_STRING, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + /** AppIndicator::connection-changed: @arg0: The #AppIndicator object diff --git a/src/app-indicator.h b/src/app-indicator.h index 767cf72..586d2dc 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -91,6 +91,11 @@ G_BEGIN_DECLS String identifier for the #AppIndicator::new-status signal. */ +/** + APP_INDICATOR_SIGNAL_NEW_LABEL: + + String identifier for the #AppIndicator::new-label signal. +*/ /** APP_INDICATOR_SIGNAL_CONNECTION_CHANGED: @@ -99,6 +104,7 @@ G_BEGIN_DECLS #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_NEW_LABEL "new-label" #define APP_INDICATOR_SIGNAL_CONNECTION_CHANGED "connection-changed" /** @@ -152,8 +158,8 @@ typedef struct _AppIndicatorPrivate AppIndicatorPrivate; 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. + @new_label: Slot for #AppIndicator::new-label. @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 class object. @@ -181,9 +187,14 @@ struct _AppIndicatorClass { void (*unfallback) (AppIndicator * indicator, GtkStatusIcon * status_icon); + /* Another DBus Signal */ + void (* new_label) (AppIndicator *indicator, + const gchar *label, + const gchar *guide, + gpointer user_data); + /* Reserved */ void (*app_indicator_reserved_1)(void); - void (*app_indicator_reserved_2)(void); }; /** -- cgit v1.2.3 From 84821ece8828fc87a45b9ba2ca75ef0a15d797ce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 16:18:42 -0500 Subject: Reusing the application service marshallers, not beautiful, but it works for now. --- src/Makefile.am | 3 ++- src/app-indicator.c | 3 ++- src/application-service-marshal.list | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 68be1c0..b704b5e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -94,7 +94,8 @@ BUILT_SOURCES += \ libappindicator_la_SOURCES = \ $(libappindicator_headers) \ app-indicator-enum-types.c \ - app-indicator.c + app-indicator.c \ + application-service-marshal.c libappindicator_la_LDFLAGS = \ -version-info 0:0:0 \ diff --git a/src/app-indicator.c b/src/app-indicator.c index ec153c6..e0ccec4 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -37,6 +37,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "app-indicator.h" #include "app-indicator-enum-types.h" +#include "application-service-marshal.h" #include "notification-item-server.h" #include "notification-watcher-client.h" @@ -388,7 +389,7 @@ app_indicator_class_init (AppIndicatorClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_label), NULL, NULL, - g_cclosure_marshal_VOID__STRING_STRING, + _application_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); /** diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index 4ac8398..b49ff41 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -18,3 +18,4 @@ # with this program. If not, see . VOID: STRING, INT, STRING, STRING, STRING VOID: INT, STRING +VOID: STRING, STRING -- cgit v1.2.3 From 0422fcb1fd43d6ad34e5b763747aa6c0e904e321 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 16:23:35 -0500 Subject: Putting the new define into the docs --- docs/reference/libappindicator-sections.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/libappindicator-sections.txt b/docs/reference/libappindicator-sections.txt index 115e0d3..49a470d 100644 --- a/docs/reference/libappindicator-sections.txt +++ b/docs/reference/libappindicator-sections.txt @@ -9,6 +9,7 @@ APP_INDICATOR_GET_CLASS APP_INDICATOR_SIGNAL_NEW_ICON APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON APP_INDICATOR_SIGNAL_NEW_STATUS +APP_INDICATOR_SIGNAL_NEW_LABEL APP_INDICATOR_SIGNAL_CONNECTION_CHANGED AppIndicatorCategory AppIndicatorStatus -- cgit v1.2.3 From 52bfc9d4ba3d38ab07004b6fdb04173912329cf8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 16:45:18 -0500 Subject: Signaling when the labels change in the idle loop --- src/app-indicator.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index e0ccec4..0da0b01 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -75,6 +75,7 @@ struct _AppIndicatorPrivate { GtkWidget *menu; gchar * label; gchar * label_guide; + guint label_change_idle; GtkStatusIcon * status_icon; gint fallback_timer; @@ -144,6 +145,7 @@ static void app_indicator_finalize (GObject *object); static void app_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); /* Other stuff */ +static void signal_label_change (AppIndicator * self); static void check_connect (AppIndicator * self); static void register_service_cb (DBusGProxy * proxy, GError * error, gpointer data); static void start_fallback_timer (AppIndicator * self, gboolean disable_timeout); @@ -430,6 +432,7 @@ app_indicator_init (AppIndicator *self) priv->menuservice = NULL; priv->label = NULL; priv->label_guide = NULL; + priv->label_change_idle = 0; priv->watcher_proxy = NULL; priv->connection = NULL; @@ -481,6 +484,11 @@ app_indicator_dispose (GObject *object) priv->fallback_timer = 0; } + if (priv->label_change_idle != 0) { + g_source_remove(priv->label_change_idle); + priv->label_change_idle = 0; + } + if (priv->menu != NULL) { g_signal_handlers_disconnect_by_func (G_OBJECT (priv->menu), client_menu_changed, @@ -640,7 +648,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->label = g_value_dup_string(value); if (g_strcmp0(oldlabel, priv->label) != 0) { - // TODO: signal change + signal_label_change(APP_INDICATOR(object)); } if (oldlabel != NULL) { @@ -653,7 +661,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->label_guide = g_value_dup_string(value); if (g_strcmp0(oldguide, priv->label_guide) != 0) { - // TODO: signal change + signal_label_change(APP_INDICATOR(object)); } if (oldguide != NULL) { @@ -735,6 +743,39 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa return; } +/* Sends the label changed signal and resets the source ID */ +static gboolean +signal_label_change_idle (gpointer user_data) +{ + AppIndicator * self = (AppIndicator *)user_data; + AppIndicatorPrivate *priv = self->priv; + + g_signal_emit(G_OBJECT(self), signals[NEW_LABEL], 0, + priv->label != NULL ? priv->label : "", + priv->label_guide != NULL ? priv->label_guide : "", + TRUE); + + priv->label_change_idle = 0; + + return FALSE; +} + +/* Sets up an idle function to send the label changed signal + so that we don't send it too many times. */ +static void +signal_label_change (AppIndicator * self) +{ + AppIndicatorPrivate *priv = self->priv; + + /* don't set it twice */ + if (priv->label_change_idle != 0) { + return; + } + + priv->label_change_idle = g_idle_add(signal_label_change_idle, self); + return; +} + /* This function is used to see if we have enough information to connect to things. If we do, and we're not connected, it connects for us. */ -- cgit v1.2.3 From a2e95f155e746d390a8e6b5253d527a655df96a2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 17:07:29 -0500 Subject: Adding a test to set the label and guides a bunch. --- tests/test-libappindicator.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 86879b3..6d06236 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -162,6 +162,68 @@ test_libappindicator_init (void) return; } +void +test_libappindicator_set_label (void) +{ + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + /* First check all the clearing modes, this is important as + we're going to use them later, we need them to work. */ + app_indicator_set_label(ci, NULL, NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "", NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, NULL, ""); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "", ""); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "label", ""); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, NULL, NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "label", "guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + + app_indicator_set_label(ci, "label2", "guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label2")); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + + app_indicator_set_label(ci, "trick-label", "trick-guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label")); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide")); + + g_object_unref(G_OBJECT(ci)); + return; +} + void test_libappindicator_props_suite (void) { @@ -169,6 +231,7 @@ test_libappindicator_props_suite (void) g_test_add_func ("/indicator-application/libappindicator/init_props", test_libappindicator_init_with_props); g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props); g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals); + g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); return; } -- cgit v1.2.3 From f72116833d67c954ec69dfe8aced4e7e26c36c23 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 17:09:57 -0500 Subject: Turning null strings into NULLs --- src/app-indicator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 0da0b01..b3fa3e5 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -651,6 +651,11 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu signal_label_change(APP_INDICATOR(object)); } + if (priv->label != NULL && priv->label[0] == '\0') { + g_free(priv->label); + priv->label = NULL; + } + if (oldlabel != NULL) { g_free(oldlabel); } @@ -664,6 +669,11 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu signal_label_change(APP_INDICATOR(object)); } + if (priv->label_guide != NULL && priv->label_guide[0] == '\0') { + g_free(priv->label_guide); + priv->label_guide = NULL; + } + if (oldguide != NULL) { g_free(oldguide); } -- cgit v1.2.3 From 29253842cb7715e7f3d3ca94bf4082edb824bb9c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 17:14:32 -0500 Subject: Stupid reverse logic in the string comparison. --- tests/test-libappindicator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 6d06236..2ac7326 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -197,7 +197,7 @@ test_libappindicator_set_label (void) app_indicator_set_label(ci, "label", ""); - g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, NULL, NULL); @@ -207,18 +207,18 @@ test_libappindicator_set_label (void) app_indicator_set_label(ci, "label", "guide"); - g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); - g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); app_indicator_set_label(ci, "label2", "guide"); - g_assert(g_strcmp0(app_indicator_get_label(ci), "label2")); - g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "label2") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); app_indicator_set_label(ci, "trick-label", "trick-guide"); - g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label")); - g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide") == 0); g_object_unref(G_OBJECT(ci)); return; -- cgit v1.2.3 From 6882b4cb557db5bc65f14d6b6e88f8f9667896b2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 21:09:58 -0500 Subject: Setting up a basic signals test --- tests/test-libappindicator.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 2ac7326..e6c8dcc 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -224,6 +224,47 @@ test_libappindicator_set_label (void) return; } +void +label_signals_cb (AppIndicator * appindicator, gchar * label, gchar * guide, gpointer user_data) +{ + gint * label_signals_count = (gint *)user_data; + (*label_signals_count)++; + return; +} + +void +label_signals_check (void) +{ + while (g_main_context_pending(NULL)) { + g_main_context_iteration(NULL, TRUE); + } + + return; +} + +void +test_libappindicator_label_signals (void) +{ + gint label_signals_count = 0; + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + g_signal_connect(G_OBJECT(ci), APP_INDICATOR_SIGNAL_NEW_LABEL, G_CALLBACK(label_signals_cb), &label_signals_count); + + app_indicator_set_label(ci, "label", "guide"); + g_assert(label_signals_count == 0); + + label_signals_check(); + g_assert(label_signals_count == 1); + + return; +} + void test_libappindicator_props_suite (void) { @@ -232,6 +273,7 @@ test_libappindicator_props_suite (void) g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props); g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals); g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); + g_test_add_func ("/indicator-application/libappindicator/label_signals", test_libappindicator_label_signals); return; } -- cgit v1.2.3 From 43e185e0c4828a5eaa0422186198d08edefd12a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 21:13:34 -0500 Subject: More signalling tests. --- tests/test-libappindicator.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index e6c8dcc..8d12ac5 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -256,9 +256,37 @@ test_libappindicator_label_signals (void) g_signal_connect(G_OBJECT(ci), APP_INDICATOR_SIGNAL_NEW_LABEL, G_CALLBACK(label_signals_cb), &label_signals_count); + /* Shouldn't be a signal as it should be stuck in idle */ app_indicator_set_label(ci, "label", "guide"); g_assert(label_signals_count == 0); + /* Should show up after idle processing */ + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Shouldn't signal with no change */ + label_signals_count = 0; + app_indicator_set_label(ci, "label", "guide"); + label_signals_check(); + g_assert(label_signals_count == 0); + + /* Change one, we should get one signal */ + app_indicator_set_label(ci, "label2", "guide"); + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Change several times, one signal */ + label_signals_count = 0; + app_indicator_set_label(ci, "label1", "guide0"); + app_indicator_set_label(ci, "label1", "guide1"); + app_indicator_set_label(ci, "label2", "guide2"); + app_indicator_set_label(ci, "label3", "guide3"); + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Clear should signal too */ + label_signals_count = 0; + app_indicator_set_label(ci, NULL, NULL); label_signals_check(); g_assert(label_signals_count == 1); -- cgit v1.2.3 From 4189a76c67f80a8c6a8e80142e7cfeffab1039e9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 11:55:52 -0500 Subject: Adding defines for the new properties and signal. --- src/application-service-appstore.c | 3 +++ 1 file changed, 3 insertions(+) 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 f2b808303f336aad4ee2663efb80a096dd61dcbd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 14:50:13 -0500 Subject: Setting the label in the simple client --- example/simple-client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/example/simple-client.c b/example/simple-client.c index fbcaaaa..d756988 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -97,6 +97,18 @@ append_submenu (GtkWidget *item) gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu); } +guint percentage = 0; + +static gboolean +percent_change (gpointer user_data) +{ + percentage = (percentage + 1) % 100; + gchar * percentstr = g_strdup_printf("%d%%", percentage); + app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); + g_free(percentstr); + return TRUE; +} + int main (int argc, char ** argv) { @@ -114,6 +126,9 @@ main (int argc, char ** argv) app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon(ci, "indicator-messages-new"); + app_indicator_set_label (ci, "1%", "100%"); + + g_timeout_add_seconds(1, percent_change, ci); menu = gtk_menu_new (); GtkWidget *item = gtk_check_menu_item_new_with_label ("1"); -- 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 1f04ea2f899a2922e9c625fd629463c4dd16aff5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 20:19:29 -0500 Subject: Make sure we get to 100 --- example/simple-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/simple-client.c b/example/simple-client.c index d756988..20cb281 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -103,7 +103,7 @@ static gboolean percent_change (gpointer user_data) { percentage = (percentage + 1) % 100; - gchar * percentstr = g_strdup_printf("%d%%", percentage); + gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); g_free(percentstr); return TRUE; -- 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 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 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 23e9b56c533e25febfa8c83c353492403cb1b4d5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 14:45:50 -0500 Subject: Adding the ability to toggle the label on and off --- example/simple-client.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/example/simple-client.c b/example/simple-client.c index 20cb281..f2fac6f 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -26,6 +26,21 @@ with this program. If not, see . GMainLoop * mainloop = NULL; static gboolean active = TRUE; +static gboolean can_haz_label = TRUE; + +static void +label_toggle_cb (GtkWidget * widget, gpointer data) +{ + can_haz_label = !can_haz_label; + + if (can_haz_label) { + gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Hide label"); + } else { + gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Show label"); + } + + return; +} static void activate_clicked_cb (GtkWidget *widget, gpointer data) @@ -103,9 +118,13 @@ static gboolean percent_change (gpointer user_data) { percentage = (percentage + 1) % 100; - gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); - app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); - g_free(percentstr); + if (can_haz_label) { + gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); + app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); + g_free(percentstr); + } else { + app_indicator_set_label (APP_INDICATOR(user_data), NULL, NULL); + } return TRUE; } @@ -166,6 +185,13 @@ main (int argc, char ** argv) gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); + item = gtk_menu_item_new_with_label ("Show label"); + label_toggle_cb(item, ci); + g_signal_connect (item, "activate", + G_CALLBACK (label_toggle_cb), ci); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show(item); + app_indicator_set_menu (ci, GTK_MENU (menu)); mainloop = g_main_loop_new(NULL, FALSE); -- 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 From d377c945f1dcc36710313fdfa7e79b725fa8d42e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 16:43:15 -0500 Subject: Fixing merge --- src/app-indicator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 3bfdf2f..22b9c03 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1339,6 +1339,7 @@ app_indicator_set_label (AppIndicator *self, const gchar * label, const gchar * 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)); -- cgit v1.2.3 From 18628e90b2a60b905569e62257f2b75a8bcb9335 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 17:09:56 -0500 Subject: Incrementing the major version number --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index b704b5e..0e84749 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,7 +98,7 @@ libappindicator_la_SOURCES = \ application-service-marshal.c libappindicator_la_LDFLAGS = \ - -version-info 0:0:0 \ + -version-info 1:0:0 \ -no-undefined \ -export-symbols-regex "^[^_d].*" -- cgit v1.2.3 From 89186858938bec991dfcbe931764b291edd24917 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 17:14:38 -0500 Subject: Changing the size of the class structure, the reason for the break. --- src/app-indicator.h | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/app-indicator.h b/src/app-indicator.h index 8320a2f..a9e1c38 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -161,12 +161,20 @@ typedef struct _AppIndicatorPrivate AppIndicatorPrivate; @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 + @new_label: Slot for #AppIndicator::new-label. @connection_changed: Slot for #AppIndicator::connection-changed. + @app_indicator_reserved_sw: Reserved for future use. + @app_indicator_reserved_ats: Reserved for future use. @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. - @new_label: Slot for #AppIndicator::new-label. + @app_indicator_reserved_1: Reserved for future use. + @app_indicator_reserved_2: Reserved for future use. + @app_indicator_reserved_3: Reserved for future use. + @app_indicator_reserved_4: Reserved for future use. + @app_indicator_reserved_5: Reserved for future use. + @app_indicator_reserved_6: Reserved for future use. The signals and external functions that make up the #AppIndicator class object. @@ -183,27 +191,33 @@ struct _AppIndicatorClass { void (* new_status) (AppIndicator *indicator, const gchar *status, gpointer user_data); + void (* new_icon_theme_path) (AppIndicator *indicator, + const gchar *icon_theme_path, + gpointer user_data); + void (* new_label) (AppIndicator *indicator, + const gchar *label, + const gchar *guide, + gpointer user_data); /* Local Signals */ void (* connection_changed) (AppIndicator * indicator, gboolean connected, gpointer user_data); + void (*app_indicator_reserved_sw)(void); + void (*app_indicator_reserved_ats)(void); /* Overridable Functions */ GtkStatusIcon * (*fallback) (AppIndicator * indicator); void (*unfallback) (AppIndicator * indicator, GtkStatusIcon * status_icon); - /* Another DBus Signal */ - void (* new_label) (AppIndicator *indicator, - const gchar *label, - const gchar *guide, - gpointer user_data); - 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); + void (*app_indicator_reserved_3)(void); + void (*app_indicator_reserved_4)(void); + void (*app_indicator_reserved_5)(void); + void (*app_indicator_reserved_6)(void); }; /** -- cgit v1.2.3 From c43dd8fd4891bfed0e1588878f0e1aa1303c1625 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 9 Aug 2010 11:32:59 -0500 Subject: Adding the Ordering Index property --- src/notification-item.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notification-item.xml b/src/notification-item.xml index 01261b5..ffd59d1 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -14,6 +14,7 @@ + -- cgit v1.2.3 From fe604c42ebf644bd808ba5ca728455a87d51bbad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 11:28:19 -0500 Subject: Adding the ordering id property. --- src/app-indicator.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 22b9c03..0b9b10e 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -112,7 +112,8 @@ enum { PROP_MENU, PROP_CONNECTED, PROP_LABEL, - PROP_LABEL_GUIDE + PROP_LABEL_GUIDE, + PROP_ORDERING_ID }; /* The strings so that they can be slowly looked up. */ @@ -126,6 +127,7 @@ enum { #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" +#define PROP_ORDERING_ID_S "ordering-id" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -330,6 +332,25 @@ app_indicator_class_init (AppIndicatorClass *klass) "To ensure that the label does not cause the panel to 'jiggle' this string should provide information on how much space it could take.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:ordering-id: + + The ordering ID is an odd parameter, and if you think you don't need + it you're probably right. In general, the application indicator try + to place the applications in a recreatable place taking into account + which category they're in to try and group them. But, there are some + cases where you'd want to ensure indicators are next to each other. + To do that you can override the generated ordering ID and replace it + with a new one. Again, you probably don't want to be doing this, but + in case you do, this is the way. + */ + g_object_class_install_property(object_class, + PROP_ORDERING_ID, + g_param_spec_uint (PROP_ORDERING_ID_S, + "The location that this app indicator should be in the list.", + "A way to override the default ordering of the applications by providing a very specific idea of where this entry should be placed.", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ -- cgit v1.2.3 From bd2b24fbcaf89d827610f5371a0c13c3db1ae38b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 11:41:48 -0500 Subject: Writing a small little function to generate the ID. --- src/generate-id.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/generate-id.h | 29 ++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/generate-id.c create mode 100644 src/generate-id.h diff --git a/src/generate-id.c b/src/generate-id.c new file mode 100644 index 0000000..95a4bee --- /dev/null +++ b/src/generate-id.c @@ -0,0 +1,58 @@ +/* +Quick litte lack to generate the ordering ID. + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +struct ordering_id_struct { + gchar category; + gchar first; + gchar second; + gchar third; +}; + +union ordering_id_union_t { + guint32 id; + struct ordering_id_struct str; +}; + +guint32 +generate_id (const gchar category, const gchar * id) +{ + union ordering_id_union_t u; + + u.str.category = category; + + u.str.first = 0; + u.str.second = 0; + u.str.third = 0; + + if (id != NULL) { + if (id[0] != '\0') { + u.str.first = id[0]; + if (id[1] != '\0') { + u.str.second = id[1]; + if (id[2] != '\0') { + u.str.third = id[2]; + } + } + } + } + + return u.id; +} diff --git a/src/generate-id.h b/src/generate-id.h new file mode 100644 index 0000000..3713158 --- /dev/null +++ b/src/generate-id.h @@ -0,0 +1,29 @@ +/* +Quick litte lack to generate the ordering ID. + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifndef __GENERATE_ID_H__ +#define __GENERATE_ID_H__ + +#include + +guint32 generate_id (const gchar category, const gchar * id); + +#endif /* __GENERATE_ID_H__ */ -- cgit v1.2.3 From 5bffdaf7141fd7909474daa23ff9107c6f047453 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 11:43:42 -0500 Subject: Brining generate-id into the fold --- .bzrignore | 1 + src/Makefile.am | 2 ++ src/app-indicator.c | 1 + src/generate-id.c | 2 ++ 4 files changed, 6 insertions(+) diff --git a/.bzrignore b/.bzrignore index 94155ae..6183694 100644 --- a/.bzrignore +++ b/.bzrignore @@ -113,3 +113,4 @@ tests/test-approver tests/test-approver-tester bindings/mono/policy.0.0.appindicator-sharp.config bindings/mono/policy.0.0.appindicator-sharp.dll +src/libapplication_la-generate-id.lo diff --git a/src/Makefile.am b/src/Makefile.am index 0e84749..ef23ccc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,8 @@ applicationlib_LTLIBRARIES = libapplication.la libapplication_la_SOURCES = \ application-service-marshal.c \ dbus-shared.h \ + generate-id.h \ + generate-id.c \ indicator-application.c libapplication_la_CFLAGS = $(INDICATOR_CFLAGS) \ -Wall \ diff --git a/src/app-indicator.c b/src/app-indicator.c index 0b9b10e..3ba2cfb 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -43,6 +43,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "notification-watcher-client.h" #include "dbus-shared.h" +#include "generate-id.h" #define PANEL_ICON_SUFFIX "panel" diff --git a/src/generate-id.c b/src/generate-id.c index 95a4bee..6855b39 100644 --- a/src/generate-id.c +++ b/src/generate-id.c @@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "generate-id.h" + struct ordering_id_struct { gchar category; gchar first; -- cgit v1.2.3 From 4a52e90da37a03c2a4b523193861010539632e6e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 11:56:31 -0500 Subject: Uhg, wrong library --- src/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ef23ccc..273a63b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,8 +15,6 @@ applicationlib_LTLIBRARIES = libapplication.la libapplication_la_SOURCES = \ application-service-marshal.c \ dbus-shared.h \ - generate-id.h \ - generate-id.c \ indicator-application.c libapplication_la_CFLAGS = $(INDICATOR_CFLAGS) \ -Wall \ @@ -97,7 +95,9 @@ libappindicator_la_SOURCES = \ $(libappindicator_headers) \ app-indicator-enum-types.c \ app-indicator.c \ - application-service-marshal.c + application-service-marshal.c \ + generate-id.h \ + generate-id.c libappindicator_la_LDFLAGS = \ -version-info 1:0:0 \ -- cgit v1.2.3 From 220d6a305dcfaa0671d7304696f2d8fb1df28431 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 11:56:49 -0500 Subject: Storing the value and allowing the get to use a generated value. --- src/app-indicator.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 3ba2cfb..4395452 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -74,6 +74,7 @@ struct _AppIndicatorPrivate { gchar *icon_theme_path; DbusmenuServer *menuservice; GtkWidget *menu; + guint32 ordering_id; gchar * label; gchar * label_guide; guint label_change_idle; @@ -468,6 +469,7 @@ app_indicator_init (AppIndicator *self) priv->icon_theme_path = NULL; priv->menu = NULL; priv->menuservice = NULL; + priv->ordering_id = 0; priv->label = NULL; priv->label_guide = NULL; priv->label_change_idle = 0; @@ -716,6 +718,9 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } break; } + case PROP_ORDERING_ID: + priv->ordering_id = g_value_get_uint(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -782,6 +787,14 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_string (value, priv->label_guide); break; + case PROP_ORDERING_ID: + if (priv->ordering_id == 0) { + g_value_set_uint(value, generate_id(priv->category, priv->id)); + } else { + g_value_set_uint(value, priv->ordering_id); + } + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; -- cgit v1.2.3 From f04dd0919da6d41443fcea69b4adb83a70fde781 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 13:49:19 -0500 Subject: Providing accessors for the ordering_id property --- src/app-indicator.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/app-indicator.h | 3 +++ 2 files changed, 46 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 4395452..377fda5 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1819,6 +1819,27 @@ app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) self); } +/** + app_indicator_set_ordering_id: + @self: The #AppIndicator + @ordering_id: A value for the ordering of this app indicator + + Sets the ordering ID for the app indicator which effects the + placement of it on the panel. For almost all app indicator + this is not the function you're looking for. + + Wrapper function for property #AppIndicator:ordering-id. +**/ +void +app_indicator_set_ordering_id (AppIndicator *self, guint32 ordering_id) +{ + g_return_if_fail (IS_APP_INDICATOR (self)); + + self->priv->ordering_id = ordering_id; + + return; +} + /** app_indicator_get_id: @self: The #AppIndicator object to use @@ -1968,3 +1989,25 @@ app_indicator_get_label_guide (AppIndicator *self) return self->priv->label_guide; } +/** + app_indicator_get_ordering_id: + @self: The #AppIndicator object to use + + Wrapper function for property #AppIndicator:ordering-id. + + Return value: The current ordering ID. +*/ +guint32 +app_indicator_get_ordering_id (AppIndicator *self) +{ + g_return_val_if_fail (IS_APP_INDICATOR (self), 0); + + guint ordering_id = 0; + + g_object_get(G_OBJECT(self), + PROP_ORDERING_ID_S, &ordering_id, + NULL); + + return ordering_id; +} + diff --git a/src/app-indicator.h b/src/app-indicator.h index a9e1c38..3cc7cc4 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -265,6 +265,8 @@ void app_indicator_set_label (AppIndicator const gchar *guide); void app_indicator_set_icon_theme_path(AppIndicator *self, const gchar *icon_theme_path); +void app_indicator_set_ordering_id (AppIndicator *self, + guint32 ordering_id); /* Get properties */ const gchar * app_indicator_get_id (AppIndicator *self); @@ -276,6 +278,7 @@ const gchar * app_indicator_get_attention_icon (AppIndicator * GtkMenu * app_indicator_get_menu (AppIndicator *self); const gchar * app_indicator_get_label (AppIndicator *self); const gchar * app_indicator_get_label_guide (AppIndicator *self); +guint32 app_indicator_get_ordering_id (AppIndicator *self); G_END_DECLS -- cgit v1.2.3 From 1cac2ea0d1e60053a733a99ebc77b5ef46d52850 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:13:44 -0500 Subject: Adding 'OrderingIndex' and realigning. --- src/application-service-appstore.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index f18a89e..0d9396b 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -38,17 +38,18 @@ static gboolean _application_service_server_get_applications (ApplicationService #include "application-service-server.h" -#define NOTIFICATION_ITEM_PROP_ID "Id" -#define NOTIFICATION_ITEM_PROP_CATEGORY "Category" -#define NOTIFICATION_ITEM_PROP_STATUS "Status" -#define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName" -#define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" -#define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" -#define NOTIFICATION_ITEM_PROP_MENU "Menu" - -#define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" -#define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" -#define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" +#define NOTIFICATION_ITEM_PROP_ID "Id" +#define NOTIFICATION_ITEM_PROP_CATEGORY "Category" +#define NOTIFICATION_ITEM_PROP_STATUS "Status" +#define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName" +#define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" +#define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" +#define NOTIFICATION_ITEM_PROP_MENU "Menu" +#define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "OrderingIndex" + +#define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" +#define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" +#define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" /* Private Stuff */ -- cgit v1.2.3 From 06c01943864dd55759d2f4372237b98d6262f903 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:17:42 -0500 Subject: I like 'index' better than 'id' -- now everything is consistent. --- src/app-indicator.c | 54 ++++++++++++++++++++++++++--------------------------- src/app-indicator.h | 6 +++--- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 377fda5..e4138d4 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -74,7 +74,7 @@ struct _AppIndicatorPrivate { gchar *icon_theme_path; DbusmenuServer *menuservice; GtkWidget *menu; - guint32 ordering_id; + guint32 ordering_index; gchar * label; gchar * label_guide; guint label_change_idle; @@ -115,7 +115,7 @@ enum { PROP_CONNECTED, PROP_LABEL, PROP_LABEL_GUIDE, - PROP_ORDERING_ID + PROP_ORDERING_INDEX }; /* The strings so that they can be slowly looked up. */ @@ -129,7 +129,7 @@ enum { #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" -#define PROP_ORDERING_ID_S "ordering-id" +#define PROP_ORDERING_INDEX_S "ordering-index" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -335,20 +335,20 @@ app_indicator_class_init (AppIndicatorClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** - AppIndicator:ordering-id: + AppIndicator:ordering-index: - The ordering ID is an odd parameter, and if you think you don't need + The ordering index is an odd parameter, and if you think you don't need it you're probably right. In general, the application indicator try to place the applications in a recreatable place taking into account which category they're in to try and group them. But, there are some cases where you'd want to ensure indicators are next to each other. - To do that you can override the generated ordering ID and replace it + To do that you can override the generated ordering index and replace it with a new one. Again, you probably don't want to be doing this, but in case you do, this is the way. */ g_object_class_install_property(object_class, - PROP_ORDERING_ID, - g_param_spec_uint (PROP_ORDERING_ID_S, + PROP_ORDERING_INDEX, + g_param_spec_uint (PROP_ORDERING_INDEX_S, "The location that this app indicator should be in the list.", "A way to override the default ordering of the applications by providing a very specific idea of where this entry should be placed.", 0, G_MAXUINT32, 0, @@ -469,7 +469,7 @@ app_indicator_init (AppIndicator *self) priv->icon_theme_path = NULL; priv->menu = NULL; priv->menuservice = NULL; - priv->ordering_id = 0; + priv->ordering_index = 0; priv->label = NULL; priv->label_guide = NULL; priv->label_change_idle = 0; @@ -718,8 +718,8 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } break; } - case PROP_ORDERING_ID: - priv->ordering_id = g_value_get_uint(value); + case PROP_ORDERING_INDEX: + priv->ordering_index = g_value_get_uint(value); break; default: @@ -787,11 +787,11 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_string (value, priv->label_guide); break; - case PROP_ORDERING_ID: - if (priv->ordering_id == 0) { + case PROP_ORDERING_INDEX: + if (priv->ordering_index == 0) { g_value_set_uint(value, generate_id(priv->category, priv->id)); } else { - g_value_set_uint(value, priv->ordering_id); + g_value_set_uint(value, priv->ordering_index); } break; @@ -1820,22 +1820,22 @@ app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) } /** - app_indicator_set_ordering_id: + app_indicator_set_ordering_index: @self: The #AppIndicator - @ordering_id: A value for the ordering of this app indicator + @ordering_index: A value for the ordering of this app indicator - Sets the ordering ID for the app indicator which effects the + Sets the ordering index for the app indicator which effects the placement of it on the panel. For almost all app indicator this is not the function you're looking for. - Wrapper function for property #AppIndicator:ordering-id. + Wrapper function for property #AppIndicator:ordering-index. **/ void -app_indicator_set_ordering_id (AppIndicator *self, guint32 ordering_id) +app_indicator_set_ordering_index (AppIndicator *self, guint32 ordering_index) { g_return_if_fail (IS_APP_INDICATOR (self)); - self->priv->ordering_id = ordering_id; + self->priv->ordering_index = ordering_index; return; } @@ -1990,24 +1990,24 @@ app_indicator_get_label_guide (AppIndicator *self) } /** - app_indicator_get_ordering_id: + app_indicator_get_ordering_index: @self: The #AppIndicator object to use - Wrapper function for property #AppIndicator:ordering-id. + Wrapper function for property #AppIndicator:ordering-index. - Return value: The current ordering ID. + Return value: The current ordering index. */ guint32 -app_indicator_get_ordering_id (AppIndicator *self) +app_indicator_get_ordering_index (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), 0); - guint ordering_id = 0; + guint ordering_index = 0; g_object_get(G_OBJECT(self), - PROP_ORDERING_ID_S, &ordering_id, + PROP_ORDERING_INDEX_S, &ordering_index, NULL); - return ordering_id; + return ordering_index; } diff --git a/src/app-indicator.h b/src/app-indicator.h index 3cc7cc4..ce152bb 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -265,8 +265,8 @@ void app_indicator_set_label (AppIndicator const gchar *guide); void app_indicator_set_icon_theme_path(AppIndicator *self, const gchar *icon_theme_path); -void app_indicator_set_ordering_id (AppIndicator *self, - guint32 ordering_id); +void app_indicator_set_ordering_index (AppIndicator *self, + guint32 ordering_index); /* Get properties */ const gchar * app_indicator_get_id (AppIndicator *self); @@ -278,7 +278,7 @@ const gchar * app_indicator_get_attention_icon (AppIndicator * GtkMenu * app_indicator_get_menu (AppIndicator *self); const gchar * app_indicator_get_label (AppIndicator *self); const gchar * app_indicator_get_label_guide (AppIndicator *self); -guint32 app_indicator_get_ordering_id (AppIndicator *self); +guint32 app_indicator_get_ordering_index (AppIndicator *self); G_END_DECLS -- cgit v1.2.3 From 09e6c21971ee0c93b72ed8386911875c3f630a1c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:37:44 -0500 Subject: Adding in an ordering index for application structures --- src/application-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0d9396b..cd827d3 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -81,6 +81,7 @@ struct _Application { gchar * menu; gchar * icon_theme_path; gboolean currently_free; + guint ordering_index; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -650,6 +651,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->menu = NULL; app->icon_theme_path = NULL; app->currently_free = FALSE; + app->ordering_index = 0; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From c27a7a980337e5216abe0ba0e77c94cf83d2fe43 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:41:53 -0500 Subject: Setting the ordering ID. --- src/application-service-appstore.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index cd827d3..4ae316c 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -32,6 +32,7 @@ with this program. If not, see . #include "dbus-properties-client.h" #include "dbus-shared.h" #include "notification-approver-client.h" +#include "generate-id.h" /* DBus Prototypes */ static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error); @@ -264,6 +265,13 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->icon_theme_path = g_strdup(""); } + gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); + if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { + app->ordering_index = generate_id(string_to_status(app->category), app->id); + } else { + app->ordering_index = g_value_get_uint(ordering_index_data); + } + /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ g_list_foreach(priv->approvers, check_with_old_approver, app); -- cgit v1.2.3 From 961575a255bf88e7befcc17fed6bcf6c87337e88 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:43:41 -0500 Subject: Pulling in the generate ID function as well --- src/Makefile.am | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 273a63b..620527c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,11 +50,15 @@ indicator_application_service_SOURCES = \ application-service-watcher.h \ application-service-watcher.c \ app-indicator-enum-types.c \ - dbus-shared.h + dbus-shared.h \ + generate-id.h \ + generate-id.c + indicator_application_service_CFLAGS = \ $(INDICATOR_CFLAGS) \ -Wall -Werror \ -DG_LOG_DOMAIN=\"indicator-application-service\" + indicator_application_service_LDADD = \ $(INDICATOR_LIBS) \ libappindicator.la -- cgit v1.2.3 From bf3f4c6eb3affcf8e66b67ed61666c93a97ca47b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:47:23 -0500 Subject: Removing the LRU file --- src/application-service-appstore.c | 16 ++++------------ src/application-service-appstore.h | 3 +-- src/application-service.c | 9 +-------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4ae316c..2aa418a 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -58,7 +58,6 @@ struct _ApplicationServiceAppstorePrivate { DBusGConnection * bus; GList * applications; GList * approvers; - AppLruFile * lrufile; }; typedef struct _Approver Approver; @@ -165,7 +164,6 @@ application_service_appstore_init (ApplicationServiceAppstore *self) priv->applications = NULL; priv->approvers = NULL; - priv->lrufile = NULL; GError * error = NULL; priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); @@ -241,7 +239,6 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->id = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID)); app->category = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY)); ApplicationServiceAppstorePrivate * priv = app->appstore->priv; - app_lru_file_touch(priv->lrufile, app->id, app->category); app->icon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); @@ -411,15 +408,13 @@ can_add_application (GList *applications, Application *app) } /* This function takes two Application structure - pointers and uses the lrufile to compare them. */ + pointers and uses their ordering index to compare them. */ static gint app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) { Application * appa = (Application *)a; Application * appb = (Application *)b; - AppLruFile * lrufile = (AppLruFile *)userdata; - - return app_lru_file_sort(lrufile, appa->id, appb->id); + return appa->ordering_index - appb->ordering_index; } /* Change the status of the application. If we're going passive @@ -456,7 +451,7 @@ apply_status (Application * app, AppIndicatorStatus status) if (app->status == APP_INDICATOR_STATUS_PASSIVE) { if (can_add_application (priv->applications, app)) { /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, NULL); g_signal_emit(G_OBJECT(app->appstore), signals[APPLICATION_ADDED], 0, @@ -769,12 +764,9 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap /* Creates a basic appstore object and attaches the LRU file object to it. */ ApplicationServiceAppstore * -application_service_appstore_new (AppLruFile * lrufile) +application_service_appstore_new (void) { - g_return_val_if_fail(IS_APP_LRU_FILE(lrufile), NULL); ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(g_object_new(APPLICATION_SERVICE_APPSTORE_TYPE, NULL)); - ApplicationServiceAppstorePrivate * priv = appstore->priv; - priv->lrufile = lrufile; return appstore; } diff --git a/src/application-service-appstore.h b/src/application-service-appstore.h index 422b0fd..665d422 100644 --- a/src/application-service-appstore.h +++ b/src/application-service-appstore.h @@ -25,7 +25,6 @@ with this program. If not, see . #include #include -#include "application-service-lru-file.h" G_BEGIN_DECLS @@ -55,7 +54,7 @@ struct _ApplicationServiceAppstore { ApplicationServiceAppstorePrivate * priv; }; -ApplicationServiceAppstore * application_service_appstore_new (AppLruFile * lrufile); +ApplicationServiceAppstore * application_service_appstore_new (void); GType application_service_appstore_get_type (void); void application_service_appstore_application_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, diff --git a/src/application-service.c b/src/application-service.c index ffd042e..94e7d2e 100644 --- a/src/application-service.c +++ b/src/application-service.c @@ -25,7 +25,6 @@ with this program. If not, see . #include "notification-item-client.h" #include "application-service-appstore.h" #include "application-service-watcher.h" -#include "application-service-lru-file.h" #include "dbus-shared.h" /* The base main loop */ @@ -36,8 +35,6 @@ static ApplicationServiceAppstore * appstore = NULL; static ApplicationServiceWatcher * watcher = NULL; /* The service management interface */ static IndicatorService * service = NULL; -/* The LRU file interface */ -static AppLruFile * lrufile = NULL; /* Recieves the disonnection signal from the service object and closes the mainloop. */ @@ -62,11 +59,8 @@ main (int argc, char ** argv) service = indicator_service_new(INDICATOR_APPLICATION_DBUS_ADDR); g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_disconnected), NULL); - /* Start up the LRU file reading */ - lrufile = app_lru_file_new(); - /* Building our app store */ - appstore = application_service_appstore_new(lrufile); + appstore = application_service_appstore_new(); /* Adding a watcher for the Apps coming up */ watcher = application_service_watcher_new(appstore); @@ -79,7 +73,6 @@ main (int argc, char ** argv) g_object_unref(G_OBJECT(watcher)); g_object_unref(G_OBJECT(appstore)); g_object_unref(G_OBJECT(service)); - g_object_unref(G_OBJECT(lrufile)); return 0; } -- cgit v1.2.3 From d2c36a2dc643c8760556736067e1134aed674800 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 14:49:00 -0500 Subject: Removing the LRU file object. --- src/Makefile.am | 2 - src/application-service-lru-file.c | 473 ------------------------------------- src/application-service-lru-file.h | 59 ----- 3 files changed, 534 deletions(-) delete mode 100644 src/application-service-lru-file.c delete mode 100644 src/application-service-lru-file.h diff --git a/src/Makefile.am b/src/Makefile.am index 620527c..a7cfc0b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,8 +44,6 @@ indicator_application_service_SOURCES = \ application-service.c \ application-service-appstore.h \ application-service-appstore.c \ - application-service-lru-file.h \ - application-service-lru-file.c \ application-service-marshal.c \ application-service-watcher.h \ application-service-watcher.c \ diff --git a/src/application-service-lru-file.c b/src/application-service-lru-file.c deleted file mode 100644 index c69a20f..0000000 --- a/src/application-service-lru-file.c +++ /dev/null @@ -1,473 +0,0 @@ -/* -This object manages the database of when the entires were touched -and loved. And writes that out to disk occationally as well. - -Copyright 2010 Canonical Ltd. - -Authors: - Ted Gould - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include "application-service-lru-file.h" - -#define ENTRY_CATEGORY "category" -#define ENTRY_FIRST_TIME "first-time" -#define ENTRY_LAST_TIME "last-time" -#define ENTRY_VERSION "version" - -#define CONFIG_DIR ("indicators" G_DIR_SEPARATOR_S "application") -#define CONFIG_FILE "lru-file.json" - -typedef struct _AppLruFilePrivate AppLruFilePrivate; -struct _AppLruFilePrivate { - GHashTable * apps; - gboolean dirty; - guint timer; - gchar * filename; -}; - -typedef struct _AppData AppData; -struct _AppData { - gchar * category; - GTimeVal last_touched; - GTimeVal first_touched; -}; - -#define APP_LRU_FILE_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_LRU_FILE_TYPE, AppLruFilePrivate)) - -static void app_lru_file_class_init (AppLruFileClass *klass); -static void app_lru_file_init (AppLruFile *self); -static void app_lru_file_dispose (GObject *object); -static void app_lru_file_finalize (GObject *object); -static void app_data_free (gpointer data); -static void get_dirty (AppLruFile * lrufile); -static gboolean load_from_file (gpointer data); -static void load_file_object_cb (JsonObject * obj, const gchar * key, JsonNode * value, gpointer data); -static void clean_off_hash_cb (gpointer key, gpointer value, gpointer data); -static void clean_off_write_end_cb (GObject * obj, GAsyncResult * res, gpointer data); - -G_DEFINE_TYPE (AppLruFile, app_lru_file, G_TYPE_OBJECT); - -/* Set up the class variable stuff */ -static void -app_lru_file_class_init (AppLruFileClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (AppLruFilePrivate)); - - object_class->dispose = app_lru_file_dispose; - object_class->finalize = app_lru_file_finalize; - - return; -} - -/* Set all the data of the per-instance variables */ -static void -app_lru_file_init (AppLruFile *self) -{ - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(self); - - /* Default values */ - priv->apps = NULL; - priv->dirty = FALSE; - priv->timer = 0; - priv->filename = NULL; - - /* Now let's build some stuff */ - priv->apps = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, app_data_free); - priv->filename = g_build_filename(g_get_user_config_dir(), CONFIG_DIR, CONFIG_FILE, NULL); - - /* No reason to delay other stuff for this, we'll - merge any values that get touched. */ - g_idle_add(load_from_file, self); - - return; -} - -/* Get rid of objects and other big things */ -static void -app_lru_file_dispose (GObject *object) -{ - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(object); - - if (priv->timer != 0) { - g_source_remove(priv->timer); - priv->timer = 0; - } - - if (priv->apps != NULL) { - /* Cleans up the keys and entries itself */ - g_hash_table_destroy(priv->apps); - priv->apps = NULL; - } - - G_OBJECT_CLASS (app_lru_file_parent_class)->dispose (object); - return; -} - -/* Deallocate memory */ -static void -app_lru_file_finalize (GObject *object) -{ - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(object); - - if (priv->filename != NULL) { - g_free(priv->filename); - priv->filename = NULL; - } - - G_OBJECT_CLASS (app_lru_file_parent_class)->finalize (object); - return; -} - -/* Takes an AppData structure and free's the - memory from it. */ -static void -app_data_free (gpointer data) -{ - AppData * appdata = (AppData *)data; - - if (appdata->category != NULL) { - g_free(appdata->category); - } - - g_free(appdata); - - return; -} - -/* Loads all of the data out of a json file */ -static gboolean -load_from_file (gpointer data) -{ - AppLruFile * lrufile = (AppLruFile *)data; - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(lrufile); - - if (!g_file_test(priv->filename, G_FILE_TEST_EXISTS)) { - return FALSE; - } - - JsonParser * parser = json_parser_new(); - - if (!json_parser_load_from_file(parser, priv->filename, NULL)) { - g_warning("Unable to parse JSON file '%s'", priv->filename); - g_object_unref(parser); - return FALSE; - } - - JsonNode * root = json_parser_get_root(parser); - JsonObject * rootobj = json_node_get_object(root); - if (rootobj == NULL) { - g_warning("Malformed LRU file. The root node is not an object."); - g_object_unref(parser); - return FALSE; - } - - json_object_foreach_member(rootobj, load_file_object_cb, lrufile); - - g_object_unref(parser); - return FALSE; -} - -/* Looks at the various things that we need on a node, makes - sure that we have them, and then copies them into the - application hash table of love. */ -static void -load_file_object_cb (JsonObject * rootobj, const gchar * key, JsonNode * value, gpointer data) -{ - AppLruFile * lrufile = (AppLruFile *)data; - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(lrufile); - - /* We're not looking at this today. */ - if (!g_strcmp0(key, ENTRY_VERSION)) { - return; - } - - JsonObject * obj = json_node_get_object(value); - if (obj == NULL) { - g_warning("Data for node '%s' is not an object.", key); - return; - } - - const gchar * obj_category = json_object_get_string_member(obj, ENTRY_CATEGORY); - const gchar * obj_first = json_object_get_string_member(obj, ENTRY_FIRST_TIME); - const gchar * obj_last = json_object_get_string_member(obj, ENTRY_LAST_TIME); - - if (obj_category == NULL || obj_first == NULL || obj_last == NULL) { - g_warning("Node '%s' is missing data. Got: ('%s', '%s', '%s')", key, obj_category, obj_first, obj_last); - get_dirty(lrufile); - return; - } - - /* Check to see how old this entry is. If it hasn't been - used in the last year, we remove the cruft. */ - GTimeVal currenttime; - g_get_current_time(¤ttime); - GDate * currentdate = g_date_new(); - g_date_set_time_val(currentdate, ¤ttime); - - GTimeVal lasttouch; - g_time_val_from_iso8601(obj_last, &lasttouch); - GDate * lastdate = g_date_new(); - g_date_set_time_val(lastdate, &lasttouch); - - gint spread = g_date_days_between(lastdate, currentdate); - - g_date_free(currentdate); - g_date_free(lastdate); - - if (spread > 365) { - g_debug("Removing node '%s' as it's %d days old.", key, spread); - get_dirty(lrufile); - return; - } - - /* See if we already have one of these. It's a little bit - unlikely, but since we're async, we need to check */ - gpointer datapntr = g_hash_table_lookup(priv->apps, key); - if (datapntr == NULL) { - /* Build a new node */ - AppData * appdata = g_new0(AppData, 1); - appdata->category = g_strdup(obj_category); - g_time_val_from_iso8601(obj_first, &appdata->first_touched); - g_time_val_from_iso8601(obj_last, &appdata->last_touched); - - g_hash_table_insert(priv->apps, g_strdup(key), appdata); - } else { - /* Merge nodes */ - AppData * appdata = (AppData *)datapntr; - GTimeVal temptime; - g_time_val_from_iso8601(obj_first, &temptime); - - if (temptime.tv_sec < appdata->first_touched.tv_sec) { - g_time_val_from_iso8601(obj_first, &appdata->first_touched); - } - } - - return; -} - -/* Write out our cache to a file so that we can unmark the dirty - bit and be happy. */ -static gboolean -clean_off (gpointer data) -{ - AppLruFile * lrufile = (AppLruFile *)data; - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(lrufile); - priv->timer = 0; - - GError * error = NULL; - - /* Check to see if our directory exists. Build it if not. */ - gchar * dirname = g_build_filename(g_get_user_config_dir(), CONFIG_DIR, NULL); - if (!g_file_test(dirname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - GFile * dirfile = g_file_new_for_path(dirname); - g_file_make_directory_with_parents(dirfile, NULL, NULL); - g_object_unref(dirfile); - } - g_free(dirname); - - GFile * file = g_file_new_for_path(priv->filename); - GFileOutputStream * ostream = g_file_replace(file, - NULL, /* etag */ - TRUE, /* backup */ - G_FILE_CREATE_NONE, /* flags */ - NULL, /* cancelable */ - &error); - if (error != NULL) { - g_warning("Unable to open a file to store LRU file: %s", error->message); - return FALSE; - } - - /* This is how the file will start */ - GString * filestring = g_string_new("{\n \"" ENTRY_VERSION "\": 1"); - - /* Put the middle in. */ - g_hash_table_foreach (priv->apps, clean_off_hash_cb, filestring); - - /* And then tack on the end. */ - g_string_append(filestring, "\n}\n"); - gchar * filedata = g_string_free(filestring, FALSE); - g_output_stream_write_async(G_OUTPUT_STREAM(ostream), - filedata, - strlen(filedata), - G_PRIORITY_DEFAULT_IDLE, - NULL, - clean_off_write_end_cb, - filedata); - - return FALSE; /* drop the timer */ -} - -/* Looks at every value in the applications hash table and - turns it into a string for writing out. */ -static void -clean_off_hash_cb (gpointer key, gpointer value, gpointer data) -{ - /* Mega-cast */ - gchar * id = (gchar *)key; - AppData * appdata = (AppData *)value; - GString * string = (GString *)data; - - gchar * firsttime = g_time_val_to_iso8601(&appdata->first_touched); - gchar * lasttime = g_time_val_to_iso8601(&appdata->last_touched); - - g_string_append_printf(string, ",\n \"%s\": { \"" ENTRY_FIRST_TIME "\": \"%s\", \"" ENTRY_LAST_TIME "\": \"%s\", \"" ENTRY_CATEGORY "\": \"%s\"}", id, firsttime, lasttime, appdata->category); - - g_free(lasttime); - g_free(firsttime); - - return; -} - -/* Very much like clean_off_write_cb except that it is the - last actor on this Output Stream so it closes it. */ -static void -clean_off_write_end_cb (GObject * obj, GAsyncResult * res, gpointer data) -{ - g_free(data); - - GError * error = NULL; - g_output_stream_close(G_OUTPUT_STREAM(obj), NULL, &error); - - if (error != NULL) { - g_warning("Unable to close LRU File: %s", error->message); - g_error_free(error); - } - - return; -} - -/* Sets the dirty bit if not already set and makes sure that - we have a timer to fix that at some point. */ -static void -get_dirty (AppLruFile * lrufile) -{ - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(lrufile); - - priv->dirty = TRUE; - - if (priv->timer == 0) { - priv->timer = g_timeout_add_seconds(60, clean_off, lrufile); - } - - return; -} - -/* API */ - -/* Simple helper to create a new object */ -AppLruFile * -app_lru_file_new (void) -{ - return APP_LRU_FILE(g_object_new(APP_LRU_FILE_TYPE, NULL)); -} - -/* This updates the timestamp for a particular - entry in the database. It also queues up a - write out of the database. But that'll happen - later. */ -void -app_lru_file_touch (AppLruFile * lrufile, const gchar * id, const gchar * category) -{ - g_return_if_fail(IS_APP_LRU_FILE(lrufile)); - g_return_if_fail(id != NULL && id[0] != '\0'); - g_return_if_fail(category != NULL && category[0] != '\0'); - - AppData * appdata = NULL; - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(lrufile); - gpointer data = g_hash_table_lookup(priv->apps, id); - - if (data == NULL) { - /* Oh, we don't have one, let's build it and put it - into the hash table ourselves */ - appdata = g_new0(AppData, 1); - - appdata->category = g_strdup(category); - g_get_current_time(&(appdata->first_touched)); - /* NOTE: last touched set below */ - - g_hash_table_insert(priv->apps, g_strdup(id), appdata); - } else { - /* Boring, we've got this one already */ - appdata = (AppData *)data; - } - - /* Touch it and mark the DB as dirty */ - g_get_current_time(&(appdata->last_touched)); - get_dirty(lrufile); - return; -} - -/* Used to sort or compare different applications. */ -gint -app_lru_file_sort (AppLruFile * lrufile, const gchar * id_a, const gchar * id_b) -{ - g_return_val_if_fail(IS_APP_LRU_FILE(lrufile), -1); - - /* Let's first look to see if the IDs are the same, this - really shouldn't happen, but it'll be confusing if we - don't get it out of the way to start. */ - if (g_strcmp0(id_a, id_b) == 0) { - return 0; - } - - AppLruFilePrivate * priv = APP_LRU_FILE_GET_PRIVATE(lrufile); - - /* Now make sure we have app data for both of these. If - not we'll assume that the one without is newer? */ - gpointer data_a = g_hash_table_lookup(priv->apps, id_a); - if (data_a == NULL) { - return -1; - } - - gpointer data_b = g_hash_table_lookup(priv->apps, id_b); - if (data_b == NULL) { - return 1; - } - - /* Ugly casting */ - AppData * appdata_a = (AppData *)data_a; - AppData * appdata_b = (AppData *)data_b; - - /* Look at categories, we'll put the categories in alpha - order if they're not the same. */ - gint catcompare = g_strcmp0(appdata_a->category, appdata_b->category); - if (catcompare != 0) { - return catcompare; - } - - /* Now we're looking at the first time that these two were - seen in this account. Only using seconds. I mean, seriously. */ - if (appdata_a->first_touched.tv_sec < appdata_b->first_touched.tv_sec) { - return -1; - } - if (appdata_b->first_touched.tv_sec < appdata_a->first_touched.tv_sec) { - return 1; - } - - /* Eh, this seems roughly impossible. But if we have to choose, - I like A better. */ - return 1; -} diff --git a/src/application-service-lru-file.h b/src/application-service-lru-file.h deleted file mode 100644 index 7c92c82..0000000 --- a/src/application-service-lru-file.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -This object manages the database of when the entires were touched -and loved. And writes that out to disk occationally as well. - -Copyright 2010 Canonical Ltd. - -Authors: - Ted Gould - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#ifndef __APP_LRU_FILE_H__ -#define __APP_LRU_FILE_H__ - -#include -#include - -G_BEGIN_DECLS - -#define APP_LRU_FILE_TYPE (app_lru_file_get_type ()) -#define APP_LRU_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APP_LRU_FILE_TYPE, AppLruFile)) -#define APP_LRU_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APP_LRU_FILE_TYPE, AppLruFileClass)) -#define IS_APP_LRU_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APP_LRU_FILE_TYPE)) -#define IS_APP_LRU_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APP_LRU_FILE_TYPE)) -#define APP_LRU_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APP_LRU_FILE_TYPE, AppLruFileClass)) - -typedef struct _AppLruFile AppLruFile; -typedef struct _AppLruFileClass AppLruFileClass; - -struct _AppLruFileClass { - GObjectClass parent_class; - -}; - -struct _AppLruFile { - GObject parent; - -}; - -GType app_lru_file_get_type (void); - -AppLruFile * app_lru_file_new (void); -void app_lru_file_touch (AppLruFile * lrufile, const gchar * id, const gchar * category); -gint app_lru_file_sort (AppLruFile * lrufile, const gchar * id_a, const gchar * id_b); - -G_END_DECLS - -#endif -- cgit v1.2.3 From 79436bdf4831e65792fd77d4883a97db213e8867 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 15:33:09 -0500 Subject: Fixing documentation with new API. --- docs/reference/Makefile.am | 1 + docs/reference/libappindicator-sections.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index 10d8b2a..d2ef3bb 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -66,6 +66,7 @@ IGNORE_HFILES= \ dbus-properties-client.h \ dbus-properties-server.h \ dbus-shared.h \ + generate-id.h \ notification-item-client.h \ notification-item-server.h \ notification-watcher-client.h \ diff --git a/docs/reference/libappindicator-sections.txt b/docs/reference/libappindicator-sections.txt index a342d99..e0effd1 100644 --- a/docs/reference/libappindicator-sections.txt +++ b/docs/reference/libappindicator-sections.txt @@ -27,6 +27,7 @@ app_indicator_set_menu app_indicator_set_icon app_indicator_set_icon_theme_path app_indicator_set_label +app_indicator_set_ordering_index app_indicator_get_id app_indicator_get_category app_indicator_get_status @@ -36,5 +37,6 @@ app_indicator_get_attention_icon app_indicator_get_menu app_indicator_get_label app_indicator_get_label_guide +app_indicator_get_ordering_index -- cgit v1.2.3 From 6c0afe20ce75adbd12427ee2bffacbf6765d2bad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 16:21:08 -0500 Subject: Adding in an override keyfile --- data/Makefile.am | 10 ++++++++-- data/ordering-override.keyfile | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 data/ordering-override.keyfile diff --git a/data/Makefile.am b/data/Makefile.am index cc1961b..b9666af 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -5,7 +5,13 @@ dbus_services_DATA = indicator-application.service %.service: %.service.in sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ -EXTRA_DIST = indicator-application.service.in +overridedir = $(datadir) +override_DATA = ordering-override.keyfile -CLEANFILES = indicator-application.service +EXTRA_DIST = \ + indicator-application.service.in \ + ordering-override.keyfile + +CLEANFILES = \ + indicator-application.service diff --git a/data/ordering-override.keyfile b/data/ordering-override.keyfile new file mode 100644 index 0000000..6665b7a --- /dev/null +++ b/data/ordering-override.keyfile @@ -0,0 +1,2 @@ +[Ordering Index Overides] +gnome-power-manager=1 -- cgit v1.2.3 From 73fb38c7e5695d4303c58fece8889dc8af0fdfe3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 16:31:39 -0500 Subject: Installing the override file in the package specific data directory. --- data/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/Makefile.am b/data/Makefile.am index b9666af..c142c4e 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -5,7 +5,7 @@ dbus_services_DATA = indicator-application.service %.service: %.service.in sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ -overridedir = $(datadir) +overridedir = $(pkgdatadir) override_DATA = ordering-override.keyfile EXTRA_DIST = \ -- cgit v1.2.3 From dad491a83573507401805d9782a02dec2bad743a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 16:50:54 -0500 Subject: Adding an override hash table --- src/application-service-appstore.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 5fc4f9b..47396bb 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -56,11 +56,14 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_SIG_NEW_LABEL "NewLabel" #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" +#define OVERRIDE_GROUP_NAME "Ordering Index Overrides" + /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { DBusGConnection * bus; GList * applications; GList * approvers; + GHashTable * ordering_overrides; }; typedef struct _Approver Approver; @@ -183,6 +186,8 @@ application_service_appstore_init (ApplicationServiceAppstore *self) priv->applications = NULL; priv->approvers = NULL; + + priv->ordering_overrides = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); GError * error = NULL; priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); @@ -225,6 +230,12 @@ application_service_appstore_dispose (GObject *object) static void application_service_appstore_finalize (GObject *object) { + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE(object)->priv; + + if (priv->ordering_overrides != NULL) { + g_hash_table_destroy(priv->ordering_overrides); + priv->ordering_overrides = NULL; + } G_OBJECT_CLASS (application_service_appstore_parent_class)->finalize (object); return; -- cgit v1.2.3 From f4b22a7fa52695acc7e1e5abd20859f320e3895f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 16:59:25 -0500 Subject: Putting together the pieces to look for override files --- src/Makefile.am | 1 + src/application-service-appstore.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index a7cfc0b..1c4e7ae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,6 +54,7 @@ indicator_application_service_SOURCES = \ indicator_application_service_CFLAGS = \ $(INDICATOR_CFLAGS) \ + -DDATADIR="\"$(pkgdatadir)\"" \ -Wall -Werror \ -DG_LOG_DOMAIN=\"indicator-application-service\" diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 47396bb..0df4dd5 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -57,6 +57,7 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" #define OVERRIDE_GROUP_NAME "Ordering Index Overrides" +#define OVERRIDE_FILE_NAME "ordering-override.keyfile" /* Private Stuff */ struct _ApplicationServiceAppstorePrivate { @@ -112,6 +113,7 @@ static void application_service_appstore_class_init (ApplicationServiceAppstoreC static void application_service_appstore_init (ApplicationServiceAppstore *self); static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); +static void load_override_file (GHashTable * hash, const gchar * filename); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app, AppIndicatorStatus status); static void approver_free (gpointer papprover, gpointer user_data); @@ -188,6 +190,11 @@ application_service_appstore_init (ApplicationServiceAppstore *self) priv->approvers = NULL; priv->ordering_overrides = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + + load_override_file(priv->ordering_overrides, DATADIR "/" OVERRIDE_FILE_NAME); + gchar * userfile = g_build_filename(g_get_user_data_dir(), "indicators", "application", OVERRIDE_FILE_NAME, NULL); + load_override_file(priv->ordering_overrides, userfile); + g_free(userfile); GError * error = NULL; priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); @@ -241,6 +248,15 @@ application_service_appstore_finalize (GObject *object) return; } +/* Loads the file and adds the override entries to the table + of overrides */ +static void +load_override_file (GHashTable * hash, const gchar * filename) +{ + + +} + /* Return from getting the properties from the item. We're looking at those and making sure we have everythign that we need. If we do, then we'll move on up to sending this onto the indicator. */ -- cgit v1.2.3 From de6c40d873a317a98d025cb094e7d89a646b4000 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 17:13:22 -0500 Subject: Fleshing out the loading overrides function. --- src/application-service-appstore.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0df4dd5..4d21291 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -253,8 +253,46 @@ application_service_appstore_finalize (GObject *object) static void load_override_file (GHashTable * hash, const gchar * filename) { + g_return_if_fail(hash != NULL); + g_return_if_fail(filename != NULL); + if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { + return; + } + + g_debug("Loading overrides from: '%s'", filename); + + GError * error = NULL; + GKeyFile * keyfile = g_key_file_new(); + g_key_file_load_from_file(keyfile, filename, G_KEY_FILE_NONE, &error); + if (error != NULL) { + g_warning("Unable to load keyfile '%s' because: %s", filename, error->message); + g_error_free(error); + g_key_file_free(keyfile); + return; + } + + gchar ** keys = g_key_file_get_keys(keyfile, OVERRIDE_GROUP_NAME, NULL, NULL); + gchar * key = keys[0]; + gint i; + + for (i = 0; (key = keys[i]) != NULL; i++) { + GError * valerror = NULL; + gint val = g_key_file_get_integer(keyfile, OVERRIDE_GROUP_NAME, key, &valerror); + + if (valerror != NULL) { + g_warning("Unable to get key '%s' out of file '%s' because: %s", key, filename, valerror->message); + g_error_free(valerror); + continue; + } + g_debug("%s: override '%s' with value '%d'", filename, key, val); + + g_hash_table_insert(hash, g_strdup(key), GINT_TO_POINTER(val)); + } + g_key_file_free(keyfile); + + return; } /* Return from getting the properties from the item. We're looking at those -- cgit v1.2.3 From 51de4ced42e132fa3a66a2739e8a3ba861842467 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Aug 2010 21:19:31 -0500 Subject: Checking for an override and applying it. --- src/application-service-appstore.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4d21291..d632456 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -346,11 +346,16 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->icon_theme_path = g_strdup(""); } - gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); - if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { - app->ordering_index = generate_id(string_to_status(app->category), app->id); + gpointer ordering_index_over = g_hash_table_lookup(priv->ordering_overrides, app->id); + if (ordering_index_over == NULL) { + gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); + if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { + app->ordering_index = generate_id(string_to_status(app->category), app->id); + } else { + app->ordering_index = g_value_get_uint(ordering_index_data); + } } else { - app->ordering_index = g_value_get_uint(ordering_index_data); + app->ordering_index = GPOINTER_TO_UINT(ordering_index_over); } gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); -- cgit v1.2.3 From bdd9c8541f5df134ad5460ef192c7dc019e893eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 09:05:07 -0500 Subject: Ensuring that we got a list of keys so we don't crash --- src/application-service-appstore.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index d632456..2306230 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -273,7 +273,14 @@ load_override_file (GHashTable * hash, const gchar * filename) return; } - gchar ** keys = g_key_file_get_keys(keyfile, OVERRIDE_GROUP_NAME, NULL, NULL); + gchar ** keys = g_key_file_get_keys(keyfile, OVERRIDE_GROUP_NAME, NULL, &error); + if (error != NULL) { + g_warning("Unable to get keys from keyfile '%s' because: %s", filename, error->message); + g_error_free(error); + g_key_file_free(keyfile); + return; + } + gchar * key = keys[0]; gint i; -- cgit v1.2.3 From 77343b7e956416b2d2a8e45b5a2a2e683e1ed836 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 09:06:41 -0500 Subject: Typo --- data/ordering-override.keyfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/ordering-override.keyfile b/data/ordering-override.keyfile index 6665b7a..dcfb75b 100644 --- a/data/ordering-override.keyfile +++ b/data/ordering-override.keyfile @@ -1,2 +1,2 @@ -[Ordering Index Overides] +[Ordering Index Overrides] gnome-power-manager=1 -- cgit v1.2.3 From fd956d9ac1489d8dc12827df67e9a201da43bc9d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 09:50:14 -0500 Subject: Flipping the order --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 2306230..57f8871 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -530,7 +530,7 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) { Application * appa = (Application *)a; Application * appb = (Application *)b; - return appa->ordering_index - appb->ordering_index; + return appb->ordering_index - appa->ordering_index; } /* Change the status of the application. If we're going passive -- cgit v1.2.3 From 26d50dfef1ddbc5cda58cb221501c6b5654b36b5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 10:10:45 -0500 Subject: Switching to be more opaque, but also more sane. --- src/generate-id.c | 2 +- src/generate-id.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/generate-id.c b/src/generate-id.c index 6855b39..79e2c26 100644 --- a/src/generate-id.c +++ b/src/generate-id.c @@ -34,7 +34,7 @@ union ordering_id_union_t { }; guint32 -generate_id (const gchar category, const gchar * id) +generate_id (const AppIndicatorCategory category, const gchar * id) { union ordering_id_union_t u; diff --git a/src/generate-id.h b/src/generate-id.h index 3713158..9d3167d 100644 --- a/src/generate-id.h +++ b/src/generate-id.h @@ -23,7 +23,8 @@ with this program. If not, see . #define __GENERATE_ID_H__ #include +#include "app-indicator.h" -guint32 generate_id (const gchar category, const gchar * id); +guint32 generate_id (const AppIndicatorCategory category, const gchar * id); #endif /* __GENERATE_ID_H__ */ -- cgit v1.2.3 From 38c7a01f9a5c462ea31403a55de5b08f3fb86222 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 11:03:02 -0500 Subject: Making the categories a case statement. --- src/generate-id.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/generate-id.c b/src/generate-id.c index 79e2c26..5b0eb8b 100644 --- a/src/generate-id.c +++ b/src/generate-id.c @@ -33,12 +33,34 @@ union ordering_id_union_t { struct ordering_id_struct str; }; +#define MULTIPLIER 32 + guint32 generate_id (const AppIndicatorCategory category, const gchar * id) { union ordering_id_union_t u; - u.str.category = category; + switch (category) { + case APP_INDICATOR_CATEGORY_OTHER: + u.str.category = MULTIPLIER * 5; + break; + case APP_INDICATOR_CATEGORY_APPLICATION_STATUS: + u.str.category = MULTIPLIER * 4; + break; + case APP_INDICATOR_CATEGORY_COMMUNICATIONS: + u.str.category = MULTIPLIER * 3; + break; + case APP_INDICATOR_CATEGORY_SYSTEM_SERVICES: + u.str.category = MULTIPLIER * 2; + break; + case APP_INDICATOR_CATEGORY_HARDWARE: + u.str.category = MULTIPLIER * 1; + break; + default: + g_warning("Got an undefined category: %d", category); + u.str.category = 0; + break; + } u.str.first = 0; u.str.second = 0; -- cgit v1.2.3 From 8bfbd55d1427fb23ab63d90df388c68799b3eaca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 11:06:39 -0500 Subject: Instead of using a struct just using multiply, which in all reality, is more clear and the compiler will optimize it for us. --- src/generate-id.c | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/generate-id.c b/src/generate-id.c index 5b0eb8b..a504e44 100644 --- a/src/generate-id.c +++ b/src/generate-id.c @@ -21,62 +21,49 @@ with this program. If not, see . #include "generate-id.h" -struct ordering_id_struct { - gchar category; - gchar first; - gchar second; - gchar third; -}; - -union ordering_id_union_t { - guint32 id; - struct ordering_id_struct str; -}; - #define MULTIPLIER 32 guint32 -generate_id (const AppIndicatorCategory category, const gchar * id) +generate_id (const AppIndicatorCategory catenum, const gchar * id) { - union ordering_id_union_t u; + gchar category = 0; + gchar first = 0; + gchar second = 0; + gchar third = 0; - switch (category) { + switch (catenum) { case APP_INDICATOR_CATEGORY_OTHER: - u.str.category = MULTIPLIER * 5; + category = MULTIPLIER * 5; break; case APP_INDICATOR_CATEGORY_APPLICATION_STATUS: - u.str.category = MULTIPLIER * 4; + category = MULTIPLIER * 4; break; case APP_INDICATOR_CATEGORY_COMMUNICATIONS: - u.str.category = MULTIPLIER * 3; + category = MULTIPLIER * 3; break; case APP_INDICATOR_CATEGORY_SYSTEM_SERVICES: - u.str.category = MULTIPLIER * 2; + category = MULTIPLIER * 2; break; case APP_INDICATOR_CATEGORY_HARDWARE: - u.str.category = MULTIPLIER * 1; + category = MULTIPLIER * 1; break; default: g_warning("Got an undefined category: %d", category); - u.str.category = 0; + category = 0; break; } - u.str.first = 0; - u.str.second = 0; - u.str.third = 0; - if (id != NULL) { if (id[0] != '\0') { - u.str.first = id[0]; + first = id[0]; if (id[1] != '\0') { - u.str.second = id[1]; + second = id[1]; if (id[2] != '\0') { - u.str.third = id[2]; + third = id[2]; } } } } - return u.id; + return (((((category * 256) + first) * 256) + second) * 256) + third; } -- cgit v1.2.3 From 0dd2e79a84c137ed4846bfd145ce362dcade3477 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 11:10:03 -0500 Subject: Ignoring the generate id library object file. --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 6183694..6f66217 100644 --- a/.bzrignore +++ b/.bzrignore @@ -114,3 +114,4 @@ tests/test-approver-tester bindings/mono/policy.0.0.appindicator-sharp.config bindings/mono/policy.0.0.appindicator-sharp.dll src/libapplication_la-generate-id.lo +src/libappindicator_la-generate-id.lo -- cgit v1.2.3 From 73018411f1b744face28d15b2b73612b11726aba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:00:39 -0500 Subject: Making it so that applications will pass '0' over dbus if they don't have a set ordering index. --- src/app-indicator.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index e4138d4..781b630 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -788,11 +788,7 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa break; case PROP_ORDERING_INDEX: - if (priv->ordering_index == 0) { - g_value_set_uint(value, generate_id(priv->category, priv->id)); - } else { - g_value_set_uint(value, priv->ordering_index); - } + g_value_set_uint(value, priv->ordering_index); break; default: @@ -2002,12 +1998,10 @@ app_indicator_get_ordering_index (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), 0); - guint ordering_index = 0; - - g_object_get(G_OBJECT(self), - PROP_ORDERING_INDEX_S, &ordering_index, - NULL); - - return ordering_index; + if (self->priv->ordering_index == 0) { + return generate_id(self->priv->category, self->priv->id); + } else { + return self->priv->ordering_index; + } } -- cgit v1.2.3 From 818f7c466b1a06cea9a70e11abcfc0fba13a37c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:02:20 -0500 Subject: Putting the ordering index into the 'x' domain. --- src/app-indicator.c | 2 +- src/application-service-appstore.c | 4 ++-- src/notification-item.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 781b630..240e1ca 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -129,7 +129,7 @@ enum { #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" -#define PROP_ORDERING_INDEX_S "ordering-index" +#define PROP_ORDERING_INDEX_S "x-ayatana-ordering-index" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 57f8871..e067b90 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -47,8 +47,8 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" #define NOTIFICATION_ITEM_PROP_LABEL "Label" -#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" -#define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "OrderingIndex" +#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" +#define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "XAyatanaOrderingIndex" #define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" #define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" diff --git a/src/notification-item.xml b/src/notification-item.xml index ffd59d1..b66dfe3 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -14,7 +14,7 @@ - + -- cgit v1.2.3 From 16cdfbcf41b0136f2e29836a7bdb76a6f05ec4b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:03:59 -0500 Subject: Changing the Dbus interface. --- src/notification-item.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notification-item.xml b/src/notification-item.xml index 01261b5..e0d3649 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -12,8 +12,8 @@ to find the icons specified above. --> - - + + @@ -29,7 +29,7 @@ - + -- cgit v1.2.3 From 2a0f0b9f099c2714556099fc7ddf1ceca5378fa2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:04:52 -0500 Subject: Changing the app store --- src/application-service-appstore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 55906ff..cf74efc 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -45,13 +45,13 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" #define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" -#define NOTIFICATION_ITEM_PROP_LABEL "Label" -#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" +#define NOTIFICATION_ITEM_PROP_LABEL "XAyatanaLabel" +#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "XAyatanaLabelGuide" #define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" #define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" #define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" -#define NOTIFICATION_ITEM_SIG_NEW_LABEL "NewLabel" +#define NOTIFICATION_ITEM_SIG_NEW_LABEL "XAyatanaNewLabel" #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" /* Private Stuff */ -- cgit v1.2.3 From ea682be679779ba60d98393f2d613e8c980b3fd2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:24:27 -0500 Subject: Adding a set of wrapper properties that can be used by the dbus interface. --- src/app-indicator.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 22b9c03..3f7c85f 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -112,7 +112,9 @@ enum { PROP_MENU, PROP_CONNECTED, PROP_LABEL, - PROP_LABEL_GUIDE + PROP_LABEL_GUIDE, + PROP_X_LABEL, + PROP_X_LABEL_GUIDE }; /* The strings so that they can be slowly looked up. */ @@ -126,6 +128,8 @@ enum { #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" +#define PROP_X_LABEL_S "x-ayatana-label" +#define PROP_X_LABEL_GUIDE_S "x-ayatana-label-guide" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -331,6 +335,32 @@ app_indicator_class_init (AppIndicatorClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:x-ayatana-label: + + Wrapper for #AppIndicator:label. Please use that in all of your + code. + */ + g_object_class_install_property(object_class, + PROP_X_LABEL, + g_param_spec_string (PROP_X_LABEL_S, + "A wrapper, please don't use.", + "A wrapper, please don't use.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:x-ayatana-label-guide: + + Wrapper for #AppIndicator:label-guide. Please use that in all of your + code. + */ + g_object_class_install_property(object_class, + PROP_X_LABEL_GUIDE, + g_param_spec_string (PROP_X_LABEL_GUIDE_S, + "A wrapper, please don't use.", + "A wrapper, please don't use.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ @@ -658,6 +688,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu check_connect (self); break; + case PROP_X_LABEL: case PROP_LABEL: { gchar * oldlabel = priv->label; priv->label = g_value_dup_string(value); @@ -676,6 +707,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } break; } + case PROP_X_LABEL_GUIDE: case PROP_LABEL_GUIDE: { gchar * oldguide = priv->label_guide; priv->label_guide = g_value_dup_string(value); -- cgit v1.2.3 From 1fbc480b06ae2596b2644134d3c906ef3ba15f8e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 13:43:36 -0500 Subject: Adding in a wrapper signal --- src/app-indicator.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 3f7c85f..e174e57 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -92,6 +92,7 @@ enum { NEW_ATTENTION_ICON, NEW_STATUS, NEW_LABEL, + X_NEW_LABEL, CONNECTION_CHANGED, NEW_ICON_THEME_PATH, LAST_SIGNAL @@ -135,6 +136,9 @@ enum { #define APP_INDICATOR_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_INDICATOR_TYPE, AppIndicatorPrivate)) +/* Signal wrapper */ +#define APP_INDICATOR_SIGNAL_X_NEW_LABEL ("x-ayatana-" APP_INDICATOR_SIGNAL_NEW_LABEL) + /* Default Path */ #define DEFAULT_ITEM_PATH "/org/ayatana/NotificationItem" @@ -425,6 +429,23 @@ app_indicator_class_init (AppIndicatorClass *klass) _application_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + /** + AppIndicator::x-ayatana-new-label: + @arg0: The #AppIndicator object + @arg1: The string for the label + @arg1: The string for the guide + + Wrapper for #AppIndicator::new-label, please don't use this signal + use the other one. + */ + signals[X_NEW_LABEL] = g_signal_new (APP_INDICATOR_SIGNAL_X_NEW_LABEL, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppIndicatorClass, new_label), + NULL, NULL, + _application_service_marshal_VOID__STRING_STRING, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + /** AppIndicator::connection-changed: @arg0: The #AppIndicator object @@ -811,6 +832,10 @@ signal_label_change_idle (gpointer user_data) priv->label != NULL ? priv->label : "", priv->label_guide != NULL ? priv->label_guide : "", TRUE); + g_signal_emit(G_OBJECT(self), signals[X_NEW_LABEL], 0, + priv->label != NULL ? priv->label : "", + priv->label_guide != NULL ? priv->label_guide : "", + TRUE); priv->label_change_idle = 0; -- cgit v1.2.3 From 7330f014db03391d1859f74b4bcbef13e587aa52 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 14:11:18 -0500 Subject: Adding the wrapper properties to the get. --- src/app-indicator.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index e174e57..cd8dcc9 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -805,10 +805,12 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE); break; + case PROP_X_LABEL: case PROP_LABEL: g_value_set_string (value, priv->label); break; + case PROP_X_LABEL_GUIDE: case PROP_LABEL_GUIDE: g_value_set_string (value, priv->label_guide); break; -- cgit v1.2.3 From 9346cf3923b01a8ee557c3a0273a445962759391 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 14:27:33 -0500 Subject: Making a wrapper property for the 'X' domain --- src/app-indicator.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 240e1ca..7528da2 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -115,7 +115,8 @@ enum { PROP_CONNECTED, PROP_LABEL, PROP_LABEL_GUIDE, - PROP_ORDERING_INDEX + PROP_ORDERING_INDEX, + PROP_X_ORDERING_INDEX }; /* The strings so that they can be slowly looked up. */ @@ -129,7 +130,8 @@ enum { #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" -#define PROP_ORDERING_INDEX_S "x-ayatana-ordering-index" +#define PROP_ORDERING_INDEX_S "ordering-index" +#define PROP_X_ORDERING_INDEX_S ("x-ayatana-" PROP_ORDERING_INDEX_S) /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -353,6 +355,20 @@ app_indicator_class_init (AppIndicatorClass *klass) "A way to override the default ordering of the applications by providing a very specific idea of where this entry should be placed.", 0, G_MAXUINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:x-ayatana-ordering-index: + + A wrapper for #AppIndicator:ordering-index so that it can match the + dbus interface currently. It will hopefully be retired, please don't + use it anywhere. + */ + g_object_class_install_property(object_class, + PROP_X_ORDERING_INDEX, + g_param_spec_uint (PROP_X_ORDERING_INDEX_S, + "A wrapper, please don't use.", + "A wrapper, please don't use.", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ @@ -718,6 +734,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } break; } + case PROP_X_ORDERING_INDEX: case PROP_ORDERING_INDEX: priv->ordering_index = g_value_get_uint(value); break; @@ -787,6 +804,7 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_string (value, priv->label_guide); break; + case PROP_X_ORDERING_INDEX: case PROP_ORDERING_INDEX: g_value_set_uint(value, priv->ordering_index); break; -- cgit v1.2.3 From a0c8fb032b4eb3fb534367832d43207cfdf31309 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 15:28:26 -0500 Subject: We were using the wrong function, we want categories not statuses! --- src/application-service-appstore.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index e067b90..e7231fe 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -115,6 +115,7 @@ static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); static void load_override_file (GHashTable * hash, const gchar * filename); static AppIndicatorStatus string_to_status(const gchar * status_string); +static AppIndicatorCategory string_to_cat(const gchar * cat_string); static void apply_status (Application * app, AppIndicatorStatus status); static void approver_free (gpointer papprover, gpointer user_data); static void check_with_new_approver (gpointer papp, gpointer papprove); @@ -357,13 +358,14 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err if (ordering_index_over == NULL) { gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { - app->ordering_index = generate_id(string_to_status(app->category), app->id); + app->ordering_index = generate_id(string_to_cat(app->category), app->id); } else { app->ordering_index = g_value_get_uint(ordering_index_data); } } else { app->ordering_index = GPOINTER_TO_UINT(ordering_index_over); } + g_debug("'%s' ordering index is '%d'", app->id, app->ordering_index); gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); if (label_data != NULL) { @@ -417,6 +419,28 @@ string_to_status(const gchar * status_string) return retval; } +/* Simple translation function -- could be optimized */ +static AppIndicatorCategory +string_to_cat(const gchar * cat_string) +{ + GEnumClass * klass = G_ENUM_CLASS(g_type_class_ref(APP_INDICATOR_TYPE_INDICATOR_CATEGORY)); + g_return_val_if_fail(klass != NULL, APP_INDICATOR_CATEGORY_OTHER); + + AppIndicatorCategory retval = APP_INDICATOR_CATEGORY_OTHER; + + GEnumValue * val = g_enum_get_value_by_nick(klass, cat_string); + if (val == NULL) { + g_warning("Unrecognized status '%s' assuming other.", cat_string); + } else { + retval = (AppIndicatorCategory)val->value; + } + + g_type_class_unref(klass); + + return retval; +} + + /* A small helper function to get the position of an application in the app list. */ static gint -- cgit v1.2.3 From cfe735bc43d3240b60da3668d5c211286ff32023 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 15:35:08 -0500 Subject: Using unsigned chars for calculating, we want no sign extension. --- src/generate-id.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generate-id.c b/src/generate-id.c index a504e44..14d762e 100644 --- a/src/generate-id.c +++ b/src/generate-id.c @@ -26,10 +26,10 @@ with this program. If not, see . guint32 generate_id (const AppIndicatorCategory catenum, const gchar * id) { - gchar category = 0; - gchar first = 0; - gchar second = 0; - gchar third = 0; + guchar category = 0; + guchar first = 0; + guchar second = 0; + guchar third = 0; switch (catenum) { case APP_INDICATOR_CATEGORY_OTHER: -- cgit v1.2.3 From d678c3504b773d726573d50f2456ae83fc2b0bb0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 15:42:56 -0500 Subject: Better debug printing. --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index e7231fe..f28c2af 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -365,7 +365,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err } else { app->ordering_index = GPOINTER_TO_UINT(ordering_index_over); } - g_debug("'%s' ordering index is '%d'", app->id, app->ordering_index); + g_debug("'%s' ordering index is '%X'", app->id, app->ordering_index); gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); if (label_data != NULL) { -- cgit v1.2.3 From f34b5e562004795cfb4e09a7daa1d3cbb21f89f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 15:45:09 -0500 Subject: Fighting wrap around --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index f28c2af..d3dc4a9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -554,7 +554,7 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) { Application * appa = (Application *)a; Application * appb = (Application *)b; - return appb->ordering_index - appa->ordering_index; + return (appb->ordering_index/2) - (appa->ordering_index/2); } /* Change the status of the application. If we're going passive -- cgit v1.2.3 From efd7be1cf7c80abc13c6d3bb3bc99cef18b8db7b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 19:59:38 -0500 Subject: Adding a count for the number of approvers that have approved the application. --- src/application-service-appstore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 55906ff..83b64f3 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -85,6 +85,7 @@ struct _Application { gchar * label; gchar * guide; gboolean currently_free; + gint approved_by; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -734,6 +735,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->label = NULL; app->guide = NULL; app->currently_free = FALSE; + app->approved_by = 0; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From e8b76a6a10b53e0cc4d34895fb396a5bc9ab4c54 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:04:06 -0500 Subject: Changing to a list, we're going to need to track who so when they disconnect we can know the state change. --- src/application-service-appstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 83b64f3..9c34a79 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -85,7 +85,7 @@ struct _Application { gchar * label; gchar * guide; gboolean currently_free; - gint approved_by; + GList * approved_by; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -735,7 +735,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->label = NULL; app->guide = NULL; app->currently_free = FALSE; - app->approved_by = 0; + app->approved_by = NULL; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From fbdf4bfec6dad26c7b3ffdedd9f1616abf20f196 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:26:08 -0500 Subject: Managing the list with the approver returns. --- src/application-service-appstore.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 9c34a79..b2c18d4 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -949,6 +949,15 @@ static void approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) { g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + Application * app = (Application *)userdata; + + if (OUT_approved) { + app->approved_by = g_list_prepend(app->approved_by, proxy); + } else { + app->approved_by = g_list_remove(app->approved_by, proxy); + } + + /* TODO: Apply status */ return; } -- cgit v1.2.3 From a635d68dff58440961c12f1db6f998836b1c556f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:31:30 -0500 Subject: Adding a visible state entry to the application structure --- src/application-service-appstore.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index b2c18d4..c32cd5e 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -62,6 +62,12 @@ struct _ApplicationServiceAppstorePrivate { AppLruFile * lrufile; }; +typedef enum { + VISIBLE_STATE_HIDDEN, + VISIBLE_STATE_NORMAL, + VISIBLE_STATE_ATTENTION +} visible_state_t; + typedef struct _Approver Approver; struct _Approver { DBusGProxy * proxy; @@ -86,6 +92,7 @@ struct _Application { gchar * guide; gboolean currently_free; GList * approved_by; + visible_state_t visible_state; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -736,6 +743,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->guide = NULL; app->currently_free = FALSE; app->approved_by = NULL; + app->visible_state = VISIBLE_STATE_HIDDEN; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From ddd87466241652a8f889e7c27f6e6b6b31797450 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:33:01 -0500 Subject: Making sure to clean up the approved by list --- src/application-service-appstore.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index c32cd5e..d0723b9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -405,6 +405,9 @@ application_free (Application * app) if (app->guide != NULL) { g_free(app->guide); } + if (app->approved_by != NULL) { + g_list_free(app->approved_by); + } g_free(app); return; -- cgit v1.2.3 From b7419c3d3e23ddc3be51f1d3c182360ffe76bf8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 20:58:36 -0500 Subject: Changing the apply_status function to be less about applying the status and more about trying to apply a visual state that can be determined by things like approvers. This means that it doesn't get passed the status. --- src/application-service-appstore.c | 77 +++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index d0723b9..bff4c77 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -116,7 +116,7 @@ static void application_service_appstore_init (ApplicationServiceAppstore static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); static AppIndicatorStatus string_to_status(const gchar * status_string); -static void apply_status (Application * app, AppIndicatorStatus status); +static void apply_status (Application * app); static void approver_free (gpointer papprover, gpointer user_data); static void check_with_new_approver (gpointer papp, gpointer papprove); static void check_with_old_approver (gpointer papprove, gpointer papp); @@ -264,6 +264,8 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->id = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID)); app->category = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY)); + app->status = string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS))); + ApplicationServiceAppstorePrivate * priv = app->appstore->priv; app_lru_file_touch(priv->lrufile, app->id, app->category); @@ -306,7 +308,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ g_list_foreach(priv->approvers, check_with_old_approver, app); - apply_status(app, string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS)))); + apply_status(app); return; } @@ -421,13 +423,16 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) Application * app = (Application *)userdata; /* Remove from the panel */ - apply_status(app, APP_INDICATOR_STATUS_PASSIVE); + app->status = APP_INDICATOR_STATUS_PASSIVE; + apply_status(app); /* Destroy the data */ application_free(app); return; } +/* Look and see if an application exists in the application + list already */ static gboolean can_add_application (GList *applications, Application *app) { @@ -466,49 +471,60 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) it removes it from the panel. If we're coming online, then it add it to the panel. Otherwise it changes the icon. */ static void -apply_status (Application * app, AppIndicatorStatus status) +apply_status (Application * app) { - if (app->status == status) { - return; - } - g_debug("Changing app status to: %d", status); - ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; + visible_state_t goal_state = VISIBLE_STATE_HIDDEN; + + if (app->status != APP_INDICATOR_STATUS_PASSIVE && + g_list_length(app->approved_by) == g_list_length(priv->approvers)) { + if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + goal_state = VISIBLE_STATE_NORMAL; + } else if (app->status == APP_INDICATOR_STATUS_ATTENTION) { + goal_state = VISIBLE_STATE_ATTENTION; + } + } + + /* Nothing needs to change, we're good */ + if (app->visible_state == goal_state) { + return; + } + /* This means we're going off line */ - if (status == APP_INDICATOR_STATUS_PASSIVE) { + if (goal_state == VISIBLE_STATE_HIDDEN) { gint position = get_position(app); if (position == -1) return; g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); - priv->applications = g_list_remove(priv->applications, app); + priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; - if (status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { + if (goal_state == VISIBLE_STATE_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { newicon = app->aicon; } /* Determine whether we're already shown or not */ - if (app->status == APP_INDICATOR_STATUS_PASSIVE) { - if (can_add_application (priv->applications, app)) { - /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ADDED], 0, - newicon, - g_list_index(priv->applications, app), /* Position */ - app->dbus_name, - app->menu, - app->icon_theme_path, - app->label, - app->guide, - TRUE); - } + if (app->visible_state == VISIBLE_STATE_HIDDEN) { + if (can_add_application (priv->applications, app)) { + /* Put on panel */ + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + newicon, + g_list_index(priv->applications, app), /* Position */ + app->dbus_name, + app->menu, + app->icon_theme_path, + app->label, + app->guide, + TRUE); + } } else { /* Icon update */ gint position = get_position(app); @@ -520,7 +536,7 @@ apply_status (Application * app, AppIndicatorStatus status) } } - app->status = status; + app->visible_state = goal_state; return; } @@ -642,7 +658,8 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data) Application * app = (Application *)data; if (!app->validated) return; - apply_status(app, string_to_status(status)); + app->status = string_to_status(status); + apply_status(app); return; } -- cgit v1.2.3 From ba6904978575157936f0fb3ce9fd4aa78ac740ee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:15:58 -0500 Subject: Moving some TODOs --- src/application-service-appstore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index bff4c77..6ee2c47 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -305,7 +305,6 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = g_strdup(""); } - /* TODO: Calling approvers, but we're ignoring the results. So, eh. */ g_list_foreach(priv->approvers, check_with_old_approver, app); apply_status(app); @@ -985,7 +984,7 @@ approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gp app->approved_by = g_list_remove(app->approved_by, proxy); } - /* TODO: Apply status */ + apply_status(app); return; } -- cgit v1.2.3 From 4398a699958b13e6e5739520eb83f9530dd333f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:30:44 -0500 Subject: Make it so that an approver that gets free'd gets removed from the applications list of approval. --- src/application-service-appstore.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 6ee2c47..5467f31 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -220,7 +220,7 @@ application_service_appstore_dispose (GObject *object) } if (priv->approvers != NULL) { - g_list_foreach(priv->approvers, approver_free, NULL); + g_list_foreach(priv->approvers, approver_free, object); g_list_free(priv->approvers); priv->approvers = NULL; } @@ -955,12 +955,27 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst return TRUE; } +/* Removes and approver from our list of approvers and + then sees if that changes our status. Most likely this + could make us visible if this approver rejected us. */ +static void +remove_approver (gpointer papp, gpointer pproxy) +{ + Application * app = (Application *)papp; + app->approved_by = g_list_remove(app->approved_by, pproxy); + apply_status(app); + return; +} + /* Frees the data associated with an approver */ static void approver_free (gpointer papprover, gpointer user_data) { Approver * approver = (Approver *)papprover; g_return_if_fail(approver != NULL); + + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); + g_list_foreach(appstore->priv->applications, remove_approver, approver->proxy); if (approver->proxy != NULL) { g_object_unref(approver->proxy); -- cgit v1.2.3 From 0db4eb579e37326484df53ff9dab3a4a6b6a8b40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:48:54 -0500 Subject: Switching a few status checks to look at the visible state --- src/application-service-appstore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 5467f31..f5b2db4 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -565,7 +565,7 @@ new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata if (app->icon != NULL) g_free(app->icon); app->icon = g_strdup(newicon); - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + if (app->visible_state == VISIBLE_STATE_NORMAL) { gint position = get_position(app); if (position == -1) return; @@ -603,7 +603,7 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat if (app->aicon != NULL) g_free(app->aicon); app->aicon = g_strdup(newicon); - if (app->status == APP_INDICATOR_STATUS_ATTENTION) { + if (app->visible_state == VISIBLE_STATE_ATTENTION) { gint position = get_position(app); if (position == -1) return; @@ -676,7 +676,7 @@ new_icon_theme_path (DBusGProxy * proxy, const gchar * icon_theme_path, gpointer if (app->icon_theme_path != NULL) g_free(app->icon_theme_path); app->icon_theme_path = g_strdup(icon_theme_path); - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { + if (app->visible_state != VISIBLE_STATE_HIDDEN) { gint position = get_position(app); if (position == -1) return; -- cgit v1.2.3 From 360e8a40e548f5080193dd60d9c7fd5c2fb50089 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 21:52:43 -0500 Subject: Simplifying the visual state to just be shown/hidden while letting the status show which icon is shown. --- src/application-service-appstore.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index f5b2db4..0991286 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -64,8 +64,7 @@ struct _ApplicationServiceAppstorePrivate { typedef enum { VISIBLE_STATE_HIDDEN, - VISIBLE_STATE_NORMAL, - VISIBLE_STATE_ATTENTION + VISIBLE_STATE_SHOWN } visible_state_t; typedef struct _Approver Approver; @@ -479,11 +478,7 @@ apply_status (Application * app) if (app->status != APP_INDICATOR_STATUS_PASSIVE && g_list_length(app->approved_by) == g_list_length(priv->approvers)) { - if (app->status == APP_INDICATOR_STATUS_ACTIVE) { - goal_state = VISIBLE_STATE_NORMAL; - } else if (app->status == APP_INDICATOR_STATUS_ATTENTION) { - goal_state = VISIBLE_STATE_ATTENTION; - } + goal_state = VISIBLE_STATE_SHOWN; } /* Nothing needs to change, we're good */ @@ -503,7 +498,7 @@ apply_status (Application * app) } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; - if (goal_state == VISIBLE_STATE_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { + if (app->status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { newicon = app->aicon; } @@ -565,7 +560,7 @@ new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata if (app->icon != NULL) g_free(app->icon); app->icon = g_strdup(newicon); - if (app->visible_state == VISIBLE_STATE_NORMAL) { + if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ACTIVE) { gint position = get_position(app); if (position == -1) return; @@ -603,7 +598,7 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat if (app->aicon != NULL) g_free(app->aicon); app->aicon = g_strdup(newicon); - if (app->visible_state == VISIBLE_STATE_ATTENTION) { + if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ATTENTION) { gint position = get_position(app); if (position == -1) return; -- cgit v1.2.3 From d72265317345f41ea39f306c149fcf098ba1194e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:12:40 -0500 Subject: Handle the proxy being destroyed, and cleaning up the approver. --- src/application-service-appstore.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0991286..00de4b9 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1017,6 +1017,42 @@ check_with_new_approver (gpointer papp, gpointer papprove) return; } +/* Look through all the approvers and find the one with a given + proxy. */ +static gint +approver_find_by_proxy (gconstpointer papprover, gconstpointer pproxy) +{ + Approver * approver = (Approver *)papprover; + + if (approver->proxy == pproxy) { + return 0; + } + + return -1; +} + +/* Tracks when a proxy gets destroyed so that we know that the + approver has dropped off the bus. */ +static void +approver_destroyed (gpointer pproxy, gpointer pappstore) +{ + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(pappstore); + + GList * lapprover = g_list_find_custom(appstore->priv->approvers, pproxy, approver_find_by_proxy); + if (lapprover == NULL) { + g_warning("Approver proxy died, but we don't seem to have that approver."); + return; + } + + Approver * approver = (Approver *)lapprover->data; + approver->proxy = NULL; + + appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); + approver_free(approver, appstore); + + return; +} + /* Adds a new approver to the app store */ void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) @@ -1041,6 +1077,8 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore return; } + g_signal_connect(G_OBJECT(approver->proxy), "destroy", G_CALLBACK(approver_destroyed), appstore); + priv->approvers = g_list_prepend(priv->approvers, approver); g_list_foreach(priv->applications, check_with_new_approver, approver); -- cgit v1.2.3 From fa45eaa48e679ddf2c264185e624723a7c1c27ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:22:24 -0500 Subject: Switching the get_position() function to look at the visibility of the applications. --- src/application-service-appstore.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 00de4b9..1b10033 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -342,18 +342,34 @@ string_to_status(const gchar * status_string) } /* A small helper function to get the position of an application - in the app list. */ + in the app list of the applications that are visible. */ static gint get_position (Application * app) { ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; - GList * applistitem = g_list_find(priv->applications, app); - if (applistitem == NULL) { - return -1; + GList * lapp; + gint count; + + /* Go through the list and try to find ours */ + for (lapp = priv->applications, count = 0; lapp != NULL; lapp = g_list_next(lapp), count++) { + if (lapp->data == app) { + break; + } + + /* If the selected app isn't visible let's not + count it's position */ + Application * thisapp = (Application *)(lapp->data); + if (thisapp->visible_state == VISIBLE_STATE_HIDDEN) { + count--; + } } - return g_list_position(priv->applications, applistitem); + if (lapp == NULL) { + return -1; + } + + return count; } /* A simple global function for dealing with freeing the information -- cgit v1.2.3 From 98252b227acb7d969aed26490dab7cba13298a7c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:26:47 -0500 Subject: Making sure to only list the visible applications. --- src/application-service-appstore.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 1b10033..6e666bc 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -914,6 +914,10 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { Application * app = (Application *)listpntr->data; + if (app->visible_state == VISIBLE_STATE_HIDDEN) { + continue; + } + GValueArray * values = g_value_array_new(5); GValue value = {0}; -- cgit v1.2.3 From 7a4bfc9135ea55b0f495513fbd7ad2734b328098 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Aug 2010 22:31:25 -0500 Subject: Changing it so that the list of applications has all the applications in it, independent of visible state. --- src/application-service-appstore.c | 56 ++++++++++---------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 6e666bc..4ba2aca 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -114,6 +114,7 @@ static void application_service_appstore_class_init (ApplicationServiceAppstoreC static void application_service_appstore_init (ApplicationServiceAppstore *self); static void application_service_appstore_dispose (GObject *object); static void application_service_appstore_finalize (GObject *object); +static gint app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata); static AppIndicatorStatus string_to_status(const gchar * status_string); static void apply_status (Application * app); static void approver_free (gpointer papprover, gpointer user_data); @@ -244,6 +245,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err { if (error != NULL) { g_warning("Unable to get properties: %s", error->message); + /* TODO: We need to free all the application data here */ return; } @@ -304,6 +306,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = g_strdup(""); } + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); g_list_foreach(priv->approvers, check_with_old_approver, app); apply_status(app); @@ -445,30 +448,6 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) return; } -/* Look and see if an application exists in the application - list already */ -static gboolean -can_add_application (GList *applications, Application *app) -{ - if (applications) - { - GList *l = NULL; - - for (l = applications; l != NULL; l = g_list_next (l)) - { - Application *tmp_app = (Application *)l->data; - - if (g_strcmp0 (tmp_app->dbus_name, app->dbus_name) == 0 && - g_strcmp0 (tmp_app->dbus_object, app->dbus_object) == 0) - { - return FALSE; - } - } - } - - return TRUE; -} - /* This function takes two Application structure pointers and uses the lrufile to compare them. */ static gint @@ -510,7 +489,6 @@ apply_status (Application * app) g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); - priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; @@ -520,21 +498,17 @@ apply_status (Application * app) /* Determine whether we're already shown or not */ if (app->visible_state == VISIBLE_STATE_HIDDEN) { - if (can_add_application (priv->applications, app)) { - /* Put on panel */ - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ADDED], 0, - newicon, - g_list_index(priv->applications, app), /* Position */ - app->dbus_name, - app->menu, - app->icon_theme_path, - app->label, - app->guide, - TRUE); - } + /* Put on panel */ + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + newicon, + g_list_index(priv->applications, app), /* Position */ + app->dbus_name, + app->menu, + app->icon_theme_path, + app->label, + app->guide, + TRUE); } else { /* Icon update */ gint position = get_position(app); @@ -867,7 +841,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst } /* Removes an application. Currently only works for the apps - that are shown. /TODO Need to fix that. */ + that are shown. */ void application_service_appstore_application_remove (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { -- cgit v1.2.3 From d81670cc9cf081b1296561d9da2176975da7643b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Aug 2010 13:40:00 -0500 Subject: 0.2.4 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9ac78ec..0b57308 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(indicator-application, 0.2.3, ted@canonical.com) +AC_INIT(indicator-application, 0.2.4, ted@canonical.com) AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-application, 0.2.3) +AM_INIT_AUTOMAKE(indicator-application, 0.2.4) AM_MAINTAINER_MODE -- cgit v1.2.3 From eadc69dd38700b68d314bc30d9a78e8400c22042 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 09:50:46 -0500 Subject: Freeing the allocated keys. --- src/application-service-appstore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4ac1576..9764798 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -298,6 +298,7 @@ load_override_file (GHashTable * hash, const gchar * filename) g_hash_table_insert(hash, g_strdup(key), GINT_TO_POINTER(val)); } + g_strfreev(keys); g_key_file_free(keyfile); return; -- cgit v1.2.3 From c04a7cf4f33a7079be7718b72c5408f51f225ca3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 12:24:11 -0500 Subject: Uhg, broken merge. --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 57c4671..771f2af 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -392,7 +392,7 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->guide = g_strdup(""); } - priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile); + priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, NULL); g_list_foreach(priv->approvers, check_with_old_approver, app); apply_status(app); -- cgit v1.2.3 From a0023d1bfb43aeb51d7b259dfc23c32139c8b14c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 14:01:38 -0500 Subject: Responding to approver errors like they're approval. --- src/application-service-appstore.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 771f2af..056f0e1 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1083,10 +1083,15 @@ approver_free (gpointer papprover, gpointer user_data) static void approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) { - g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + if (error == NULL) { + g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); + } else { + g_debug("Approver responded error: %s", error->message); + } + Application * app = (Application *)userdata; - if (OUT_approved) { + if (OUT_approved || error != NULL) { app->approved_by = g_list_prepend(app->approved_by, proxy); } else { app->approved_by = g_list_remove(app->approved_by, proxy); -- cgit v1.2.3 From ba5b85a76a469fb5fa860a723ffd09c939bc7f0e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Aug 2010 14:01:57 -0500 Subject: Making sure to remove our applications from the list as well. --- src/application-service-appstore.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 056f0e1..73fc5d1 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -551,6 +551,9 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) app->status = APP_INDICATOR_STATUS_PASSIVE; apply_status(app); + /* Remove from the application list */ + app->appstore->priv->applications = g_list_remove(app->appstore->priv->applications, app); + /* Destroy the data */ application_free(app); return; -- cgit v1.2.3 From 93f92e8e6a6bda708d227f3ebe9c8dae15694b9e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:41:02 -0500 Subject: Making the list so that if there are errors we handle them well. --- src/application-service-appstore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 73fc5d1..85d72f7 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -578,10 +578,12 @@ apply_status (Application * app) ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; + g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); + visible_state_t goal_state = VISIBLE_STATE_HIDDEN; if (app->status != APP_INDICATOR_STATUS_PASSIVE && - g_list_length(app->approved_by) == g_list_length(priv->approvers)) { + g_list_length(app->approved_by) >= g_list_length(priv->approvers)) { goal_state = VISIBLE_STATE_SHOWN; } -- cgit v1.2.3 From fb1811ef2421e512b49bc5bb5c2796ba669ca29f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:42:41 -0500 Subject: Making it so that we don't set the proxy to null right away. --- src/application-service-appstore.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 85d72f7..9f1920d 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -75,6 +75,7 @@ typedef enum { typedef struct _Approver Approver; struct _Approver { DBusGProxy * proxy; + gboolean destroy_by_proxy; }; typedef struct _Application Application; @@ -1076,7 +1077,9 @@ approver_free (gpointer papprover, gpointer user_data) g_list_foreach(appstore->priv->applications, remove_approver, approver->proxy); if (approver->proxy != NULL) { - g_object_unref(approver->proxy); + if (!approver->destroy_by_proxy) { + g_object_unref(approver->proxy); + } approver->proxy = NULL; } @@ -1153,7 +1156,7 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) } Approver * approver = (Approver *)lapprover->data; - approver->proxy = NULL; + approver->destroy_by_proxy = TRUE; appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); approver_free(approver, appstore); @@ -1171,6 +1174,7 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (appstore); Approver * approver = g_new0(Approver, 1); + approver->destroy_by_proxy = FALSE; GError * error = NULL; approver->proxy = dbus_g_proxy_new_for_name_owner(priv->bus, -- cgit v1.2.3 From 72c93f2c3aea90bc18a694a723915f33701a021b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 12:43:38 -0500 Subject: Commenting out debug message --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 9f1920d..30af2ea 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -579,7 +579,7 @@ apply_status (Application * app) ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = appstore->priv; - g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); + /* g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); */ visible_state_t goal_state = VISIBLE_STATE_HIDDEN; -- cgit v1.2.3 From 1d51365ac7ecc5299f49c1c8a1985caa16a125c9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 10:27:53 -0500 Subject: XAyatana the register interface --- src/notification-watcher.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notification-watcher.xml b/src/notification-watcher.xml index cc7882d..5f19dd2 100644 --- a/src/notification-watcher.xml +++ b/src/notification-watcher.xml @@ -22,7 +22,7 @@ - + -- cgit v1.2.3 From a1e4f99efd90621eb9615ca761e65a37f941cbe8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 10:29:09 -0500 Subject: Changing function name as well. --- src/application-service-watcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application-service-watcher.c b/src/application-service-watcher.c index 4fe3bc7..5b77620 100644 --- a/src/application-service-watcher.c +++ b/src/application-service-watcher.c @@ -34,7 +34,7 @@ static gboolean _notification_watcher_server_register_status_notifier_item (Appl static gboolean _notification_watcher_server_registered_status_notifier_items (ApplicationServiceWatcher * appwatcher, GArray ** apps); static gboolean _notification_watcher_server_protocol_version (ApplicationServiceWatcher * appwatcher, char ** version); static gboolean _notification_watcher_server_register_notification_host (ApplicationServiceWatcher * appwatcher, const gchar * host); -static gboolean _notification_watcher_server_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method); +static gboolean _notification_watcher_server_x_ayatana_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method); static gboolean _notification_watcher_server_is_notification_host_registered (ApplicationServiceWatcher * appwatcher, gboolean * haveHost); static void get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data); @@ -252,7 +252,7 @@ get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data) } static gboolean -_notification_watcher_server_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method) +_notification_watcher_server_x_ayatana_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method) { ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(appwatcher); -- cgit v1.2.3 From 12c8cd4a0caa402426b23adad343e83d05d27d3f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 10:31:20 -0500 Subject: Adding a signal to the approver interface --- src/notification-approver.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/notification-approver.xml b/src/notification-approver.xml index b1e69b9..4a8e39b 100644 --- a/src/notification-approver.xml +++ b/src/notification-approver.xml @@ -18,5 +18,12 @@ + + + + + + + -- cgit v1.2.3 From ca213633c7a98b7d9dd37a5a373f7ef825098eeb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:02:47 -0500 Subject: Connecting into the signal coming from the approver --- src/application-service-appstore.c | 29 +++++++++++++++++++++++++++++ src/application-service-marshal.list | 1 + 2 files changed, 30 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 30af2ea..789ca48 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -183,6 +183,12 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_application_service_marshal_VOID__BOOLEAN_STRING_OBJECT, + G_TYPE_NONE, + G_TYPE_BOOLEAN, + G_TYPE_STRING, + G_TYPE_OBJECT, + G_TYPE_INVALID); dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, &dbus_glib__application_service_server_object_info); @@ -1164,6 +1170,17 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) return; } +/* A signal when an approver changes the why that it thinks about + a particular indicator. */ +void +approver_revise_judgement (DBusGProxy * proxy, gboolean new_status, gchar * address, DBusGProxy * get_path, gpointer user_data) +{ + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); + appstore = NULL; + + return; +} + /* Adds a new approver to the app store */ void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) @@ -1191,6 +1208,18 @@ application_service_appstore_approver_add (ApplicationServiceAppstore * appstore g_signal_connect(G_OBJECT(approver->proxy), "destroy", G_CALLBACK(approver_destroyed), appstore); + dbus_g_proxy_add_signal(approver->proxy, + "ReviseJudgement", + G_TYPE_BOOLEAN, + G_TYPE_STRING, + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(approver->proxy, + "ReviseJudgement", + G_CALLBACK(approver_revise_judgement), + appstore, + NULL); + priv->approvers = g_list_prepend(priv->approvers, approver); g_list_foreach(priv->applications, check_with_new_approver, approver); diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index f432028..2b2efa5 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -20,3 +20,4 @@ VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING VOID: INT, STRING, STRING VOID: INT, STRING VOID: STRING, STRING +VOID: BOOL, STRING, OBJECT -- cgit v1.2.3 From 1865cf3b4e415dcb8b9cf85208ab88596d00b043 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:26:10 -0500 Subject: Refactor so that there is a function to look for applications. --- src/application-service-appstore.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 789ca48..7040b2a 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -959,6 +959,24 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst return; } +/* Looks for an application in the list of applications */ +static Application * +find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object) +{ + ApplicationServiceAppstorePrivate * priv = appstore->priv; + GList * listpntr; + + for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { + Application * app = (Application *)listpntr->data; + + if (!g_strcmp0(app->dbus_name, address) && !g_strcmp0(app->dbus_object, object)) { + return app; + } + } + + return NULL; +} + /* Removes an application. Currently only works for the apps that are shown. */ void @@ -968,16 +986,11 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); - ApplicationServiceAppstorePrivate * priv = appstore->priv; - GList * listpntr; - - for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { - Application * app = (Application *)listpntr->data; - - if (!g_strcmp0(app->dbus_name, dbus_name) && !g_strcmp0(app->dbus_object, dbus_object)) { - application_removed_cb(NULL, app); - break; /* NOTE: Must break as the list will become inconsistent */ - } + Application * app = find_application(appstore, dbus_name, dbus_object); + if (app != NULL) { + application_removed_cb(NULL, app); + } else { + g_warning("Unable to find application %s:%s", dbus_name, dbus_object); } return; -- cgit v1.2.3 From 9fc60ae8675fe81a3c051e5f4de0378ecfd75069 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 18 Aug 2010 14:26:38 -0500 Subject: Flesh out the revise judgement handler to update the list of approvers. --- src/application-service-appstore.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 7040b2a..2d77d28 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1188,8 +1188,27 @@ approver_destroyed (gpointer pproxy, gpointer pappstore) void approver_revise_judgement (DBusGProxy * proxy, gboolean new_status, gchar * address, DBusGProxy * get_path, gpointer user_data) { + g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(user_data)); + g_return_if_fail(address != NULL && address[0] != '\0'); + g_return_if_fail(get_path != NULL); + const gchar * path = dbus_g_proxy_get_path(get_path); + g_return_if_fail(path != NULL && path[0] != '\0'); + ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); - appstore = NULL; + + Application * app = find_application(appstore, address, path); + + if (app == NULL) { + g_warning("Unable to update approver status of application (%s:%s) as it was not found", address, path); + return; + } + + if (new_status) { + app->approved_by = g_list_prepend(app->approved_by, proxy); + } else { + app->approved_by = g_list_remove(app->approved_by, proxy); + } + apply_status(app); return; } -- cgit v1.2.3 From ced17927880fc723477afd0a7ee4be7aee9eac32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Aug 2010 13:56:42 -0500 Subject: Fix approver for function change --- tests/test-approver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-approver.c b/tests/test-approver.c index bc25761..2665505 100644 --- a/tests/test-approver.c +++ b/tests/test-approver.c @@ -128,7 +128,7 @@ check_for_service (gpointer user_data) NOTIFICATION_WATCHER_DBUS_IFACE); g_debug("Registering Approver"); - org_kde_StatusNotifierWatcher_register_notification_approver_async (proxy, APPROVER_PATH, &cats, register_cb, NULL); + org_kde_StatusNotifierWatcher_x_ayatana_register_notification_approver_async (proxy, APPROVER_PATH, &cats, register_cb, NULL); return FALSE; } -- cgit v1.2.3 From b51c1debf9807ad357564975c394badbafccaa1b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Aug 2010 13:56:53 -0500 Subject: 0.2.5 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 0b57308..035c9da 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(indicator-application, 0.2.4, ted@canonical.com) +AC_INIT(indicator-application, 0.2.5, ted@canonical.com) AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-application, 0.2.4) +AM_INIT_AUTOMAKE(indicator-application, 0.2.5) AM_MAINTAINER_MODE -- cgit v1.2.3