enlightenment/src/modules/conf_theme/e_int_config_theme.c

782 lines
23 KiB
C
Raw Normal View History

#include "e.h"
#include "e_mod_main.h"
2012-07-02 01:09:17 -07:00
static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static void _fill_data(E_Config_Dialog_Data *cfdata);
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
struct _E_Config_Dialog_Data
{
E_Config_Dialog *cfd;
/* Basic */
2012-07-02 01:09:17 -07:00
Evas_Object *o_fm;
Evas_Object *o_up_button;
Evas_Object *o_preview;
Evas_Object *o_personal;
Evas_Object *o_system;
int fmdir;
const char *theme;
Eio_File *eio[2];
Eio_File *init[2];
Eina_List *theme_init; /* list of eio ops to load themes */
Eina_List *themes; /* eet file refs to work around load locking */
int show_splash;
Eina_Bool free : 1;
/* Dialog */
Evas_Object *win_import;
};
static void
_e_int_theme_preview_clear(Evas_Object *preview)
{
Eina_List *objs = evas_object_data_get(preview, "objects");
Evas_Object *o;
e_widget_preview_extern_object_set(preview, NULL);
EINA_LIST_FREE(objs, o) evas_object_del(o);
evas_object_data_del(preview, "objects");
}
static void
_e_int_theme_edje_file_set(Evas_Object *o, const char *file, const char *group)
{
if (!edje_object_file_set(o, file, group))
e_theme_edje_object_set(o, NULL, group);
}
static Eina_Bool
_e_int_theme_preview_set(Evas_Object *preview, const char *file)
{
Evas *e;
Evas_Coord w = 320, h = 240, mw = 0, mh = 0;
Eina_List *objs = NULL;
Evas_Object *o, *po, *po2, *po3, *r;
_e_int_theme_preview_clear(preview);
e = e_widget_preview_evas_get(preview);
evas_object_size_hint_min_get(preview, &w, &h);
w *= 2; h *= 2;
2015-01-01 14:31:25 -08:00
#warning REMOVE STUPID ELM HACK BEFORE RELEASE
r = evas_object_rectangle_add(e);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/desktop/background");
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);
evas_object_show(o);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
_e_int_theme_edje_file_set(o, file, "e/comp/frame/popup");
evas_object_move(o, (w - (400 * e_scale)) / 2, h - (40 * e_scale));
evas_object_resize(o, 400 * e_scale, (40 * e_scale));
evas_object_show(o);
edje_object_signal_emit(o, "e,state,shadow,on", "e");
edje_object_signal_emit(o, "e,state,visible,on", "e");
objs = eina_list_append(objs, o);
po = o;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/shelf/default/base");
evas_object_show(o);
edje_object_signal_emit(o, "e,state,orientation,bottom", "e");
edje_object_part_swallow(po, "e.swallow.content", o);
objs = eina_list_append(objs, o);
po = o;
po2 = po;
o = elm_box_add(r);
elm_box_horizontal_set(o, 1);
evas_object_show(o);
edje_object_part_swallow(po, "e.swallow.content", o);
objs = eina_list_append(objs, o);
po = o;
mh = 42 * e_scale;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/start/main");
evas_object_show(o);
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/shelf/default/inset");
evas_object_show(o);
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, 4 * mh, 0);
objs = eina_list_append(objs, o);
po2 = o;
o = elm_box_add(r);
elm_box_horizontal_set(o, 1);
evas_object_show(o);
edje_object_part_swallow(po2, "e.swallow.content", o);
objs = eina_list_append(objs, o);
po3 = o;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/pager/desk");
evas_object_show(o);
edje_object_signal_emit(o, "e,state,selected", "e");
elm_box_pack_end(po3, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/pager/desk");
evas_object_show(o);
elm_box_pack_end(po3, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/pager/desk");
evas_object_show(o);
elm_box_pack_end(po3, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/pager/desk");
evas_object_show(o);
elm_box_pack_end(po3, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/backlight/main");
evas_object_show(o);
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/mixer/main");
evas_object_show(o);
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/battery/main");
evas_object_show(o);
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/modules/clock/main");
evas_object_show(o);
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, mh, 0);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
_e_int_theme_edje_file_set(o, file, "e/comp/frame/default");
evas_object_move(o, w / 2, h / 9);
evas_object_resize(o, w / 3, h / 3);
evas_object_show(o);
edje_object_signal_emit(o, "e,state,shadow,on", "e");
edje_object_signal_emit(o, "e,state,visible,on", "e");
edje_object_signal_emit(o, "e,state,focus,off", "e");
objs = eina_list_append(objs, o);
po = o;
po2 = po;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/widgets/border/default/border");
edje_object_part_text_set(o, "e.text.title", "Title");
evas_object_show(o);
edje_object_signal_emit(o, "e,state,unfocused", "e");
edje_object_part_swallow(po, "e.swallow.content", o);
objs = eina_list_append(objs, o);
po = o;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/theme/about");
edje_object_size_min_get(o, &mw, &mh);
if (mw > 0) evas_object_resize(po2, mw, mh);
edje_object_part_text_set(o, "e.text.label", "Close");
edje_object_part_text_set(o, "e.text.theme", "Select Theme");
evas_object_show(o);
edje_object_part_swallow(po, "e.swallow.client", o);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
_e_int_theme_edje_file_set(o, file, "e/comp/frame/default");
evas_object_move(o, w / 10, h / 5);
evas_object_resize(o, w / 2, h / 3);
evas_object_show(o);
edje_object_signal_emit(o, "e,state,shadow,on", "e");
edje_object_signal_emit(o, "e,state,visible,on", "e");
edje_object_signal_emit(o, "e,state,focus,on", "e");
objs = eina_list_append(objs, o);
po = o;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/widgets/border/default/border");
edje_object_part_text_set(o, "e.text.title", "Title");
evas_object_show(o);
edje_object_signal_emit(o, "e,state,focused", "e");
edje_object_part_swallow(po, "e.swallow.content", o);
objs = eina_list_append(objs, o);
po = o;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/widgets/dialog/main");
evas_object_show(o);
edje_object_signal_emit(o, "e,icon,enabled", "e");
edje_object_part_swallow(po, "e.swallow.client", o);
objs = eina_list_append(objs, o);
po = o;
po2 = po;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/widgets/dialog/text");
edje_object_part_text_set(o, "e.textblock.message",
"<hilight>Welcome to enlightenment.</hilight><br>"
"<br>"
"This is a sample set of content for a<br>"
"theme to test to see what it looks like.");
evas_object_show(o);
edje_object_part_swallow(po, "e.swallow.content", o);
objs = eina_list_append(objs, o);
o = e_icon_add(e);
e_util_icon_theme_set(o, "dialog-warning");
evas_object_show(o);
evas_object_size_hint_min_set(o, 64 * e_scale, 64 * e_scale);
edje_object_part_swallow(po, "e.swallow.icon", o);
objs = eina_list_append(objs, o);
o = elm_box_add(r);
elm_box_horizontal_set(o, 1);
elm_box_homogeneous_set(o, 1);
evas_object_show(o);
edje_object_part_swallow(po, "e.swallow.buttons", o);
objs = eina_list_append(objs, o);
po = o;
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/widgets/button");
evas_object_show(o);
edje_object_signal_emit(o, "e,state,text", "e");
edje_object_part_text_set(o, "e.text.label", "OK");
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, 50, 20);
objs = eina_list_append(objs, o);
o = edje_object_add(e);
_e_int_theme_edje_file_set(o, file, "e/widgets/button");
evas_object_show(o);
edje_object_signal_emit(o, "e,state,text", "e");
edje_object_part_text_set(o, "e.text.label", "Cancel");
E_FILL(o);
elm_box_pack_end(po, o);
evas_object_size_hint_min_set(o, 50, 20);
objs = eina_list_append(objs, o);
elm_box_recalculate(po);
evas_object_size_hint_min_get(po, &mw, &mh);
evas_object_size_hint_min_set(po, mw, mh);
edje_object_part_swallow(po2, "e.swallow.buttons", po);
evas_object_data_set(preview, "objects", objs);
// e_widget_preview_edje_set(preview, file, "e/desktop/background");
return EINA_TRUE;
}
2010-01-22 12:28:39 -08:00
E_Config_Dialog *
e_int_config_theme(Evas_Object *parent EINA_UNUSED, const char *params __UNUSED__)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
if (e_config_dialog_find("E", "appearance/theme")) return NULL;
v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
v->basic.apply_cfdata = _basic_apply_data;
v->basic.create_widgets = _basic_create_widgets;
v->override_auto_apply = 1;
cfd = e_config_dialog_new(NULL,
_("Theme Selector"),
"E", "appearance/theme",
"preferences-desktop-theme", 0, v, NULL);
return cfd;
}
2010-01-22 12:28:39 -08:00
void
e_int_config_theme_import_done(E_Config_Dialog *dia)
{
E_Config_Dialog_Data *cfdata;
cfdata = dia->cfdata;
cfdata->win_import = NULL;
}
2010-01-22 12:28:39 -08:00
void
e_int_config_theme_update(E_Config_Dialog *dia, char *file)
{
E_Config_Dialog_Data *cfdata;
cfdata = dia->cfdata;
cfdata->fmdir = 1;
e_widget_radio_toggle_set(cfdata->o_personal, 1);
eina_stringshare_replace(&cfdata->theme, file);
if (cfdata->o_fm)
{
ecore_file_mkpath(elm_theme_user_dir_get());
e_widget_flist_path_set(cfdata->o_fm, elm_theme_user_dir_get(), "/");
}
if (cfdata->o_preview)
_e_int_theme_preview_set(cfdata->o_preview, cfdata->theme);
if (cfdata->o_fm) e_widget_change(cfdata->o_fm);
}
static Eina_Bool
_eio_filter_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, const char *file)
{
return eina_str_has_extension(file, ".edj");
}
static void
_cb_button_up(void *data1, void *data2 __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
cfdata = data1;
if (cfdata->o_fm) e_widget_flist_parent_go(cfdata->o_fm);
}
static void
_cb_files_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
if (!cfdata->o_fm) return;
if (cfdata->o_up_button)
e_widget_disabled_set(cfdata->o_up_button,
!e_widget_flist_has_parent_get(cfdata->o_fm));
}
static void
_cb_files_selection_change(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
Eina_List *selected;
E_Fm2_Icon_Info *ici;
const char *real_path;
char buf[4096];
cfdata = data;
if (!cfdata->o_fm) return;
if (!(selected = e_widget_flist_selected_list_get(cfdata->o_fm))) return;
ici = selected->data;
real_path = e_widget_flist_real_path_get(cfdata->o_fm);
if (!strcmp(real_path, "/"))
snprintf(buf, sizeof(buf), "/%s", ici->file);
else
snprintf(buf, sizeof(buf), "%s/%s", real_path, ici->file);
eina_list_free(selected);
if (ecore_file_is_dir(buf)) return;
eina_stringshare_del(cfdata->theme);
cfdata->theme = eina_stringshare_add(buf);
if (cfdata->o_preview)
_e_int_theme_preview_set(cfdata->o_preview, buf);
if (cfdata->o_fm) e_widget_change(cfdata->o_fm);
}
#if 0
/* FIXME unused */
static void
_cb_files_selected(void *data, Evas_Object *obj, void *event_info)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
}
2012-07-02 01:09:17 -07:00
#endif
static void
_cb_files_files_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
2006-08-21 09:16:56 -07:00
const char *p;
char buf[PATH_MAX];
size_t len;
cfdata = data;
if ((!cfdata->theme) || (!cfdata->o_fm)) return;
p = e_widget_flist_real_path_get(cfdata->o_fm);
if (p)
{
if (strncmp(p, cfdata->theme, strlen(p))) return;
}
if (!p) return;
snprintf(buf, sizeof(buf), "%s", elm_theme_user_dir_get());
len = strlen(buf);
if (!strncmp(cfdata->theme, buf, len))
p = cfdata->theme + len + 1;
else
{
snprintf(buf, sizeof(buf), "%s", elm_theme_system_dir_get());
len = strlen(buf);
if (!strncmp(cfdata->theme, buf, len))
p = cfdata->theme + len + 1;
else
p = cfdata->theme;
}
e_widget_flist_select_set(cfdata->o_fm, p, 1);
e_widget_flist_file_show(cfdata->o_fm, p);
}
static void
_cb_dir(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
char path[PATH_MAX];
cfdata = data;
if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s", elm_theme_system_dir_get());
else
{
snprintf(path, sizeof(path), "%s", elm_theme_user_dir_get());
ecore_file_mkpath(path);
}
e_widget_flist_path_set(cfdata->o_fm, path, "/");
}
static void
_cb_files_files_deleted(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
Eina_List *sel, *all, *n;
E_Fm2_Icon_Info *ici, *ic;
cfdata = data;
if ((!cfdata->theme) || (!cfdata->o_fm)) return;
if (!(all = e_widget_flist_all_list_get(cfdata->o_fm))) return;
if (!(sel = e_widget_flist_selected_list_get(cfdata->o_fm))) return;
ici = sel->data;
all = eina_list_data_find_list(all, ici);
n = eina_list_next(all);
if (!n)
{
n = eina_list_prev(all);
if (!n) return;
}
if (!(ic = n->data)) return;
e_widget_flist_select_set(cfdata->o_fm, ic->file, 1);
e_widget_flist_file_show(cfdata->o_fm, ic->file);
eina_list_free(n);
evas_object_smart_callback_call(cfdata->o_fm, "selection_change", cfdata);
}
static void
_cb_import(void *data1, void *data2 __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
cfdata = data1;
if (cfdata->win_import)
elm_win_raise(cfdata->win_import);
else
cfdata->win_import = e_int_config_theme_import(cfdata->cfd);
}
2006-04-01 19:56:07 -08:00
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
const char *theme;
char path[PATH_MAX];
size_t len;
cfdata->show_splash = e_config->show_splash;
theme = elm_theme_get(NULL);
if (theme)
{
snprintf(path, sizeof(path), "%s.edj", theme);
cfdata->theme = eina_stringshare_add(path);
}
else
{
snprintf(path, sizeof(path), "%s/%s", elm_theme_system_dir_get(),
"default.edj");
cfdata->theme = eina_stringshare_add(path);
}
if (cfdata->theme[0] != '/')
{
snprintf(path, sizeof(path), "%s/%s", elm_theme_user_dir_get(),
cfdata->theme);
if (ecore_file_exists(path))
eina_stringshare_replace(&cfdata->theme, path);
else
{
snprintf(path, sizeof(path), "%s/%s", elm_theme_system_dir_get(),
cfdata->theme);
if (ecore_file_exists(path))
eina_stringshare_replace(&cfdata->theme, path);
}
}
snprintf(path, sizeof(path), "%s", elm_theme_system_dir_get());
len = strlen(path);
if (!strncmp(cfdata->theme, path, len))
cfdata->fmdir = 1;
}
static void
_open_test_cb(void *file)
{
Dear all, I'm attaching a patch for some minor bugs in the e17. Please take a look at attached patch. 01. missing E_FREE(inst) File: src/bin/e_exec.c: 347 Function: _e_exec_cb_exec 02. missing null check File: src/bin/e_fm.c: 10173 Function: _e_fm_error_dialog I'm not sure, but all other codes always check the return value of e_fm2_op_registry_entry_get except here. 03. missing free(slave) File: src/bin/e_fm_ipc.c: 804 Function: _e_fm_ipc_slave_run 04. eina_list_remove after free File: src/bin/e_fm/e_fm_ipc.c :1325 Function: _e_fm_ipc_cb_fop_trash_idler 05. invalid check for _udisks_del, it might be _udisks_chg. File: src/bin/e_fm/e_fm_main_udisks.c : 162 Function: _e_fm_main_udisks_test 06. uninitialized gx and gy values File: src/bin/e_gadcon_popup.c: 172 Function: _e_gadcon_popup_position These could be changed in e_gadcon_client_geometry_get if gcc->o_base is null. 07. unnecessary code 'evas = e_win_evas_get(dia->win)' File: src/bin/e_import_config_dialog.c: 456 Function: e_import_config_dialog_show 08. missing free(sizes) src/bin/e_randr_11_serialization.c: 136 Function: _11_try_restore_configuration() 09. unnecessary variable output_info File: src/bin/e_randr_12.c: 560 Function: _output_property_change_event_cb 10. eina_list_remove after free File: src/bin/e_randr_12_serialization.c : 357 Function: _12_serialized_setup_update 11. no check of the return value of symlink. File: src/bin/e_widget_fsel.c: 84 Function: _e_wid_fsel_favorites_add 12. no evr->var check before comparing string values File: src/modules/conf_applications/e_int_config_defapps.c: 432 Function: _basic_apply 13. missing error message or check return value of edje_file_group_exists File: src/modules/conf_theme/e_int_config_theme.c: 333 Function: _open_test_cb Anyway, I've added e_util_dialog_show if failed. Is it okay? 14. missing index range check File: src/modules/gadman/e_mod_config.c: 153 Function: _cb_config It could read negative array index, because return value of e_widget_ilist_selected_get might be negative. BR, Gwanglim SVN revision: 80020
2012-12-02 23:54:07 -08:00
if (!edje_file_group_exists(eet_file_get(file), "e/desktop/background"))
e_util_dialog_show(_("Theme File Error"),
_("%s is probably not an E17 theme!"),
eet_file_get(file));
}
static void
_open_done_cb(void *data, Eio_File *handler, Eet_File *file)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->themes = eina_list_append(cfdata->themes, file);
cfdata->theme_init = eina_list_remove(cfdata->theme_init, handler);
ecore_job_add(_open_test_cb, file);
}
static void
_open_error_cb(void *data, Eio_File *handler, int error __UNUSED__)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->theme_init = eina_list_remove(cfdata->theme_init, handler);
if (cfdata->free) _free_data(NULL, cfdata);
}
static void
_init_main_cb(void *data, Eio_File *handler __UNUSED__, const char *file)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->theme_init = eina_list_append(cfdata->theme_init, eio_eet_open(file, EET_FILE_MODE_READ, _open_done_cb, _open_error_cb, cfdata));
}
static void
_init_done_cb(void *data, Eio_File *handler)
{
E_Config_Dialog_Data *cfdata = data;
if (cfdata->init[0] == handler)
cfdata->init[0] = NULL;
else
cfdata->init[1] = NULL;
if (cfdata->free) _free_data(NULL, cfdata);
}
static void
_init_error_cb(void *data, Eio_File *handler, int error __UNUSED__)
{
E_Config_Dialog_Data *cfdata = data;
if (cfdata->init[0] == handler)
cfdata->init[0] = NULL;
else
cfdata->init[1] = NULL;
if (cfdata->free) _free_data(NULL, cfdata);
}
static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
cfd->cfdata = cfdata;
cfdata->cfd = cfd;
_fill_data(cfdata);
/* Grab the "Personal" themes. */
cfdata->init[0] = eio_file_ls(elm_theme_user_dir_get(), _eio_filter_cb, _init_main_cb, _init_done_cb, _init_error_cb, cfdata);
/* Grab the "System" themes. */
cfdata->init[1] = eio_file_ls(elm_theme_system_dir_get(), _eio_filter_cb, _init_main_cb, _init_done_cb, _init_error_cb, cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Eina_List *l;
Eio_File *ls;
Eet_File *ef;
E_FREE_FUNC(cfdata->win_import, evas_object_del);
if (cfdata->eio[0]) eio_file_cancel(cfdata->eio[0]);
if (cfdata->eio[1]) eio_file_cancel(cfdata->eio[1]);
EINA_LIST_FOREACH(cfdata->theme_init, l, ls)
eio_file_cancel(ls);
EINA_LIST_FREE(cfdata->themes, ef)
eet_close(ef);
if (cfdata->eio[0] || cfdata->eio[1] || cfdata->themes || cfdata->theme_init)
cfdata->free = EINA_TRUE;
else
E_FREE(cfdata);
}
static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *o, *ot, *of, *il, *ol;
E_Zone *z;
E_Radio_Group *rg;
char path[PATH_MAX];
z = e_zone_current_get(e_comp_get(NULL));
e_dialog_resizable_set(cfd->dia, 1);
ot = e_widget_table_add(e_win_evas_win_get(evas), 0);
ol = e_widget_table_add(e_win_evas_win_get(evas), 0);
il = e_widget_table_add(e_win_evas_win_get(evas), 1);
rg = e_widget_radio_group_new(&(cfdata->fmdir));
o = e_widget_radio_add(evas, _("Personal"), 0, rg);
cfdata->o_personal = o;
evas_object_smart_callback_add(o, "changed", _cb_dir, cfdata);
e_widget_table_object_append(il, o, 0, 0, 1, 1, 1, 1, 0, 0);
o = e_widget_radio_add(evas, _("System"), 1, rg);
cfdata->o_system = o;
evas_object_smart_callback_add(o, "changed", _cb_dir, cfdata);
e_widget_table_object_append(il, o, 1, 0, 1, 1, 1, 1, 0, 0);
e_widget_table_object_append(ol, il, 0, 0, 1, 1, 0, 0, 0, 0);
2009-03-06 14:18:15 -08:00
o = e_widget_button_add(evas, _("Go up a Directory"), "go-up",
_cb_button_up, cfdata, NULL);
cfdata->o_up_button = o;
e_widget_table_object_append(ol, o, 0, 1, 1, 1, 0, 0, 0, 0);
if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s", elm_theme_system_dir_get());
else
{
snprintf(path, sizeof(path), "%s", elm_theme_user_dir_get());
ecore_file_mkpath(path);
}
o = e_widget_flist_add(evas);
cfdata->o_fm = o;
{
E_Fm2_Config *cfg;
cfg = e_widget_flist_config_get(o);
cfg->view.no_click_rename = 1;
}
evas_object_smart_callback_add(o, "dir_changed",
_cb_files_changed, cfdata);
evas_object_smart_callback_add(o, "selection_change",
_cb_files_selection_change, cfdata);
evas_object_smart_callback_add(o, "changed",
_cb_files_files_changed, cfdata);
evas_object_smart_callback_add(o, "files_deleted",
_cb_files_files_deleted, cfdata);
e_widget_flist_path_set(o, path, "/");
e_widget_size_min_set(o, 160, 160);
e_widget_table_object_append(ol, o, 0, 2, 1, 1, 1, 1, 1, 1);
e_widget_table_object_append(ot, ol, 0, 0, 1, 1, 1, 1, 1, 1);
of = e_widget_list_add(evas, 0, 0);
il = e_widget_list_add(evas, 0, 1);
o = e_widget_button_add(evas, _(" Import..."), "preferences-desktop-theme",
_cb_import, cfdata, NULL);
e_widget_list_object_append(il, o, 1, 0, 0.5);
o = e_widget_check_add(evas, _("Show startup splash"), &cfdata->show_splash);
e_widget_list_object_append(il, o, 1, 0, 0.5);
e_widget_list_object_append(of, il, 1, 0, 0.0);
{
Evas_Object *oa;
int mw, mh;
mw = 320;
mh = (mw * z->h) / z->w;
oa = e_widget_aspect_add(evas, mw, mh);
o = e_widget_preview_add(evas, mw, mh);
evas_object_size_hint_min_set(o, mw, mh);
cfdata->o_preview = o;
if (cfdata->theme)
_e_int_theme_preview_set(o, cfdata->theme);
e_widget_aspect_child_set(oa, o);
e_widget_list_object_append(of, oa, 1, 1, 0);
evas_object_show(o);
evas_object_show(oa);
}
e_widget_table_object_append(ot, of, 1, 0, 1, 1, 1, 1, 1, 1);
return ot;
}
static int
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
E_Action *a;
const char *file;
char *name;
file = ecore_file_file_get(cfdata->theme);
name = ecore_file_strip_ext(file);
e_config->show_splash = cfdata->show_splash;
if (name)
{
const char *theme = elm_theme_get(NULL);
if (e_util_strcmp(name, theme))
{
elm_theme_set(NULL, name);
elm_config_all_flush();
elm_config_save();
free(name);
name = NULL;
a = e_action_find("restart");
if ((a) && (a->func.go)) a->func.go(NULL, NULL);
}
free(name);
}
return 1; /* Apply was OK */
}