//#define DEBUG 1
+// FIXME: Scan through ~/.e/e/applications/all, nuke any dangling links. Start simple, add smarts later.
// 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];
static int menu_count;
static int item_count;
+static int _do_nuke;
EAPI void
-e_fdo_menu_to_order(void)
+e_fdo_menu_to_order(int do_nuke)
{
char dir[PATH_MAX];
- ecore_desktop_instrumentation_reset();
- /* Nuke the old menus. */
- snprintf(dir, sizeof(dir), "%s/.e/e/applications/menu/all/", e_user_homedir_get());
- ecore_file_recursive_rm(dir);
menu_count = 0;
item_count = 0;
+ _do_nuke = do_nuke;
+ ecore_desktop_instrumentation_reset();
+ if (do_nuke)
+ {
+ /* Nuke the old menus. */
+ snprintf(dir, sizeof(dir), "%s/.e/e/applications/menu/all/", e_user_homedir_get());
+ ecore_file_recursive_rm(dir);
+ }
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 ((item_count < 50) || (menu_count > (item_count * 3)))
+ if ((do_nuke) && ((item_count < 50) || (menu_count > (item_count * 3))) )
{
struct category_data cat_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;
- desktop = ecore_desktop_get(file, NULL);
+ 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->OnlyShowIn == NULL) ||(ecore_hash_get(desktop->OnlyShowIn, "Enlightenment") != NULL))
&& ((desktop->NotShowIn == NULL) ||(ecore_hash_get(desktop->NotShowIn, "Enlightenment") == NULL)) )
{
- char path2[PATH_MAX];
-
+ item_count++;
+ if (!exists)
+ {
#ifdef DEBUG
- printf("MAKING MENU ITEM %s -> %s (%s)\n", order_data->order_path, file, key);
+ printf("MAKING MENU ITEM %s -> %s (%s)\n", order_data->order_path, file, key);
#endif
- item_count++;
- snprintf(path2, sizeof(path2), "%s/.e/e/applications/all/%s", e_user_homedir_get(), key);
- if (!ecore_file_exists(path2))
- ecore_file_symlink(file, path2);
- ecore_sheap_insert(order_data->sheap, strdup(key));
+ ecore_file_symlink(file, path2);
+ do_add = 1;
+ }
+ if (do_add)
+ ecore_sheap_insert(order_data->sheap, strdup(key));
}
}
#ifndef E_FDO_MENU_TO_ORDER_H
#define E_FDO_MENU_TO_ORDER_H
-EAPI void e_fdo_menu_to_order(void);
+EAPI void e_fdo_menu_to_order(int do_nuke);
#endif
#endif
static E_Dialog *_e_int_config_apps_regen_dialog = NULL;
static void
-_e_int_config_apps_cb_regen_dialog_ok(void *data, E_Dialog *dia)
+_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();
+ 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_cancel(void *data, E_Dialog *dia)
+_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_Dialog *dia;
dia = win->data;
- _e_int_config_apps_cb_regen_dialog_cancel(NULL, dia);
+ e_object_del(E_OBJECT(_e_int_config_apps_regen_dialog));
+ _e_int_config_apps_regen_dialog = NULL;
}
static void
_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, _("Are you sure you want to regenerate your Applications menus?"));
+ 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 are about to regenerate your Applications menus.<br>"
+ _("You can regenerate your Applications menu.<br>"
"This will delete any customizations you have made.<br>"
- "This will replace the Applications menu with the system menus.<br>"
+ "This will replace the Applications menu with the system menu.<br>"
"<br>"
- "Are you sure you want to do this?"
+ "Or you could just update your Applications menu.<br>"
+ "This will add any new Applications, and remove any old ones from<br>"
+ "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, _("Yes"), NULL,
- _e_int_config_apps_cb_regen_dialog_ok, NULL);
- e_dialog_button_add(_e_int_config_apps_regen_dialog, _("No"), NULL,
- _e_int_config_apps_cb_regen_dialog_cancel, NULL);
+ 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);
*/
if (!once)
{
- mt = e_widget_button_add(evas, _("Regenerate \"Applications\" Menu"), "enlightenment/regenerate_menus",
+ 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);
snprintf(buf, sizeof(buf), "%s/.e/e/applications/menu/all/.order", homedir);
if (!ecore_file_exists(buf))
{
- e_fdo_menu_to_order();
+ e_fdo_menu_to_order(1);
}
- /* FIXME: Add another temporary hack to keep the users happy.
- * Move ~/.e/e/applications/all/*.eap to ~/.e/e/icons/*.edj
- * Read the non .edj info from them and construct a matching ~/.e/e/applications/all/*.desktop
- * Add an icon path to these .desktop files that points to the ~/.e/e/icons/*.edj files.
- */
/* 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))