forked from enlightenment/enlightenment
Added import function to bg config dialog
SVN revision: 19959
This commit is contained in:
parent
58da3b51f2
commit
5da013565d
|
@ -121,6 +121,7 @@ e_widget_slider.h \
|
|||
e_int_config_window_manipulation.h \
|
||||
e_int_config_window_display.h \
|
||||
e_int_config_background.h \
|
||||
e_int_config_background_import.h \
|
||||
e_int_config_theme.h \
|
||||
e_int_config_menus.h \
|
||||
e_int_config_general.h \
|
||||
|
@ -233,6 +234,7 @@ e_widget_slider.c \
|
|||
e_int_config_window_manipulation.c \
|
||||
e_int_config_window_display.c \
|
||||
e_int_config_background.c \
|
||||
e_int_config_background_import.c \
|
||||
e_int_config_theme.c \
|
||||
e_int_config_menus.c \
|
||||
e_int_config_general.c \
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
#include "e_int_config_window_manipulation.h"
|
||||
#include "e_int_config_window_display.h"
|
||||
#include "e_int_config_background.h"
|
||||
#include "e_int_config_background_import.h"
|
||||
#include "e_int_config_theme.h"
|
||||
#include "e_int_config_menus.h"
|
||||
#include "e_int_config_general.h"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#include "e.h"
|
||||
|
||||
#define BG_SET_DEFAULT_DESK 0
|
||||
|
@ -9,33 +10,45 @@
|
|||
|
||||
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);
|
||||
static int _advanced_apply_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_advanced_create_widgets (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _load_bgs (E_Config_Dialog *cfd, Evas_Object *il);
|
||||
void _ilist_cb_bg_selected (void *data);
|
||||
static void _bg_config_dialog_cb_import (void *data, void *data2);
|
||||
static int _bg_dialog_close (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static void _bg_file_added (void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path);
|
||||
|
||||
static Ecore_File_Monitor *_bg_file_monitor;
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
char *bg, *current_bg;
|
||||
int bg_method;
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog *import;
|
||||
Evas_Object *il;
|
||||
};
|
||||
|
||||
EAPI E_Config_Dialog *
|
||||
e_int_config_background(E_Container *con)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View v;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
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.advanced.apply_cfdata = _advanced_apply_data;
|
||||
v.advanced.create_widgets = _advanced_create_widgets;
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Background Settings"), NULL, 0, &v, NULL);
|
||||
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->advanced.apply_cfdata = _advanced_apply_data;
|
||||
v->advanced.create_widgets = _advanced_create_widgets;
|
||||
v->close_cfdata = _bg_dialog_close;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Background Settings"), NULL, 0, v, NULL);
|
||||
return cfd;
|
||||
}
|
||||
|
||||
|
@ -55,14 +68,20 @@ _create_data(E_Config_Dialog *cfd)
|
|||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
cfd->cfdata = cfdata;
|
||||
_fill_data(cfdata);
|
||||
cfd->cfdata = cfdata;
|
||||
cfdata->cfd = cfd;
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (_bg_file_monitor)
|
||||
{
|
||||
ecore_file_monitor_del(_bg_file_monitor);
|
||||
_bg_file_monitor = NULL;
|
||||
}
|
||||
if (cfdata->current_bg) free(cfdata->current_bg);
|
||||
free(cfdata);
|
||||
}
|
||||
|
@ -71,11 +90,15 @@ static Evas_Object *
|
|||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *ot, *of, *il, *im;
|
||||
char path[4096];
|
||||
|
||||
_fill_data(cfdata);
|
||||
|
||||
ot = e_widget_table_add(evas, 0);
|
||||
il = e_widget_ilist_add(evas, 48, 48, &(cfdata->bg));
|
||||
|
||||
cfdata->il = il;
|
||||
|
||||
e_widget_ilist_selector_set(il, 1);
|
||||
e_widget_min_size_set(il, 180, 40);
|
||||
|
||||
|
@ -87,17 +110,31 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
e_widget_ilist_go(il);
|
||||
e_widget_table_object_append(ot, il, 0, 0, 1, 2, 1, 1, 1, 1);
|
||||
|
||||
/* Add import Button */
|
||||
o = e_widget_button_add(evas, _("Import An Image"), NULL, _bg_config_dialog_cb_import, cfd, NULL);
|
||||
e_widget_table_object_append(ot, o, 0, 2, 1, 1, 1, 0, 0, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Background Preview"), 0);
|
||||
e_widget_min_size_set(of, 320, 240);
|
||||
e_widget_table_object_append(ot, of, 1, 0, 1, 2, 1, 1, 1, 1);
|
||||
e_widget_framelist_object_append(of, im);
|
||||
|
||||
if (_bg_file_monitor)
|
||||
{
|
||||
ecore_file_monitor_del(_bg_file_monitor);
|
||||
_bg_file_monitor = NULL;
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get());
|
||||
_bg_file_monitor = ecore_file_monitor_add(path, _bg_file_added, cfdata);
|
||||
return ot;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!cfdata->bg) return 1;
|
||||
|
||||
while (e_config->desktop_backgrounds)
|
||||
{
|
||||
E_Config_Desktop_Background *cfbg;
|
||||
|
@ -107,7 +144,7 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
if (e_config->desktop_default_background)
|
||||
evas_stringshare_del(e_config->desktop_default_background);
|
||||
|
||||
if (!(cfdata->bg[0])) e_config->desktop_default_background = NULL;
|
||||
if (!cfdata->bg[0]) e_config->desktop_default_background = NULL;
|
||||
else
|
||||
e_config->desktop_default_background = evas_stringshare_add(cfdata->bg);
|
||||
|
||||
|
@ -123,11 +160,13 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
|||
{
|
||||
Evas_Object *o, *ot, *of, *il, *im, *oc;
|
||||
E_Radio_Group *rg;
|
||||
char path[4096];
|
||||
|
||||
_fill_data(cfdata);
|
||||
|
||||
ot = e_widget_table_add(evas, 0);
|
||||
il = e_widget_ilist_add(evas, 48, 48, &(cfdata->bg));
|
||||
cfdata->il = il;
|
||||
e_widget_ilist_selector_set(il, 1);
|
||||
e_widget_min_size_set(il, 180, 40);
|
||||
|
||||
|
@ -156,6 +195,15 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
|||
e_widget_framelist_object_append(of, oc);
|
||||
|
||||
e_widget_table_object_append(ot, of, 1, 2, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
if (_bg_file_monitor)
|
||||
{
|
||||
ecore_file_monitor_del(_bg_file_monitor);
|
||||
_bg_file_monitor = NULL;
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get());
|
||||
_bg_file_monitor = ecore_file_monitor_add(path, _bg_file_added, cfdata);
|
||||
return ot;
|
||||
}
|
||||
|
||||
|
@ -185,8 +233,7 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
if (e_config->desktop_default_background)
|
||||
evas_stringshare_del(e_config->desktop_default_background);
|
||||
|
||||
if (!(cfdata->bg[0]))
|
||||
e_config->desktop_default_background = NULL;
|
||||
if (!cfdata->bg[0]) e_config->desktop_default_background = NULL;
|
||||
else
|
||||
e_config->desktop_default_background = evas_stringshare_add(cfdata->bg);
|
||||
|
||||
|
@ -234,8 +281,10 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
|
|||
Evas *evasbuf;
|
||||
const char *f;
|
||||
char *c;
|
||||
evas = evas_object_evas_get(il);
|
||||
|
||||
if (!il) return;
|
||||
|
||||
evas = evas_object_evas_get(il);
|
||||
bg_obj = edje_object_add(cfd->dia->win->evas);
|
||||
|
||||
/* Load The Theme's Background */
|
||||
|
@ -253,7 +302,7 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
|
|||
else
|
||||
o = e_thumb_evas_object_get(c, cfd->dia->win->evas, 48, 48, 1);
|
||||
|
||||
e_widget_ilist_append(il, o, _("Theme Background"), _ilist_cb_bg_selected, cfd, "");
|
||||
e_widget_ilist_append(il, o, "Theme Background", _ilist_cb_bg_selected, cfd, "");
|
||||
}
|
||||
if (!e_config->desktop_default_background)
|
||||
e_widget_ilist_selected_set(il, 0);
|
||||
|
@ -279,7 +328,7 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
|
|||
|
||||
bgs = ecore_file_ls(d->dir);
|
||||
if (!bgs) continue;
|
||||
while (bg_file = ecore_list_next(bgs))
|
||||
while ((bg_file = ecore_list_next(bgs)))
|
||||
{
|
||||
char full_path[4096];
|
||||
|
||||
|
@ -349,3 +398,64 @@ _ilist_cb_bg_selected(void *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_bg_config_dialog_cb_import(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog *parent;
|
||||
E_Config_Dialog *import;
|
||||
|
||||
parent = data;
|
||||
if (!parent) return;
|
||||
|
||||
import = e_int_config_background_import(parent);
|
||||
parent->cfdata->import = import;
|
||||
}
|
||||
|
||||
static void
|
||||
_bg_file_added(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Evas *evas;
|
||||
Evas_Object *il, *ic;
|
||||
char *file;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
il = cfdata->il;
|
||||
if (!il) return;
|
||||
|
||||
cfd = cfdata->cfd;
|
||||
if (!cfd) return;
|
||||
|
||||
evas = e_win_evas_get(cfd->dia->win);
|
||||
|
||||
file = (char *)ecore_file_get_file((char *)path);
|
||||
if (event == ECORE_FILE_EVENT_CREATED_FILE)
|
||||
{
|
||||
printf("File Added: %s\n", path);
|
||||
if (e_util_edje_collection_exists((char *)path, "desktop/background"))
|
||||
{
|
||||
if (!e_thumb_exists((char *)path))
|
||||
ic = e_thumb_generate_begin((char *)path, 48, 48, evas, &ic, NULL, NULL);
|
||||
else
|
||||
ic = e_thumb_evas_object_get((char *)path, evas, 48, 48, 1);
|
||||
e_widget_ilist_append(il, ic, ecore_file_strip_ext(file), _ilist_cb_bg_selected, cfd, (char *)path);
|
||||
}
|
||||
}
|
||||
free(file);
|
||||
}
|
||||
|
||||
static int
|
||||
_bg_dialog_close(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!cfd) return 0;
|
||||
if (!cfdata) return 0;
|
||||
if (!cfdata->import->dia) return 0;
|
||||
|
||||
e_object_del_attach_func_set(E_OBJECT(cfd->dia), NULL);
|
||||
e_object_del(E_OBJECT(cfdata->import->dia));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,362 @@
|
|||
#include "e.h"
|
||||
|
||||
#define E_BG_SCALE 0
|
||||
#define E_BG_TILE 1
|
||||
#define E_BG_CENTER 2
|
||||
|
||||
/* TODO:
|
||||
* Currently the bg config dialog needs to be reloaded in order
|
||||
* to display new images created from here.
|
||||
*
|
||||
* If you close the bg config dialog, before closing this then SEGV.
|
||||
*/
|
||||
|
||||
/* Personally I hate having to define this twice, but Tileing needs a fill */
|
||||
#define IMG_EDC_TMPL_TILE \
|
||||
"images {\n" \
|
||||
" image: \"%s\" COMP;\n" \
|
||||
"}\n" \
|
||||
"collections {\n" \
|
||||
" group {\n" \
|
||||
" name: \"desktop/background\";\n" \
|
||||
" max: %d %d;\n" \
|
||||
" parts {\n" \
|
||||
" part {\n" \
|
||||
" name: \"background_image\";\n" \
|
||||
" type: IMAGE;\n" \
|
||||
" mouse_events: 0;\n" \
|
||||
" description {\n" \
|
||||
" state: \"default\" 0.0;\n" \
|
||||
" visible: 1;\n" \
|
||||
" rel1 {\n" \
|
||||
" relative: 0.0 0.0;\n" \
|
||||
" offset: 0 0;\n" \
|
||||
" }\n" \
|
||||
" rel2 {\n" \
|
||||
" relative: 1.0 1.0;\n" \
|
||||
" offset: -1 -1;\n" \
|
||||
" }\n" \
|
||||
" image {\n" \
|
||||
" normal: \"%s\";\n" \
|
||||
" }\n" \
|
||||
" fill {\n" \
|
||||
" size {\n" \
|
||||
" relative: 0.0 0.0;\n" \
|
||||
" offset: %d %d;\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"}\n"
|
||||
|
||||
#define IMG_EDC_TMPL \
|
||||
"images {\n" \
|
||||
" image: \"%s\" COMP;\n" \
|
||||
"}\n" \
|
||||
"collections {\n" \
|
||||
" group {\n" \
|
||||
" name: \"desktop/background\";\n" \
|
||||
" max: %d %d;\n" \
|
||||
" parts {\n" \
|
||||
" part {\n" \
|
||||
" name: \"background_image\";\n" \
|
||||
" type: IMAGE;\n" \
|
||||
" mouse_events: 0;\n" \
|
||||
" description {\n" \
|
||||
" state: \"default\" 0.0;\n" \
|
||||
" visible: 1;\n" \
|
||||
" rel1 {\n" \
|
||||
" relative: 0.0 0.0;\n" \
|
||||
" offset: 0 0;\n" \
|
||||
" }\n" \
|
||||
" rel2 {\n" \
|
||||
" relative: 1.0 1.0;\n" \
|
||||
" offset: -1 -1;\n" \
|
||||
" }\n" \
|
||||
" image {\n" \
|
||||
" normal: \"%s\";\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"}\n"
|
||||
|
||||
static Ecore_Event_Handler *_edj_exe_exit_handler = NULL;
|
||||
|
||||
static void *_create_data (E_Config_Dialog *cfd);
|
||||
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);
|
||||
static int _advanced_apply_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_advanced_create_widgets (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_data (E_Config_Dialog_Data *cfdata);
|
||||
static void _efm_hilite_cb (Evas_Object *obj, char *file, void *data);
|
||||
static void _bg_edj_gen (Evas *evas, char *filename, int method);
|
||||
static int _edj_exe_exit_cb (void *data, int type, void *event);
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
char *file;
|
||||
int method;
|
||||
};
|
||||
|
||||
EAPI E_Config_Dialog *
|
||||
e_int_config_background_import(E_Config_Dialog *parent)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
/* Create A New Import Dialog */
|
||||
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->advanced.apply_cfdata = NULL; //_advanced_apply_data;
|
||||
v->advanced.create_widgets = NULL;//_advanced_create_widgets;
|
||||
|
||||
cfd = e_config_dialog_new(parent->con, _("Import An Image"), NULL, 0, v, NULL);
|
||||
ecore_x_icccm_transient_for_set(cfd->dia->win->evas_win, parent->dia->win->evas_win);
|
||||
return cfd;
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
cfd->cfdata = cfdata;
|
||||
_fill_data(cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
free(cfdata);
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Fm_File *f;
|
||||
Evas *evas;
|
||||
|
||||
if (!cfdata->file[0]) return 0;
|
||||
|
||||
f = e_fm_file_new(cfdata->file);
|
||||
if (!f) return;
|
||||
|
||||
if (!e_fm_file_is_image(f)) return 0;
|
||||
free(f);
|
||||
|
||||
evas = e_win_evas_get(cfd->dia->win);
|
||||
_bg_edj_gen(evas, cfdata->file, cfdata->method);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *ot, *of, *ofm;
|
||||
E_Dialog *dia;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
_fill_data(cfdata);
|
||||
|
||||
dia = cfd->dia;
|
||||
|
||||
ot = e_widget_table_add(evas, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Image To Import"), 0);
|
||||
|
||||
ofm = e_widget_fileman_add(evas, (&(cfdata->file)));
|
||||
e_widget_fileman_hilite_callback_add(ofm, _efm_hilite_cb, dia);
|
||||
|
||||
e_widget_framelist_object_append(of, ofm);
|
||||
e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Options"), 0);
|
||||
rg = e_widget_radio_group_new(&cfdata->method);
|
||||
o = e_widget_radio_add(evas, _("Center"), E_BG_CENTER, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
o = e_widget_radio_add(evas, _("Scale"), E_BG_SCALE, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
o = e_widget_radio_add(evas, _("Tile"), E_BG_TILE, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
return ot;
|
||||
}
|
||||
|
||||
static int
|
||||
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Fm_File *f;
|
||||
Evas *evas;
|
||||
|
||||
if (!cfdata->file[0]) return 0;
|
||||
|
||||
f = e_fm_file_new(cfdata->file);
|
||||
if (!f) return;
|
||||
|
||||
if (!e_fm_file_is_image(f)) return 0;
|
||||
free(f);
|
||||
|
||||
evas = e_win_evas_get(cfd->dia->win);
|
||||
_bg_edj_gen(evas, cfdata->file, cfdata->method);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *ot, *of, *ofm;
|
||||
E_Dialog *dia;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
_fill_data(cfdata);
|
||||
|
||||
dia = cfd->dia;
|
||||
|
||||
ot = e_widget_table_add(evas, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Image To Import"), 0);
|
||||
|
||||
ofm = e_widget_fileman_add(evas, (&(cfdata->file)));
|
||||
e_widget_fileman_hilite_callback_add(ofm, _efm_hilite_cb, dia);
|
||||
|
||||
e_widget_framelist_object_append(of, ofm);
|
||||
e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Options"), 0);
|
||||
rg = e_widget_radio_group_new(&cfdata->method);
|
||||
o = e_widget_radio_add(evas, _("Center"), E_BG_CENTER, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
o = e_widget_radio_add(evas, _("Scale"), E_BG_SCALE, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
o = e_widget_radio_add(evas, _("Tile"), E_BG_TILE, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
e_widget_table_object_append(ot, of, 1, 0, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
return ot;
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_data(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
cfdata->method = E_BG_SCALE;
|
||||
}
|
||||
|
||||
static void
|
||||
_efm_hilite_cb(Evas_Object *obj, char *file, void *data)
|
||||
{
|
||||
E_Dialog *dia;
|
||||
E_Fm_File *f;
|
||||
|
||||
dia = (E_Dialog *)data;
|
||||
if (!dia) return;
|
||||
|
||||
f = e_fm_file_new(file);
|
||||
if (!f) return;
|
||||
|
||||
if (e_fm_file_is_image(f))
|
||||
{
|
||||
e_dialog_button_disable_num_set(dia, 0, 0);
|
||||
e_dialog_button_disable_num_set(dia, 1, 0);
|
||||
}
|
||||
free(f);
|
||||
}
|
||||
|
||||
static void
|
||||
_bg_edj_gen(Evas *evas, char *filename, int method)
|
||||
{
|
||||
Evas_Object *img;
|
||||
int fd = 0;
|
||||
int w, h, ret;
|
||||
const char *file;
|
||||
char buff[4096], cmd[4096];
|
||||
char ipart[512];
|
||||
char *imgdir = NULL;
|
||||
static char tmpn[1024];
|
||||
FILE *out = NULL;
|
||||
Ecore_Exe *x;
|
||||
|
||||
if (!filename) return;
|
||||
file = ecore_file_get_file(filename);
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/.e/e/backgrounds/%s.edj", e_user_homedir_get(), ecore_file_strip_ext(file));
|
||||
strcpy(tmpn, "/tmp/e_bgdlg_new.edc-tmp-XXXXXX");
|
||||
fd = mkstemp(tmpn);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("Error Creating tmp file: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
out = fopen(tmpn, "w");
|
||||
if (!out)
|
||||
{
|
||||
printf("Cannot open %s for writting\n", tmpn);
|
||||
return;
|
||||
}
|
||||
|
||||
imgdir = ecore_file_get_dir(filename);
|
||||
if (!imgdir) ipart[0] = '\0';
|
||||
if (imgdir)
|
||||
{
|
||||
snprintf(ipart, sizeof(ipart), "-id %s", imgdir);
|
||||
free(imgdir);
|
||||
}
|
||||
|
||||
img = evas_object_image_add(evas);
|
||||
evas_object_image_file_set(img, filename, NULL);
|
||||
evas_object_image_size_get(img, &w, &h);
|
||||
evas_object_del(img);
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case E_BG_CENTER:
|
||||
fprintf(out, IMG_EDC_TMPL, file, w, h, file);
|
||||
break;
|
||||
case E_BG_TILE:
|
||||
fprintf(out, IMG_EDC_TMPL_TILE, file, w, h, file, w, h);
|
||||
break;
|
||||
case E_BG_SCALE:
|
||||
fprintf(out, IMG_EDC_TMPL, file, w, h, file);
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", ipart, tmpn, buff);
|
||||
|
||||
_edj_exe_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _edj_exe_exit_cb, NULL);
|
||||
x = ecore_exe_run(cmd, tmpn);
|
||||
}
|
||||
|
||||
static int
|
||||
_edj_exe_exit_cb(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Exe_Event_Del *ev;
|
||||
Ecore_Exe *x;
|
||||
|
||||
ev = event;
|
||||
if (!ev->exe) return 1;
|
||||
|
||||
x = ev->exe;
|
||||
if (!x) return 1;
|
||||
|
||||
x = NULL;
|
||||
ecore_event_handler_del(_edj_exe_exit_handler);
|
||||
|
||||
unlink(data);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
#ifndef E_INT_CONFIG_BACKGROUND_IMPORT_H
|
||||
#define E_INT_CONFIG_BACKGROUND_IMPORT_H
|
||||
|
||||
EAPI E_Config_Dialog *e_int_config_background_import(E_Config_Dialog *parent);
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue