diff options
author | Ted Gould <ted@gould.cx> | 2010-08-11 12:11:34 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-11 12:11:34 -0500 |
commit | 68b74230e9641ddd34e2ff48f9be982f15ea58c6 (patch) | |
tree | 1992840ebd3c863d3e797fed2df9b8f37658b8a3 /src/generate-id.c | |
parent | 5dcb1d4db537966b7cc685dcba2a6e5352476232 (diff) | |
parent | 0dd2e79a84c137ed4846bfd145ce362dcade3477 (diff) | |
download | libayatana-appindicator-68b74230e9641ddd34e2ff48f9be982f15ea58c6.tar.gz libayatana-appindicator-68b74230e9641ddd34e2ff48f9be982f15ea58c6.tar.bz2 libayatana-appindicator-68b74230e9641ddd34e2ff48f9be982f15ea58c6.zip |
* Upstream Merge
* Cleaning up the ID creation and ordering to put low numbers to
the right.
Diffstat (limited to 'src/generate-id.c')
-rw-r--r-- | src/generate-id.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/generate-id.c b/src/generate-id.c index 6855b39..a504e44 100644 --- a/src/generate-id.c +++ b/src/generate-id.c @@ -21,40 +21,49 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #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 gchar 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; - u.str.category = category; + switch (catenum) { + case APP_INDICATOR_CATEGORY_OTHER: + category = MULTIPLIER * 5; + break; + case APP_INDICATOR_CATEGORY_APPLICATION_STATUS: + category = MULTIPLIER * 4; + break; + case APP_INDICATOR_CATEGORY_COMMUNICATIONS: + category = MULTIPLIER * 3; + break; + case APP_INDICATOR_CATEGORY_SYSTEM_SERVICES: + category = MULTIPLIER * 2; + break; + case APP_INDICATOR_CATEGORY_HARDWARE: + category = MULTIPLIER * 1; + break; + default: + g_warning("Got an undefined category: %d", category); + 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; } |