2005-12-19 06:42:43 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
/* PROTOTYPES - same all the time */
|
|
|
|
typedef struct _E_Cfg_Theme_Data E_Cfg_Theme_Data;
|
|
|
|
|
|
|
|
static void *_create_data(E_Config_Dialog *cfd);
|
2006-01-14 08:05:35 -08:00
|
|
|
static void _free_data(E_Config_Dialog *cfd, 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);
|
2005-12-19 06:42:43 -08:00
|
|
|
|
|
|
|
/* Actual config data we will be playing with whil the dialog is active */
|
2006-01-14 08:05:35 -08:00
|
|
|
struct _E_Config_Dialog_Data
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
|
|
|
/*- BASIC -*/
|
|
|
|
char *theme;
|
|
|
|
char *current_theme;
|
|
|
|
/*- ADVANCED -*/
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _E_Cfg_Theme_Data
|
|
|
|
{
|
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
char *file;
|
|
|
|
char *theme;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* a nice easy setup function that does the dirty work */
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_Config_Dialog *
|
2005-12-19 06:42:43 -08:00
|
|
|
e_int_config_theme(E_Container *con)
|
|
|
|
{
|
|
|
|
E_Config_Dialog *cfd;
|
2006-01-22 06:17:43 -08:00
|
|
|
E_Config_Dialog_View *v;
|
|
|
|
|
|
|
|
v = E_NEW(E_Config_Dialog_View, 1);
|
2005-12-19 06:42:43 -08:00
|
|
|
|
|
|
|
/* methods */
|
2006-01-22 06:17:43 -08:00
|
|
|
v->create_cfdata = _create_data;
|
|
|
|
v->free_cfdata = _free_data;
|
|
|
|
v->basic.apply_cfdata = _basic_apply_data;
|
|
|
|
v->basic.create_widgets = _basic_create_widgets;
|
2006-02-15 12:30:59 -08:00
|
|
|
v->override_auto_apply = 1;
|
|
|
|
|
2005-12-19 06:42:43 -08:00
|
|
|
/* create config diaolg for NULL object/data */
|
2006-01-22 06:17:43 -08:00
|
|
|
cfd = e_config_dialog_new(con, _("Theme Selector"), NULL, 0, v, NULL);
|
2005-12-19 06:42:43 -08:00
|
|
|
return cfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**--CREATE--**/
|
|
|
|
static void
|
2006-01-14 08:05:35 -08:00
|
|
|
_fill_data(E_Config_Dialog_Data *cfdata)
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
|
|
|
/* get current theme */
|
|
|
|
E_Config_Theme * c;
|
|
|
|
c = e_theme_config_get("theme");
|
|
|
|
cfdata->current_theme = strdup(c->file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
_create_data(E_Config_Dialog *cfd)
|
|
|
|
{
|
|
|
|
/* Create cfdata - cfdata is a temporary block of config data that this
|
|
|
|
* dialog will be dealing with while configuring. it will be applied to
|
|
|
|
* the running systems/config in the apply methods
|
|
|
|
*/
|
2006-01-14 08:05:35 -08:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2005-12-19 06:42:43 -08:00
|
|
|
|
2006-01-14 08:05:35 -08:00
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
2005-12-19 06:42:43 -08:00
|
|
|
_fill_data(cfdata);
|
|
|
|
return cfdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-14 08:05:35 -08:00
|
|
|
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
|
|
|
/* Free the cfdata */
|
|
|
|
free(cfdata->current_theme);
|
|
|
|
free(cfdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**--APPLY--**/
|
|
|
|
static int
|
2006-01-14 08:05:35 -08:00
|
|
|
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
|
|
|
E_Action *a;
|
|
|
|
|
|
|
|
/* Actually take our cfdata settings and apply them in real life */
|
|
|
|
e_theme_config_set("theme", cfdata->theme);
|
|
|
|
e_config_save_queue();
|
|
|
|
|
|
|
|
a = e_action_find("restart");
|
2006-01-11 01:44:05 -08:00
|
|
|
if ((a) && (a->func.go)) a->func.go(NULL, NULL);
|
2005-12-19 06:42:43 -08:00
|
|
|
return 1; /* Apply was OK */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_e_config_theme_cb_standard(void *data)
|
|
|
|
{
|
|
|
|
E_Cfg_Theme_Data *d;
|
2006-01-14 08:05:35 -08:00
|
|
|
E_Config_Dialog_Data *cfdata;
|
2006-01-11 01:44:05 -08:00
|
|
|
const char *tmp;
|
2005-12-19 06:42:43 -08:00
|
|
|
|
|
|
|
d = data;
|
2006-03-03 20:11:51 -08:00
|
|
|
e_widget_preview_edje_set(d->cfd->data, d->file, "desktop/background");
|
|
|
|
// e_widget_image_object_set(d->cfd->data, e_thumb_evas_object_get(d->file, d->cfd->dia->win->evas, 160, 120, 1));
|
2006-01-10 07:05:09 -08:00
|
|
|
|
|
|
|
cfdata = d->cfd->cfdata;
|
2006-01-10 20:35:51 -08:00
|
|
|
if (cfdata->current_theme)
|
2006-01-10 07:05:09 -08:00
|
|
|
{
|
2006-01-11 01:44:05 -08:00
|
|
|
tmp = ecore_file_get_file(d->file);
|
|
|
|
if (!strcmp(tmp, cfdata->current_theme))
|
2006-01-10 20:35:51 -08:00
|
|
|
{
|
|
|
|
e_dialog_button_disable_num_set(d->cfd->dia, 0, 1);
|
|
|
|
e_dialog_button_disable_num_set(d->cfd->dia, 1, 1);
|
|
|
|
}
|
2006-01-10 07:05:09 -08:00
|
|
|
}
|
2005-12-19 06:42:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**--GUI--**/
|
|
|
|
static Evas_Object *
|
2006-01-14 08:05:35 -08:00
|
|
|
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
|
|
|
/* generate the core widget layout for a basic dialog */
|
2006-04-01 19:38:58 -08:00
|
|
|
Evas_Object *o, *o2, *fr, *im = NULL;
|
2005-12-19 06:42:43 -08:00
|
|
|
Evas_Object *il;
|
|
|
|
char *homedir;
|
2006-01-11 01:44:05 -08:00
|
|
|
Evas_Object *theme;
|
|
|
|
char fulltheme[PATH_MAX];
|
2006-04-01 19:56:07 -08:00
|
|
|
int i = 0, selnum = -1;
|
2006-04-01 19:38:58 -08:00
|
|
|
Ecore_Evas *eebuf;
|
|
|
|
Evas *evasbuf;
|
2006-04-01 19:56:07 -08:00
|
|
|
Evas_List *l, *paths;
|
2005-12-19 06:42:43 -08:00
|
|
|
|
|
|
|
theme = edje_object_add(evas);
|
|
|
|
|
|
|
|
_fill_data(cfdata);
|
|
|
|
cfdata->theme = NULL;
|
|
|
|
|
|
|
|
o = e_widget_table_add(evas, 0);
|
|
|
|
|
|
|
|
il = e_widget_ilist_add(evas, 48, 48, &(cfdata->theme));
|
|
|
|
|
2006-04-01 19:38:58 -08:00
|
|
|
eebuf = ecore_evas_buffer_new(1, 1);
|
|
|
|
evasbuf = ecore_evas_get(eebuf);
|
|
|
|
o2 = edje_object_add(evasbuf);
|
2006-04-01 19:56:07 -08:00
|
|
|
|
|
|
|
paths = e_path_dir_list_get(path_themes);
|
|
|
|
for (l = paths; l; l = l->next)
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
|
|
|
Ecore_List *themes;
|
2006-04-01 19:38:58 -08:00
|
|
|
char *themefile;
|
2006-04-01 20:18:18 -08:00
|
|
|
E_Path_Dir *d;
|
2006-04-01 19:56:07 -08:00
|
|
|
int detected;
|
|
|
|
|
2006-04-01 20:18:18 -08:00
|
|
|
d = l->data;
|
|
|
|
if (!ecore_file_is_dir(d->dir)) continue;
|
|
|
|
themes = ecore_file_ls(d->dir);
|
2006-04-01 19:56:07 -08:00
|
|
|
if (!themes) continue;
|
|
|
|
|
|
|
|
detected = 0;
|
|
|
|
homedir = e_user_homedir_get();
|
|
|
|
if (homedir)
|
2006-04-01 19:38:58 -08:00
|
|
|
{
|
2006-04-01 20:18:18 -08:00
|
|
|
if (!strncmp(d->dir, homedir, strlen(homedir)))
|
2006-04-01 19:38:58 -08:00
|
|
|
{
|
2006-04-01 19:56:07 -08:00
|
|
|
e_widget_ilist_header_append(il, NULL, _("Personal"));
|
|
|
|
i++;
|
|
|
|
detected = 1;
|
2006-04-01 19:38:58 -08:00
|
|
|
}
|
2006-04-01 19:56:07 -08:00
|
|
|
free(homedir);
|
2006-04-01 19:38:58 -08:00
|
|
|
}
|
2006-04-01 19:56:07 -08:00
|
|
|
if (!detected)
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
2006-04-01 20:18:18 -08:00
|
|
|
if (!strncmp(d->dir, e_prefix_data_get(), strlen(e_prefix_data_get())))
|
2006-04-01 19:56:07 -08:00
|
|
|
{
|
|
|
|
e_widget_ilist_header_append(il, NULL, _("System"));
|
|
|
|
i++;
|
|
|
|
detected = 1;
|
|
|
|
}
|
2006-04-01 19:38:58 -08:00
|
|
|
}
|
2006-04-01 19:56:07 -08:00
|
|
|
if (!detected)
|
2006-04-01 19:38:58 -08:00
|
|
|
{
|
2006-04-01 19:56:07 -08:00
|
|
|
e_widget_ilist_header_append(il, NULL, _("Other"));
|
2006-04-01 19:38:58 -08:00
|
|
|
i++;
|
2006-04-01 19:56:07 -08:00
|
|
|
detected = 1;
|
2006-04-01 19:38:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
while ((themefile = ecore_list_next(themes)))
|
|
|
|
{
|
2006-04-01 20:18:18 -08:00
|
|
|
snprintf(fulltheme, sizeof(fulltheme), "%s/%s", d->dir, themefile);
|
2006-04-01 19:38:58 -08:00
|
|
|
if (ecore_file_is_dir(fulltheme)) continue;
|
2005-12-19 06:42:43 -08:00
|
|
|
|
2006-04-01 19:38:58 -08:00
|
|
|
/* minimum theme requirements */
|
|
|
|
if (edje_object_file_set(o2, fulltheme, "desktop/background"))
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
2006-04-01 19:38:58 -08:00
|
|
|
Evas_Object *o3 = NULL;
|
|
|
|
char *noext;
|
|
|
|
E_Cfg_Theme_Data *cb_data;
|
|
|
|
|
|
|
|
if (!e_thumb_exists(fulltheme))
|
2006-04-03 07:01:00 -07:00
|
|
|
o3 = e_thumb_generate_begin(fulltheme, 48, 48, cfd->dia->win->evas, &o3, NULL, NULL);
|
2005-12-19 06:42:43 -08:00
|
|
|
else
|
2006-04-01 19:38:58 -08:00
|
|
|
o3 = e_thumb_evas_object_get(fulltheme, cfd->dia->win->evas, 48, 48, 1);
|
|
|
|
|
|
|
|
noext = ecore_file_strip_ext(themefile);
|
2005-12-19 06:42:43 -08:00
|
|
|
|
2006-04-01 19:38:58 -08:00
|
|
|
cb_data = E_NEW(E_Cfg_Theme_Data, 1);
|
|
|
|
cb_data->cfd = cfd;
|
|
|
|
cb_data->file = strdup(fulltheme);
|
|
|
|
cb_data->theme = strdup(themefile);
|
|
|
|
|
|
|
|
e_widget_ilist_append(il, o3, noext,
|
|
|
|
_e_config_theme_cb_standard, cb_data,
|
|
|
|
themefile);
|
|
|
|
if (!(strcmp(themefile, cfdata->current_theme)))
|
2005-12-19 06:42:43 -08:00
|
|
|
{
|
2006-04-01 19:38:58 -08:00
|
|
|
selnum = i;
|
2006-05-01 02:11:16 -07:00
|
|
|
im = e_widget_preview_add(evas, 320,
|
2006-05-01 23:23:55 -07:00
|
|
|
(320 * e_zone_current_get(cfd->dia->win->container)->h) /
|
|
|
|
e_zone_current_get(cfd->dia->win->container)->w);
|
2006-04-01 19:38:58 -08:00
|
|
|
e_widget_preview_edje_set(im, fulltheme, "desktop/background");
|
|
|
|
// im = e_widget_image_add_from_object(evas, theme, 320, 240);
|
|
|
|
// e_widget_image_object_set(im, e_thumb_evas_object_get(fulltheme, evas, 320, 240, 1));
|
2005-12-19 06:42:43 -08:00
|
|
|
}
|
2006-04-01 19:38:58 -08:00
|
|
|
free(noext);
|
|
|
|
i++;
|
2005-12-19 06:42:43 -08:00
|
|
|
}
|
|
|
|
}
|
2006-04-01 19:38:58 -08:00
|
|
|
free(themefile);
|
|
|
|
ecore_list_destroy(themes);
|
2005-12-19 06:42:43 -08:00
|
|
|
}
|
2006-04-01 19:56:07 -08:00
|
|
|
if (paths) e_path_dir_list_free(paths);
|
2006-04-01 19:38:58 -08:00
|
|
|
evas_object_del(o2);
|
|
|
|
ecore_evas_free(eebuf);
|
2005-12-19 06:42:43 -08:00
|
|
|
|
|
|
|
e_widget_ilist_go(il);
|
2006-01-02 03:33:10 -08:00
|
|
|
e_widget_min_size_set(il, 180, 40);
|
2005-12-19 06:42:43 -08:00
|
|
|
e_widget_table_object_append(o, il, 0, 0, 1, 2, 1, 1, 1, 1);
|
|
|
|
if (im == NULL)
|
|
|
|
{
|
2006-01-11 01:44:05 -08:00
|
|
|
snprintf(fulltheme, sizeof(fulltheme), PACKAGE_DATA_DIR"/data/themes/default.edj");
|
2006-05-01 02:11:16 -07:00
|
|
|
im = e_widget_preview_add(evas, 320,
|
2006-05-01 23:23:55 -07:00
|
|
|
(320 * e_zone_current_get(cfd->dia->win->container)->h) /
|
|
|
|
e_zone_current_get(cfd->dia->win->container)->w);
|
2006-03-03 20:11:51 -08:00
|
|
|
e_widget_preview_edje_set(im, fulltheme, "desktop/background");
|
|
|
|
// theme = e_thumb_generate_begin(fulltheme, 320, 240, evas, &theme, NULL, NULL);
|
|
|
|
// im = e_widget_image_add_from_object(evas, theme, 320, 240);
|
|
|
|
// e_widget_image_object_set(im, e_thumb_evas_object_get(fulltheme, evas, 320, 240, 1));
|
2005-12-19 06:42:43 -08:00
|
|
|
}
|
|
|
|
cfd->data = im;
|
2006-03-03 20:11:51 -08:00
|
|
|
|
|
|
|
e_widget_table_object_append(o, im, 1, 0, 1, 2, 1, 1, 1, 1);
|
2006-04-01 19:38:58 -08:00
|
|
|
|
|
|
|
if (selnum >= 0) e_widget_ilist_selected_set(il, selnum);
|
2005-12-19 06:42:43 -08:00
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|