summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-08-07 11:45:30 +0200
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-08-07 13:02:54 +0200
commit2e4fb25922a79b91197adaa5fbd37e7bf5e40aa6 (patch)
tree9b31d2a78006a22c8c993eeae0ec9e8371fb4089 /src/lib/efreet
parent75dd06bcb18fc951d981dc9b06870bb8519520ff (diff)
efreet: clean up ugly internal_get function
CID: #1039186
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet_menu.c123
1 files changed, 60 insertions, 63 deletions
diff --git a/src/lib/efreet/efreet_menu.c b/src/lib/efreet/efreet_menu.c
index e4bc66f07e..739e9c188a 100644
--- a/src/lib/efreet/efreet_menu.c
+++ b/src/lib/efreet/efreet_menu.c
@@ -175,8 +175,6 @@ static Eina_Hash *efreet_menu_filter_cbs = NULL;
175static Eina_Hash *efreet_menu_move_cbs = NULL; 175static Eina_Hash *efreet_menu_move_cbs = NULL;
176static Eina_Hash *efreet_menu_layout_cbs = NULL; 176static Eina_Hash *efreet_menu_layout_cbs = NULL;
177 177
178static Efreet_Menu *efreet_menu_internal_get(Efreet_Menu_Cb func, void *data);
179
180static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal, 178static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal,
181 const char *name, 179 const char *name,
182 Efreet_Menu_Internal **parent); 180 Efreet_Menu_Internal **parent);
@@ -527,13 +525,71 @@ efreet_menu_file_set(const char *file)
527EAPI void 525EAPI void
528efreet_menu_async_get(Efreet_Menu_Cb func, const void *data) 526efreet_menu_async_get(Efreet_Menu_Cb func, const void *data)
529{ 527{
530 efreet_menu_internal_get(func, (void*)data); 528 char menu[PATH_MAX];
529 const char *dir;
530 Eina_List *config_dirs, *l;
531
532 if (!func) return;
533
534#ifndef STRICT_SPEC
535 /* prefer user set menu */
536 if (efreet_menu_file)
537 {
538 if (ecore_file_exists(efreet_menu_file))
539 efreet_menu_async_parse(efreet_menu_file, func, data);
540 }
541#endif
542
543 /* check the users config directory first */
544 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
545 efreet_config_home_get(), efreet_menu_prefix);
546 if (ecore_file_exists(menu))
547 efreet_menu_async_parse(menu, func, data);
548
549 /* fallback to the XDG_CONFIG_DIRS */
550 config_dirs = efreet_config_dirs_get();
551 EINA_LIST_FOREACH(config_dirs, l, dir)
552 {
553 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
554 dir, efreet_menu_prefix);
555 if (ecore_file_exists(menu))
556 efreet_menu_async_parse(menu, func, data);
557 }
531} 558}
532 559
533EAPI Efreet_Menu * 560EAPI Efreet_Menu *
534efreet_menu_get(void) 561efreet_menu_get(void)
535{ 562{
536 return efreet_menu_internal_get(NULL, NULL); 563 char menu[PATH_MAX];
564 const char *dir;
565 Eina_List *config_dirs, *l;
566
567#ifndef STRICT_SPEC
568 /* prefer user set menu */
569 if (efreet_menu_file)
570 {
571 if (ecore_file_exists(efreet_menu_file))
572 return efreet_menu_parse(efreet_menu_file);
573 }
574#endif
575
576 /* check the users config directory first */
577 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
578 efreet_config_home_get(), efreet_menu_prefix);
579 if (ecore_file_exists(menu))
580 return efreet_menu_parse(menu);
581
582 /* fallback to the XDG_CONFIG_DIRS */
583 config_dirs = efreet_config_dirs_get();
584 EINA_LIST_FOREACH(config_dirs, l, dir)
585 {
586 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
587 dir, efreet_menu_prefix);
588 if (ecore_file_exists(menu))
589 return efreet_menu_parse(menu);
590 }
591
592 return NULL;
537} 593}
538 594
539EAPI void 595EAPI void
@@ -730,65 +786,6 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent)
730 } 786 }
731} 787}
732 788
733static Efreet_Menu *
734efreet_menu_internal_get(Efreet_Menu_Cb func, void *data)
735{
736 char menu[PATH_MAX];
737 const char *dir;
738 Eina_List *config_dirs, *l;
739
740#ifndef STRICT_SPEC
741 /* prefer user set menu */
742 if (efreet_menu_file)
743 {
744 if (ecore_file_exists(efreet_menu_file))
745 {
746 if (func)
747 {
748 efreet_menu_async_parse(efreet_menu_file, func, data);
749 return NULL;
750 }
751 else
752 return efreet_menu_parse(efreet_menu_file);
753 }
754 }
755#endif
756
757 /* check the users config directory first */
758 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
759 efreet_config_home_get(), efreet_menu_prefix);
760 if (ecore_file_exists(menu))
761 {
762 if (func)
763 {
764 efreet_menu_async_parse(menu, func, data);
765 return NULL;
766 }
767 else
768 return efreet_menu_parse(menu);
769 }
770
771 /* fallback to the XDG_CONFIG_DIRS */
772 config_dirs = efreet_config_dirs_get();
773 EINA_LIST_FOREACH(config_dirs, l, dir)
774 {
775 snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu",
776 dir, efreet_menu_prefix);
777 if (ecore_file_exists(menu))
778 {
779 if (func)
780 {
781 efreet_menu_async_parse(menu, func, data);
782 return NULL;
783 }
784 else
785 return efreet_menu_parse(menu);
786 }
787 }
788
789 return NULL;
790}
791
792/** 789/**
793 * @internal 790 * @internal
794 * @return Returns a new Efreet_Menu_Internal struct 791 * @return Returns a new Efreet_Menu_Internal struct