From: Sebastian Dransfeld Date: Sat, 24 Mar 2007 18:02:29 +0000 (+0000) Subject: Remove fdo to .order code. Menus will be used directly soon. X-Git-Tag: submit/efl/20131021.015651~11860 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6022657127aed49cc18762a06623b6719256189;p=platform%2Fupstream%2Fenlightenment.git Remove fdo to .order code. Menus will be used directly soon. SVN revision: 29029 --- diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 0d2b27c..3b60a27 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -176,7 +176,6 @@ e_int_config_wallpaper.h \ e_int_config_wallpaper_import.h \ e_int_config_wallpaper_gradient.h \ e_color_dialog.h \ -e_fdo_menu_to_order.h \ e_sys.h \ e_obj_dialog.h \ e_int_config_transitions.h \ @@ -340,7 +339,6 @@ e_int_config_wallpaper.c \ e_int_config_wallpaper_import.c \ e_int_config_wallpaper_gradient.c \ e_color_dialog.c \ -e_fdo_menu_to_order.c \ e_sys.c \ e_int_config_transitions.c \ e_obj_dialog.c \ diff --git a/src/bin/e_fdo_menu_to_order.c b/src/bin/e_fdo_menu_to_order.c deleted file mode 100644 index 45b5cc8..0000000 --- a/src/bin/e_fdo_menu_to_order.c +++ /dev/null @@ -1,415 +0,0 @@ -#include "e.h" - -//#define DEBUG 1 - - -// FIXME: If there is only one top level menu, likely called "Applications", then throw it away. The top level is already called "Applications". - - -struct order_data -{ - char order_path[PATH_MAX]; - Ecore_Sheap *sheap; -}; - - -struct category_data -{ - char *path; - Ecore_Hash *menus; -}; - -static void _e_fdo_menu_to_order_make_apps(const char *name, const char *path, const char *directory, Ecore_Hash *apps); -static void _e_fdo_menu_to_order_dump_each_hash_node(void *value, void *user_data); -static void _e_fdo_menu_to_order_add_sheap(Ecore_Sheap *sheap, const char *order_path, const char *file); -static void _e_fdo_menu_to_order_cb_desktop_dir_foreach(void *list_data, void *data); -static void _e_fdo_menu_to_order_cb_desktop_foreach(void *list_data, void *data); -static char *_e_fdo_menu_to_order_find_category(char *category); -static void _e_fdo_menu_to_order_dump_each_hash_node2(void *value, void *user_data); - -static int menu_count; -static int item_count; -static int _do_nuke; - -EAPI void -e_fdo_menu_to_order(int do_nuke) -{ - Ecore_List *files; - const char *home; - char dir[PATH_MAX]; - - menu_count = 0; - item_count = 0; - _do_nuke = do_nuke; - ecore_desktop_instrumentation_reset(); - home = e_user_homedir_get(); - if (do_nuke) - { - /* Nuke the old menus. */ - snprintf(dir, sizeof(dir), "%s/.e/e/applications/menu/all/", home); - ecore_file_recursive_rm(dir); - } - /* Scan through ~/.e/e/applications/all, nuke any dangling links. - * Start simple, add smarts later. - */ - snprintf(dir, sizeof(dir), "%s/.e/e/applications/all", home); - files = ecore_file_ls(dir); - if (files) - { - const char *file; - - while ((file = ecore_list_next(files))) - { - char *real_file; - - snprintf(dir, sizeof(dir), "%s/.e/e/applications/all/%s", home, file); - /* If it's not a link, readlink returns NULL. - * There are other failures that can result in NULL, we don't care about those. - */ - real_file = ecore_file_readlink(dir); - if (real_file) - { - if ((do_nuke) || (!ecore_file_exists(real_file)) ) - { - /* FIXME: Should also remove that item from any menus it is in. */ - ecore_file_unlink(dir); - } - free(real_file); - } - } - } - - ecore_desktop_menu_for_each(_e_fdo_menu_to_order_make_apps); - ecore_desktop_instrumentation_print(); - /* This is a hueristic to guess if there are not enough apps. Feel free to tweak it. */ - if ((do_nuke) && ((item_count < 50) || (menu_count > (item_count * 3))) ) - { - struct category_data cat_data; - - printf("Not enough applications found in the system menus, creating fallback menus.\n"); - /* search out all .desktop files and generate menus ala e17genmenu. */ - ecore_desktop_instrumentation_reset(); - cat_data.menus = ecore_hash_new(ecore_str_hash, ecore_str_compare); - if (cat_data.menus) - { - ecore_hash_set_free_key(cat_data.menus, free); - ecore_hash_set_free_value(cat_data.menus, (Ecore_Free_Cb) ecore_hash_destroy); - ecore_desktop_paths_for_each(ECORE_DESKTOP_PATHS_DESKTOPS, _e_fdo_menu_to_order_cb_desktop_dir_foreach, &cat_data); - ecore_hash_for_each_node(cat_data.menus, _e_fdo_menu_to_order_dump_each_hash_node2, &cat_data); - } - ecore_desktop_instrumentation_print(); - } -} - -static void -_e_fdo_menu_to_order_make_apps(const char *name, const char *path, const char *directory, Ecore_Hash *apps) -{ - struct order_data order_data; - - order_data.sheap = ecore_sheap_new(ecore_str_compare, 100); - if (order_data.sheap) - { - ecore_sheap_set_free_cb(order_data.sheap, free); - snprintf(order_data.order_path, sizeof(order_data.order_path), "%s/.e/e/applications/menu/all/%s", e_user_homedir_get(), path); - /* Collect the apps. */ - ecore_hash_for_each_node(apps, _e_fdo_menu_to_order_dump_each_hash_node, &order_data); - - /* Check if we need to create the directory. */ - if ((order_data.sheap->size) && (!ecore_file_exists(order_data.order_path))) - { - Ecore_Sheap *sheap; - char *temp; - - sheap = ecore_sheap_new(ecore_str_compare, 100); - temp = ecore_file_get_dir(order_data.order_path); - if ((sheap) && (temp)) - { - ecore_sheap_set_free_cb(sheap, free); - ecore_file_mkpath(order_data.order_path); - menu_count++; - /* If we create a dir, we add it to the parents .order file. */ - _e_fdo_menu_to_order_add_sheap(sheap, temp, ecore_file_get_file(order_data.order_path)); - } - if (temp) free(temp); - if (sheap) ecore_sheap_destroy(sheap); - } - - if (ecore_file_exists(order_data.order_path)) - { - if (directory) - { - char dir[PATH_MAX]; - - snprintf(dir, sizeof(dir), "%s/.directory", order_data.order_path); - if ((ecore_file_exists(directory)) && (!ecore_file_exists(dir))) - ecore_file_symlink(directory, dir); - } - /* Create the apps. */ - _e_fdo_menu_to_order_add_sheap(order_data.sheap, order_data.order_path, NULL); - ecore_sheap_destroy(order_data.sheap); - } - } -} - -static void -_e_fdo_menu_to_order_dump_each_hash_node(void *value, void *user_data) -{ - struct order_data *order_data; - Ecore_Hash_Node *node; - Ecore_Desktop *desktop; - const char *file, *key; - char path2[PATH_MAX]; - int do_add, exists = 0; - - order_data = (struct order_data *)user_data; - node = (Ecore_Hash_Node *) value; - key = (char *)node->key; - file = (char *)node->value; - do_add = _do_nuke; - snprintf(path2, sizeof(path2), "%s/.e/e/applications/all/%s", e_user_homedir_get(), key); - if (ecore_file_exists(path2)) - { - desktop = ecore_desktop_get(path2, NULL); - exists = 1; - } - else - desktop = ecore_desktop_get(file, NULL); - /* Check if we process */ - if (!desktop) return; - if ( (!desktop->hidden) && (!desktop->no_display) - && ((desktop->type == NULL) || (strcmp(desktop->type, "Application") == 0)) - && ((desktop->OnlyShowIn == NULL) ||(ecore_hash_get(desktop->OnlyShowIn, "Enlightenment") != NULL)) - && ((desktop->NotShowIn == NULL) ||(ecore_hash_get(desktop->NotShowIn, "Enlightenment") == NULL)) ) - { - item_count++; - if (!exists) - { -#ifdef DEBUG - printf("MAKING MENU ITEM %s -> %s (%s)\n", order_data->order_path, file, key); -#endif - ecore_file_symlink(file, path2); - do_add = 1; - } - if (do_add) - ecore_sheap_insert(order_data->sheap, strdup(key)); - } -} - -static void -_e_fdo_menu_to_order_add_sheap(Ecore_Sheap *sheap, const char *order_path, const char *file) -{ - char path2[PATH_MAX]; - FILE *f; - - if (file) - ecore_sheap_insert(sheap, strdup(file)); - snprintf(path2, sizeof(path2), "%s/.order", order_path); - f = fopen(path2, "r"); - if (f) - { - char buffer[PATH_MAX]; - - /* Read all entries from existing order file, store in sheap for sorting. */ - while (fgets(buffer, sizeof(buffer), f) != NULL) - { - int length; - - /* Strip new line char */ - if (buffer[(length = strlen(buffer) - 1)] == '\n') - buffer[length] = '\0'; - ecore_sheap_insert(sheap, strdup(buffer)); - } - fclose(f); - } - - f = fopen(path2, "w"); - if (!f) - fprintf(stderr, "ERROR: Cannot open order file %s \n", path2); - else - { - char *last = NULL; - int i; - - for (i = 0; i < sheap->size; i++) - { - char *item; - - item = ecore_sheap_item(sheap, i); - if (item) - { - /* Weed out the dupes. */ - if ((last) && (strcmp(last, item) == 0)) - continue; - fprintf(f, "%s\n", item); - last = item; - } - } - fclose(f); - } -} - -static void -_e_fdo_menu_to_order_cb_desktop_dir_foreach(void *list_data, void *data) -{ - char *path = list_data; - struct category_data *cat_data = data; - Ecore_List *desktops; - - if(!path) return; - if(!cat_data) return; - - cat_data->path = path; - desktops = ecore_file_ls(path); - if(desktops) - ecore_list_for_each(desktops, _e_fdo_menu_to_order_cb_desktop_foreach, cat_data); -} - -static void -_e_fdo_menu_to_order_cb_desktop_foreach(void *list_data, void *data) -{ - const char* filename = list_data; - struct category_data *cat_data = data; - char path[PATH_MAX], *ext; - Ecore_Desktop *desktop = ecore_desktop_get(path, NULL); - - if(!filename) - return; - - ext = strrchr(filename, '.'); - if ((ext) && (strcmp(ext, ".desktop") == 0)) - { - snprintf(path, PATH_MAX, "%s/%s", cat_data->path, filename); - desktop = ecore_desktop_get(path, NULL); - /* Check if we process */ - if (!desktop) return; - if ( (!desktop->hidden) && (!desktop->no_display) - && ((desktop->type == NULL) || (strcmp(desktop->type, "Application") == 0)) - && ((desktop->OnlyShowIn == NULL) ||(ecore_hash_get(desktop->OnlyShowIn, "Enlightenment") != NULL)) - && ((desktop->NotShowIn == NULL) ||(ecore_hash_get(desktop->NotShowIn, "Enlightenment") == NULL)) ) - { - char *category; - Ecore_Hash *menu; - - category = _e_fdo_menu_to_order_find_category(desktop->categories); - menu = ecore_hash_get(cat_data->menus, category); - if (!menu) - { - menu = ecore_hash_new(ecore_str_hash, ecore_str_compare); - if (menu) - { - ecore_hash_set_free_key(menu, free); - ecore_hash_set_free_value(menu, free); - ecore_hash_set(cat_data->menus, strdup(category), menu); - } - } - - if (menu) - ecore_hash_set(menu, strdup(filename), strdup(path)); - } - } -} - - -// FIXME: There are better ways of dealing with this, just a quick cut'n'paste from e17genmenu for now. - -#define CATEGORIES "Accessibility:Accessories:Amusement:AudioVideo:Core:Development:Education:Game:Graphics:Multimedia:Network:Office:Programming:Settings:System:TextEditor:Utility:Video" - -static char * -_e_fdo_menu_to_order_find_category(char *category) -{ - char *token, *cat, *categories; - - cat = NULL; - if (category) - { - categories = strdup(CATEGORIES); - if (categories) - { - token = strtok(categories, ":"); - while (token) - { - /* Check If this token is in supplied $t */ - if (strstr(category, token) != NULL) - { - if (strstr(token, "Development") != NULL) - { - cat = _("Programming"); - } - else if (strstr(token, "Game") != NULL) - { - cat = _("Games"); - } - else if ((strstr(token, "AudioVideo") != NULL) || - (strstr(token, "Sound") != NULL) || (strstr(token, "Video") != NULL) || (strstr(token, "Multimedia") != NULL)) - { - cat = _("Multimedia"); - } - else if (strstr(token, "Net") != NULL) - { - cat = _("Internet"); - } - else if (strstr(token, "Education") != NULL) - { - cat = _("Edutainment"); - } - else if (strstr(token, "Amusement") != NULL) - { - cat = _("Toys"); - } - else if (strstr(token, "System") != NULL) - { - cat = _("System"); - } - else if ((strstr(token, "Shells") != NULL) || (strstr(token, "Utility") != NULL) || (strstr(token, "Tools") != NULL)) - { - cat = _("Utilities"); - } - else if ((strstr(token, "Viewers") != NULL) || (strstr(token, "Editors") != NULL) || (strstr(token, "Text") != NULL)) - { - cat = _("Editors"); - } - else if (strstr(token, "Graphics") != NULL) - { - cat = _("Graphics"); - } - else if ((strstr(token, "WindowManagers") != NULL) || (strstr(token, "Core") != NULL)) - { - cat = _("Core"); - } - else if ((strstr(token, "Settings") != NULL) || (strstr(token, "Accessibility") != NULL)) - { - cat = _("Settings"); - } - else if (strstr(token, "Office") != NULL) - { - cat = _("Office"); - } - else - { - cat = _("Core"); - } - } - token = strtok(NULL, ":"); - } - if (token) - free(token); - free(categories); - } - } - if (!cat) - cat = _("Core"); - return strdup(cat); -} - -static void -_e_fdo_menu_to_order_dump_each_hash_node2(void *value, void *user_data) -{ - Ecore_Hash_Node *node; - Ecore_Hash *menu; - char *category; - - node = (Ecore_Hash_Node *) value; - category = (char *)node->key; - menu = (Ecore_Hash *)node->value; - _e_fdo_menu_to_order_make_apps(category, category, "", menu); -} diff --git a/src/bin/e_fdo_menu_to_order.h b/src/bin/e_fdo_menu_to_order.h deleted file mode 100644 index b09b90180..0000000 --- a/src/bin/e_fdo_menu_to_order.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 - */ -#ifdef E_TYPEDEFS -#else -#ifndef E_FDO_MENU_TO_ORDER_H -#define E_FDO_MENU_TO_ORDER_H - -EAPI void e_fdo_menu_to_order(int do_nuke); - -#endif -#endif diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index 3cf5a58..81dc728 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -151,7 +151,6 @@ #include "e_widget_color_well.h" #include "e_widget_csel.h" #include "e_color_dialog.h" -#include "e_fdo_menu_to_order.h" #include "e_sys.h" #include "e_int_config_transitions.h" #include "e_obj_dialog.h" diff --git a/src/bin/e_int_config_apps.c b/src/bin/e_int_config_apps.c index 7df6dac..8c9d6a3 100644 --- a/src/bin/e_int_config_apps.c +++ b/src/bin/e_int_config_apps.c @@ -582,67 +582,6 @@ _cb_button_move_down(void *data1, void *data2) } #endif -static E_Dialog *_e_int_config_apps_regen_dialog = NULL; - -static void -_e_int_config_apps_cb_regen_dialog_regen(void *data, E_Dialog *dia) -{ - e_object_del(E_OBJECT(_e_int_config_apps_regen_dialog)); - _e_int_config_apps_regen_dialog = NULL; - e_fdo_menu_to_order(1); -// if (cfdata->gui.o_fm_all) e_fm2_refresh(cfdata->gui.o_fm_all); -// if (cfdata->gui.o_fm) e_fm2_refresh(cfdata->gui.o_fm); -} - -static void -_e_int_config_apps_cb_regen_dialog_update(void *data, E_Dialog *dia) -{ - e_object_del(E_OBJECT(_e_int_config_apps_regen_dialog)); - _e_int_config_apps_regen_dialog = NULL; - e_fdo_menu_to_order(0); -} - -static void -_e_int_config_apps_cb_regen_dialog_delete(E_Win *win) -{ - E_Dialog *dia; - - dia = win->data; - e_object_del(E_OBJECT(_e_int_config_apps_regen_dialog)); - _e_int_config_apps_regen_dialog = NULL; -} - -static void -_cb_button_regen(void *data1, void *data2) -{ - E_Config_Dialog_Data *cfdata; - - cfdata = data1; - if (_e_int_config_apps_regen_dialog) e_object_del(E_OBJECT(_e_int_config_apps_regen_dialog)); - _e_int_config_apps_regen_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_menu_regen_dialog"); - if (!_e_int_config_apps_regen_dialog) return; - e_win_delete_callback_set(_e_int_config_apps_regen_dialog->win, _e_int_config_apps_cb_regen_dialog_delete); - e_dialog_title_set(_e_int_config_apps_regen_dialog, _("Regenerate or update your Applications menu?")); - e_dialog_text_set(_e_int_config_apps_regen_dialog, - _("You can regenerate your Applications menu.
" - "This will delete any customizations you have made.
" - "This will replace the Applications menu with the system menu.
" - "
" - "Or you could just update your Applications menu.
" - "This will add any new Applications, and remove any old ones from
" - "your Applications menu. Customizations you have made will remain." - )); - e_dialog_icon_set(_e_int_config_apps_regen_dialog, "enlightenment/regenerate_menus", 64); - e_dialog_button_add(_e_int_config_apps_regen_dialog, _("Regenerate"), NULL, - _e_int_config_apps_cb_regen_dialog_regen, NULL); - e_dialog_button_add(_e_int_config_apps_regen_dialog, _("Update"), NULL, - _e_int_config_apps_cb_regen_dialog_update, NULL); - e_dialog_button_focus_num(_e_int_config_apps_regen_dialog, 1); - e_win_centered_set(_e_int_config_apps_regen_dialog->win, 1); - e_dialog_show(_e_int_config_apps_regen_dialog); - e_dialog_border_icon_set(_e_int_config_apps_regen_dialog,"enlightenment/regenerate_menus"); -} - static Evas_Object * _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) { @@ -821,14 +760,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_framelist_object_append(of, mt); e_widget_disabled_set(cfdata->gui.o_move_down_button, 1); */ - if (!once) - { - mt = e_widget_button_add(evas, _("Regenerate / Update \"Applications\" Menu"), "enlightenment/regenerate_menus", - _cb_button_regen, cfdata, NULL); - cfdata->gui.o_regen_button = mt; - e_widget_framelist_object_append(of, mt); - } - e_widget_table_object_append(ot, of, 2, 0, 2, 4, 1, 1, 1, 1); } e_widget_list_object_append(o, ot, 1, 1, 0.5); diff --git a/src/bin/e_main.c b/src/bin/e_main.c index 842aa0b..dac5c6f 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -1043,16 +1043,6 @@ _e_main_dirs_init(void) homedir); system(buf); } - /* FIXME: THIS is a hack to get people started!!! - * Soon to be replaced with fancy background converting and resyncing code. - * Currently this is likely to be done each time E is started up on some systems. - * On the other hand, some of those systems wont have FDO menus, so this should not take long. - */ - snprintf(buf, sizeof(buf), "%s/.e/e/applications/menu/all/.order", homedir); - if (!ecore_file_exists(buf)) - { - e_fdo_menu_to_order(1); - } /* FIXME: THIS is to get people started - shoudl be in a wizard */ snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites", homedir); if (!ecore_file_exists(buf))