3 struct _E_Config_Dialog_Data
5 Efreet_Desktop *desktop;
6 int type; /* desktop type */
8 char *name; /* app name (e.g. Firefox) */
9 char *generic_name; /* generic app name (e.g. Web Browser) */
10 char *comment; /* a longer description */
11 char *exec; /* command to execute */
12 char *try_exec; /* executable to test for an apps existence */
13 char *url; /* url to open */
15 char *startup_wm_class; /* window class */
16 char *categories; /* list of category names that app is in */
17 char *mimes; /* list of mimes this app can handle */
18 char *icon; /* absolute path to file or icon name */
24 E_Desktop_Edit *editor;
26 char *orig_path; /* informational only */
27 Evas_Object *orig_path_entry; /* to set when info changes */
28 Evas_Object *icon_entry; /* to set when icon changes */
30 /* speed up check_changed tests */
31 Eina_Bool changed_categories;
32 Eina_Bool changed_mimes;
33 Eina_Bool edited_categories;
34 Eina_Bool edited_mimes;
37 /* local subsystem functions */
39 static int _e_desktop_edit_view_create(E_Desktop_Edit *editor, E_Container *con);
40 static void _e_desktop_edit_free(E_Desktop_Edit *editor);
41 static void *_e_desktop_edit_create_data(E_Config_Dialog *cfd);
42 static void _e_desktop_edit_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *data);
43 static int _e_desktop_edit_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *data);
44 static int _e_desktop_edit_basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *data);
45 static Evas_Object *_e_desktop_edit_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *data);
46 static void _e_desktop_editor_cb_icon_select(void *data1, void *data2);
47 static void _e_desktop_edit_cb_icon_select_destroy(void *obj);
48 static void _e_desktop_edit_cb_icon_select_ok(void *data, E_Dialog *dia);
49 static void _e_desktop_edit_cb_icon_select_cancel(void *data, E_Dialog *dia);
50 static void _e_desktop_editor_icon_update(E_Config_Dialog_Data *cfdata);
51 static void _e_desktop_editor_cb_exec_select(void *data1, void *data2);
52 static void _e_desktop_edit_cb_exec_select_destroy(void *obj);
53 static void _e_desktop_edit_cb_exec_select_ok(void *data, E_Dialog *dia);
54 static void _e_desktop_edit_cb_exec_select_cancel(void *data, E_Dialog *dia);
55 static void _e_desktop_editor_exec_update(E_Config_Dialog_Data *cfdata);
56 static void _e_desktop_edit_select_cb(void *data, Evas_Object *obj);
57 static void _e_desktop_editor_icon_entry_changed(void *data, Evas_Object *obj);
59 #define IFADD(src, dst) if (src) dst = eina_stringshare_add(src); else dst = NULL
60 #define IFDEL(src) if (src) eina_stringshare_del(src); src = NULL;
61 #define IFDUP(src, dst) if (src) dst = strdup(src); else dst = NULL
62 #define IFFREE(src) if (src) free(src); src = NULL;
64 /* externally accessible functions */
67 e_desktop_border_create(E_Border *bd)
69 Efreet_Desktop *desktop = NULL;
70 const char *desktop_dir, *icon_dir;
71 const char *bname, *bclass, *btitle;
74 bname = bd->client.icccm.name;
75 if ((bname) && (bname[0] == 0)) bname = NULL;
76 bclass = bd->client.icccm.class;
77 if ((bclass) && (bclass[0] == 0)) bclass = NULL;
78 btitle = e_border_name_get(bd);
80 desktop_dir = e_user_desktop_dir_get();
82 if ((!desktop_dir) || (!e_util_dir_check(desktop_dir))) return NULL;
84 icon_dir = e_user_icon_dir_get();
85 if ((!icon_dir) || (!e_util_dir_check(icon_dir))) return NULL;
89 snprintf(path, sizeof(path), "%s/%s.desktop", desktop_dir, bname);
90 desktop = efreet_desktop_empty_new(path);
96 for (i = 1; i < 65536; i++)
98 snprintf(path, sizeof(path), "%s/_new_app-%i.desktop",
100 if (!ecore_file_exists(path))
102 desktop = efreet_desktop_empty_new(path);
108 snprintf(path, sizeof(path), "%s/_rename_me-%i.desktop",
109 desktop_dir, (int)ecore_time_get());
110 desktop = efreet_desktop_empty_new(NULL);
119 if (bclass) desktop->name = strdup(bclass);
120 else if (bname) desktop->name = strdup(bname);
121 else if (btitle) desktop->name = strdup(btitle);
123 if (btitle) desktop->comment = strdup(btitle);
125 if (bclass) desktop->startup_wm_class = strdup(bclass);
126 if (bd->client.icccm.command.argc > 0)
127 // FIXME this should concat the entire argv array together
128 desktop->exec = strdup(bd->client.icccm.command.argv[0]);
130 desktop->exec = strdup(bname);
133 // if (bd->client.netwm.startup_id > 0) desktop->startup_notify = 1;
134 if (bd->client.netwm.icons)
137 * - Find the icon with the best size
138 * - Should use mkstemp
140 snprintf(path, sizeof(path), "%s/%s-%.6f.png", icon_dir, bname, ecore_time_get());
141 if (e_util_icon_save(&(bd->client.netwm.icons[0]), path))
142 desktop->icon = strdup(path);
144 fprintf(stderr, "Could not save file from ARGB: %s\n", path);
149 EAPI E_Desktop_Edit *
150 e_desktop_border_edit(E_Container *con, E_Border *bd)
152 E_Desktop_Edit *editor;
155 if (!con) return NULL;
156 editor = E_OBJECT_ALLOC(E_Desktop_Edit, E_DESKTOP_EDIT_TYPE, _e_desktop_edit_free);
157 if (!editor) return NULL;
159 editor->desktop = bd->desktop;
161 /* the border does not yet have a desktop entry. add one and pre-populate
162 it with values from the border */
163 if (!editor->desktop)
165 editor->desktop = e_desktop_border_create(bd);
166 if ((editor->desktop) && (editor->desktop->icon))
167 editor->tmp_image_path = strdup(editor->desktop->icon);
172 if ((!bname) && (!bclass))
174 e_util_dialog_show(_("Incomplete Window Properties"),
175 _("The window you are creating an icon for<br>"
176 "does not contain window name and class<br>"
177 "properties, so the needed properties for<br>"
178 "the icon so that it will be used for this<br>"
179 "window cannot be guessed. You will need to<br>"
180 "use the window title instead. This will only<br>"
181 "work if the window title is the same at<br>"
182 "the time the window starts up, and does not<br>"
186 if (!_e_desktop_edit_view_create(editor, con))
188 e_object_del(E_OBJECT(editor));
192 e_config_dialog_changed_set(editor->cfd, new_desktop);
197 EAPI E_Desktop_Edit *
198 e_desktop_edit(E_Container *con, Efreet_Desktop *desktop)
200 E_Desktop_Edit *editor;
202 if (!con) return NULL;
203 editor = E_OBJECT_ALLOC(E_Desktop_Edit, E_DESKTOP_EDIT_TYPE, _e_desktop_edit_free);
204 if (!editor) return NULL;
205 if (desktop) editor->desktop = desktop;
206 if (!_e_desktop_edit_view_create(editor, con))
208 e_object_del(E_OBJECT(editor));
215 _e_desktop_edit_view_create(E_Desktop_Edit *editor, E_Container *con)
217 E_Config_Dialog_View *v;
219 v = E_NEW(E_Config_Dialog_View, 1);
223 v->create_cfdata = _e_desktop_edit_create_data;
224 v->free_cfdata = _e_desktop_edit_free_data;
225 v->basic.apply_cfdata = _e_desktop_edit_basic_apply_data;
226 v->basic.create_widgets = _e_desktop_edit_basic_create_widgets;
227 v->basic.check_changed = _e_desktop_edit_basic_check_changed;
230 e_config_dialog_new(con, _("Desktop Entry Editor"), "E",
231 "applications/new_application",
232 "preferences-applications", 0, v, editor);
243 /* local subsystem functions */
245 _e_desktop_edit_free(E_Desktop_Edit *editor)
248 E_OBJECT_CHECK(editor);
249 E_OBJECT_TYPE_CHECK(editor, E_EAP_EDIT_TYPE);
251 IFFREE(editor->tmp_image_path);
256 * Populates the config dialog's data from the .desktop file passed in
259 _e_desktop_edit_create_data(E_Config_Dialog *cfd)
261 E_Config_Dialog_Data *cfdata;
262 Efreet_Desktop *desktop = NULL;
265 cfdata = E_NEW(E_Config_Dialog_Data, 1);
266 if (!cfdata) return NULL;
267 cfdata->editor = cfd->data;
270 * If we can't write to the file on it's current location,
271 * we always save to the user's applications dir.
272 * If the file is already there, then edit it directly. Otherwise, create
273 * a new empty desktop entry there.
275 * cfdata->editor->desktop is the the desktop passed in
276 * cfdata->desktop is the desktop to save
277 * desktop is the desktop to load
280 if (cfdata->editor->desktop)
285 if (ecore_file_can_write (cfdata->editor->desktop->orig_path))
286 cfdata->desktop = efreet_desktop_uncached_new(cfdata->editor->desktop->orig_path);
289 snprintf(dir, sizeof(dir), "%s/applications", efreet_data_home_get());
290 if (!strncmp(dir, cfdata->editor->desktop->orig_path, strlen(dir)))
291 cfdata->desktop = efreet_desktop_uncached_new(cfdata->editor->desktop->orig_path);
294 /* file not in user's dir, so create new desktop that points there */
295 if (!ecore_file_exists(dir)) ecore_file_mkdir(dir);
296 file = ecore_file_file_get(cfdata->editor->desktop->orig_path);
297 snprintf(path, sizeof(path), "%s/%s", dir, file);
299 * if a file already exists in the user dir with this name, we
300 * fetch the pointer to it, so the caches stay consistent (this
301 * probably will never return non null, since the ui shouldn't
302 * provide a means to edit a file in a system dir when one
303 * exists in the user's
305 cfdata->desktop = efreet_desktop_uncached_new(path);
308 desktop = cfdata->editor->desktop;
311 if (!cfdata->desktop)
312 cfdata->desktop = efreet_desktop_empty_new(path);
314 if (!desktop) desktop = cfdata->desktop;
316 IFDUP(desktop->name, cfdata->name);
317 IFDUP(desktop->generic_name, cfdata->generic_name);
318 IFDUP(desktop->comment, cfdata->comment);
319 IFDUP(desktop->exec, cfdata->exec);
320 IFDUP(desktop->try_exec, cfdata->try_exec);
321 IFDUP(desktop->url, cfdata->url);
322 IFDUP(desktop->startup_wm_class, cfdata->startup_wm_class);
323 IFDUP(desktop->orig_path, cfdata->orig_path);
325 if (desktop->categories)
326 cfdata->categories = efreet_desktop_string_list_join(desktop->categories);
327 if (desktop->mime_types)
328 cfdata->mimes = efreet_desktop_string_list_join(desktop->mime_types);
330 IFDUP(desktop->icon, cfdata->icon);
332 cfdata->startup_notify = desktop->startup_notify;
333 cfdata->terminal = desktop->terminal;
334 cfdata->show_in_menus = !desktop->no_display;
336 if (cfdata->exec && *cfdata->exec)
338 else if (cfdata->url && *cfdata->url)
345 * Frees the config dialog data
348 _e_desktop_edit_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
350 if (cfdata->editor->tmp_image_path)
352 if ((!cfdata->desktop) || (!cfdata->editor->saved) ||
353 (!cfdata->desktop->icon) ||
354 (strcmp(cfdata->editor->tmp_image_path, cfdata->desktop->icon)))
356 ecore_file_unlink(cfdata->editor->tmp_image_path);
359 if (cfdata->desktop) efreet_desktop_free(cfdata->desktop);
361 IFFREE(cfdata->name);
362 IFFREE(cfdata->generic_name);
363 IFFREE(cfdata->comment);
364 IFFREE(cfdata->exec);
365 IFFREE(cfdata->try_exec);
367 IFFREE(cfdata->startup_wm_class);
368 IFFREE(cfdata->categories);
369 IFFREE(cfdata->icon);
370 IFFREE(cfdata->mimes);
371 IFFREE(cfdata->orig_path);
373 if (cfdata->editor->icon_fsel_dia)
374 e_object_del(E_OBJECT(cfdata->editor->icon_fsel_dia));
376 e_object_del(E_OBJECT(cfdata->editor));
381 _e_desktop_edit_user_local_desktop_filename_generate(E_Config_Dialog_Data *cfdata, char *path)
383 char basename[PATH_MAX];
388 if ((cfdata->name) && (cfdata->name[0]))
390 else if ((cfdata->desktop) && (cfdata->desktop->name) &&
391 (cfdata->desktop->name[0]))
398 const char *s = name;
399 for (i = 0; i < sizeof(basename) && s[i]; i++)
409 eina_strlcpy(basename, "unnamed_desktop", sizeof(basename));
411 i = snprintf(path, PATH_MAX, "%s/applications/%s.desktop",
412 efreet_data_home_get(), basename);
418 prefix = i - (sizeof(".desktop") - 1);
420 for (i = 0; ecore_file_exists(path); i++)
421 snprintf(path + prefix, PATH_MAX - prefix, "-%u.desktop", i);
425 _e_desktop_edit_update_orig_path(E_Config_Dialog_Data *cfdata)
427 const char *orig_path;
430 if ((cfdata->desktop->orig_path) && (cfdata->desktop->orig_path[0]))
431 orig_path = cfdata->desktop->orig_path;
434 _e_desktop_edit_user_local_desktop_filename_generate(cfdata, path);
435 orig_path = cfdata->orig_path = strdup(path);
438 if (cfdata->orig_path_entry)
439 e_widget_entry_text_set(cfdata->orig_path_entry, orig_path);
443 * Apply the basic config dialog
446 _e_desktop_edit_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
448 E_Desktop_Edit *editor;
451 editor = cfdata->editor;
453 IFFREE(cfdata->desktop->name);
454 IFDUP(cfdata->name, cfdata->desktop->name);
455 IFFREE(cfdata->desktop->comment);
456 IFDUP(cfdata->comment, cfdata->desktop->comment);
458 switch (cfdata->type)
461 IFFREE(cfdata->desktop->url);
462 IFDUP(cfdata->url, cfdata->desktop->url);
465 IFFREE(cfdata->desktop->exec);
466 IFDUP(cfdata->exec, cfdata->desktop->exec);
467 IFFREE(cfdata->desktop->try_exec);
468 IFDUP(cfdata->try_exec, cfdata->desktop->try_exec);
472 IFFREE(cfdata->desktop->generic_name);
473 IFDUP(cfdata->generic_name, cfdata->desktop->generic_name);
474 IFFREE(cfdata->desktop->startup_wm_class);
475 IFDUP(cfdata->startup_wm_class, cfdata->desktop->startup_wm_class);
477 EINA_LIST_FREE(cfdata->desktop->categories, str)
478 eina_stringshare_del(str);
479 cfdata->desktop->categories = efreet_desktop_string_list_parse(cfdata->categories);
481 EINA_LIST_FREE(cfdata->desktop->mime_types, str)
482 eina_stringshare_del(str);
483 cfdata->desktop->mime_types = efreet_desktop_string_list_parse(cfdata->mimes);
485 IFFREE(cfdata->desktop->icon);
486 IFDUP(cfdata->icon, cfdata->desktop->icon);
488 cfdata->desktop->startup_notify = cfdata->startup_notify;
489 cfdata->desktop->terminal = cfdata->terminal;
490 cfdata->desktop->no_display = !cfdata->show_in_menus;
492 if (cfdata->desktop->orig_path && cfdata->desktop->orig_path[0])
493 cfdata->editor->saved = efreet_desktop_save(cfdata->desktop);
496 _e_desktop_edit_update_orig_path(cfdata);
497 cfdata->editor->saved = efreet_desktop_save_as
498 (cfdata->desktop, cfdata->orig_path);
504 _e_desktop_edit_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
508 if ((cfdata->startup_notify != cfdata->desktop->startup_notify) ||
509 (cfdata->terminal != cfdata->desktop->terminal) ||
510 (cfdata->show_in_menus != !cfdata->desktop->no_display))
517 if (cfdata->desktop->k) \
518 __k = cfdata->desktop->k; \
519 else if ((cfdata->editor) && (cfdata->editor->desktop)) \
520 __k = cfdata->editor->desktop->k; \
523 if ((cfdata->k && !__k) || (!cfdata->k && __k) || \
524 (cfdata->k && __k && strcmp(cfdata->k, __k) != 0)) \
535 CHECK(startup_wm_class);
541 if (cfdata->edited_categories)
544 Eina_List *lst, *old_lst;
546 cfdata->edited_categories = EINA_FALSE;
547 cfdata->changed_categories = EINA_FALSE;
549 if (cfdata->desktop->categories)
550 old_lst = cfdata->desktop->categories;
551 else if ((cfdata->editor) && (cfdata->editor->desktop))
552 old_lst = cfdata->editor->desktop->categories;
556 lst = efreet_desktop_string_list_parse(cfdata->categories);
557 if (eina_list_count(lst) != eina_list_count(old_lst))
558 cfdata->changed_categories = EINA_TRUE;
560 EINA_LIST_FREE(lst, str)
562 if (!cfdata->changed_categories)
566 Eina_Bool found = EINA_FALSE;
567 EINA_LIST_FOREACH(old_lst, n, old)
569 if (strcmp(str, old) == 0)
576 cfdata->changed_categories = EINA_TRUE;
578 eina_stringshare_del(str);
581 ret |= cfdata->changed_categories;
585 if (cfdata->edited_mimes)
588 Eina_List *lst, *old_lst;
590 cfdata->edited_mimes = EINA_FALSE;
591 cfdata->changed_mimes = EINA_FALSE;
593 if (cfdata->desktop->mime_types)
594 old_lst = cfdata->desktop->mime_types;
595 else if ((cfdata->editor) && (cfdata->editor->desktop))
596 old_lst = cfdata->editor->desktop->mime_types;
600 lst = efreet_desktop_string_list_parse(cfdata->mimes);
601 if (eina_list_count(lst) != eina_list_count(old_lst))
602 cfdata->changed_mimes = EINA_TRUE;
604 EINA_LIST_FREE(lst, str)
606 if (!cfdata->changed_mimes)
610 Eina_Bool found = EINA_FALSE;
611 EINA_LIST_FOREACH(old_lst, n, old)
613 if (strcmp(str, old) == 0)
620 cfdata->changed_mimes = EINA_TRUE;
622 eina_stringshare_del(str);
626 ret |= cfdata->changed_mimes;
633 _e_desktop_editor_name_changed(void *data, Evas_Object *obj __UNUSED__)
635 E_Config_Dialog_Data *cfdata = data;
636 _e_desktop_edit_update_orig_path(cfdata);
640 _e_desktop_editor_categories_changed(void *data, Evas_Object *obj __UNUSED__)
642 E_Config_Dialog_Data *cfdata = data;
643 cfdata->edited_categories = EINA_TRUE;
647 _e_desktop_editor_icon_entry_changed(void *data, Evas_Object *obj __UNUSED__)
649 E_Config_Dialog_Data *cfdata = data;
650 _e_desktop_editor_icon_update(cfdata);
654 _e_desktop_editor_mimes_changed(void *data, Evas_Object *obj __UNUSED__)
656 E_Config_Dialog_Data *cfdata = data;
657 cfdata->edited_mimes = EINA_TRUE;
661 _e_desktop_edit_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
663 E_Desktop_Edit *editor = cfdata->editor;
665 Evas_Object *otb, *ol, *o, *ot;
670 otb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale);
672 ot = e_widget_table_add(evas, 0);
674 o = e_widget_label_add(evas, _("Name"));
675 e_widget_table_object_append(ot, o, 0, 0, 1, 1, 1, 1, 0, 0);
677 o = e_widget_entry_add(evas, &(cfdata->name), NULL, NULL, NULL);
678 e_widget_size_min_get(o, &mw, &mh);
679 if (mw < 220) mw = 220;
680 e_widget_size_min_set(o, mw, mh);
681 if ((!cfdata->desktop->orig_path) || (!cfdata->desktop->orig_path[0]))
682 e_widget_on_change_hook_set(o, _e_desktop_editor_name_changed, cfdata);
683 e_widget_table_object_append(ot, o, 1, 0, 1, 1, 1, 1, 1, 0);
685 o = e_widget_label_add(evas, _("Comment"));
686 e_widget_table_object_append(ot, o, 0, 1, 1, 1, 1, 1, 0, 0);
688 o = e_widget_entry_add(evas, &(cfdata->comment), NULL, NULL, NULL);
689 e_widget_table_object_append(ot, o, 1, 1, 1, 1, 1, 1, 1, 0);
691 rg = e_widget_radio_group_new(&(cfdata->type));
693 // desktop type: application
695 o = e_widget_radio_add(evas, _("Application"), 0, rg);
696 e_widget_table_object_append(ot, o, 0, 2, 1, 1, 1, 1, 0, 0);
698 editor->entry_widget_exec = e_widget_entry_add
699 (evas, &(cfdata->exec), NULL, NULL, NULL);
700 e_widget_table_object_append(ot, editor->entry_widget_exec, 1, 2, 1, 1, 1, 1, 1, 0);
702 o = e_widget_button_add
703 (evas, "...", NULL, _e_desktop_editor_cb_exec_select, cfdata, editor);
704 e_widget_table_object_append(ot, o, 2, 2, 1, 1, 0, 0, 0, 0);
707 o = e_widget_radio_add(evas, _("URL"), 1, rg);
708 e_widget_table_object_append(ot, o, 0, 3, 1, 1, 1, 1, 0, 0);
710 editor->entry_widget_url = e_widget_entry_add
711 (evas, &(cfdata->url), NULL, NULL, NULL);
712 e_widget_table_object_append(ot, editor->entry_widget_url, 1, 3, 1, 1, 1, 1, 1, 0);
713 // FIXME: add url selection dialog (file:/etc/..)
715 e_widget_toolbook_page_append
716 (otb, NULL, _("Basic"), ot, 1, 0, 1, 0, 0.5, 0.0);
718 /* e_widget_size_min_get(ol, &mw, &mh); */
720 ot = e_widget_table_add(evas, 0);
722 editor->img_widget = e_widget_button_add
723 (evas, "", NULL, _e_desktop_editor_cb_icon_select, cfdata, editor);
724 _e_desktop_editor_icon_update(cfdata);
725 e_widget_size_min_set(editor->img_widget, 192, 192);
727 e_widget_table_object_append(ot, editor->img_widget, 0, 0, 2, 1, 1, 1, 0, 0);
729 o = e_widget_label_add(evas, _("Icon"));
730 e_widget_table_object_append(ot, o, 0, 1, 1, 1, 1, 1, 0, 0);
732 o = e_widget_entry_add(evas, &(cfdata->icon), NULL, NULL, NULL);
733 cfdata->icon_entry = o;
734 e_widget_on_change_hook_set(o, _e_desktop_editor_icon_entry_changed, cfdata);
735 e_widget_table_object_append(ot, o, 1, 1, 1, 1, 1, 1, 1, 0);
737 e_widget_toolbook_page_append
738 (otb, NULL, _("Icon"), ot, 0, 0, 0, 0, 0.5, 0.5);
740 ot = e_widget_table_add(evas, 0);
742 o = e_widget_label_add(evas, _("Generic Name"));
743 e_widget_table_object_append(ot, o, 0, 0, 1, 1, 1, 1, 0, 0);
745 o = e_widget_entry_add(evas, &(cfdata->generic_name), NULL, NULL, NULL);
746 e_widget_table_object_append(ot, o, 1, 0, 1, 1, 1, 1, 1, 0);
748 o = e_widget_label_add(evas, _("Window Class"));
749 e_widget_table_object_append(ot, o, 0, 1, 1, 1, 1, 1, 0, 0);
751 o = e_widget_entry_add(evas, &(cfdata->startup_wm_class), NULL, NULL, NULL);
752 e_widget_table_object_append(ot, o, 1, 1, 1, 1, 1, 1, 1, 0);
754 o = e_widget_label_add(evas, _("Categories"));
755 e_widget_table_object_append(ot, o, 0, 2, 1, 1, 1, 1, 0, 0);
757 o = e_widget_entry_add(evas, &(cfdata->categories), NULL, NULL, NULL);
758 e_widget_on_change_hook_set(o, _e_desktop_editor_categories_changed, cfdata);
759 e_widget_table_object_append(ot, o, 1, 2, 1, 1, 1, 1, 1, 0);
761 o = e_widget_label_add(evas, _("Mime Types"));
762 e_widget_table_object_append(ot, o, 0, 3, 1, 1, 1, 1, 0, 0);
764 o = e_widget_entry_add(evas, &(cfdata->mimes), NULL, NULL, NULL);
765 e_widget_on_change_hook_set(o, _e_desktop_editor_mimes_changed, cfdata);
766 e_widget_table_object_append(ot, o, 1, 3, 1, 1, 1, 1, 1, 0);
768 o = e_widget_label_add(evas, _("Desktop file"));
769 e_widget_table_object_append(ot, o, 0, 4, 1, 1, 1, 1, 0, 0);
771 o = e_widget_entry_add(evas, NULL, NULL, NULL, NULL);
772 e_widget_table_object_append(ot, o, 1, 4, 1, 1, 1, 1, 1, 0);
773 e_widget_disabled_set(o, 1);
774 cfdata->orig_path_entry = o;
775 _e_desktop_edit_update_orig_path(cfdata);
777 e_widget_toolbook_page_append
778 (otb, NULL, _("General"), ot, 1, 0, 1, 0, 0.5, 0.0);
781 ol = e_widget_list_add(evas, 0, 0);
782 o = e_widget_check_add(evas, _("Startup Notify"), &(cfdata->startup_notify));
783 e_widget_list_object_append(ol, o, 1, 0, 0.0);
784 o = e_widget_check_add(evas, _("Run in Terminal"), &(cfdata->terminal));
785 e_widget_list_object_append(ol, o, 1, 0, 0.0);
786 o = e_widget_check_add(evas, _("Show in Menus"), &(cfdata->show_in_menus));
787 e_widget_list_object_append(ol, o, 1, 0, 0.0);
788 e_widget_toolbook_page_append
789 (otb, NULL, _("Options"), ol, 1, 0, 1, 0, 0.5, 0.0);
791 e_widget_toolbook_page_show(otb, 0);
793 e_dialog_resizable_set(cfd->dia, 1);
794 e_util_win_auto_resize_fill(cfd->dia->win);
795 e_win_centered_set(cfd->dia->win, 1);
801 _e_desktop_editor_cb_icon_select(void *data1, void *data2)
803 E_Config_Dialog_Data *cfdata;
807 E_Desktop_Edit *editor;
809 const char *icon_path = NULL;
814 if (editor->icon_fsel_dia) return;
816 dia = e_dialog_new(cfdata->editor->cfd->con, "E", "_eap_icon_select_dialog");
818 e_object_del_attach_func_set(E_OBJECT(dia),
819 _e_desktop_edit_cb_icon_select_destroy);
820 e_dialog_title_set(dia, _("Select an Icon"));
823 /* absolute path to icon */
824 /* XXX change this to a generic icon selector (that can do either
825 * files from a dir, or icons in the current theme */
828 if (ecore_file_exists(cfdata->icon))
829 icon_path = cfdata->icon;
831 icon_path = efreet_icon_path_find(e_config->icon_theme, cfdata->icon, 64);
834 path = ecore_file_dir_get(icon_path);
839 o = e_widget_fsel_add(dia->win->evas, "/", path, NULL, NULL,
840 _e_desktop_edit_select_cb, cfdata,
846 o = e_widget_fsel_add(dia->win->evas, "~/", "/", NULL, NULL,
847 _e_desktop_edit_select_cb, cfdata,
852 editor->icon_fsel = o;
853 e_widget_size_min_get(o, &mw, &mh);
854 e_dialog_content_set(dia, o, mw, mh);
856 /* buttons at the bottom */
857 e_dialog_button_add(dia, _("OK"), NULL,
858 _e_desktop_edit_cb_icon_select_ok, cfdata);
859 e_dialog_button_add(dia, _("Cancel"), NULL,
860 _e_desktop_edit_cb_icon_select_cancel, cfdata);
861 e_dialog_resizable_set(dia, 1);
862 e_win_centered_set(dia->win, 1);
864 editor->icon_fsel_dia = dia;
868 _e_desktop_editor_cb_exec_select(void *data1, void *data2)
870 E_Config_Dialog_Data *cfdata;
874 E_Desktop_Edit *editor;
880 if (editor->exec_fsel_dia) return;
882 dia = e_dialog_new(cfdata->editor->cfd->con, "E", "_eap_exec_select_dialog");
884 e_object_del_attach_func_set(E_OBJECT(dia),
885 _e_desktop_edit_cb_exec_select_destroy);
886 e_dialog_title_set(dia, _("Select an Executable"));
889 /* absolute path to exe */
892 path = ecore_file_dir_get(cfdata->exec);
893 if (path && !ecore_file_exists(path))
902 o = e_widget_fsel_add(dia->win->evas, "/", path, NULL, NULL,
903 _e_desktop_edit_select_cb, cfdata,
910 o = e_widget_fsel_add(dia->win->evas, "~/", "/", NULL, NULL,
911 _e_desktop_edit_select_cb, cfdata,
916 editor->exec_fsel = o;
917 e_widget_size_min_get(o, &mw, &mh);
918 e_dialog_content_set(dia, o, mw, mh);
920 /* buttons at the bottom */
921 e_dialog_button_add(dia, _("OK"), NULL,
922 _e_desktop_edit_cb_exec_select_ok, cfdata);
923 e_dialog_button_add(dia, _("Cancel"), NULL,
924 _e_desktop_edit_cb_exec_select_cancel, cfdata);
925 e_dialog_resizable_set(dia, 1);
926 e_win_centered_set(dia->win, 1);
928 editor->exec_fsel_dia = dia;
932 _e_desktop_edit_select_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
937 _e_desktop_edit_cb_icon_select_destroy(void *obj)
940 E_Config_Dialog_Data *cfdata = dia->data;
942 /* extra unref isn't needed - there is no extra ref() anywhere i saw */
943 /* e_object_unref(E_OBJECT(dia));*/
944 _e_desktop_edit_cb_icon_select_cancel(cfdata, NULL);
948 _e_desktop_edit_cb_icon_select_ok(void *data, E_Dialog *dia)
950 E_Config_Dialog_Data *cfdata;
954 file = e_widget_fsel_selection_path_get(cfdata->editor->icon_fsel);
956 IFFREE(cfdata->icon);
957 IFDUP(file, cfdata->icon);
958 e_widget_entry_text_set(cfdata->icon_entry, cfdata->icon);
960 _e_desktop_edit_cb_icon_select_cancel(data, dia);
964 _e_desktop_edit_cb_icon_select_cancel(void *data, E_Dialog *dia)
966 E_Config_Dialog_Data *cfdata;
969 if (dia) e_util_defer_object_del(E_OBJECT(dia));
970 cfdata->editor->icon_fsel_dia = NULL;
971 _e_desktop_editor_icon_update(cfdata);
975 _e_desktop_editor_icon_update(E_Config_Dialog_Data *cfdata)
979 if (!cfdata->editor->img_widget) return;
980 o = e_util_icon_theme_icon_add(cfdata->icon, 128, cfdata->editor->evas);
982 /* NB this takes care of freeing any previous icon object */
983 e_widget_button_icon_set(cfdata->editor->img_widget, o);
984 e_widget_change(cfdata->editor->img_widget);
988 _e_desktop_edit_cb_exec_select_destroy(void *obj)
991 E_Config_Dialog_Data *cfdata = dia->data;
993 /* guess it should work like _e_desktop_edit_cb_icon_select_destroy */
994 /* e_object_unref(E_OBJECT(dia)); */
995 _e_desktop_edit_cb_exec_select_cancel(cfdata, NULL);
999 _e_desktop_edit_cb_exec_select_ok(void *data, E_Dialog *dia)
1001 E_Config_Dialog_Data *cfdata;
1005 file = e_widget_fsel_selection_path_get(cfdata->editor->exec_fsel);
1007 IFFREE(cfdata->exec);
1008 IFDUP(file, cfdata->exec);
1010 _e_desktop_edit_cb_exec_select_cancel(data, dia);
1014 _e_desktop_edit_cb_exec_select_cancel(void *data, E_Dialog *dia)
1016 E_Config_Dialog_Data *cfdata;
1019 if (dia) e_util_defer_object_del(E_OBJECT(dia));
1020 cfdata->editor->exec_fsel_dia = NULL;
1021 _e_desktop_editor_exec_update(cfdata);
1025 _e_desktop_editor_exec_update(E_Config_Dialog_Data *cfdata)
1027 if (!cfdata->editor->entry_widget_exec) return;
1028 e_widget_entry_text_set(cfdata->editor->entry_widget_exec, cfdata->exec);