summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-20 10:26:11 +0200
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-20 11:56:46 +0200
commitf0ff83c3f5302eb38df1c66dc036accb616d7ce9 (patch)
tree67d79c453567a5267fbe1b91975f45abc40cccaf /src/lib/efreet
parentc504706873af0a69268c996a1d08ffdadd100dbd (diff)
efreet: Reorganize file
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet_menu.c241
1 files changed, 121 insertions, 120 deletions
diff --git a/src/lib/efreet/efreet_menu.c b/src/lib/efreet/efreet_menu.c
index bdd173a403..dc0389985b 100644
--- a/src/lib/efreet/efreet_menu.c
+++ b/src/lib/efreet/efreet_menu.c
@@ -300,11 +300,11 @@ static void efreet_menu_concatenate(Efreet_Menu_Internal *dest, Efreet_Menu_Inte
300static int efreet_menu_cb_menu_compare(Efreet_Menu_Internal *a, Efreet_Menu_Internal *b); 300static int efreet_menu_cb_menu_compare(Efreet_Menu_Internal *a, Efreet_Menu_Internal *b);
301static int efreet_menu_cb_md_compare(const Efreet_Menu_Desktop *a, const Efreet_Menu_Desktop *b); 301static int efreet_menu_cb_md_compare(const Efreet_Menu_Desktop *a, const Efreet_Menu_Desktop *b);
302 302
303static void efreet_menu_path_set(Efreet_Menu_Internal *internal, const char *path);
304
303static int efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent); 305static int efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent);
304static int efreet_menu_save_indent(FILE *f, int indent); 306static int efreet_menu_save_indent(FILE *f, int indent);
305 307
306static void efreet_menu_path_set(Efreet_Menu_Internal *internal, const char *path);
307
308int 308int
309efreet_menu_init(void) 309efreet_menu_init(void)
310{ 310{
@@ -633,104 +633,6 @@ efreet_menu_save(Efreet_Menu *menu, const char *path)
633 return ret; 633 return ret;
634} 634}
635 635
636static int
637efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent)
638{
639 Eina_List *l;
640
641 efreet_menu_save_indent(f, indent);
642 fprintf(f, "<Menu>\n");
643 if (menu->name)
644 {
645 efreet_menu_save_indent(f, indent + 1);
646 fprintf(f, "<Name>%s</Name>\n", menu->name);
647 }
648
649 if (indent == 0)
650 {
651 /* Only save these for the root element */
652 efreet_menu_save_indent(f, indent + 1);
653 fprintf(f, "<DefaultAppDirs/>\n");
654 efreet_menu_save_indent(f, indent + 1);
655 fprintf(f, "<DefaultDirectoryDirs/>\n");
656 }
657
658 if (menu->desktop)
659 {
660 efreet_menu_save_indent(f, indent + 1);
661 fprintf(f, "<Directory>%s</Directory>\n", menu->desktop->orig_path);
662 }
663
664 if (menu->entries)
665 {
666 Efreet_Menu *entry;
667 int has_desktop = 0, has_menu = 0;
668
669 efreet_menu_save_indent(f, indent + 1);
670 fprintf(f, "<Layout>\n");
671 EINA_LIST_FOREACH(menu->entries, l, entry)
672 {
673 if (entry->type == EFREET_MENU_ENTRY_MENU)
674 {
675 efreet_menu_save_indent(f, indent + 2);
676 fprintf(f, "<Menuname>%s</Menuname>\n", entry->id);
677 has_menu = 1;
678 }
679 else if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
680 {
681 efreet_menu_save_indent(f, indent + 2);
682 fprintf(f, "<Filename>%s</Filename>\n", entry->id);
683 has_desktop = 1;
684 }
685 else if (entry->type == EFREET_MENU_ENTRY_SEPARATOR)
686 {
687 efreet_menu_save_indent(f, indent + 2);
688 fprintf(f, "<Separator/>\n");
689 }
690 }
691 efreet_menu_save_indent(f, indent + 1);
692 fprintf(f, "</Layout>\n");
693
694 if (has_desktop)
695 {
696 efreet_menu_save_indent(f, indent + 1);
697 fprintf(f, "<Include>\n");
698 EINA_LIST_FOREACH(menu->entries, l, entry)
699 {
700 if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
701 {
702 efreet_menu_save_indent(f, indent + 2);
703 fprintf(f, "<Filename>%s</Filename>\n", entry->id);
704 }
705 }
706 efreet_menu_save_indent(f, indent + 1);
707 fprintf(f, "</Include>\n");
708 }
709
710 if (has_menu)
711 {
712 EINA_LIST_FOREACH(menu->entries, l, entry)
713 {
714 if (entry->type == EFREET_MENU_ENTRY_MENU)
715 efreet_menu_save_menu(entry, f, indent + 1);
716 }
717 }
718 }
719 efreet_menu_save_indent(f, indent);
720 fprintf(f, "</Menu>\n");
721 return 1;
722}
723
724static int
725efreet_menu_save_indent(FILE *f, int indent)
726{
727 int i;
728
729 for (i = 0; i < indent; i++)
730 fprintf(f, " ");
731 return 1;
732}
733
734EAPI int 636EAPI int
735efreet_menu_desktop_insert(Efreet_Menu *menu, Efreet_Desktop *desktop, int pos) 637efreet_menu_desktop_insert(Efreet_Menu *menu, Efreet_Desktop *desktop, int pos)
736{ 638{
@@ -2993,26 +2895,6 @@ efreet_menu_by_name_find(Efreet_Menu_Internal *internal, const char *name, Efree
2993 return internal; 2895 return internal;
2994} 2896}
2995 2897
2996static void
2997efreet_menu_path_set(Efreet_Menu_Internal *internal, const char *path)
2998{
2999 char *tmp, *p;
3000 size_t len;
3001
3002 len = strlen(path) + 1;
3003 tmp = alloca(len);
3004 memcpy(tmp, path, len);
3005 p = strrchr(tmp, '/');
3006 if (p)
3007 {
3008 *p = '\0';
3009 p++;
3010
3011 internal->file.path = eina_stringshare_add(tmp);
3012 internal->file.name = eina_stringshare_add(p);
3013 }
3014}
3015
3016/** 2898/**
3017 * @internal 2899 * @internal
3018 * @return Returns a new Efreet_Menu_Move struct on success or NULL on failure 2900 * @return Returns a new Efreet_Menu_Move struct on success or NULL on failure
@@ -3797,3 +3679,122 @@ efreet_menu_layout_is_empty(Efreet_Menu *entry)
3797 } 3679 }
3798 return 1; 3680 return 1;
3799} 3681}
3682
3683static void
3684efreet_menu_path_set(Efreet_Menu_Internal *internal, const char *path)
3685{
3686 char *tmp, *p;
3687 size_t len;
3688
3689 len = strlen(path) + 1;
3690 tmp = alloca(len);
3691 memcpy(tmp, path, len);
3692 p = strrchr(tmp, '/');
3693 if (p)
3694 {
3695 *p = '\0';
3696 p++;
3697
3698 internal->file.path = eina_stringshare_add(tmp);
3699 internal->file.name = eina_stringshare_add(p);
3700 }
3701}
3702
3703static int
3704efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent)
3705{
3706 Eina_List *l;
3707
3708 efreet_menu_save_indent(f, indent);
3709 fprintf(f, "<Menu>\n");
3710 if (menu->name)
3711 {
3712 efreet_menu_save_indent(f, indent + 1);
3713 fprintf(f, "<Name>%s</Name>\n", menu->name);
3714 }
3715
3716 if (indent == 0)
3717 {
3718 /* Only save these for the root element */
3719 efreet_menu_save_indent(f, indent + 1);
3720 fprintf(f, "<DefaultAppDirs/>\n");
3721 efreet_menu_save_indent(f, indent + 1);
3722 fprintf(f, "<DefaultDirectoryDirs/>\n");
3723 }
3724
3725 if (menu->desktop)
3726 {
3727 efreet_menu_save_indent(f, indent + 1);
3728 fprintf(f, "<Directory>%s</Directory>\n", menu->desktop->orig_path);
3729 }
3730
3731 if (menu->entries)
3732 {
3733 Efreet_Menu *entry;
3734 int has_desktop = 0, has_menu = 0;
3735
3736 efreet_menu_save_indent(f, indent + 1);
3737 fprintf(f, "<Layout>\n");
3738 EINA_LIST_FOREACH(menu->entries, l, entry)
3739 {
3740 if (entry->type == EFREET_MENU_ENTRY_MENU)
3741 {
3742 efreet_menu_save_indent(f, indent + 2);
3743 fprintf(f, "<Menuname>%s</Menuname>\n", entry->id);
3744 has_menu = 1;
3745 }
3746 else if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
3747 {
3748 efreet_menu_save_indent(f, indent + 2);
3749 fprintf(f, "<Filename>%s</Filename>\n", entry->id);
3750 has_desktop = 1;
3751 }
3752 else if (entry->type == EFREET_MENU_ENTRY_SEPARATOR)
3753 {
3754 efreet_menu_save_indent(f, indent + 2);
3755 fprintf(f, "<Separator/>\n");
3756 }
3757 }
3758 efreet_menu_save_indent(f, indent + 1);
3759 fprintf(f, "</Layout>\n");
3760
3761 if (has_desktop)
3762 {
3763 efreet_menu_save_indent(f, indent + 1);
3764 fprintf(f, "<Include>\n");
3765 EINA_LIST_FOREACH(menu->entries, l, entry)
3766 {
3767 if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
3768 {
3769 efreet_menu_save_indent(f, indent + 2);
3770 fprintf(f, "<Filename>%s</Filename>\n", entry->id);
3771 }
3772 }
3773 efreet_menu_save_indent(f, indent + 1);
3774 fprintf(f, "</Include>\n");
3775 }
3776
3777 if (has_menu)
3778 {
3779 EINA_LIST_FOREACH(menu->entries, l, entry)
3780 {
3781 if (entry->type == EFREET_MENU_ENTRY_MENU)
3782 efreet_menu_save_menu(entry, f, indent + 1);
3783 }
3784 }
3785 }
3786 efreet_menu_save_indent(f, indent);
3787 fprintf(f, "</Menu>\n");
3788 return 1;
3789}
3790
3791static int
3792efreet_menu_save_indent(FILE *f, int indent)
3793{
3794 int i;
3795
3796 for (i = 0; i < indent; i++)
3797 fprintf(f, " ");
3798 return 1;
3799}
3800