forked from enlightenment/enlightenment
Part one of the quick'n'dirty "save our menu costumizations" hack.
SVN revision: 27107
This commit is contained in:
parent
010bf1ed24
commit
1c3843fea7
|
@ -3,8 +3,10 @@
|
|||
//#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];
|
||||
|
@ -28,22 +30,27 @@ static void _e_fdo_menu_to_order_dump_each_hash_node2(void *value, void *user_d
|
|||
|
||||
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;
|
||||
|
||||
|
@ -119,12 +126,22 @@ _e_fdo_menu_to_order_dump_each_hash_node(void *value, void *user_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)
|
||||
|
@ -132,16 +149,17 @@ _e_fdo_menu_to_order_dump_each_hash_node(void *value, void *user_data)
|
|||
&& ((desktop->OnlyShowIn == NULL) ||(ecore_hash_get(desktop->OnlyShowIn, "Enlightenment") != NULL))
|
||||
&& ((desktop->NotShowIn == NULL) ||(ecore_hash_get(desktop->NotShowIn, "Enlightenment") == NULL)) )
|
||||
{
|
||||
char path2[PATH_MAX];
|
||||
|
||||
#ifdef DEBUG
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#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
|
||||
|
|
|
@ -515,20 +515,21 @@ _cb_button_move_down(void *data1, void *data2)
|
|||
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
|
||||
|
@ -537,7 +538,8 @@ _e_int_config_apps_cb_regen_dialog_delete(E_Win *win)
|
|||
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
|
||||
|
@ -550,19 +552,21 @@ _cb_button_regen(void *data1, void *data2)
|
|||
_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);
|
||||
|
@ -741,7 +745,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
*/
|
||||
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);
|
||||
|
|
|
@ -996,13 +996,8 @@ _e_main_dirs_init(void)
|
|||
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))
|
||||
|
|
Loading…
Reference in New Issue