2 #include "e_mod_main.h"
4 struct _E_Config_Dialog_Data
7 int show_label, eap_label;
11 Evas_Object *radio_name;
12 Evas_Object *radio_comment;
13 Evas_Object *radio_generic;
14 E_Confirm_Dialog *dialog_delete;
18 static void *_create_data(E_Config_Dialog *cfd);
19 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
20 static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
21 static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
22 static void _cb_add(void *data, void *data2);
23 static void _cb_del(void *data, void *data2);
24 static void _cb_config(void *data, void *data2);
25 static void _cb_entry_ok(char *text, void *data);
26 static void _cb_confirm_dialog_yes(void *data);
27 static void _cb_confirm_dialog_destroy(void *data);
28 static void _load_tlist(E_Config_Dialog_Data *cfdata);
29 static void _show_label_cb_change(void *data, Evas_Object *obj);
30 static void _lock_move_cb_change(void *data, Evas_Object *obj);
33 _config_ibar_module(Config_Item *ci)
36 E_Config_Dialog_View *v;
39 v = E_NEW(E_Config_Dialog_View, 1);
42 v->create_cfdata = _create_data;
43 v->free_cfdata = _free_data;
44 v->basic.apply_cfdata = _basic_apply_data;
45 v->basic.create_widgets = _basic_create_widgets;
46 v->advanced.apply_cfdata = NULL;
47 v->advanced.create_widgets = NULL;
49 snprintf(buf, sizeof(buf), "%s/e-module-ibar.edj",
50 e_module_dir_get(ibar_config->module));
52 /* Create The Dialog */
53 cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
55 "E", "_e_mod_ibar_config_dialog",
57 ibar_config->config_dialog = cfd;
61 _fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
64 cfdata->dir = eina_stringshare_ref(ci->dir);
66 cfdata->dir = eina_stringshare_add("");
67 cfdata->show_label = ci->show_label;
68 cfdata->eap_label = ci->eap_label;
69 cfdata->lock_move = ci->lock_move;
73 _create_data(E_Config_Dialog *cfd)
75 E_Config_Dialog_Data *cfdata;
79 cfdata = E_NEW(E_Config_Dialog_Data, 1);
80 _fill_data(ci, cfdata);
85 _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
87 if (cfdata->dir) eina_stringshare_del(cfdata->dir);
88 if (cfdata->dialog_delete) e_object_del(E_OBJECT(cfdata->dialog_delete));
89 ibar_config->config_dialog = NULL;
94 _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
96 Evas_Object *o, *of, *ol, *ob, *ot;
99 o = e_widget_list_add(evas, 0, 0);
101 of = e_widget_frametable_add(evas, _("Selected Bar Source"), 0);
102 ol = e_widget_ilist_add(evas, 32, 32, &(cfdata->dir));
105 e_widget_size_min_set(ol, 140, 140);
106 e_widget_frametable_object_append(of, ol, 0, 0, 1, 2, 1, 1, 1, 0);
108 ot = e_widget_table_add(evas, 0);
109 ob = e_widget_button_add(evas, _("Add"), "list-add", _cb_add, cfdata, NULL);
110 e_widget_table_object_append(ot, ob, 0, 0, 1, 1, 1, 1, 1, 0);
111 ob = e_widget_button_add(evas, _("Delete"), "list-remove", _cb_del, cfdata, NULL);
112 e_widget_table_object_append(ot, ob, 0, 1, 1, 1, 1, 1, 1, 0);
113 ob = e_widget_button_add(evas, _("Setup"), "configure", _cb_config, cfdata, NULL);
114 e_widget_table_object_append(ot, ob, 0, 2, 1, 1, 1, 1, 1, 0);
116 if (!e_configure_registry_exists("applications/ibar_applications"))
117 e_widget_disabled_set(ob, 1);
119 e_widget_frametable_object_append(of, ot, 1, 0, 1, 1, 1, 1, 1, 0);
120 e_widget_list_object_append(o, of, 1, 1, 0.5);
122 of = e_widget_framelist_add(evas, _("Icon Labels"), 0);
123 ob = e_widget_check_add(evas, _("Show Icon Label"), &(cfdata->show_label));
124 e_widget_on_change_hook_set(ob, _show_label_cb_change, cfdata);
125 e_widget_framelist_object_append(of, ob);
127 rg = e_widget_radio_group_new(&(cfdata->eap_label));
129 cfdata->radio_name = e_widget_radio_add(evas, _("Display App Name"), 0, rg);
130 e_widget_framelist_object_append(of, cfdata->radio_name);
131 if (!cfdata->show_label) e_widget_disabled_set(cfdata->radio_name, 1);
133 cfdata->radio_comment = e_widget_radio_add(evas, _("Display App Comment"), 1, rg);
134 e_widget_framelist_object_append(of, cfdata->radio_comment);
135 if (!cfdata->show_label) e_widget_disabled_set(cfdata->radio_comment, 1);
137 cfdata->radio_generic = e_widget_radio_add(evas, _("Display App Generic"), 2, rg);
138 e_widget_framelist_object_append(of, cfdata->radio_generic);
139 if (!cfdata->show_label) e_widget_disabled_set(cfdata->radio_generic, 1);
141 e_widget_list_object_append(o, of, 1, 1, 0.5);
143 of = e_widget_framelist_add(evas, _("Icon Movement"), 0);
144 ob = e_widget_check_add(evas, _("Lock Icon Move"), &(cfdata->lock_move));
145 e_widget_on_change_hook_set(ob, _lock_move_cb_change, cfdata);
146 e_widget_framelist_object_append(of, ob);
148 e_widget_list_object_append(o, of, 1, 1, 0.5);
154 _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
159 if (ci->dir) eina_stringshare_del(ci->dir);
161 if (cfdata->dir) ci->dir = eina_stringshare_ref(cfdata->dir);
163 ci->show_label = cfdata->show_label;
164 ci->eap_label = cfdata->eap_label;
165 ci->lock_move = cfdata->lock_move;
166 _ibar_config_update(ci);
167 e_config_save_queue();
172 _cb_add(void *data, void *data2 __UNUSED__)
174 E_Config_Dialog_Data *cfdata;
177 e_entry_dialog_show(_("Create new IBar source"), "enlightenment",
178 _("Enter a name for this new source:"), "", NULL, NULL,
179 _cb_entry_ok, NULL, cfdata);
183 _cb_del(void *data, void *data2 __UNUSED__)
186 E_Config_Dialog_Data *cfdata;
187 E_Confirm_Dialog *dialog;
190 if (cfdata->dialog_delete) return;
192 snprintf(buf, sizeof(buf), _("You requested to delete \"%s\".<br><br>"
193 "Are you sure you want to delete this bar source?"),
196 dialog = e_confirm_dialog_show(_("Are you sure you want to delete this bar source?"),
197 "application-exit", buf, NULL, NULL,
198 _cb_confirm_dialog_yes, NULL, cfdata, NULL,
199 _cb_confirm_dialog_destroy, cfdata);
200 cfdata->dialog_delete = dialog;
204 _cb_config(void *data, void *data2 __UNUSED__)
207 E_Config_Dialog_Data *cfdata;
210 e_user_dir_snprintf(path, sizeof(path), "applications/bar/%s/.order",
212 e_configure_registry_call("internal/ibar_other",
213 e_container_current_get(e_manager_current_get()),
218 _cb_entry_ok(char *text, void *data)
225 len = e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s", text);
226 if (len + sizeof("/.order") >= sizeof(buf)) return;
227 if (!ecore_file_exists(buf))
229 ecore_file_mkdir(buf);
230 memcpy(buf + len, "/.order", sizeof("/.order"));
236 /* Populate this .order file with some defaults */
237 snprintf(tmp, sizeof(tmp), "xterm.desktop\n" "sylpheed.desktop\n"
238 "firefox.desktop\n" "openoffice.desktop\n" "xchat.desktop\n"
239 "gimp.desktop\n" "xmms.desktop\n");
240 ret = fwrite(tmp, sizeof(char), strlen(tmp), f);
249 _cb_confirm_dialog_yes(void *data)
251 E_Config_Dialog_Data *cfdata;
255 if (e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s", cfdata->dir) >= sizeof(buf))
257 if (ecore_file_is_dir(buf))
258 ecore_file_recursive_rm(buf);
264 _cb_confirm_dialog_destroy(void *data)
266 E_Config_Dialog_Data *cfdata;
269 cfdata->dialog_delete = NULL;
273 _load_tlist(E_Config_Dialog_Data *cfdata)
276 char buf[4096], *file;
281 e_widget_ilist_clear(cfdata->tlist);
283 len = e_user_dir_concat_static(buf, "applications/bar");
284 if (len + 2 >= sizeof(buf)) return;
285 dirs = ecore_file_ls(buf);
290 EINA_LIST_FREE(dirs, file)
292 if (file[0] == '.') continue;
293 if (eina_strlcpy(buf + len, file, sizeof(buf) - len) >= sizeof(buf) - len)
295 if (ecore_file_is_dir(buf))
297 e_widget_ilist_append(cfdata->tlist, NULL, file, NULL, NULL, file);
298 if ((cfdata->dir) && (!strcmp(cfdata->dir, file)))
306 e_widget_ilist_go(cfdata->tlist);
307 if (selnum >= 0) e_widget_ilist_selected_set(cfdata->tlist, selnum);
311 _show_label_cb_change(void *data, Evas_Object *obj __UNUSED__)
313 E_Config_Dialog_Data *cfdata;
317 e_widget_disabled_set(cfdata->radio_name, !cfdata->show_label);
318 e_widget_disabled_set(cfdata->radio_comment, !cfdata->show_label);
319 e_widget_disabled_set(cfdata->radio_generic, !cfdata->show_label);
323 _lock_move_cb_change(void *data, Evas_Object *obj __UNUSED__)
325 E_Config_Dialog_Data *cfdata;