From fc5ce5b535565b03a1bd3b15870de17bfe36b132 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Sat, 3 Apr 2010 15:37:24 +0000 Subject: [PATCH] Rework Apps dialog to work nicer on smaller screens. Uses the ilist end toggles too :) Rename Favorites Menu to Favorite Applications. Move Favorites to be in the Apps category. NB: Dialog works good, but efeet_util_path_to_file_id is returning garbage so any saves wrt order files (ibar, startup, restart apps) will produce garbage in the .order file hence peoples problems w/ missing IBar apps, etc, etc. SVN revision: 47723 --- .../conf_applications/e_int_config_apps.c | 879 ++++++++---------- src/modules/conf_applications/e_mod_main.c | 20 +- 2 files changed, 405 insertions(+), 494 deletions(-) diff --git a/src/modules/conf_applications/e_int_config_apps.c b/src/modules/conf_applications/e_int_config_apps.c index 01cdc0af1..46dc20552 100644 --- a/src/modules/conf_applications/e_int_config_apps.c +++ b/src/modules/conf_applications/e_int_config_apps.c @@ -1,6 +1,3 @@ -/* - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 - */ #include "e.h" typedef struct _E_Config_Data @@ -11,71 +8,67 @@ typedef struct _E_Config_Data struct _E_Config_Dialog_Data { E_Config_Data *data; - Evas_Object *o_all, *o_sel; - Evas_Object *o_add, *o_del; - Evas_Object *o_up, *o_down; + Evas_Object *o_list, *o_add, *o_del; + Evas_Object *o_order, *o_up, *o_down; Eina_List *apps; }; -/* local protos */ +/* local function prototypes */ static E_Config_Dialog *_create_dialog(E_Container *con, E_Config_Data *data); static void *_create_data(E_Config_Dialog *cfd); -static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); -static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata); +static Evas_Object *_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata); +static int _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata); static Eina_List *_load_menu(const char *path); static Eina_List *_load_order(const char *path); -static void _fill_apps(E_Config_Dialog_Data *cfdata); -static void _fill_list(E_Config_Dialog_Data *cfdata); -static int _cb_sort_desks(const void *d1, const void *d2); -static void _all_list_cb_change(void *data, Evas_Object *obj); -static void _sel_list_cb_change(void *data, Evas_Object *obj); -static void _all_list_cb_selected(void *data); -static void _sel_list_cb_selected(void *data); -static void _cb_add(void *data, void *data2); -static void _cb_del(void *data, void *data2); -static void _cb_up(void *data, void *data2); -static void _cb_down(void *data, void *data2); static int _save_menu(E_Config_Dialog_Data *cfdata); static int _save_order(E_Config_Dialog_Data *cfdata); +static void _fill_apps_list(E_Config_Dialog_Data *cfdata); +static void _fill_order_list(E_Config_Dialog_Data *cfdata); +static void _cb_apps_list_selected(void *data); +static void _cb_order_list_selected(void *data); +static int _cb_desks_sort(const void *data1, const void *data2); +static void _cb_add(void *data, void *data2 __UNUSED__); +static void _cb_del(void *data, void *data2 __UNUSED__); +static void _cb_up(void *data, void *data2 __UNUSED__); +static void _cb_down(void *data, void *data2 __UNUSED__); + +E_Config_Dialog * +e_int_config_apps_add(E_Container *con, const char *params __UNUSED__) +{ + E_Desktop_Edit *ed; + + if (!(ed = e_desktop_edit(con, NULL))) return NULL; + return ed->cfd; +} E_Config_Dialog * e_int_config_apps_favs(E_Container *con, const char *params __UNUSED__) { E_Config_Data *data; - char buf[PATH_MAX]; + char buff[PATH_MAX]; - e_user_dir_concat_static(buf, "applications/menu/favorite.menu"); + e_user_dir_concat_static(buff, "applications/menu/favorite.menu"); data = E_NEW(E_Config_Data, 1); - data->title = eina_stringshare_add(_("Favorites Menu")); + data->title = eina_stringshare_add(_("Favorite Applications")); data->dialog = eina_stringshare_add("menus/favorites_menu"); data->icon = eina_stringshare_add("user-bookmarks"); - data->filename = eina_stringshare_add(buf); - + data->filename = eina_stringshare_add(buff); return _create_dialog(con, data); } -E_Config_Dialog * -e_int_config_apps_add(E_Container *con, const char *params __UNUSED__) -{ - E_Desktop_Edit *ed = e_desktop_edit(con, NULL); - if (!ed) return NULL; - return ed->cfd; -} - E_Config_Dialog * e_int_config_apps_ibar(E_Container *con, const char *params __UNUSED__) { E_Config_Data *data; - char buf[PATH_MAX]; + char buff[PATH_MAX]; - e_user_dir_concat_static(buf, "applications/bar/default/.order"); + e_user_dir_concat_static(buff, "applications/bar/default/.order"); data = E_NEW(E_Config_Data, 1); data->title = eina_stringshare_add(_("IBar Applications")); data->dialog = eina_stringshare_add("applications/ibar_applications"); data->icon = eina_stringshare_add("preferences-applications-ibar"); - data->filename = eina_stringshare_add(buf); - + data->filename = eina_stringshare_add(buff); return _create_dialog(con, data); } @@ -90,7 +83,6 @@ e_int_config_apps_ibar_other(E_Container *con, const char *path) data->dialog = eina_stringshare_add("internal/ibar_other"); data->icon = eina_stringshare_add("preferences-applications-ibar"); data->filename = eina_stringshare_add(path); - return _create_dialog(con, data); } @@ -98,15 +90,14 @@ E_Config_Dialog * e_int_config_apps_startup(E_Container *con, const char *params __UNUSED__) { E_Config_Data *data; - char buf[PATH_MAX]; + char buff[PATH_MAX]; - e_user_dir_concat_static(buf, "applications/startup/.order"); + e_user_dir_concat_static(buff, "applications/startup/.order"); data = E_NEW(E_Config_Data, 1); data->title = eina_stringshare_add(_("Startup Applications")); data->dialog = eina_stringshare_add("applications/startup_applications"); data->icon = eina_stringshare_add("preferences-applications-startup"); - data->filename = eina_stringshare_add(buf); - + data->filename = eina_stringshare_add(buff); return _create_dialog(con, data); } @@ -114,33 +105,31 @@ E_Config_Dialog * e_int_config_apps_restart(E_Container *con, const char *params __UNUSED__) { E_Config_Data *data; - char buf[PATH_MAX]; + char buff[PATH_MAX]; - e_user_dir_concat_static(buf, "applications/restart/.order"); + e_user_dir_concat_static(buff, "applications/restart/.order"); data = E_NEW(E_Config_Data, 1); data->title = eina_stringshare_add(_("Restart Applications")); data->dialog = eina_stringshare_add("applications/restart_applications"); data->icon = eina_stringshare_add("preferences-applications-restart"); - data->filename = eina_stringshare_add(buf); - + data->filename = eina_stringshare_add(buff); return _create_dialog(con, data); } -/* local functions */ +/* local function prototypes */ static E_Config_Dialog * _create_dialog(E_Container *con, E_Config_Data *data) { - E_Config_Dialog *cfd; E_Config_Dialog_View *v; if (e_config_dialog_find("E", data->dialog)) { - if (data->title) eina_stringshare_del(data->title); - if (data->dialog) eina_stringshare_del(data->dialog); - if (data->icon) eina_stringshare_del(data->icon); - if (data->filename) eina_stringshare_del(data->filename); - E_FREE(data); - return NULL; + if (data->title) eina_stringshare_del(data->title); + if (data->dialog) eina_stringshare_del(data->dialog); + if (data->icon) eina_stringshare_del(data->icon); + if (data->filename) eina_stringshare_del(data->filename); + E_FREE(data); + return NULL; } v = E_NEW(E_Config_Dialog_View, 1); @@ -148,10 +137,9 @@ _create_dialog(E_Container *con, E_Config_Data *data) v->free_cfdata = _free_data; v->basic.create_widgets = _basic_create; v->basic.apply_cfdata = _basic_apply; - cfd = e_config_dialog_new(con, data->title, "E", data->dialog, - data->icon, 0, v, data); - e_dialog_resizable_set(cfd->dia, 1); - return cfd; + + return e_config_dialog_new(con, data->title, "E", data->dialog, + data->icon, 0, v, data); } static void * @@ -163,9 +151,7 @@ _create_data(E_Config_Dialog *cfd) if (!(data = cfd->data)) return NULL; if (!data->filename) return NULL; - - ext = strrchr(data->filename, '.'); - if (!ext) return NULL; + if (!(ext = strrchr(data->filename, '.'))) return NULL; cfdata = E_NEW(E_Config_Dialog_Data, 1); cfdata->data = data; @@ -178,111 +164,95 @@ _create_data(E_Config_Dialog *cfd) } static void -_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { E_Config_Data *data; - Efreet_Desktop *desktop; + Efreet_Desktop *desk; - data = cfdata->data; - if (data) + if (data = cfdata->data) { - if (data->title) eina_stringshare_del(data->title); - if (data->dialog) eina_stringshare_del(data->dialog); - if (data->icon) eina_stringshare_del(data->icon); - if (data->filename) eina_stringshare_del(data->filename); - E_FREE(data); + if (data->title) eina_stringshare_del(data->title); + if (data->dialog) eina_stringshare_del(data->dialog); + if (data->icon) eina_stringshare_del(data->icon); + if (data->filename) eina_stringshare_del(data->filename); + E_FREE(data); } - EINA_LIST_FREE(cfdata->apps, desktop) - efreet_desktop_free(desktop); + EINA_LIST_FREE(cfdata->apps, desk) + efreet_desktop_free(desk); E_FREE(cfdata); } static Evas_Object * -_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) +_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata) { - Evas_Coord wmw, wmh; - Evas_Object *o, *ot, *ow, *bt; + Evas_Object *otb, *ot; - o = e_widget_list_add(evas, 0, 1); - ot = e_widget_frametable_add(evas, _("All Applications"), 0); - ow = e_widget_ilist_add(evas, 24, 24, NULL); - e_widget_ilist_multi_select_set(ow, 1); - e_widget_on_change_hook_set(ow, _all_list_cb_change, cfdata); - cfdata->o_all = ow; - _fill_apps(cfdata); - e_widget_frametable_object_append(ot, ow, 0, 0, 1, 1, 1, 1, 1, 1); - ow = e_widget_button_add(evas, _("Add"), "list-add", _cb_add, - cfdata, NULL); - cfdata->o_add = ow; - e_widget_disabled_set(ow, 1); - e_widget_frametable_object_append(ot, ow, 0, 1, 1, 1, 1, 0, 1, 0); - e_widget_size_min_get(ot, &wmw, &wmh); - e_widget_size_min_set(ot, wmw, wmh); - e_widget_list_object_append(o, ot, 1, 1, 0.5); + otb = e_widget_toolbook_add(evas, 24, 24); - ot = e_widget_frametable_add(evas, _("Selected Applications"), 0); - ow = e_widget_ilist_add(evas, 24, 24, NULL); - e_widget_ilist_multi_select_set(ow, 1); - e_widget_on_change_hook_set(ow, _sel_list_cb_change, cfdata); - cfdata->o_sel = ow; - _fill_list(cfdata); - e_widget_frametable_object_append(ot, ow, 0, 0, 1, 1, 1, 1, 1, 1); - bt = e_widget_table_add(evas, 0); - ow = e_widget_button_add(evas, _("Up"), "go-up", _cb_up, - cfdata, NULL); - cfdata->o_up = ow; - e_widget_disabled_set(ow, 1); - e_widget_table_object_append(bt, ow, 0, 0, 1, 1, 1, 0, 1, 0); - ow = e_widget_button_add(evas, _("Down"), "go-down", _cb_down, - cfdata, NULL); - cfdata->o_down = ow; - e_widget_disabled_set(ow, 1); - e_widget_table_object_append(bt, ow, 1, 0, 1, 1, 1, 0, 1, 0); - e_widget_frametable_object_append(ot, bt, 0, 1, 1, 1, 1, 0, 1, 0); - ow = e_widget_button_add(evas, _("Delete"), "list-remove", _cb_del, - cfdata, NULL); - cfdata->o_del = ow; - e_widget_disabled_set(ow, 1); - e_widget_frametable_object_append(ot, ow, 0, 2, 1, 1, 1, 0, 1, 0); - e_widget_size_min_get(ot, &wmw, &wmh); - e_widget_size_min_set(ot, wmw, wmh); - e_widget_list_object_append(o, ot, 1, 1, 0.5); + /* Selection page */ + ot = e_widget_table_add(evas, EINA_FALSE); + cfdata->o_list = e_widget_ilist_add(evas, 24, 24, NULL); + e_widget_ilist_multi_select_set(cfdata->o_list, EINA_TRUE); + _fill_apps_list(cfdata); + e_widget_table_object_append(ot, cfdata->o_list, 0, 0, 2, 1, 1, 1, 1, 1); + cfdata->o_add = e_widget_button_add(evas, _("Add"), "list-add", + _cb_add, cfdata, NULL); + e_widget_disabled_set(cfdata->o_add, EINA_TRUE); + e_widget_table_object_append(ot, cfdata->o_add, 0, 1, 1, 1, 1, 1, 1, 0); + cfdata->o_del = e_widget_button_add(evas, _("Remove"), "list-remove", + _cb_del, cfdata, NULL); + e_widget_disabled_set(cfdata->o_del, EINA_TRUE); + e_widget_table_object_append(ot, cfdata->o_del, 1, 1, 1, 1, 1, 1, 1, 0); + e_widget_toolbook_page_append(otb, NULL, _("Selection"), ot, + 1, 1, 1, 1, 0.5, 0.0); - return o; + /* Order page */ + ot = e_widget_table_add(evas, EINA_FALSE); + cfdata->o_order = e_widget_ilist_add(evas, 24, 24, NULL); + _fill_order_list(cfdata); + e_widget_table_object_append(ot, cfdata->o_order, 0, 0, 2, 1, 1, 1, 1, 1); + cfdata->o_up = e_widget_button_add(evas, _("Up"), "go-up", + _cb_up, cfdata, NULL); + e_widget_disabled_set(cfdata->o_up, EINA_TRUE); + e_widget_table_object_append(ot, cfdata->o_up, 0, 1, 1, 1, 1, 1, 1, 0); + cfdata->o_down = e_widget_button_add(evas, _("Down"), "go-down", + _cb_down, cfdata, NULL); + e_widget_disabled_set(cfdata->o_down, EINA_TRUE); + e_widget_table_object_append(ot, cfdata->o_down, 1, 1, 1, 1, 1, 1, 1, 0); + e_widget_toolbook_page_append(otb, NULL, _("Order"), ot, + 1, 1, 1, 1, 0.5, 0.0); + + e_widget_toolbook_page_show(otb, 0); + return otb; } static int -_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { - int ret = 0; - char *ext; + const char *ext; if ((!cfdata->data) || (!cfdata->data->filename)) return 0; - ext = strrchr(cfdata->data->filename, '.'); - if (!ext) return 0; + if (!(ext = strrchr(cfdata->data->filename, '.'))) return 0; if (!strcmp(ext, ".menu")) - ret = _save_menu(cfdata); + return _save_menu(cfdata); else if (!strcmp(ext, ".order")) - ret = _save_order(cfdata); - - return ret; + return _save_order(cfdata); + return 1; } static Eina_List * _load_menu(const char *path) { Efreet_Menu *menu, *entry; - Eina_List *apps = NULL; - Eina_List *l; + Eina_List *apps = NULL, *l; - apps = NULL; menu = efreet_menu_parse(path); - if ((!menu) || (!menu->entries)) return apps; - EINA_LIST_FOREACH(menu->entries, l, entry) + if ((!menu) || (!menu->entries)) return NULL; + EINA_LIST_FOREACH(menu->entries, l, entry) { - if (entry->type != EFREET_MENU_ENTRY_DESKTOP) continue; - efreet_desktop_ref(entry->desktop); - apps = eina_list_append(apps, entry->desktop); + if (entry->type != EFREET_MENU_ENTRY_DESKTOP) continue; + efreet_desktop_ref(entry->desktop); + apps = eina_list_append(apps, entry->desktop); } efreet_menu_free(menu); return apps; @@ -292,347 +262,36 @@ static Eina_List * _load_order(const char *path) { E_Order *order = NULL; - Eina_List *l = NULL; - Eina_List *apps = NULL; + Eina_List *apps = NULL, *l; + Efreet_Desktop *desk; - apps = NULL; - if (!path) return apps; - order = e_order_new(path); - if (!order) return apps; - for (l = order->desktops; l; l = l->next) + if (!path) return NULL; + if (!(order = e_order_new(path))) return NULL; + EINA_LIST_FOREACH(order->desktops, l, desk) { - efreet_desktop_ref(l->data); - apps = eina_list_append(apps, l->data); + efreet_desktop_ref(desk); + apps = eina_list_append(apps, desk); } e_object_del(E_OBJECT(order)); return apps; } -static void -_fill_apps(E_Config_Dialog_Data *cfdata) -{ - Eina_List *desks = NULL, *l = NULL; - Efreet_Desktop *desk = NULL; - Evas *evas; - int w, h; - - l = NULL; - - evas = evas_object_evas_get(cfdata->o_all); - desks = efreet_util_desktop_name_glob_list("*"); - - desks = eina_list_sort(desks, 0, _cb_sort_desks); - EINA_LIST_FREE(desks, desk) - { - if (!eina_list_search_unsorted(l, _cb_sort_desks, desk)) - l = eina_list_append(l, desk); - else - efreet_desktop_free(desk); - } - - l = eina_list_sort(l, 0, _cb_sort_desks); - - evas_event_freeze(evas); - edje_freeze(); - e_widget_ilist_freeze(cfdata->o_all); - e_widget_ilist_clear(cfdata->o_all); - - EINA_LIST_FREE(l, desk) - { - Evas_Object *icon = NULL; - - icon = e_util_desktop_icon_add(desk, 24, evas); - e_widget_ilist_append(cfdata->o_all, icon, desk->name, - _all_list_cb_selected, cfdata, desk->orig_path); - efreet_desktop_free(desk); - } - - e_widget_ilist_go(cfdata->o_all); - e_widget_ilist_thaw(cfdata->o_all); - edje_thaw(); - evas_event_thaw(evas); - e_widget_size_min_get(cfdata->o_all, &w, &h); - e_widget_size_min_set(cfdata->o_all, w, h); -} - -static void -_fill_list(E_Config_Dialog_Data *cfdata) -{ - Efreet_Desktop *desk = NULL; - Evas *evas; - int w, h; - - if (!cfdata->apps) return; - evas = evas_object_evas_get(cfdata->o_sel); - evas_event_freeze(evas); - edje_freeze(); - e_widget_ilist_freeze(cfdata->o_sel); - e_widget_ilist_clear(cfdata->o_sel); - - EINA_LIST_FREE(cfdata->apps, desk) - { - Evas_Object *icon = NULL; - - icon = e_util_desktop_icon_add(desk, 24, evas); - e_widget_ilist_append(cfdata->o_sel, icon, desk->name, - _sel_list_cb_selected, cfdata, desk->orig_path); - } - - cfdata->apps = NULL; - e_widget_ilist_go(cfdata->o_sel); - e_widget_size_min_get(cfdata->o_sel, &w, &h); - e_widget_size_min_set(cfdata->o_sel, w, h); - e_widget_ilist_thaw(cfdata->o_sel); - edje_thaw(); - evas_event_thaw(evas); - e_widget_disabled_set(cfdata->o_del, 1); -} - -static int -_cb_sort_desks(const void *data1, const void *data2) -{ - const Efreet_Desktop *d1 = data1; - const Efreet_Desktop *d2 = data2; - - if (!d1->name) return 1; - if (!d2->name) return -1; - return strcmp(d1->name, d2->name); -} - -static void -_all_list_cb_change(void *data, Evas_Object *obj) -{ - E_Config_Dialog_Data *cfdata = NULL; - - if (!(cfdata = data)) return; - - /* unselect anything in Sel List & disable buttons */ - e_widget_ilist_unselect(cfdata->o_sel); - e_widget_disabled_set(cfdata->o_up, 1); - e_widget_disabled_set(cfdata->o_down, 1); - e_widget_disabled_set(cfdata->o_del, 1); -} - -static void -_sel_list_cb_change(void *data, Evas_Object *obj) -{ - E_Config_Dialog_Data *cfdata = NULL; - - if (!(cfdata = data)) return; - - /* unselect anything in All List & disable buttons */ - e_widget_ilist_unselect(cfdata->o_all); - e_widget_disabled_set(cfdata->o_add, 1); -} - -static void -_all_list_cb_selected(void *data) -{ - E_Config_Dialog_Data *cfdata = NULL; - int sel; - - if (!(cfdata = data)) return; - sel = e_widget_ilist_selected_count_get(cfdata->o_all); - if (sel == 0) - e_widget_disabled_set(cfdata->o_add, 1); - else - e_widget_disabled_set(cfdata->o_add, 0); -} - -static void -_sel_list_cb_selected(void *data) -{ - E_Config_Dialog_Data *cfdata = NULL; - int sel, count; - - if (!(cfdata = data)) return; - e_widget_disabled_set(cfdata->o_del, 0); - sel = e_widget_ilist_selected_get(cfdata->o_sel); - count = e_widget_ilist_count(cfdata->o_sel); - if (sel == 0) - e_widget_disabled_set(cfdata->o_up, 1); - else - e_widget_disabled_set(cfdata->o_up, 0); - if (sel < (count - 1)) - e_widget_disabled_set(cfdata->o_down, 0); - else - e_widget_disabled_set(cfdata->o_down, 1); -} - -static void -_cb_add(void *data, void *data2) -{ - E_Config_Dialog_Data *cfdata = NULL; - Eina_List *l = NULL; - Evas *evas; - int w, h, i; - - if (!(cfdata = data)) return; - evas = evas_object_evas_get(cfdata->o_all); - evas_event_freeze(evas); - edje_freeze(); - e_widget_ilist_freeze(cfdata->o_all); - - for (i = 0, l = e_widget_ilist_items_get(cfdata->o_all); l; l = l->next, i++) - { - E_Ilist_Item *item = NULL; - Efreet_Desktop *desk = NULL; - Evas_Object *icon = NULL; - const char *lbl; - - if (!(item = l->data)) continue; - if (!item->selected) continue; - lbl = e_widget_ilist_nth_label_get(cfdata->o_all, i); - if (!lbl) continue; - desk = efreet_util_desktop_name_find(lbl); - if (!desk) continue; - icon = e_util_desktop_icon_add(desk, 24, evas); - e_widget_ilist_append(cfdata->o_sel, icon, desk->name, - _sel_list_cb_selected, cfdata, desk->orig_path); - efreet_desktop_free(desk); - } - - e_widget_ilist_go(cfdata->o_sel); - e_widget_size_min_get(cfdata->o_sel, &w, &h); - e_widget_size_min_set(cfdata->o_sel, w, h); - e_widget_ilist_thaw(cfdata->o_sel); - e_widget_ilist_unselect(cfdata->o_all); - edje_thaw(); - evas_event_thaw(evas); -} - -static void -_cb_del(void *data, void *data2) -{ - E_Config_Dialog_Data *cfdata = NULL; - Eina_List *l = NULL; - Evas *evas; - int w, h; - - if (!(cfdata = data)) return; - evas = evas_object_evas_get(cfdata->o_sel); - evas_event_freeze(evas); - edje_freeze(); - e_widget_ilist_freeze(cfdata->o_sel); - for (l = e_widget_ilist_items_get(cfdata->o_sel); l; l = l->next) - { - int i = 0; - - i = e_widget_ilist_selected_get(cfdata->o_sel); - if (i == -1) break; - e_widget_ilist_remove_num(cfdata->o_sel, i); - } - e_widget_ilist_unselect(cfdata->o_sel); - e_widget_ilist_go(cfdata->o_sel); - e_widget_size_min_get(cfdata->o_sel, &w, &h); - e_widget_size_min_set(cfdata->o_sel, w, h); - e_widget_ilist_thaw(cfdata->o_sel); - edje_thaw(); - evas_event_thaw(evas); -} - -static void -_cb_up(void *data, void *data2) -{ - E_Config_Dialog_Data *cfdata = NULL; - Evas_Object *icon = NULL; - Efreet_Desktop *desk = NULL; - Evas *evas; - const char *lbl; - int sel, w, h; - - if (!(cfdata = data)) return; - if (e_widget_ilist_selected_count_get(cfdata->o_sel) > 1) return; - evas = evas_object_evas_get(cfdata->o_sel); - evas_event_freeze(evas); - edje_freeze(); - e_widget_ilist_freeze(cfdata->o_sel); - sel = e_widget_ilist_selected_get(cfdata->o_sel); - lbl = e_widget_ilist_nth_label_get(cfdata->o_sel, sel); - if (lbl) - { - desk = efreet_util_desktop_name_find(lbl); - if (desk) - { - e_widget_ilist_remove_num(cfdata->o_sel, sel); - e_widget_ilist_go(cfdata->o_sel); - icon = e_util_desktop_icon_add(desk, 24, evas); - e_widget_ilist_prepend_relative(cfdata->o_sel, icon, desk->name, - _sel_list_cb_selected, cfdata, - desk->orig_path, (sel - 1)); - e_widget_ilist_selected_set(cfdata->o_sel, (sel - 1)); - efreet_desktop_free(desk); - } - } - e_widget_ilist_go(cfdata->o_sel); - e_widget_size_min_get(cfdata->o_sel, &w, &h); - e_widget_size_min_set(cfdata->o_sel, w, h); - e_widget_ilist_thaw(cfdata->o_sel); - edje_thaw(); - evas_event_thaw(evas); -} - -static void -_cb_down(void *data, void *data2) -{ - E_Config_Dialog_Data *cfdata = NULL; - Evas_Object *icon = NULL; - Efreet_Desktop *desk = NULL; - Evas *evas; - const char *lbl; - int sel, w, h; - - if (!(cfdata = data)) return; - if (e_widget_ilist_selected_count_get(cfdata->o_sel) > 1) return; - evas = evas_object_evas_get(cfdata->o_sel); - evas_event_freeze(evas); - edje_freeze(); - e_widget_ilist_freeze(cfdata->o_sel); - sel = e_widget_ilist_selected_get(cfdata->o_sel); - lbl = e_widget_ilist_nth_label_get(cfdata->o_sel, sel); - if (lbl) - { - desk = efreet_util_desktop_name_find(lbl); - if (desk) - { - e_widget_ilist_remove_num(cfdata->o_sel, sel); - e_widget_ilist_go(cfdata->o_sel); - icon = e_util_desktop_icon_add(desk, 24, evas); - e_widget_ilist_append_relative(cfdata->o_sel, icon, desk->name, - _sel_list_cb_selected, cfdata, - desk->orig_path, sel); - e_widget_ilist_selected_set(cfdata->o_sel, (sel + 1)); - efreet_desktop_free(desk); - } - } - e_widget_ilist_go(cfdata->o_sel); - e_widget_size_min_get(cfdata->o_sel, &w, &h); - e_widget_size_min_set(cfdata->o_sel, w, h); - e_widget_ilist_thaw(cfdata->o_sel); - edje_thaw(); - evas_event_thaw(evas); -} - static int _save_menu(E_Config_Dialog_Data *cfdata) { - Eina_List *l = NULL; + Eina_List *l; Efreet_Menu *menu = NULL; - int i, ret; + const E_Ilist_Item *it; + int ret; menu = efreet_menu_new("Favorites"); - for (i = 0, l = e_widget_ilist_items_get(cfdata->o_sel); l; l = l->next, i++) + EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_order), l, it) { - Efreet_Desktop *desk = NULL; - const char *lbl; + Efreet_Desktop *desk; - if (!l->data) continue; - lbl = e_widget_ilist_nth_label_get(cfdata->o_sel, i); - if (!lbl) continue; - desk = efreet_util_desktop_name_find(lbl); - if (!desk) continue; - efreet_menu_desktop_insert(menu, desk, -1); - efreet_desktop_free(desk); + if (!(desk = efreet_util_desktop_name_find(it->label))) continue; + efreet_menu_desktop_insert(menu, desk, -1); + efreet_desktop_free(desk); } ret = efreet_menu_save(menu, cfdata->data->filename); efreet_menu_free(menu); @@ -642,26 +301,292 @@ _save_menu(E_Config_Dialog_Data *cfdata) static int _save_order(E_Config_Dialog_Data *cfdata) { - Eina_List *l = NULL; + Eina_List *l; E_Order *order = NULL; - int i; + const E_Ilist_Item *it; - order = e_order_new(cfdata->data->filename); - if (!order) return 0; + if (!(order = e_order_new(cfdata->data->filename))) return 0; e_order_clear(order); - for (i = 0, l = e_widget_ilist_items_get(cfdata->o_sel); l; l = l->next, i++) + EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_order), l, it) { - Efreet_Desktop *desk = NULL; - const char *lbl; + Efreet_Desktop *desk; - if (!l->data) continue; - lbl = e_widget_ilist_nth_label_get(cfdata->o_sel, i); - if (!lbl) continue; - desk = efreet_util_desktop_name_find(lbl); - if (!desk) continue; - e_order_append(order, desk); - efreet_desktop_free(desk); + if (!(desk = efreet_util_desktop_name_find(it->label))) continue; + e_order_append(order, desk); + efreet_desktop_free(desk); } e_object_del(E_OBJECT(order)); return 1; } + +static void +_fill_apps_list(E_Config_Dialog_Data *cfdata) +{ + Eina_List *l = NULL, *desks = NULL; + Efreet_Desktop *desk = NULL; + Evas *evas; + + desks = efreet_util_desktop_name_glob_list("*"); + EINA_LIST_FREE(desks, desk) + { + if (!eina_list_search_unsorted(l, _cb_desks_sort, desk)) + l = eina_list_append(l, desk); + else + efreet_desktop_free(desk); + } + l = eina_list_sort(l, -1, _cb_desks_sort); + + evas = evas_object_evas_get(cfdata->o_list); + evas_event_freeze(evas); + edje_freeze(); + e_widget_ilist_freeze(cfdata->o_list); + e_widget_ilist_clear(cfdata->o_list); + + EINA_LIST_FREE(l, desk) + { + Evas_Object *icon = NULL, *end = NULL; + + end = edje_object_add(evas); + if (!e_theme_edje_object_set(end, "base/theme/widgets", + "e/widgets/ilist/toggle_end")) + { + evas_object_del(end); + end = NULL; + } + + if (eina_list_search_unsorted(cfdata->apps, _cb_desks_sort, desk)) + { + if (end) edje_object_signal_emit(end, "e,state,checked", "e"); + } + else + { + if (end) edje_object_signal_emit(end, "e,state,unchecked", "e"); + } + + icon = e_util_desktop_icon_add(desk, 24, evas); + e_widget_ilist_append_full(cfdata->o_list, icon, end, desk->name, + _cb_apps_list_selected, cfdata, NULL); + efreet_desktop_free(desk); + } + + e_widget_ilist_go(cfdata->o_list); + e_widget_ilist_thaw(cfdata->o_list); + edje_thaw(); + evas_event_thaw(evas); +} + +static void +_fill_order_list(E_Config_Dialog_Data *cfdata) +{ + Eina_List *l = NULL, *desks = NULL; + Efreet_Desktop *desk = NULL; + Evas *evas; + + evas = evas_object_evas_get(cfdata->o_order); + evas_event_freeze(evas); + edje_freeze(); + e_widget_ilist_freeze(cfdata->o_order); + e_widget_ilist_clear(cfdata->o_order); + + EINA_LIST_FOREACH(cfdata->apps, l, desk) + { + Evas_Object *icon = NULL; + + icon = e_util_desktop_icon_add(desk, 24, evas); + e_widget_ilist_append(cfdata->o_order, icon, desk->name, + _cb_order_list_selected, cfdata, NULL); + } + + e_widget_ilist_go(cfdata->o_order); + e_widget_ilist_thaw(cfdata->o_order); + edje_thaw(); + evas_event_thaw(evas); +} + +static void +_cb_apps_list_selected(void *data) +{ + E_Config_Dialog_Data *cfdata; + const E_Ilist_Item *it; + Eina_List *l; + unsigned int enabled = 0, disabled = 0; + + if (!(cfdata = data)) return; + EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_list), l, it) + { + Efreet_Desktop *desk; + + if ((!it->selected) || (it->header)) continue; + if (!(desk = efreet_util_desktop_name_find(it->label))) continue; + if (eina_list_search_unsorted(cfdata->apps, _cb_desks_sort, desk)) + enabled++; + else + disabled++; + efreet_desktop_free(desk); + } + e_widget_disabled_set(cfdata->o_add, !disabled); + e_widget_disabled_set(cfdata->o_del, !enabled); +} + +static void +_cb_order_list_selected(void *data) +{ + E_Config_Dialog_Data *cfdata; + int sel, count; + + if (!(cfdata = data)) return; + sel = e_widget_ilist_selected_get(cfdata->o_order); + count = e_widget_ilist_count(cfdata->o_order); + e_widget_disabled_set(cfdata->o_up, (sel == 0)); + e_widget_disabled_set(cfdata->o_down, !(sel < (count - 1))); +} + +static int +_cb_desks_sort(const void *data1, const void *data2) +{ + const Efreet_Desktop *d1, *d2; + + if (!(d1 = data1)) return 1; + if (!d1->name) return 1; + if (!(d2 = data2)) return -1; + if (!d2->name) return -1; + return strcmp(d1->name, d2->name); +} + +static void +_cb_add(void *data, void *data2 __UNUSED__) +{ + E_Config_Dialog_Data *cfdata; + const E_Ilist_Item *it; + Eina_List *l; + + if (!(cfdata = data)) return; + EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_list), l, it) + { + Efreet_Desktop *desk; + + if ((!it->selected) || (it->header)) continue; + if (!(desk = efreet_util_desktop_name_find(it->label))) continue; + if (!eina_list_search_unsorted(cfdata->apps, _cb_desks_sort, desk)) + { + Evas_Object *end; + + end = e_widget_ilist_item_end_get(it); + if (end) edje_object_signal_emit(end, "e,state,checked", "e"); + efreet_desktop_ref(desk); + cfdata->apps = eina_list_append(cfdata->apps, desk); + } + else + efreet_desktop_free(desk); + } + e_widget_ilist_unselect(cfdata->o_list); + e_widget_disabled_set(cfdata->o_add, EINA_TRUE); + e_widget_disabled_set(cfdata->o_del, EINA_TRUE); + _fill_order_list(cfdata); +} + +static void +_cb_del(void *data, void *data2 __UNUSED__) +{ + E_Config_Dialog_Data *cfdata; + const E_Ilist_Item *it; + Eina_List *l; + + if (!(cfdata = data)) return; + EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_list), l, it) + { + Efreet_Desktop *desk; + + if ((!it->selected) || (it->header)) continue; + if (!(desk = efreet_util_desktop_name_find(it->label))) continue; + if (eina_list_search_unsorted(cfdata->apps, _cb_desks_sort, desk)) + { + Evas_Object *end; + + end = e_widget_ilist_item_end_get(it); + if (end) edje_object_signal_emit(end, "e,state,unchecked", "e"); + efreet_desktop_unref(desk); + cfdata->apps = eina_list_remove(cfdata->apps, desk); + } + else + efreet_desktop_free(desk); + } + e_widget_ilist_unselect(cfdata->o_list); + e_widget_disabled_set(cfdata->o_add, EINA_TRUE); + e_widget_disabled_set(cfdata->o_del, EINA_TRUE); + _fill_order_list(cfdata); +} + +static void +_cb_up(void *data, void *data2 __UNUSED__) +{ + E_Config_Dialog_Data *cfdata; + Efreet_Desktop *desk; + Evas *evas; + const char *lbl; + int sel; + + if (!(cfdata = data)) return; + evas = evas_object_evas_get(cfdata->o_order); + evas_event_freeze(evas); + edje_freeze(); + e_widget_ilist_freeze(cfdata->o_order); + + sel = e_widget_ilist_selected_get(cfdata->o_order); + lbl = e_widget_ilist_selected_label_get(cfdata->o_order); + if (desk = efreet_util_desktop_name_find(lbl)) + { + Evas_Object *icon = NULL; + + e_widget_ilist_remove_num(cfdata->o_order, sel); + e_widget_ilist_go(cfdata->o_order); + icon = e_util_desktop_icon_add(desk, 24, evas); + e_widget_ilist_prepend_relative(cfdata->o_order, icon, desk->name, + _cb_order_list_selected, cfdata, + NULL, (sel - 1)); + e_widget_ilist_selected_set(cfdata->o_order, (sel - 1)); + efreet_desktop_free(desk); + } + + e_widget_ilist_go(cfdata->o_order); + e_widget_ilist_thaw(cfdata->o_order); + edje_thaw(); + evas_event_thaw(evas); +} + +static void +_cb_down(void *data, void *data2 __UNUSED__) +{ + E_Config_Dialog_Data *cfdata; + Efreet_Desktop *desk; + Evas *evas; + const char *lbl; + int sel; + + if (!(cfdata = data)) return; + evas = evas_object_evas_get(cfdata->o_order); + evas_event_freeze(evas); + edje_freeze(); + e_widget_ilist_freeze(cfdata->o_order); + + sel = e_widget_ilist_selected_get(cfdata->o_order); + lbl = e_widget_ilist_selected_label_get(cfdata->o_order); + if (desk = efreet_util_desktop_name_find(lbl)) + { + Evas_Object *icon = NULL; + + e_widget_ilist_remove_num(cfdata->o_order, sel); + e_widget_ilist_go(cfdata->o_order); + icon = e_util_desktop_icon_add(desk, 24, evas); + e_widget_ilist_append_relative(cfdata->o_order, icon, desk->name, + _cb_order_list_selected, cfdata, + NULL, sel); + e_widget_ilist_selected_set(cfdata->o_order, (sel + 1)); + efreet_desktop_free(desk); + } + + e_widget_ilist_go(cfdata->o_order); + e_widget_ilist_thaw(cfdata->o_order); + edje_thaw(); + evas_event_thaw(evas); +} diff --git a/src/modules/conf_applications/e_mod_main.c b/src/modules/conf_applications/e_mod_main.c index 87f3e7481..781de99be 100644 --- a/src/modules/conf_applications/e_mod_main.c +++ b/src/modules/conf_applications/e_mod_main.c @@ -4,23 +4,10 @@ #include "e.h" #include "e_mod_main.h" -/***************************************************************************/ -/**/ /* actual module specifics */ static E_Module *conf_module = NULL; -/**/ -/***************************************************************************/ - -/***************************************************************************/ -/**/ - -/**/ -/***************************************************************************/ - -/***************************************************************************/ -/**/ /* module setup */ EAPI E_Module_Api e_modapi = { @@ -33,13 +20,13 @@ e_modapi_init(E_Module *m) { e_configure_registry_category_add("applications", 20, _("Apps"), NULL, "preferences-applications"); e_configure_registry_item_add("applications/new_application", 10, _("New Application"), NULL, "preferences-applications-add", e_int_config_apps_add); + e_configure_registry_item_add("applications/favorite_applications", 10, _("Favorite Applications"), NULL, "user-bookmarks", e_int_config_apps_favs); e_configure_registry_item_add("applications/ibar_applications", 20, _("IBar Applications"), NULL, "preferences-applications-ibar", e_int_config_apps_ibar); e_configure_registry_item_add("applications/restart_applications", 30, _("Restart Applications"), NULL, "preferences-applications-restart", e_int_config_apps_restart); e_configure_registry_item_add("applications/startup_applications", 40, _("Startup Applications"), NULL, "preferences-applications-startup", e_int_config_apps_startup); e_configure_registry_category_add("internal", -1, _("Internal"), NULL, "enlightenment/internal"); e_configure_registry_item_add("internal/ibar_other", -1, _("IBar Other"), NULL, "preferences-system-windows", e_int_config_apps_ibar_other); - e_configure_registry_category_add("menus", 60, _("Menus"), NULL, "preferences-menus"); - e_configure_registry_item_add("menus/favorites_menu", 10, _("Favorites Menu"), NULL, "user-bookmarks", e_int_config_apps_favs); + conf_module = m; e_module_delayed_set(m, 1); return m; @@ -50,10 +37,9 @@ e_modapi_shutdown(E_Module *m) { E_Config_Dialog *cfd; while ((cfd = e_config_dialog_get("E", "_config_apps_dialog"))) e_object_del(E_OBJECT(cfd)); - e_configure_registry_item_del("menus/favorites_menu"); - e_configure_registry_category_del("menus"); e_configure_registry_item_del("internal/ibar_other"); e_configure_registry_category_del("internal"); + e_configure_registry_item_del("applications/favorite_applications"); e_configure_registry_item_del("applications/new_application"); e_configure_registry_item_del("applications/ibar_applications"); e_configure_registry_item_del("applications/restart_applications");