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 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