~ted/libindicator/lp942042

« back to all changes in this revision

Viewing changes to libindicator/indicator-desktop-shortcuts.c

  • Committer: Ted Gould
  • Date: 2012-02-27 19:32:25 UTC
  • Revision ID: ted@gould.cx-20120227193225-q90a1quh5s32hkwm
Changing our defines around to make sure to mark things the way that we think about them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <gio/gdesktopappinfo.h>
29
29
#include "indicator-desktop-shortcuts.h"
30
30
 
31
 
#define GROUP_SUFFIX          "Shortcut Group"
32
 
#define SHORTCUTS_KEY         "X-Ayatana-Desktop-Shortcuts"
33
 
#define ENVIRON_KEY           "TargetEnvironment"
 
31
#define ACTIONS_KEY               "Actions"
 
32
#define ACTION_GROUP_PREFIX       "Desktop Action"
 
33
 
 
34
#define OLD_GROUP_SUFFIX          "Shortcut Group"
 
35
#define OLD_SHORTCUTS_KEY         "X-Ayatana-Desktop-Shortcuts"
 
36
#define OLD_ENVIRON_KEY           "TargetEnvironment"
34
37
 
35
38
#define PROP_DESKTOP_FILE_S   "desktop-file"
36
39
#define PROP_IDENTITY_S       "identity"
173
176
                        break;
174
177
                }
175
178
 
176
 
                if (!g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, SHORTCUTS_KEY, NULL)) {
 
179
                if (!g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, OLD_SHORTCUTS_KEY, NULL)) {
177
180
                        g_key_file_free(keyfile);
178
181
                        break;
179
182
                }
256
259
        /* Okay, we've got everything we need.  Let's get it on! */
257
260
        gint i;
258
261
        gsize num_nicks = 0;
259
 
        gchar ** nicks = g_key_file_get_string_list(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, SHORTCUTS_KEY, &num_nicks, NULL);
 
262
        gchar ** nicks = g_key_file_get_string_list(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, OLD_SHORTCUTS_KEY, &num_nicks, NULL);
260
263
 
261
264
        /* If there is an error from get_string_list num_nicks should still
262
265
           be zero, so this loop will drop out. */
263
266
        for (i = 0; i < num_nicks; i++) {
264
267
                /* g_debug("Looking at group nick %s", nicks[i]); */
265
 
                gchar * groupname = g_strdup_printf("%s " GROUP_SUFFIX, nicks[i]);
 
268
                gchar * groupname = g_strdup_printf("%s " OLD_GROUP_SUFFIX, nicks[i]);
266
269
                if (!g_key_file_has_group(priv->keyfile, groupname)) {
267
270
                        g_warning("Unable to find group '%s'", groupname);
268
271
                        g_free(groupname);
296
299
static gboolean
297
300
should_show (GKeyFile * keyfile, const gchar * group, const gchar * identity, gboolean should_have_target)
298
301
{
299
 
        if (should_have_target && g_key_file_has_key(keyfile, group, ENVIRON_KEY, NULL)) {
 
302
        if (should_have_target && g_key_file_has_key(keyfile, group, OLD_ENVIRON_KEY, NULL)) {
300
303
                /* If we've got this key, we're going to return here and not
301
304
                   process the deprecated keys. */
302
305
                gint j;
303
306
                gsize num_env = 0;
304
 
                gchar ** envs = g_key_file_get_string_list(keyfile, group, ENVIRON_KEY, &num_env, NULL);
 
307
                gchar ** envs = g_key_file_get_string_list(keyfile, group, OLD_ENVIRON_KEY, &num_env, NULL);
305
308
 
306
309
                for (j = 0; j < num_env; j++) {
307
310
                        if (g_strcmp0(envs[j], identity) == 0) {
319
322
                return TRUE;    
320
323
        } else {
321
324
                if (should_have_target) {
322
 
                        g_warning(GROUP_SUFFIX " does not have key '" ENVIRON_KEY "' falling back to deprecated use of '" G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "' and '" G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "'.");
 
325
                        g_warning(OLD_GROUP_SUFFIX " does not have key '" OLD_ENVIRON_KEY "' falling back to deprecated use of '" G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "' and '" G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "'.");
323
326
                }
324
327
        }
325
328
 
452
455
        g_return_val_if_fail(priv->keyfile != NULL, NULL);
453
456
        g_return_val_if_fail(is_valid_nick((gchar **)priv->nicks->data, nick), NULL);
454
457
 
455
 
        gchar * groupheader = g_strdup_printf("%s " GROUP_SUFFIX, nick);
 
458
        gchar * groupheader = g_strdup_printf("%s " OLD_GROUP_SUFFIX, nick);
456
459
        if (!g_key_file_has_group(priv->keyfile, groupheader)) {
457
460
                g_warning("The group for nick '%s' doesn't exist anymore.", nick);
458
461
                g_free(groupheader);
512
515
        g_return_val_if_fail(priv->keyfile != NULL, FALSE);
513
516
        g_return_val_if_fail(is_valid_nick((gchar **)priv->nicks->data, nick), FALSE);
514
517
 
515
 
        gchar * groupheader = g_strdup_printf("%s " GROUP_SUFFIX, nick);
 
518
        gchar * groupheader = g_strdup_printf("%s " OLD_GROUP_SUFFIX, nick);
516
519
        if (!g_key_file_has_group(priv->keyfile, groupheader)) {
517
520
                g_warning("The group for nick '%s' doesn't exist anymore.", nick);
518
521
                g_free(groupheader);