Port theme dialog to use new e_widget_flist.

SVN revision: 34547
This commit is contained in:
Christopher Michael 2008-05-12 20:40:44 +00:00
parent e75948ef52
commit 6d7088ea42
1 changed files with 67 additions and 158 deletions

View File

@ -20,7 +20,6 @@ struct _E_Config_Dialog_Data
E_Config_Dialog *cfd;
/* Basic */
Evas_Object *o_frame;
Evas_Object *o_fm;
Evas_Object *o_up_button;
Evas_Object *o_preview;
@ -76,38 +75,23 @@ EAPI void
e_int_config_theme_update(E_Config_Dialog *dia, char *file)
{
E_Config_Dialog_Data *cfdata;
const char *homedir;
char path[4096];
cfdata = dia->cfdata;
homedir = e_user_homedir_get();
cfdata->fmdir = 1;
e_widget_radio_toggle_set(cfdata->o_personal, 1);
snprintf(path, sizeof(path), "%s/.e/e/themes", homedir);
snprintf(path, sizeof(path), "%s/.e/e/themes", e_user_homedir_get());
E_FREE(cfdata->theme);
cfdata->theme = strdup(file);
if (cfdata->o_fm)
e_fm2_path_set(cfdata->o_fm, path, "/");
e_widget_flist_path_set(cfdata->o_fm, path, "/");
if (cfdata->o_preview)
e_widget_preview_edje_set(cfdata->o_preview, cfdata->theme, "e/desktop/background");
if (cfdata->o_frame)
e_widget_change(cfdata->o_frame);
/*
if (cfdata->o_fm)
{
e_fm2_select_set(cfdata->o_fm, file, 1);
e_fm2_file_show(cfdata->o_fm, file);
evas_object_smart_callback_call(cfdata->o_fm,
"selection_change", cfdata);
}
*/
if (cfdata->o_fm) e_widget_change(cfdata->o_fm);
}
static void
@ -116,10 +100,7 @@ _cb_button_up(void *data1, void *data2)
E_Config_Dialog_Data *cfdata;
cfdata = data1;
if (cfdata->o_fm)
e_fm2_parent_go(cfdata->o_fm);
if (cfdata->o_frame)
e_widget_scrollframe_child_pos_set(cfdata->o_frame, 0, 0);
if (cfdata->o_fm) e_widget_flist_parent_go(cfdata->o_fm);
}
static void
@ -129,18 +110,9 @@ _cb_files_changed(void *data, Evas_Object *obj, void *event_info)
cfdata = data;
if (!cfdata->o_fm) return;
if (!e_fm2_has_parent_get(cfdata->o_fm))
{
if (cfdata->o_up_button)
e_widget_disabled_set(cfdata->o_up_button, 1);
}
else
{
if (cfdata->o_up_button)
e_widget_disabled_set(cfdata->o_up_button, 0);
}
if (cfdata->o_frame)
e_widget_scrollframe_child_pos_set(cfdata->o_frame, 0, 0);
if (cfdata->o_up_button)
e_widget_disabled_set(cfdata->o_up_button,
!e_widget_flist_has_parent_get(cfdata->o_fm));
}
static void
@ -155,11 +127,10 @@ _cb_files_selection_change(void *data, Evas_Object *obj, void *event_info)
cfdata = data;
if (!cfdata->o_fm) return;
selected = e_fm2_selected_list_get(cfdata->o_fm);
if (!selected) return;
if (!(selected = e_widget_flist_selected_list_get(cfdata->o_fm))) return;
ici = selected->data;
realpath = e_fm2_real_path_get(cfdata->o_fm);
realpath = e_widget_flist_real_path_get(cfdata->o_fm);
if (!strcmp(realpath, "/"))
snprintf(buf, sizeof(buf), "/%s", ici->file);
@ -173,8 +144,7 @@ _cb_files_selection_change(void *data, Evas_Object *obj, void *event_info)
cfdata->theme = strdup(buf);
if (cfdata->o_preview)
e_widget_preview_edje_set(cfdata->o_preview, buf, "e/desktop/background");
if (cfdata->o_frame)
e_widget_change(cfdata->o_frame);
if (cfdata->o_fm) e_widget_change(cfdata->o_fm);
}
static void
@ -190,20 +160,19 @@ _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
{
E_Config_Dialog_Data *cfdata;
const char *p;
const char *homedir;
char buf[4096];
cfdata = data;
if (!cfdata->theme) return;
if (!cfdata->o_fm) return;
p = e_fm2_real_path_get(cfdata->o_fm);
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;
}
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/themes", homedir);
if (!p) return;
snprintf(buf, sizeof(buf), "%s/.e/e/themes", e_user_homedir_get());
if (!strncmp(cfdata->theme, buf, strlen(buf)))
p = cfdata->theme + strlen(buf) + 1;
else
@ -214,8 +183,8 @@ _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
else
p = cfdata->theme;
}
e_fm2_select_set(cfdata->o_fm, p, 1);
e_fm2_file_show(cfdata->o_fm, p);
e_widget_flist_select_set(cfdata->o_fm, p, 1);
e_widget_flist_file_show(cfdata->o_fm, p);
}
static void
@ -223,19 +192,13 @@ _cb_dir(void *data, Evas_Object *obj, void *event_info)
{
E_Config_Dialog_Data *cfdata;
char path[4096];
const char *homedir;
cfdata = data;
if (cfdata->fmdir == 1)
{
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get());
}
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get());
else
{
homedir = e_user_homedir_get();
snprintf(path, sizeof(path), "%s/.e/e/themes", homedir);
}
e_fm2_path_set(cfdata->o_fm, path, "/");
snprintf(path, sizeof(path), "%s/.e/e/themes", e_user_homedir_get());
e_widget_flist_path_set(cfdata->o_fm, path, "/");
}
static void
@ -246,13 +209,10 @@ _cb_files_files_deleted(void *data, Evas_Object *obj, void *event_info)
E_Fm2_Icon_Info *ici, *ic;
cfdata = data;
if (!cfdata->theme) return;
if (!cfdata->o_fm) return;
if ((!cfdata->theme) || (!cfdata->o_fm)) return;
all = e_fm2_all_list_get(cfdata->o_fm);
if (!all) return;
sel = e_fm2_selected_list_get(cfdata->o_fm);
if (!sel) 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;
@ -264,11 +224,10 @@ _cb_files_files_deleted(void *data, Evas_Object *obj, void *event_info)
if (!n) return;
}
ic = n->data;
if (!ic) return;
if (!(ic = n->data)) return;
e_fm2_select_set(cfdata->o_fm, ic->file, 1);
e_fm2_file_show(cfdata->o_fm, ic->file);
e_widget_flist_select_set(cfdata->o_fm, ic->file, 1);
e_widget_flist_file_show(cfdata->o_fm, ic->file);
evas_list_free(n);
@ -292,20 +251,20 @@ _fill_data(E_Config_Dialog_Data *cfdata)
{
E_Config_Theme * c;
char path[4096];
const char *homedir;
c = e_theme_config_get("theme");
if (c)
cfdata->theme = strdup(c->file);
else
{
snprintf(path, sizeof(path), "%s/data/themes/default.edj", e_prefix_data_get());
snprintf(path, sizeof(path), "%s/data/themes/default.edj",
e_prefix_data_get());
cfdata->theme = strdup(path);
}
if (cfdata->theme[0] != '/')
{
homedir = e_user_homedir_get();
snprintf(path, sizeof(path), "%s/.e/e/themes/%s", homedir, cfdata->theme);
snprintf(path, sizeof(path), "%s/.e/e/themes/%s",
e_user_homedir_get(), cfdata->theme);
if (ecore_file_exists(path))
{
E_FREE(cfdata->theme);
@ -313,7 +272,8 @@ _fill_data(E_Config_Dialog_Data *cfdata)
}
else
{
snprintf(path, sizeof(path), "%s/data/themes/%s", e_prefix_data_get(), cfdata->theme);
snprintf(path, sizeof(path), "%s/data/themes/%s",
e_prefix_data_get(), cfdata->theme);
if (ecore_file_exists(path))
{
E_FREE(cfdata->theme);
@ -357,13 +317,9 @@ static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *o, *ot, *of, *il, *ol;
char path[4096];
const char *homedir;
E_Fm2_Config fmc;
E_Zone *z;
E_Radio_Group *rg;
homedir = e_user_homedir_get();
char path[4096];
z = e_zone_current_get(cfd->con);
@ -391,51 +347,22 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get());
else
snprintf(path, sizeof(path), "%s/.e/e/themes", homedir);
snprintf(path, sizeof(path), "%s/.e/e/themes", e_user_homedir_get());
cfdata->o_fm = NULL;
o = e_fm2_add(evas);
memset(&fmc, 0, sizeof(E_Fm2_Config));
fmc.view.mode = E_FM2_VIEW_MODE_LIST;
fmc.view.open_dirs_in_place = 1;
fmc.view.selector = 1;
fmc.view.single_click = 0;
fmc.view.no_subdir_jump = 0;
fmc.icon.list.w = 48;
fmc.icon.list.h = 48;
fmc.icon.fixed.w = 1;
fmc.icon.fixed.h = 1;
fmc.icon.extension.show = 0;
fmc.icon.key_hint = NULL;
fmc.list.sort.no_case = 1;
fmc.list.sort.dirs.first = 0;
fmc.list.sort.dirs.last = 1;
fmc.selection.single = 1;
fmc.selection.windows_modifiers = 0;
e_fm2_config_set(o, &fmc);
e_fm2_icon_menu_flags_set(o, E_FM2_MENU_NO_SHOW_HIDDEN);
o = e_widget_flist_add(evas);
cfdata->o_fm = o;
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, "selected",
_cb_files_selected, 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_fm2_path_set(o, path, "/");
of = e_widget_scrollframe_pan_add(evas, o,
e_fm2_pan_set,
e_fm2_pan_get,
e_fm2_pan_max_get,
e_fm2_pan_child_size_get);
cfdata->o_fm = o;
cfdata->o_frame = of;
e_widget_min_size_set(of, 160, 160);
e_widget_table_object_append(ol, of, 0, 2, 1, 1, 1, 1, 1, 1);
e_widget_min_size_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);
@ -585,14 +512,13 @@ _get_theme_categories_list(void)
for (g = e_theme_category_list(); g; g = g->next)
{
const char *c;
c = g->data;
if (!c) continue;
if (!(c = g->data)) continue;
cats2 = cats;
while (cats2)
{
if (!strcmp(c, cats2->data))
break;
if (!strcmp(c, cats2->data)) break;
cats2 = cats2->next;
}
if (!cats2)
@ -620,9 +546,7 @@ _get_theme_categories_list(void)
{
theme = themes->data;
if (!strcmp(category + 5, theme->category))
{
newtheme->file = strdup(theme->file);
}
newtheme->file = strdup(theme->file);
}
tcl = evas_list_append(tcl, newtheme);
}
@ -639,16 +563,17 @@ _files_ilist_nth_label_to_file(void *data, int n)
E_Config_Dialog_Data *cfdata;
char file[1024];
cfdata = data;
if (!cfdata) return NULL;
if (!(cfdata = data)) return NULL;
if (!cfdata->o_files_ilist) return NULL;
if (n > cfdata->personal_file_count)
snprintf(file, sizeof(file), "%s/data/themes/%s.edj",
e_prefix_data_get(), e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n));
e_prefix_data_get(),
e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n));
else
snprintf(file, sizeof(file), "%s/.e/e/themes/%s.edj",
e_user_homedir_get(), e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n));
e_user_homedir_get(),
e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n));
return strdup(file);
}
@ -662,20 +587,18 @@ _preview_set(void *data)
int n, ret = 0;
Evas_List *p;
cfdata = data;
if (!cfdata) return;
if (!(cfdata = data)) return;
n = e_widget_ilist_selected_get(cfdata->o_files_ilist);
theme = _files_ilist_nth_label_to_file(cfdata, n);
snprintf(c_label, sizeof(c_label), "%s:",
e_widget_ilist_selected_label_get(cfdata->o_categories_ilist));
e_widget_ilist_selected_label_get(cfdata->o_categories_ilist));
if (theme)
{
p = cfdata->parts_list;
while (p)
{
if (strstr((char *)(p->data), c_label))
break;
if (strstr((char *)(p->data), c_label)) break;
p = p->next;
}
if (p)
@ -698,8 +621,7 @@ _cb_adv_categories_change(void *data, Evas_Object *obj)
Evas_Object *ic = NULL;
int n;
cfdata = data;
if (!cfdata) return;
if (!(cfdata = data)) return;
label = e_widget_ilist_selected_label_get(cfdata->o_categories_ilist);
if (!label) return;
@ -754,10 +676,7 @@ _theme_file_used(Evas_List *tlist, const char *filename)
while (tlist)
{
theme = tlist->data;
if (theme->file && !strcmp(theme->file, filename))
{
return 1;
}
if (theme->file && !strcmp(theme->file, filename)) return 1;
tlist = tlist->next;
}
@ -803,6 +722,7 @@ _ilist_files_add(E_Config_Dialog_Data *cfdata, const char *header, const char *d
while (themefiles)
{
Evas_Object *ic = NULL;
if (_theme_file_used(cfdata->theme_list, themefiles->data))
{
ic = edje_object_add(evas);
@ -828,8 +748,7 @@ _fill_files_ilist(E_Config_Dialog_Data *cfdata)
Evas_Object *o;
char theme_dir[4096];
o = cfdata->o_files_ilist;
if (!o) return;
if (!(o = cfdata->o_files_ilist)) return;
evas = evas_object_evas_get(o);
evas_event_freeze(evas);
@ -839,13 +758,13 @@ _fill_files_ilist(E_Config_Dialog_Data *cfdata)
/* Grab the "Personal" themes. */
snprintf(theme_dir, sizeof(theme_dir), "%s/.e/e/themes",
e_user_homedir_get());
e_user_homedir_get());
cfdata->personal_file_count =
_ilist_files_add(cfdata, _("Personal"), theme_dir);
/* Grab the "System" themes. */
snprintf(theme_dir, sizeof(theme_dir),
"%s/data/themes", e_prefix_data_get());
"%s/data/themes", e_prefix_data_get());
_ilist_files_add(cfdata, _("System"), theme_dir);
e_widget_ilist_go(o);
@ -862,8 +781,7 @@ _fill_categories_ilist(E_Config_Dialog_Data *cfdata)
E_Config_Theme *theme;
Evas_Object *o;
o = cfdata->o_categories_ilist;
if (!o) return;
if (!(o = cfdata->o_categories_ilist)) return;
evas = evas_object_evas_get(o);
evas_event_freeze(evas);
@ -904,13 +822,10 @@ _cb_adv_btn_assign(void *data1, void *data2)
const char *label;
int n;
cfdata = data1;
if (!cfdata) return;
if (!(cfdata = data1)) return;
oc = cfdata->o_categories_ilist;
if (!oc) return;
of = cfdata->o_files_ilist;
if (!of) return;
if (!(oc = cfdata->o_categories_ilist)) return;
if (!(of = cfdata->o_files_ilist)) return;
evas = evas_object_evas_get(oc);
n = e_widget_ilist_selected_get(oc);
@ -975,13 +890,10 @@ _cb_adv_btn_clear(void *data1, void *data2)
const char *filename = NULL;
int n;
cfdata = data1;
if (!cfdata) return;
if (!(cfdata = data1)) return;
oc = cfdata->o_categories_ilist;
if (!oc) return;
of = cfdata->o_files_ilist;
if (!of) return;
if (!(oc = cfdata->o_categories_ilist)) return;
if (!(of = cfdata->o_files_ilist)) return;
n = e_widget_ilist_selected_get(oc);
e_widget_ilist_nth_icon_set(oc, n, NULL);
@ -1024,13 +936,10 @@ _cb_adv_btn_clearall(void *data1, void *data2)
Evas_Object *oc = NULL, *of = NULL;
int n;
cfdata = data1;
if (!cfdata) return;
if (!(cfdata = data1)) return;
oc = cfdata->o_categories_ilist;
if (!oc) return;
of = cfdata->o_files_ilist;
if (!of) return;
if (!(oc = cfdata->o_categories_ilist)) return;
if (!(of = cfdata->o_files_ilist)) return;
for (n = 0; n < e_widget_ilist_count(oc); n++)
e_widget_ilist_nth_icon_set(oc, n, NULL);