3 #include "e_mod_main.h"
5 static const char *xdg_sel = NULL;
6 static Eina_List *menus = NULL;
9 check_menu_dir(const char *dir)
11 char buf[PATH_MAX], *file;
14 snprintf(buf, sizeof(buf), "%s/menus", dir);
15 files = ecore_file_ls(buf);
16 EINA_LIST_FREE(files, file)
18 if (e_util_glob_match(file, "*.menu"))
20 snprintf(buf, sizeof(buf), "%s/menus/%s", dir, file);
21 menus = eina_list_append(menus, strdup(buf));
28 wizard_page_init(E_Wizard_Page *pg __UNUSED__)
38 "/usr/local/opt/etc/xdg",
42 // FIXME: add more "known locations"
47 e_user_homedir_concat(buf, sizeof(buf), ".config");
50 for (i = 0; dirs[i]; i++) check_menu_dir(dirs[i]);
53 snprintf(buf, sizeof(buf), "%s/etc/xdg", e_prefix_get());
54 for (i = 0; dirs[i]; i++)
56 if (!strcmp(dirs[i], buf))
62 if (newdir) check_menu_dir(buf);
67 wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
74 wizard_page_show(E_Wizard_Page *pg)
76 Evas_Object *o, *of, *ob;
80 o = e_widget_list_add(pg->evas, 1, 0);
81 e_wizard_title_set(_("Menus"));
85 of = e_widget_framelist_add(pg->evas, _("Error"), 0);
87 ob = e_widget_textblock_add(pg->evas);
88 e_widget_size_min_set(ob, 140 * e_scale, 140 * e_scale);
89 e_widget_textblock_markup_set
91 _("No menu files were<br>"
92 "found on your system.<br>"
94 "documentation on<br>"
95 "www.enlightenment.org<br>"
96 "for more details on<br>"
98 "application menus<br>"
100 e_widget_framelist_object_append(of, ob);
101 e_widget_list_object_append(o, of, 1, 1, 0.5);
102 evas_object_show(ob);
103 evas_object_show(of);
107 of = e_widget_framelist_add(pg->evas, _("Select application menu"), 0);
109 ob = e_widget_ilist_add(pg->evas, 32 * e_scale, 32 * e_scale, &xdg_sel);
110 e_widget_size_min_set(ob, 140 * e_scale, 140 * e_scale);
112 e_widget_ilist_freeze(ob);
114 EINA_LIST_FREE(menus, file)
116 char buf[PATH_MAX], buf2[PATH_MAX], *p, *p2, *tlabel, *tdesc;
122 e_user_homedir_concat(buf, sizeof(buf),
123 ".config/menus/applications.menu");
124 snprintf(buf2, sizeof(buf2),
125 "%s/etc/xdg/menus/enlightenment.menu",
127 if (!strcmp("/etc/xdg/menus/applications.menu", file))
129 label = _("System Default");
132 else if (!strcmp(buf2, file))
134 label = _("Enlightenment Default");
137 else if (!strcmp(buf, file))
139 label = _("Personal Default");
143 p = strrchr(file, '/');
148 if (!p2) p2 = strrchr(p, '.');
151 tlabel = malloc(p2 - p + 1);
154 eina_strlcpy(tlabel, p, p2 - p + 1);
155 tlabel[0] = toupper(tlabel[0]);
159 p = strrchr(p2, '.');
162 tdesc = malloc(p - p2 + 1);
165 eina_strlcpy(tdesc, p2, p - p2 + 1);
166 tdesc[0] = toupper(tdesc[0]);
167 snprintf(buf, sizeof(buf), "%s (%s)", tlabel, tdesc);
170 snprintf(buf, sizeof(buf), "%s", tlabel);
173 snprintf(buf, sizeof(buf), "%s", tlabel);
176 snprintf(buf, sizeof(buf), "%s", tlabel);
184 e_widget_ilist_append(ob, NULL, label, NULL, NULL, file);
185 if (tlabel) free(tlabel);
186 if (tdesc) free(tdesc);
190 e_widget_ilist_go(ob);
191 e_widget_ilist_thaw(ob);
193 if (sel >= 0) e_widget_ilist_selected_set(ob, sel);
195 e_widget_framelist_object_append(of, ob);
196 e_widget_list_object_append(o, of, 1, 1, 0.5);
197 evas_object_show(ob);
198 evas_object_show(of);
201 e_wizard_page_show(o);
203 return 1; /* 1 == show ui, and wait for user, 0 == just continue */
207 wizard_page_hide(E_Wizard_Page *pg)
209 evas_object_del(pg->data);
214 wizard_page_apply(E_Wizard_Page *pg __UNUSED__)
216 if ((xdg_sel) && (!strcmp("/etc/xdg/menus/applications.menu", xdg_sel)))
218 eina_stringshare_del(xdg_sel);
221 e_config->default_system_menu = eina_stringshare_ref(xdg_sel);
222 efreet_menu_file_set(e_config->default_system_menu);