summaryrefslogtreecommitdiff
path: root/src/lib/efreet/efreet_menu.c
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-19 14:45:13 +0200
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-20 11:56:46 +0200
commit3190e526f4eca4df1d4dab81cd9fbd0a0146b11c (patch)
tree2c85624c7fd51fbb2e14e07b9233ea1c79dd844e /src/lib/efreet/efreet_menu.c
parente5f4fa4454c0892ba1537c273ad24215fe5a1820 (diff)
efreet: Remove static variable
Diffstat (limited to 'src/lib/efreet/efreet_menu.c')
-rw-r--r--src/lib/efreet/efreet_menu.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/lib/efreet/efreet_menu.c b/src/lib/efreet/efreet_menu.c
index 8b8a482c5c..b95d23fc0b 100644
--- a/src/lib/efreet/efreet_menu.c
+++ b/src/lib/efreet/efreet_menu.c
@@ -36,6 +36,9 @@ struct Efreet_Menu_Internal
36 const char *name; /**< Name to use in the menus */ 36 const char *name; /**< Name to use in the menus */
37 } name; /**< The names for this menu */ 37 } name; /**< The names for this menu */
38 38
39 Eina_Hash *efreet_merged_menus; /**< Merged menus */
40 Eina_Hash *efreet_merged_dirs; /**< Merged dirs */
41
39 Efreet_Desktop *directory; /**< The directory */ 42 Efreet_Desktop *directory; /**< The directory */
40 Eina_List *directories; /**< All the directories set in the menu file */ 43 Eina_List *directories; /**< All the directories set in the menu file */
41 44
@@ -156,9 +159,6 @@ Eina_List *efreet_menu_kde_legacy_dirs = NULL; /**< The directories to use for K
156static const char *efreet_tag_menu = NULL; 159static const char *efreet_tag_menu = NULL;
157static const char *efreet_menu_file = NULL; /**< A menu file set explicityl as default */ 160static const char *efreet_menu_file = NULL; /**< A menu file set explicityl as default */
158 161
159static Eina_Hash *efreet_merged_menus = NULL;
160static Eina_Hash *efreet_merged_dirs = NULL;
161
162static Eina_Hash *efreet_menu_handle_cbs = NULL; 162static Eina_Hash *efreet_menu_handle_cbs = NULL;
163static Eina_Hash *efreet_menu_filter_cbs = NULL; 163static Eina_Hash *efreet_menu_filter_cbs = NULL;
164static Eina_Hash *efreet_menu_move_cbs = NULL; 164static Eina_Hash *efreet_menu_move_cbs = NULL;
@@ -212,7 +212,7 @@ static void efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Inter
212 Efreet_Menu_Layout *layout); 212 Efreet_Menu_Layout *layout);
213static int efreet_menu_layout_is_empty(Efreet_Menu *entry); 213static int efreet_menu_layout_is_empty(Efreet_Menu *entry);
214 214
215static Efreet_Menu_Internal *efreet_menu_internal_new(void); 215static Efreet_Menu_Internal *efreet_menu_internal_new(Efreet_Menu_Internal *parent);
216static void efreet_menu_internal_free(Efreet_Menu_Internal *internal); 216static void efreet_menu_internal_free(Efreet_Menu_Internal *internal);
217static void efreet_menu_create_sub_menu_list(Efreet_Menu_Internal *internal); 217static void efreet_menu_create_sub_menu_list(Efreet_Menu_Internal *internal);
218static void efreet_menu_create_app_dirs_list(Efreet_Menu_Internal *internal); 218static void efreet_menu_create_app_dirs_list(Efreet_Menu_Internal *internal);
@@ -479,9 +479,6 @@ efreet_menu_shutdown(void)
479 479
480 IF_FREE_LIST(efreet_menu_kde_legacy_dirs, eina_stringshare_del); 480 IF_FREE_LIST(efreet_menu_kde_legacy_dirs, eina_stringshare_del);
481 481
482 IF_FREE_HASH(efreet_merged_menus);
483 IF_FREE_HASH(efreet_merged_dirs);
484
485 IF_RELEASE(efreet_tag_menu); 482 IF_RELEASE(efreet_tag_menu);
486 483
487 eina_log_domain_unregister(_efreet_menu_log_dom); 484 eina_log_domain_unregister(_efreet_menu_log_dom);
@@ -564,15 +561,11 @@ efreet_menu_parse(const char *path)
564 return NULL; 561 return NULL;
565 } 562 }
566 563
567 IF_FREE_HASH(efreet_merged_menus);
568 efreet_merged_menus = eina_hash_string_superfast_new(NULL);
569
570 IF_FREE_HASH(efreet_merged_dirs);
571 efreet_merged_dirs = eina_hash_string_superfast_new(NULL);
572
573 /* split apart the filename and the path */ 564 /* split apart the filename and the path */
574 internal = efreet_menu_internal_new(); 565 internal = efreet_menu_internal_new(NULL);
575 if (!internal) return NULL; 566 if (!internal) return NULL;
567 internal->efreet_merged_menus = eina_hash_string_superfast_new(NULL);
568 internal->efreet_merged_dirs = eina_hash_string_superfast_new(NULL);
576 569
577 /* Set default values */ 570 /* Set default values */
578 internal->show_empty = 0; 571 internal->show_empty = 0;
@@ -614,6 +607,8 @@ efreet_menu_parse(const char *path)
614 607
615 /* layout menu */ 608 /* layout menu */
616 entry = efreet_menu_layout_menu(internal); 609 entry = efreet_menu_layout_menu(internal);
610 IF_FREE_HASH(internal->efreet_merged_menus);
611 IF_FREE_HASH(internal->efreet_merged_dirs);
617 efreet_menu_internal_free(internal); 612 efreet_menu_internal_free(internal);
618 return entry; 613 return entry;
619} 614}
@@ -828,7 +823,7 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent)
828 * @brief Allocates and initializes a new Efreet_Menu_Internal structure 823 * @brief Allocates and initializes a new Efreet_Menu_Internal structure
829 */ 824 */
830static Efreet_Menu_Internal * 825static Efreet_Menu_Internal *
831efreet_menu_internal_new(void) 826efreet_menu_internal_new(Efreet_Menu_Internal *parent)
832{ 827{
833 Efreet_Menu_Internal *internal; 828 Efreet_Menu_Internal *internal;
834 829
@@ -840,6 +835,12 @@ efreet_menu_internal_new(void)
840 internal->inline_header = -1; 835 internal->inline_header = -1;
841 internal->inline_alias = -1; 836 internal->inline_alias = -1;
842 837
838 if (parent)
839 {
840 internal->efreet_merged_menus = parent->efreet_merged_menus;
841 internal->efreet_merged_dirs = parent->efreet_merged_dirs;
842 }
843
843 return internal; 844 return internal;
844} 845}
845 846
@@ -944,7 +945,7 @@ efreet_menu_handle_sub_menu(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
944 945
945 efreet_menu_create_sub_menu_list(parent); 946 efreet_menu_create_sub_menu_list(parent);
946 947
947 internal = efreet_menu_internal_new(); 948 internal = efreet_menu_internal_new(parent);
948 if (!internal) return 0; 949 if (!internal) return 0;
949 internal->file.path = eina_stringshare_add(parent->file.path); 950 internal->file.path = eina_stringshare_add(parent->file.path);
950 if (!efreet_menu_handle_menu(internal, xml)) 951 if (!efreet_menu_handle_menu(internal, xml))
@@ -1479,12 +1480,12 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
1479 if (!ecore_file_exists(path)) return 1; 1480 if (!ecore_file_exists(path)) return 1;
1480 1481
1481 /* don't merge the same path twice */ 1482 /* don't merge the same path twice */
1482 if (eina_hash_find(efreet_merged_menus, path)) 1483 if (eina_hash_find(parent->efreet_merged_menus, path))
1483 { 1484 {
1484 return 1; 1485 return 1;
1485 } 1486 }
1486 1487
1487 eina_hash_add(efreet_merged_menus, path, (void *)1); 1488 eina_hash_add(parent->efreet_merged_menus, path, (void *)1);
1488 1489
1489 merge_xml = efreet_xml_new(path); 1490 merge_xml = efreet_xml_new(path);
1490 1491
@@ -1495,7 +1496,7 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
1495 return 0; 1496 return 0;
1496 } 1497 }
1497 1498
1498 internal = efreet_menu_internal_new(); 1499 internal = efreet_menu_internal_new(parent);
1499 if (!internal) return 0; 1500 if (!internal) return 0;
1500 efreet_menu_path_set(internal, path); 1501 efreet_menu_path_set(internal, path);
1501 efreet_menu_handle_menu(internal, merge_xml); 1502 efreet_menu_handle_menu(internal, merge_xml);
@@ -1554,8 +1555,8 @@ efreet_menu_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char
1554 if (!parent || !xml || !path) return 0; 1555 if (!parent || !xml || !path) return 0;
1555 1556
1556 /* check to see if we've merged this directory already */ 1557 /* check to see if we've merged this directory already */
1557 if (eina_hash_find(efreet_merged_dirs, path)) return 1; 1558 if (eina_hash_find(parent->efreet_merged_dirs, path)) return 1;
1558 eina_hash_add(efreet_merged_dirs, path, (void *)1); 1559 eina_hash_add(parent->efreet_merged_dirs, path, (void *)1);
1559 1560
1560 it = eina_file_direct_ls(path); 1561 it = eina_file_direct_ls(path);
1561 if (!it) return 1; 1562 if (!it) return 1;
@@ -1699,7 +1700,7 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root,
1699 return NULL; 1700 return NULL;
1700 } 1701 }
1701 1702
1702 legacy_internal = efreet_menu_internal_new(); 1703 legacy_internal = efreet_menu_internal_new(parent);
1703 if (!legacy_internal) 1704 if (!legacy_internal)
1704 return NULL; 1705 return NULL;
1705 legacy_internal->name.internal = eina_stringshare_add(ecore_file_file_get(path)); 1706 legacy_internal->name.internal = eina_stringshare_add(ecore_file_file_get(path));
@@ -2930,7 +2931,7 @@ efreet_menu_resolve_moves(Efreet_Menu_Internal *internal)
2930 2931
2931 *path = '\0'; 2932 *path = '\0';
2932 2933
2933 ancestor = efreet_menu_internal_new(); 2934 ancestor = efreet_menu_internal_new(parent);
2934 if (!ancestor) goto error; 2935 if (!ancestor) goto error;
2935 ancestor->name.internal = eina_stringshare_add(tmp); 2936 ancestor->name.internal = eina_stringshare_add(tmp);
2936 2937