BUG Fixes: clip/get first time, add advanced section for setting bg on this desk, default, all. Advanced needs Set for this desk and Set for all to be implemented yet.
SVN revision: 19694
This commit is contained in:
parent
5ea3442fba
commit
5356abd965
|
@ -3,6 +3,10 @@
|
||||||
*/
|
*/
|
||||||
#include "e.h"
|
#include "e.h"
|
||||||
|
|
||||||
|
#define BG_SET_DEFAULT_DESK 0
|
||||||
|
#define BG_SET_THIS_DESK 1
|
||||||
|
#define BG_SET_ALL_DESK 2
|
||||||
|
|
||||||
/* PROTOTYPES - same all the time */
|
/* PROTOTYPES - same all the time */
|
||||||
typedef struct _CFData CFData;
|
typedef struct _CFData CFData;
|
||||||
typedef struct _E_Cfg_Bg_Data E_Cfg_Bg_Data;
|
typedef struct _E_Cfg_Bg_Data E_Cfg_Bg_Data;
|
||||||
|
@ -11,6 +15,9 @@ static void *_create_data(E_Config_Dialog *cfd);
|
||||||
static void _free_data(E_Config_Dialog *cfd, CFData *cfdata);
|
static void _free_data(E_Config_Dialog *cfd, CFData *cfdata);
|
||||||
static int _basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata);
|
static int _basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata);
|
||||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata);
|
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata);
|
||||||
|
static int _advanced_apply_data(E_Config_Dialog *cfd, CFData *cfdata);
|
||||||
|
static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata);
|
||||||
|
static void _load_bgs(Evas *evas, E_Config_Dialog *cfd, Evas_Object *il);
|
||||||
|
|
||||||
/* Actual config data we will be playing with whil the dialog is active */
|
/* Actual config data we will be playing with whil the dialog is active */
|
||||||
struct _CFData
|
struct _CFData
|
||||||
|
@ -18,6 +25,7 @@ struct _CFData
|
||||||
/*- BASIC -*/
|
/*- BASIC -*/
|
||||||
char *file ;
|
char *file ;
|
||||||
/*- ADVANCED -*/
|
/*- ADVANCED -*/
|
||||||
|
int bg_method;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _E_Cfg_Bg_Data
|
struct _E_Cfg_Bg_Data
|
||||||
|
@ -38,12 +46,10 @@ e_int_config_background(E_Container *con)
|
||||||
v.free_cfdata = _free_data;
|
v.free_cfdata = _free_data;
|
||||||
v.basic.apply_cfdata = _basic_apply_data;
|
v.basic.apply_cfdata = _basic_apply_data;
|
||||||
v.basic.create_widgets = _basic_create_widgets;
|
v.basic.create_widgets = _basic_create_widgets;
|
||||||
/* Make these NULL for now until we have something here */
|
v.advanced.apply_cfdata = _advanced_apply_data;
|
||||||
v.advanced.apply_cfdata = NULL;
|
v.advanced.create_widgets = _advanced_create_widgets;
|
||||||
v.advanced.create_widgets = NULL;
|
|
||||||
/* create config diaolg for NULL object/data */
|
/* create config diaolg for NULL object/data */
|
||||||
cfd = e_config_dialog_new(con, _("Background Settings"), NULL, 0, &v, NULL);
|
cfd = e_config_dialog_new(con, _("Background Settings"), NULL, 0, &v, NULL);
|
||||||
//e_dialog_resizable_set(cfd->dia, 1);
|
|
||||||
return cfd;
|
return cfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +57,8 @@ e_int_config_background(E_Container *con)
|
||||||
static void
|
static void
|
||||||
_fill_data(CFData *cfdata)
|
_fill_data(CFData *cfdata)
|
||||||
{
|
{
|
||||||
/* TODO: get debfault bg */
|
cfdata->bg_method = BG_SET_DEFAULT_DESK;
|
||||||
|
/* TODO: get default bg */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -80,14 +86,6 @@ _free_data(E_Config_Dialog *cfd, CFData *cfdata)
|
||||||
static int
|
static int
|
||||||
_basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata)
|
_basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata)
|
||||||
{
|
{
|
||||||
E_Zone *z;
|
|
||||||
E_Desk *d;
|
|
||||||
|
|
||||||
z = e_zone_current_get(cfd->con);
|
|
||||||
d = e_desk_current_get(z);
|
|
||||||
/* Actually take our cfdata settings and apply them in real life */
|
|
||||||
printf("file: %s\n", cfdata->file);
|
|
||||||
//e_bg_add(cfd->con, z, 0, 0, cfdata->file);
|
|
||||||
if (e_config->desktop_default_background) evas_stringshare_del(e_config->desktop_default_background);
|
if (e_config->desktop_default_background) evas_stringshare_del(e_config->desktop_default_background);
|
||||||
e_config->desktop_default_background = evas_stringshare_add(cfdata->file);
|
e_config->desktop_default_background = evas_stringshare_add(cfdata->file);
|
||||||
e_bg_update();
|
e_bg_update();
|
||||||
|
@ -101,20 +99,15 @@ _e_config_bg_cb_standard(void *data)
|
||||||
E_Cfg_Bg_Data *d;
|
E_Cfg_Bg_Data *d;
|
||||||
|
|
||||||
d = data;
|
d = data;
|
||||||
e_widget_image_object_set(d->cfd->data, e_thumb_evas_object_get(d->file, d->cfd->dia->win->evas, 160, 120, 1));
|
e_widget_image_object_set(d->cfd->data, e_thumb_evas_object_get(d->file, d->cfd->dia->win->evas, 200, 160, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**--GUI--**/
|
/**--GUI--**/
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
|
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
|
||||||
{
|
{
|
||||||
/* generate the core widget layout for a basic dialog */
|
Evas_Object *o, *fr, *il;
|
||||||
Evas_Object *o, *fr, *im = NULL;
|
Evas_Object *im = NULL;
|
||||||
Evas_Object *il;
|
|
||||||
char buf[4096];
|
|
||||||
char *homedir;
|
|
||||||
Evas_Object *bg;
|
|
||||||
|
|
||||||
_fill_data(cfdata);
|
_fill_data(cfdata);
|
||||||
|
|
||||||
|
@ -122,7 +115,107 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
|
||||||
|
|
||||||
cfdata->file = NULL;
|
cfdata->file = NULL;
|
||||||
il = e_widget_ilist_add(evas, 48, 48, &(cfdata->file));
|
il = e_widget_ilist_add(evas, 48, 48, &(cfdata->file));
|
||||||
//e_widget_ilist_selector_set(il, 1);
|
e_widget_ilist_selector_set(il, 1);
|
||||||
|
e_widget_min_size_set(il, 240, 200);
|
||||||
|
|
||||||
|
_load_bgs(evas, cfd, il);
|
||||||
|
im = cfd->data;
|
||||||
|
|
||||||
|
e_widget_focus_set(il, 1);
|
||||||
|
e_widget_ilist_go(il);
|
||||||
|
e_widget_table_object_append(o, il, 0, 0, 1, 2, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
fr = e_widget_framelist_add(evas, "Preview", 0);
|
||||||
|
e_widget_min_size_set(fr, 180, 160);
|
||||||
|
e_widget_table_object_append(o, fr, 1, 0, 1, 1, 1, 1, 1, 1);
|
||||||
|
e_widget_framelist_object_append(fr, im);
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_advanced_apply_data(E_Config_Dialog *cfd, CFData *cfdata)
|
||||||
|
{
|
||||||
|
E_Zone *z;
|
||||||
|
E_Desk *d;
|
||||||
|
Evas_List *l;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
z = e_zone_current_get(cfd->con);
|
||||||
|
switch (cfdata->bg_method)
|
||||||
|
{
|
||||||
|
case BG_SET_DEFAULT_DESK:
|
||||||
|
if (e_config->desktop_default_background) evas_stringshare_del(e_config->desktop_default_background);
|
||||||
|
e_config->desktop_default_background = evas_stringshare_add(cfdata->file);
|
||||||
|
e_bg_update();
|
||||||
|
e_config_save_queue();
|
||||||
|
break;
|
||||||
|
case BG_SET_THIS_DESK:
|
||||||
|
d = e_desk_current_get(z);
|
||||||
|
e_desk_xy_get(d, &x, &y);
|
||||||
|
break;
|
||||||
|
case BG_SET_ALL_DESK:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1; /* Apply was OK */
|
||||||
|
}
|
||||||
|
|
||||||
|
static Evas_Object *
|
||||||
|
_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
|
||||||
|
{
|
||||||
|
Evas_Object *o, *fr, *il;
|
||||||
|
Evas_Object *im = NULL;
|
||||||
|
Evas_Object *oc;
|
||||||
|
E_Radio_Group *rg;
|
||||||
|
|
||||||
|
_fill_data(cfdata);
|
||||||
|
|
||||||
|
o = e_widget_table_add(evas, 0);
|
||||||
|
|
||||||
|
cfdata->file = NULL;
|
||||||
|
il = e_widget_ilist_add(evas, 48, 48, &(cfdata->file));
|
||||||
|
e_widget_ilist_selector_set(il, 1);
|
||||||
|
e_widget_min_size_set(il, 240, 200);
|
||||||
|
|
||||||
|
_load_bgs(evas, cfd, il);
|
||||||
|
im = cfd->data;
|
||||||
|
|
||||||
|
e_widget_focus_set(il, 1);
|
||||||
|
e_widget_ilist_go(il);
|
||||||
|
e_widget_table_object_append(o, il, 0, 0, 1, 2, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
fr = e_widget_framelist_add(evas, "Preview", 0);
|
||||||
|
e_widget_min_size_set(fr, 180, 160);
|
||||||
|
e_widget_table_object_append(o, fr, 1, 0, 1, 1, 1, 1, 1, 1);
|
||||||
|
e_widget_framelist_object_append(fr, im);
|
||||||
|
|
||||||
|
rg = e_widget_radio_group_new(&(cfdata->bg_method));
|
||||||
|
|
||||||
|
fr = e_widget_framelist_add(evas, "Set Background For", 0);
|
||||||
|
e_widget_min_size_set(fr, 180, 160);
|
||||||
|
|
||||||
|
oc = e_widget_radio_add(evas, _("Default Desktop"), BG_SET_DEFAULT_DESK, rg);
|
||||||
|
e_widget_framelist_object_append(fr, oc);
|
||||||
|
oc = e_widget_radio_add(evas, _("This Desktop"), BG_SET_THIS_DESK, rg);
|
||||||
|
e_widget_disabled_set(oc, 1);
|
||||||
|
e_widget_framelist_object_append(fr, oc);
|
||||||
|
oc = e_widget_radio_add(evas, _("All Desktops"), BG_SET_ALL_DESK, rg);
|
||||||
|
e_widget_disabled_set(oc, 1);
|
||||||
|
e_widget_framelist_object_append(fr, oc);
|
||||||
|
|
||||||
|
e_widget_table_object_append(o, fr, 1, 1, 1, 1, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_load_bgs(Evas *evas, E_Config_Dialog *cfd, Evas_Object *il)
|
||||||
|
{
|
||||||
|
Evas_Object *im = NULL;
|
||||||
|
Evas_Object *bg = NULL;
|
||||||
|
char buf[4096];
|
||||||
|
char *homedir;
|
||||||
|
|
||||||
homedir = e_user_homedir_get();
|
homedir = e_user_homedir_get();
|
||||||
if (homedir)
|
if (homedir)
|
||||||
{
|
{
|
||||||
|
@ -130,7 +223,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
|
||||||
free(homedir);
|
free(homedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ecore_file_exists(buf)) && (ecore_file_is_dir(buf)))
|
if (ecore_file_is_dir(buf))
|
||||||
{
|
{
|
||||||
Ecore_List *bgs;
|
Ecore_List *bgs;
|
||||||
|
|
||||||
|
@ -151,33 +244,18 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
|
||||||
while ((bgfile = ecore_list_next(bgs)))
|
while ((bgfile = ecore_list_next(bgs)))
|
||||||
{
|
{
|
||||||
snprintf(fullbg, sizeof(fullbg), "%s/%s", buf, bgfile);
|
snprintf(fullbg, sizeof(fullbg), "%s/%s", buf, bgfile);
|
||||||
if (ecore_file_is_dir(fullbg))
|
if (ecore_file_is_dir(fullbg)) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
/* minimum theme requirements */
|
/* minimum theme requirements */
|
||||||
if (edje_object_file_set(o, fullbg, "desktop/background"))
|
if (edje_object_file_set(o, fullbg, "desktop/background"))
|
||||||
{
|
{
|
||||||
Evas_Object *o = NULL;
|
Evas_Object *o = NULL;
|
||||||
char *noext, *ext;
|
char *noext;
|
||||||
E_Cfg_Bg_Data *cb_data;
|
E_Cfg_Bg_Data *cb_data;
|
||||||
|
|
||||||
o = e_thumb_generate_begin(fullbg, 48, 48, cfd->dia->win->evas, &o, NULL, NULL);
|
o = e_thumb_generate_begin(fullbg, 48, 48, evas, &o, NULL, NULL);
|
||||||
|
|
||||||
ext = strrchr(bgfile ,'.');
|
noext = ecore_file_strip_ext(bgfile);
|
||||||
|
|
||||||
if (!ext)
|
|
||||||
{
|
|
||||||
noext = strdup(bgfile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
noext = malloc((ext - bgfile + 1));
|
|
||||||
if (bgfile)
|
|
||||||
{
|
|
||||||
memcpy(noext, bgfile, ext - bgfile);
|
|
||||||
noext[ext - bgfile] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cb_data = E_NEW(E_Cfg_Bg_Data, 1);
|
cb_data = E_NEW(E_Cfg_Bg_Data, 1);
|
||||||
cb_data->cfd = cfd;
|
cb_data->cfd = cfd;
|
||||||
cb_data->file = strdup(fullbg);
|
cb_data->file = strdup(fullbg);
|
||||||
|
@ -188,33 +266,27 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
|
||||||
e_widget_ilist_selected_set(il, i);
|
e_widget_ilist_selected_set(il, i);
|
||||||
bg = edje_object_add(evas);
|
bg = edje_object_add(evas);
|
||||||
edje_object_file_set(bg, e_config->desktop_default_background, "desktop/background");
|
edje_object_file_set(bg, e_config->desktop_default_background, "desktop/background");
|
||||||
im = e_widget_image_add_from_object(evas, bg, 160, 120);
|
im = e_widget_image_add_from_object(evas, bg, 200, 160);
|
||||||
|
e_widget_image_object_set(im, e_thumb_evas_object_get(fullbg, evas, 200, 160, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
free(noext);
|
free(noext);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(bgfile);
|
||||||
evas_object_del(o);
|
evas_object_del(o);
|
||||||
ecore_evas_free(eebuf);
|
ecore_evas_free(eebuf);
|
||||||
ecore_list_destroy(bgs);
|
ecore_list_destroy(bgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e_widget_ilist_go(il);
|
|
||||||
e_widget_min_size_set(il, 240, 320);
|
|
||||||
e_widget_table_object_append(o, il, 0, 0, 1, 2, 1, 1, 1, 1);
|
|
||||||
fr = e_widget_framelist_add(evas, "Preview", 0);
|
|
||||||
if (im == NULL)
|
if (im == NULL)
|
||||||
{
|
{
|
||||||
bg = edje_object_add(evas);
|
bg = edje_object_add(evas);
|
||||||
e_theme_edje_object_set(bg, "base/theme/background", "desktop/background");
|
e_theme_edje_object_set(bg, "base/theme/background", "desktop/background");
|
||||||
im = e_widget_image_add_from_object(evas, bg, 160, 120);
|
im = e_widget_image_add_from_object(evas, bg, 200, 160);
|
||||||
}
|
}
|
||||||
cfd->data = im;
|
cfd->data = im;
|
||||||
e_widget_min_size_set(fr, 180, 150);
|
|
||||||
e_widget_table_object_append(o, fr, 1, 0, 1, 1, 1, 1, 1, 1);
|
|
||||||
e_widget_framelist_object_append(fr, im);
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue