summaryrefslogtreecommitdiff
path: root/src/lib/efreet/efreet_menu.c
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-20 09:58:41 +0200
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-20 11:56:46 +0200
commite8ff0e7b688d80dece749f595ece3ed65f2ccc6a (patch)
treeebf331783861bb5851cbfd453fab8f1fb74e86d3 /src/lib/efreet/efreet_menu.c
parent3190e526f4eca4df1d4dab81cd9fbd0a0146b11c (diff)
efreet: Init efreet_menu_prefix in init
Makes efreet_menu_prefix access threadsafe
Diffstat (limited to 'src/lib/efreet/efreet_menu.c')
-rw-r--r--src/lib/efreet/efreet_menu.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/lib/efreet/efreet_menu.c b/src/lib/efreet/efreet_menu.c
index b95d23fc0b..bdd173a403 100644
--- a/src/lib/efreet/efreet_menu.c
+++ b/src/lib/efreet/efreet_menu.c
@@ -164,8 +164,6 @@ static Eina_Hash *efreet_menu_filter_cbs = NULL;
164static Eina_Hash *efreet_menu_move_cbs = NULL; 164static Eina_Hash *efreet_menu_move_cbs = NULL;
165static Eina_Hash *efreet_menu_layout_cbs = NULL; 165static Eina_Hash *efreet_menu_layout_cbs = NULL;
166 166
167static const char *efreet_menu_prefix_get(void);
168
169static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal, 167static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal,
170 const char *name, 168 const char *name,
171 Efreet_Menu_Internal **parent); 169 Efreet_Menu_Internal **parent);
@@ -385,6 +383,9 @@ efreet_menu_init(void)
385 return 0; 383 return 0;
386 } 384 }
387 385
386 efreet_menu_prefix = getenv("XDG_MENU_PREFIX");
387 if (!efreet_menu_prefix) efreet_menu_prefix = "";
388
388 efreet_menu_handle_cbs = eina_hash_string_superfast_new(NULL); 389 efreet_menu_handle_cbs = eina_hash_string_superfast_new(NULL);
389 efreet_menu_filter_cbs = eina_hash_string_superfast_new(NULL); 390 efreet_menu_filter_cbs = eina_hash_string_superfast_new(NULL);
390 efreet_menu_move_cbs = eina_hash_string_superfast_new(NULL); 391 efreet_menu_move_cbs = eina_hash_string_superfast_new(NULL);
@@ -524,7 +525,7 @@ efreet_menu_get(void)
524 525
525 /* check the users config directory first */ 526 /* check the users config directory first */
526 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu", 527 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
527 efreet_config_home_get(), efreet_menu_prefix_get()); 528 efreet_config_home_get(), efreet_menu_prefix);
528 if (ecore_file_exists(menu)) 529 if (ecore_file_exists(menu))
529 return efreet_menu_parse(menu); 530 return efreet_menu_parse(menu);
530 531
@@ -533,7 +534,7 @@ efreet_menu_get(void)
533 EINA_LIST_FOREACH(config_dirs, l, dir) 534 EINA_LIST_FOREACH(config_dirs, l, dir)
534 { 535 {
535 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu", 536 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
536 dir, efreet_menu_prefix_get()); 537 dir, efreet_menu_prefix);
537 if (ecore_file_exists(menu)) 538 if (ecore_file_exists(menu))
538 return efreet_menu_parse(menu); 539 return efreet_menu_parse(menu);
539 } 540 }
@@ -881,22 +882,6 @@ efreet_menu_internal_free(Efreet_Menu_Internal *internal)
881 882
882/** 883/**
883 * @internal 884 * @internal
884 * @return Returns the XDG_MENU_PREFIX env variable or "" if none set
885 * @brief Retrieves the XDG_MENU_PREFIX or "" if not set.
886 */
887static const char *
888efreet_menu_prefix_get(void)
889{
890 if (efreet_menu_prefix) return efreet_menu_prefix;
891
892 efreet_menu_prefix = getenv("XDG_MENU_PREFIX");
893 if (!efreet_menu_prefix) efreet_menu_prefix = "";
894
895 return efreet_menu_prefix;
896}
897
898/**
899 * @internal
900 * @param menu The menu to populate 885 * @param menu The menu to populate
901 * @param xml The xml dom tree to populate from 886 * @param xml The xml dom tree to populate from
902 * @return Returns 1 if this XML tree is valid, 0 otherwise 887 * @return Returns 1 if this XML tree is valid, 0 otherwise
@@ -1595,18 +1580,16 @@ efreet_menu_handle_default_merge_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *
1595#ifndef STRICT_SPEC 1580#ifndef STRICT_SPEC
1596 char parent_path[PATH_MAX]; 1581 char parent_path[PATH_MAX];
1597#endif 1582#endif
1598 const char *prefix;
1599 1583
1600 if (!parent || !xml) return 0; 1584 if (!parent || !xml) return 0;
1601 1585
1602 prefix = efreet_menu_prefix_get(); 1586 if (!strcmp(efreet_menu_prefix, "gnome-") &&
1603 if (!strcmp(prefix, "gnome-") &&
1604 (!strcmp(parent->file.name, "gnome-applications.menu"))) 1587 (!strcmp(parent->file.name, "gnome-applications.menu")))
1605 { 1588 {
1606 p = alloca(sizeof("applications")); 1589 p = alloca(sizeof("applications"));
1607 memcpy(p, "applications", sizeof("applications")); 1590 memcpy(p, "applications", sizeof("applications"));
1608 } 1591 }
1609 else if ((!strcmp(prefix, "kde-") && 1592 else if ((!strcmp(efreet_menu_prefix, "kde-") &&
1610 (!strcmp(parent->file.name, "kde-applications.menu")))) 1593 (!strcmp(parent->file.name, "kde-applications.menu"))))
1611 { 1594 {
1612 p = alloca(sizeof("applications")); 1595 p = alloca(sizeof("applications"));