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