aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-10 21:26:08 -0500
committerTed Gould <ted@gould.cx>2010-08-10 21:26:08 -0500
commit21fcf7a390364a622f3f51d529f33603983a78e8 (patch)
treed6bb72442c33caac9966fe02b652393c7ab485af
parent1c31b31680c5664bb2034f1c4374312b57f29ea7 (diff)
parent51de4ced42e132fa3a66a2739e8a3ba861842467 (diff)
downloadlibayatana-appindicator-21fcf7a390364a622f3f51d529f33603983a78e8.tar.gz
libayatana-appindicator-21fcf7a390364a622f3f51d529f33603983a78e8.tar.bz2
libayatana-appindicator-21fcf7a390364a622f3f51d529f33603983a78e8.zip
* Upstream Merge
* Adding in override files for the ordering IDs
-rw-r--r--data/Makefile.am10
-rw-r--r--data/ordering-override.keyfile2
-rw-r--r--debian/changelog7
-rw-r--r--src/Makefile.am1
-rw-r--r--src/application-service-appstore.c78
5 files changed, 92 insertions, 6 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index cc1961b..c142c4e 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 = $(pkgdatadir)
+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
diff --git a/debian/changelog b/debian/changelog
index fa3b845..76926b4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+indicator-application (0.2.3-0ubuntu2~ppa5~order2) UNRELEASED; urgency=low
+
+ * Upstream Merge
+ * Adding in override files for the ordering IDs
+
+ -- Ted Gould <ted@ubuntu.com> Tue, 10 Aug 2010 21:23:31 -0500
+
indicator-application (0.2.3-0ubuntu2~ppa5~order1) maverick; urgency=low
* Upstream Merge
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 5fc4f9b..d632456 100644
--- a/src/application-service-appstore.c
+++ b/src/application-service-appstore.c
@@ -56,11 +56,15 @@ 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"
+#define OVERRIDE_FILE_NAME "ordering-override.keyfile"
+
/* Private Stuff */
struct _ApplicationServiceAppstorePrivate {
DBusGConnection * bus;
GList * applications;
GList * approvers;
+ GHashTable * ordering_overrides;
};
typedef struct _Approver Approver;
@@ -109,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);
@@ -183,6 +188,13 @@ 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);
+
+ 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);
@@ -225,11 +237,64 @@ 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;
}
+/* Loads the file and adds the override entries to the table
+ of overrides */
+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
and making sure we have everythign that we need. If we do, then we'll
move on up to sending this onto the indicator. */
@@ -281,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);