forked from enlightenment/enlightenment
Add a Favorites Editor :) (Don't forget to Apply your changes)
#if 0 out the old Apps Editor(s) for now, they are broken anyway, until I get them working a little later. SVN revision: 29397
This commit is contained in:
parent
0696521bbd
commit
4f2e047047
|
@ -133,7 +133,7 @@ e_int_config_winlist.h \
|
|||
e_int_config_display.h \
|
||||
e_int_config_desklock.h \
|
||||
e_int_config_exebuf.h \
|
||||
e_int_config_apps.h \
|
||||
e_int_config_apps_menu.h \
|
||||
e_int_config_cfgdialogs.h \
|
||||
e_int_config_color_classes.h \
|
||||
e_int_config_mime.h \
|
||||
|
@ -293,7 +293,7 @@ e_int_config_winlist.c \
|
|||
e_int_config_display.c \
|
||||
e_int_config_desklock.c \
|
||||
e_int_config_exebuf.c \
|
||||
e_int_config_apps.c \
|
||||
e_int_config_apps_menu.c \
|
||||
e_int_config_cfgdialogs.c \
|
||||
e_int_config_intl.c \
|
||||
e_int_config_imc.c \
|
||||
|
|
|
@ -403,10 +403,12 @@ _e_configure_fill_cat_list(void *data)
|
|||
_e_configure_item_add(cat, _("Transitions"), "enlightenment/transitions", e_int_config_transitions);
|
||||
_e_configure_item_add(cat, _("Startup"), "enlightenment/startup", e_int_config_startup);
|
||||
|
||||
#if 0
|
||||
cat = _e_configure_category_add(eco, _("Applications"), "enlightenment/applications");
|
||||
_e_configure_item_add(cat, _("IBar Applications"), "enlightenment/ibar_applications", e_int_config_apps_ibar);
|
||||
_e_configure_item_add(cat, _("Restart Applications"), "enlightenment/restart_applications", e_int_config_apps_restart);
|
||||
_e_configure_item_add(cat, _("Startup Applications"), "enlightenment/startup_applications", e_int_config_apps_startup);
|
||||
#endif
|
||||
|
||||
cat = _e_configure_category_add(eco, _("Screen"), "enlightenment/screen_setup");
|
||||
_e_configure_item_add(cat, _("Virtual Desktops"), "enlightenment/desktops", e_int_config_desks);
|
||||
|
@ -426,7 +428,10 @@ _e_configure_fill_cat_list(void *data)
|
|||
_e_configure_item_add(cat, _("Window Manipulation"), "enlightenment/window_manipulation", e_int_config_window_manipulation);
|
||||
|
||||
cat = _e_configure_category_add(eco, _("Menus"), "enlightenment/menus");
|
||||
_e_configure_item_add(cat, _("Favorites Menu"), "enlightenment/favorites", e_int_config_apps_favs);
|
||||
#if 0
|
||||
_e_configure_item_add(cat, _("Application Menus"), "enlightenment/applications", e_int_config_apps);
|
||||
#endif
|
||||
_e_configure_item_add(cat, _("Menu Settings"), "enlightenment/menu_settings", e_int_config_menus);
|
||||
_e_configure_item_add(cat, _("Client List Menu"), "enlightenment/windows", e_int_config_clientlist);
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
#include "e_int_config_screensaver.h"
|
||||
#include "e_int_config_dpms.h"
|
||||
#include "e_int_config_exebuf.h"
|
||||
#include "e_int_config_apps.h"
|
||||
#include "e_int_config_apps_menu.h"
|
||||
#include "e_int_config_cfgdialogs.h"
|
||||
#include "e_int_config_intl.h"
|
||||
#include "e_int_config_imc.h"
|
||||
|
|
|
@ -0,0 +1,274 @@
|
|||
#include "e.h"
|
||||
|
||||
/* TODO: This should be modified to handle any other fdo menu editing.
|
||||
*
|
||||
*/
|
||||
|
||||
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 _fill_apps(E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_list(E_Config_Dialog_Data *cfdata);
|
||||
static void _apps_cb_selected(void *data);
|
||||
static void _list_cb_selected(void *data);
|
||||
static void _cb_add(void *data, void *data2);
|
||||
static void _cb_del(void *data, void *data2);
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
Evas_Object *o_apps, *o_list;
|
||||
Evas_Object *o_add, *o_del;
|
||||
Efreet_Menu *menu;
|
||||
|
||||
char *fav, *app;
|
||||
};
|
||||
|
||||
EAPI E_Config_Dialog *
|
||||
e_int_config_apps_favs(E_Container *con)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
if (e_config_dialog_find("E", "_config_apps_favs_dialog")) return NULL;
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.create_widgets = _basic_create;
|
||||
v->basic.apply_cfdata = _basic_apply;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Favorites Menu"), "E",
|
||||
"_config_apps_favs_dialog",
|
||||
"enlightenment/favorites", 0, v, NULL);
|
||||
return cfd;
|
||||
}
|
||||
|
||||
/* Private Functions */
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
char buf[4096];
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/menu/favorite.menu",
|
||||
e_user_homedir_get());
|
||||
cfdata->menu = efreet_menu_parse(buf);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (cfdata->menu) efreet_menu_free(cfdata->menu);
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *ot, *of, *ob;
|
||||
|
||||
ot = e_widget_table_add(evas, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("All Applications"), 0);
|
||||
ob = e_widget_ilist_add(evas, 24, 24, &(cfdata->app));
|
||||
cfdata->o_apps = ob;
|
||||
_fill_apps(cfdata);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_table_object_append(ot, of, 0, 0, 1, 4, 1, 0, 1, 0);
|
||||
|
||||
ob = e_widget_button_add(evas, _("Add"), "widget/add", _cb_add, cfdata, NULL);
|
||||
cfdata->o_add = ob;
|
||||
e_widget_disabled_set(ob, 1);
|
||||
e_widget_table_object_append(ot, ob, 1, 1, 1, 1, 1, 0, 1, 0);
|
||||
ob = e_widget_button_add(evas, _("Delete"), "widget/del", _cb_del, cfdata, NULL);
|
||||
cfdata->o_del = ob;
|
||||
e_widget_disabled_set(ob, 1);
|
||||
e_widget_table_object_append(ot, ob, 1, 2, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Favorites"), 0);
|
||||
ob = e_widget_ilist_add(evas, 24, 24, &(cfdata->fav));
|
||||
cfdata->o_list = ob;
|
||||
_fill_list(cfdata);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_table_object_append(ot, of, 2, 0, 1, 4, 1, 0, 1, 0);
|
||||
|
||||
return ot;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
char buf[4096];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/menu/favorite.menu",
|
||||
e_user_homedir_get());
|
||||
efreet_menu_save(cfdata->menu, buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_apps(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas *evas;
|
||||
Evas_Coord w;
|
||||
Efreet_Menu *menu;
|
||||
|
||||
evas = evas_object_evas_get(cfdata->o_apps);
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(cfdata->o_apps);
|
||||
|
||||
menu = efreet_menu_get();
|
||||
if (menu->entries)
|
||||
{
|
||||
Efreet_Menu *entry;
|
||||
|
||||
ecore_list_goto_first(menu->entries);
|
||||
while ((entry = ecore_list_next(menu->entries)))
|
||||
{
|
||||
Efreet_Menu *sub;
|
||||
|
||||
if (entry->type != EFREET_MENU_ENTRY_MENU) continue;
|
||||
e_widget_ilist_header_append(cfdata->o_apps, NULL, entry->id);
|
||||
if (!entry->entries) continue;
|
||||
ecore_list_goto_first(entry->entries);
|
||||
while ((sub = ecore_list_next(entry->entries)))
|
||||
{
|
||||
Evas_Object *icon = NULL;
|
||||
|
||||
if (sub->type != EFREET_MENU_ENTRY_DESKTOP) continue;
|
||||
if (sub->icon)
|
||||
{
|
||||
const char *file;
|
||||
|
||||
if (sub->icon[0] == '/') file = sub->icon;
|
||||
else
|
||||
file = efreet_icon_path_find(e_config->icon_theme,
|
||||
sub->icon, "24x24");
|
||||
|
||||
icon = e_icon_add(evas);
|
||||
e_icon_file_set(icon, file);
|
||||
e_icon_fill_inside_set(icon, 1);
|
||||
}
|
||||
e_widget_ilist_append(cfdata->o_apps, icon, sub->name,
|
||||
_apps_cb_selected, cfdata,
|
||||
sub->desktop->orig_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e_widget_ilist_go(cfdata->o_apps);
|
||||
e_widget_min_size_get(cfdata->o_apps, &w, NULL);
|
||||
e_widget_min_size_set(cfdata->o_apps, w, 200);
|
||||
e_widget_ilist_thaw(cfdata->o_apps);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
|
||||
if (menu) efreet_menu_free(menu);
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_list(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas *evas;
|
||||
Evas_Coord w;
|
||||
Efreet_Menu *menu, *entry;
|
||||
|
||||
menu = cfdata->menu;
|
||||
if (!menu->entries) return;
|
||||
|
||||
evas = evas_object_evas_get(cfdata->o_list);
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(cfdata->o_list);
|
||||
|
||||
ecore_list_goto_first(menu->entries);
|
||||
while ((entry = ecore_list_next(menu->entries)))
|
||||
{
|
||||
Evas_Object *icon = NULL;
|
||||
const char *file;
|
||||
|
||||
if (entry->type != EFREET_MENU_ENTRY_DESKTOP) continue;
|
||||
|
||||
if (entry->icon)
|
||||
{
|
||||
if (entry->icon[0] == '/') file = entry->icon;
|
||||
else
|
||||
file = efreet_icon_path_find(e_config->icon_theme,
|
||||
entry->icon, "24x24");
|
||||
|
||||
icon = e_icon_add(evas);
|
||||
e_icon_file_set(icon, file);
|
||||
e_icon_fill_inside_set(icon, 1);
|
||||
}
|
||||
e_widget_ilist_append(cfdata->o_list, icon, entry->name,
|
||||
_list_cb_selected, cfdata,
|
||||
entry->desktop->orig_path);
|
||||
}
|
||||
|
||||
e_widget_ilist_go(cfdata->o_list);
|
||||
e_widget_min_size_get(cfdata->o_list, &w, NULL);
|
||||
e_widget_min_size_set(cfdata->o_list, w, 200);
|
||||
e_widget_ilist_thaw(cfdata->o_list);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
}
|
||||
|
||||
static void
|
||||
_apps_cb_selected(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
e_widget_disabled_set(cfdata->o_add, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_list_cb_selected(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
e_widget_disabled_set(cfdata->o_del, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_add(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_Object *icon;
|
||||
Efreet_Desktop *desk;
|
||||
const char *name;
|
||||
|
||||
cfdata = data;
|
||||
if (e_widget_ilist_selected_get(cfdata->o_apps) < 0) return;
|
||||
desk = efreet_desktop_get(cfdata->app);
|
||||
if (!desk) return;
|
||||
|
||||
icon = e_widget_ilist_selected_icon_get(cfdata->o_apps);
|
||||
name = e_widget_ilist_selected_label_get(cfdata->o_apps);
|
||||
e_widget_ilist_append(cfdata->o_list, icon, name,
|
||||
_list_cb_selected, cfdata, cfdata->app);
|
||||
/* Disab Add till del */
|
||||
efreet_menu_desktop_insert(cfdata->menu, desk, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_del(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Efreet_Desktop *desk;
|
||||
int num;
|
||||
|
||||
cfdata = data;
|
||||
num = e_widget_ilist_selected_get(cfdata->o_list);
|
||||
if (num < 0) return;
|
||||
desk = efreet_desktop_get(cfdata->fav);
|
||||
if (!desk) return;
|
||||
e_widget_ilist_remove_num(cfdata->o_list, num);
|
||||
/* TODO: Efreet Menu Desktop Delete */
|
||||
efreet_menu_desktop_remove(cfdata->menu, desk);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
#ifndef E_INT_CONFIG_APPS_H
|
||||
#define E_INT_CONFIG_APPS_H
|
||||
|
||||
EAPI E_Config_Dialog *e_int_config_apps_favs(E_Container *con);
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue