diff --git a/TODO b/TODO index c8a503ec4..90463e270 100644 --- a/TODO +++ b/TODO @@ -12,10 +12,6 @@ Some of the things (in very short form) that need to be done to E17... state and i think is also now causing segv's (not sure yet), but it needs a complete going over if not a rewrite. :( * BUG: "match this window only" doesnt fall back to other unused remembers -* BUG: make window sticky. send window to another desktop - get ghost window. - should 1. make any such operation in the pager useless and do - nothing if the window is sticky and 2. in the pager disallow dragging - out of the pager desktop if the window is sticky. * BUG: if app asks for borderless in properties - borderless toggle in menu doesn't have any effect. * BUG: change exe name in basic mode in eap editor and icon vanishes (don't @@ -76,7 +72,6 @@ Some of the things (in very short form) that need to be done to E17... * Dragging a non-eap icon from a border to the ibar should automatically create the icon and add that (instead of warning the user that this can't be done) -* new fm code doesn't indicate it is still scanning a dir - needs to * new fm code relays-out a dir every time the queue is processed - maybe try to speed this up * new fm code's file scannign isnt insanely fast - icon size calcs etc. speed @@ -88,12 +83,6 @@ Some of the things (in very short form) that need to be done to E17... CLEANUPS ------------------------------------------------------------------------------- -* wallpaper dialog needs to display backgrounds in all of the background path - locations. Currently it is only searching ~/.e/e/backgrounds -* wallpaper dialog needs a "for this screen only" option of containers or - zones > 1 :) -* wallpaper dialog needs to probably use fm2 for list of bg's (use 2 fm views - one for system, one for personal). * bg import dialog and code needs a big workover - needs a few more options on import like quality (lossy low, medium, high, perfect), when scaling do you stretch, scale retaining aspect within the screen or extend beyond screen diff --git a/configure.in b/configure.in index 128e99874..44c94edda 100644 --- a/configure.in +++ b/configure.in @@ -273,6 +273,7 @@ data/themes/images/Makefile data/other/Makefile data/xsession/Makefile data/xsession/enlightenment.desktop +data/backgrounds/Makefile doc/Makefile po/Makefile intl/Makefile diff --git a/data/Makefile.am b/data/Makefile.am index 6b1e13757..c9590c2a2 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,3 +1,3 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = fonts images init themes other xsession input_methods +SUBDIRS = fonts images init themes other xsession input_methods backgrounds diff --git a/data/backgrounds/Blue_Sky_Tree.edj b/data/backgrounds/Blue_Sky_Tree.edj new file mode 100644 index 000000000..379fa983b Binary files /dev/null and b/data/backgrounds/Blue_Sky_Tree.edj differ diff --git a/data/backgrounds/Cracked_Earth.edj b/data/backgrounds/Cracked_Earth.edj new file mode 100644 index 000000000..3b6ca5c53 Binary files /dev/null and b/data/backgrounds/Cracked_Earth.edj differ diff --git a/data/backgrounds/Ivy_Wall.edj b/data/backgrounds/Ivy_Wall.edj new file mode 100644 index 000000000..61f37156e Binary files /dev/null and b/data/backgrounds/Ivy_Wall.edj differ diff --git a/data/backgrounds/Ladybug.edj b/data/backgrounds/Ladybug.edj new file mode 100644 index 000000000..3b37ee671 Binary files /dev/null and b/data/backgrounds/Ladybug.edj differ diff --git a/data/backgrounds/Makefile.am b/data/backgrounds/Makefile.am new file mode 100644 index 000000000..cf74725c3 --- /dev/null +++ b/data/backgrounds/Makefile.am @@ -0,0 +1,9 @@ +MAINTAINERCLEANFILES = Makefile.in +filesdir = $(datadir)/enlightenment/data/backgrounds +files_DATA = \ +Ivy_Wall.edj \ +Ladybug.edj \ +Blue_Sky_Tree.edj \ +Cracked_Earth.edj + +EXTRA_DIST = $(files_DATA) diff --git a/data/themes/default_icons.edc b/data/themes/default_icons.edc index 455d0c803..96a616688 100644 --- a/data/themes/default_icons.edc +++ b/data/themes/default_icons.edc @@ -536,6 +536,23 @@ group { } } } +group { + name: "icons/widget/up_dir"; + parts { + part { + name: "icon"; + mouse_events: 0; + description { + state: "default" 0.0; + aspect: 0.83333333333 0.83333333333; + max: 12 10; + image { + normal: "e17_icon_up_arrow.png"; + } + } + } + } +} group { name: "icons/enlightenment/mouse"; max: 64 64; diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index e4383fa8e..795f2f96b 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -167,7 +167,9 @@ e_fm.h \ e_widget_scrollframe.h \ e_sha1.h \ e_widget_fsel.h \ -e_fm_mime.h +e_fm_mime.h \ +e_int_config_wallpaper.h \ +e_int_config_wallpaper_import.h enlightenment_src = \ e_user.c \ @@ -311,6 +313,8 @@ e_widget_scrollframe.c \ e_sha1.c \ e_widget_fsel.c \ e_fm_mime.c \ +e_int_config_wallpaper.c \ +e_int_config_wallpaper_import.c \ $(ENLIGHTENMENTHEADERS) enlightenment_SOURCES = \ diff --git a/src/bin/e_border.c b/src/bin/e_border.c index a54c3084c..333f257eb 100644 --- a/src/bin/e_border.c +++ b/src/bin/e_border.c @@ -77,6 +77,7 @@ static void _e_border_event_border_iconify_free(void *data, void *ev); static void _e_border_event_border_uniconify_free(void *data, void *ev); static void _e_border_event_border_stick_free(void *data, void *ev); static void _e_border_event_border_unstick_free(void *data, void *ev); +static void _e_border_event_border_property_free(void *data, void *ev); static void _e_border_zone_update(E_Border *bd); @@ -131,6 +132,7 @@ EAPI int E_EVENT_BORDER_STACK = 0; EAPI int E_EVENT_BORDER_ICON_CHANGE = 0; EAPI int E_EVENT_BORDER_FOCUS_IN = 0; EAPI int E_EVENT_BORDER_FOCUS_OUT = 0; +EAPI int E_EVENT_BORDER_PROPERTY = 0; #define GRAV_SET(bd, grav) \ ecore_x_window_gravity_set(bd->bg_win, grav); \ @@ -183,6 +185,7 @@ e_border_init(void) E_EVENT_BORDER_ICON_CHANGE = ecore_event_type_new(); E_EVENT_BORDER_FOCUS_IN = ecore_event_type_new(); E_EVENT_BORDER_FOCUS_OUT = ecore_event_type_new(); + E_EVENT_BORDER_PROPERTY = ecore_event_type_new(); return 1; } @@ -3726,6 +3729,7 @@ _e_border_cb_window_property(void *data, int ev_type, void *ev) { printf("ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER\n"); } + return 1; } @@ -4660,6 +4664,7 @@ _e_border_cb_grab_replay(void *data, int type, void *event) static void _e_border_eval(E_Border *bd) { + E_Event_Border_Property *event; int change_urgent = 0; int rem_change = 0; @@ -6217,6 +6222,12 @@ _e_border_eval(E_Border *bd) if ((bd->remember) && (rem_change)) e_remember_update(bd->remember, bd); + + + event = calloc(1, sizeof(E_Event_Border_Property)); + event->border = bd; + e_object_ref(E_OBJECT(bd)); + ecore_event_add(E_EVENT_BORDER_PROPERTY, event, _e_border_event_border_property_free, NULL); } static void @@ -6621,6 +6632,16 @@ _e_border_event_border_focus_out_free(void *data, void *ev) free(e); } +static void +_e_border_event_border_property_free(void *data, void *ev) +{ + E_Event_Border_Property *e; + + e = ev; + e_object_unref(E_OBJECT(e->border)); + free(e); +} + static void _e_border_zone_update(E_Border *bd) { diff --git a/src/bin/e_border.h b/src/bin/e_border.h index 9195c553f..c7ea68a80 100644 --- a/src/bin/e_border.h +++ b/src/bin/e_border.h @@ -89,6 +89,7 @@ typedef struct _E_Event_Border_Stack E_Event_Border_Stack; typedef struct _E_Event_Border_Icon_Change E_Event_Border_Icon_Change; typedef struct _E_Event_Border_Focus_In E_Event_Border_Focus_In; typedef struct _E_Event_Border_Focus_Out E_Event_Border_Focus_Out; +typedef struct _E_Event_Border_Property E_Event_Border_Property; #else #ifndef E_BORDER_H @@ -535,6 +536,11 @@ struct _E_Event_Border_Focus_Out E_Border *border; }; +struct _E_Event_Border_Property +{ + E_Border *border; +}; + EAPI int e_border_init(void); EAPI int e_border_shutdown(void); @@ -628,6 +634,7 @@ extern EAPI int E_EVENT_BORDER_STACK; extern EAPI int E_EVENT_BORDER_ICON_CHANGE; extern EAPI int E_EVENT_BORDER_FOCUS_IN; extern EAPI int E_EVENT_BORDER_FOCUS_OUT; +extern EAPI int E_EVENT_BORDER_PROPERTY; #endif #endif diff --git a/src/bin/e_configure.c b/src/bin/e_configure.c index d0cb56e59..eb6f7f8a9 100644 --- a/src/bin/e_configure.c +++ b/src/bin/e_configure.c @@ -64,7 +64,8 @@ e_configure_show(E_Container *con) /* add items here */ e_configure_header_item_add(eco, "enlightenment/appearance", _("Appearance")); - e_configure_standard_item_add(eco, "enlightenment/background", _("Wallpaper"), e_int_config_background); +// e_configure_standard_item_add(eco, "enlightenment/background", _("Wallpaper"), e_int_config_background); + e_configure_standard_item_add(eco, "enlightenment/background", _("Wallpaper"), e_int_config_wallpaper); e_configure_standard_item_add(eco, "enlightenment/themes", _("Theme"), e_int_config_theme); e_configure_standard_item_add(eco, "enlightenment/fonts", _("Fonts"), e_int_config_fonts); e_configure_standard_item_add(eco, "enlightenment/mouse", _("Mouse Cursor"), e_int_config_cursor); diff --git a/src/bin/e_entry.c b/src/bin/e_entry.c index 563f782d0..fb80270fa 100644 --- a/src/bin/e_entry.c +++ b/src/bin/e_entry.c @@ -108,7 +108,7 @@ e_editable_text_text_set(Evas_Object *object, const char *text) { E_Editable_Text_Smart_Data *sd; - if ((!object) || (!text) || !(sd = evas_object_smart_data_get(object))) + if ((!object) || !(sd = evas_object_smart_data_get(object))) return; evas_object_textblock_text_markup_set(sd->text_object, text); diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 7b932dbcd..a328674d3 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -397,13 +397,36 @@ e_fm2_select_set(Evas_Object *obj, char *file, int select) } else { - if (ic->sd->config->view.single_click) + if (ic->sd->config->selection.single) _e_fm2_icon_deselect(ic); ic->last_selected = 0; } } } +EAPI void +e_fm2_file_show(Evas_Object *obj, char *file) +{ + E_Fm2_Smart_Data *sd; + Evas_List *l; + E_Fm2_Icon *ic; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; // safety + if (!evas_object_type_get(obj)) return; // safety + if (strcmp(evas_object_type_get(obj), "e_fm")) return; // safety + for (l = sd->icons; l; l = l->next) + { + ic = l->data; + if (!strcmp(ic->info.file, file)) + { + e_fm2_pan_set(obj, ic->x, ic->y); + evas_object_smart_callback_call(obj, "pan_changed", NULL); + return; + } + } +} + EAPI void e_fm2_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y) { @@ -1401,7 +1424,7 @@ _e_fm2_icon_icon_set(E_Fm2_Icon *ic) snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file); ic->obj_icon = e_thumb_icon_add(evas_object_evas_get(ic->sd->obj)); e_thumb_icon_file_set(ic->obj_icon, buf, NULL); - e_thumb_icon_size_set(ic->obj_icon, 64, 48); + e_thumb_icon_size_set(ic->obj_icon, 64, 64); evas_object_smart_callback_add(ic->obj_icon, "e_thumb_gen", _e_fm2_cb_icon_thumb_gen, ic); _e_fm2_icon_thumb(ic); edje_object_part_swallow(ic->obj, "icon_swallow", ic->obj_icon); @@ -1444,7 +1467,7 @@ _e_fm2_icon_icon_set(E_Fm2_Icon *ic) snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file); ic->obj_icon = e_thumb_icon_add(evas_object_evas_get(ic->sd->obj)); e_thumb_icon_file_set(ic->obj_icon, buf, "desktop/background"); - e_thumb_icon_size_set(ic->obj_icon, 64, 64); + e_thumb_icon_size_set(ic->obj_icon, 64, 48); evas_object_smart_callback_add(ic->obj_icon, "e_thumb_gen", _e_fm2_cb_icon_thumb_gen, ic); _e_fm2_icon_thumb(ic); edje_object_part_swallow(ic->obj, "icon_swallow", ic->obj_icon); diff --git a/src/bin/e_fm.h b/src/bin/e_fm.h index 2def4446f..fcde284fc 100644 --- a/src/bin/e_fm.h +++ b/src/bin/e_fm.h @@ -108,6 +108,7 @@ EAPI E_Fm2_Config *e_fm2_config_get(Evas_Object *obj); EAPI Evas_List *e_fm2_selected_list_get(Evas_Object *obj); EAPI Evas_List *e_fm2_all_list_get(Evas_Object *obj); EAPI void e_fm2_select_set(Evas_Object *obj, char *file, int select); +EAPI void e_fm2_file_show(Evas_Object *obj, char *file); EAPI void e_fm2_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y); EAPI void e_fm2_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y); diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index 7862d3132..51e6f4d6e 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -144,3 +144,5 @@ #include "e_widget_framelist.h" #include "e_widget_fsel.h" #include "e_fm_mime.h" +#include "e_int_config_wallpaper.h" +#include "e_int_config_wallpaper_import.h" diff --git a/src/bin/e_int_config_wallpaper.c b/src/bin/e_int_config_wallpaper.c new file mode 100644 index 000000000..9e8500699 --- /dev/null +++ b/src/bin/e_int_config_wallpaper.c @@ -0,0 +1,806 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + +#include "e.h" + +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); + +struct _E_Config_Dialog_Data +{ + E_Config_Dialog *cfd; + Evas_Object *o_usrbg_frame; + Evas_Object *o_usrbg_fm; + Evas_Object *o_usrbg_up_button; + Evas_Object *o_sysbg_frame; + Evas_Object *o_sysbg_fm; + Evas_Object *o_sysbg_up_button; + Evas_Object *o_preview; + Evas_Object *o_theme_bg; + int use_theme_bg; + char *bg; + /* advanced */ + int all_this_desk_screen; + /* dialogs */ + E_Win *win_import; +}; + +EAPI E_Config_Dialog * +e_int_config_wallpaper(E_Container *con) +{ + E_Config_Dialog *cfd; + E_Config_Dialog_View *v; + + 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 = _advanced_apply_data; + v->advanced.create_widgets = _advanced_create_widgets; + v->override_auto_apply = 1; + cfd = e_config_dialog_new(con, _("Wallpaper Settings"), "enlightenment/background", 0, v, NULL); + return cfd; +} + +EAPI void +e_int_config_wallpaper_update(E_Config_Dialog *dia, char *file) +{ + E_Config_Dialog_Data *cfdata; + char path[4096], *homedir; + + cfdata = dia->cfdata; + homedir = e_user_homedir_get(); + if (!homedir) return; + snprintf(path, sizeof(path), "%s/.e/e/backgrounds", homedir); + E_FREE(cfdata->bg); + cfdata->bg = strdup(file); + cfdata->use_theme_bg = 0; + if (cfdata->o_theme_bg) + e_widget_check_checked_set(cfdata->o_theme_bg, cfdata->use_theme_bg); + if (cfdata->o_usrbg_fm) + e_fm2_path_set(cfdata->o_usrbg_fm, path, "/"); + if (cfdata->o_preview) + e_widget_preview_edje_set(cfdata->o_preview, cfdata->bg, "desktop/background"); + if (cfdata->o_theme_bg) + e_widget_check_checked_set(cfdata->o_theme_bg, 0); + cfdata->use_theme_bg = 0; + if (cfdata->o_usrbg_frame) + e_widget_change(cfdata->o_usrbg_frame); + if (cfdata->o_sysbg_fm) + e_fm2_select_set(cfdata->o_sysbg_fm, "", 0); +} + +EAPI void +e_int_config_wallpaper_import_done(E_Config_Dialog *dia) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = dia->cfdata; + cfdata->win_import = NULL; + printf("DONE!\n"); +} + + +static void +_cb_usrbg_button_up(void *data1, void *data2) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data1; + if (cfdata->o_usrbg_fm) + e_fm2_parent_go(cfdata->o_usrbg_fm); + if (cfdata->o_usrbg_frame) + e_widget_scrollframe_child_pos_set(cfdata->o_usrbg_frame, 0, 0); +} + +static void +_cb_usrbg_files_changed(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data; + if (!cfdata->o_usrbg_fm) return; + if (!e_fm2_has_parent_get(cfdata->o_usrbg_fm)) + { + if (cfdata->o_usrbg_up_button) + e_widget_disabled_set(cfdata->o_usrbg_up_button, 1); + } + else + { + if (cfdata->o_usrbg_up_button) + e_widget_disabled_set(cfdata->o_usrbg_up_button, 0); + } + if (cfdata->o_usrbg_frame) + e_widget_scrollframe_child_pos_set(cfdata->o_usrbg_frame, 0, 0); +} + +static void +_cb_usrbg_files_selection_change(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + Evas_List *selected; + E_Fm2_Icon_Info *ici; + const char *realpath; + char buf[4096]; + + cfdata = data; + if (!cfdata->o_usrbg_fm) return; + selected = e_fm2_selected_list_get(cfdata->o_usrbg_fm); + if (!selected) return; + ici = selected->data; + realpath = e_fm2_real_path_get(cfdata->o_usrbg_fm); + if (!strcmp(realpath, "/")) + snprintf(buf, sizeof(buf), "/%s", ici->file); + else + snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file); + evas_list_free(selected); + if (ecore_file_is_dir(buf)) return; + E_FREE(cfdata->bg); + cfdata->bg = strdup(buf); + if (cfdata->o_preview) + e_widget_preview_edje_set(cfdata->o_preview, buf, "desktop/background"); + if (cfdata->o_theme_bg) + e_widget_check_checked_set(cfdata->o_theme_bg, 0); + cfdata->use_theme_bg = 0; + if (cfdata->o_usrbg_frame) + e_widget_change(cfdata->o_usrbg_frame); + e_fm2_select_set(cfdata->o_sysbg_fm, "", 0); +} + +static void +_cb_usrbg_files_selected(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data; +} + +static void +_cb_usrbg_files_files_changed(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + char *p, *homedir, buf[4096]; + + cfdata = data; + if (!cfdata->bg) return; + if (!cfdata->o_usrbg_fm) return; + p = (char *)e_fm2_real_path_get(cfdata->o_usrbg_fm); + if (p) + { + if (strncmp(p, cfdata->bg, strlen(p))) return; + } + homedir = e_user_homedir_get(); + if (!homedir) return; + snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds", homedir); + free(homedir); + if (!p) return; + if (!strncmp(cfdata->bg, buf, strlen(buf))) + p = cfdata->bg + strlen(buf) + 1; + else + p = cfdata->bg; + e_fm2_select_set(cfdata->o_usrbg_fm, p, 1); + e_fm2_file_show(cfdata->o_usrbg_fm, p); +} + + +static void +_cb_sysbg_button_up(void *data1, void *data2) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data1; + if (cfdata->o_sysbg_fm) + e_fm2_parent_go(cfdata->o_sysbg_fm); + if (cfdata->o_sysbg_frame) + e_widget_scrollframe_child_pos_set(cfdata->o_sysbg_frame, 0, 0); +} + +static void +_cb_sysbg_files_changed(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data; + if (!cfdata->o_sysbg_fm) return; + if (!e_fm2_has_parent_get(cfdata->o_sysbg_fm)) + { + if (cfdata->o_sysbg_up_button) + e_widget_disabled_set(cfdata->o_sysbg_up_button, 1); + } + else + { + if (cfdata->o_sysbg_up_button) + e_widget_disabled_set(cfdata->o_sysbg_up_button, 0); + } + if (cfdata->o_sysbg_frame) + e_widget_scrollframe_child_pos_set(cfdata->o_sysbg_frame, 0, 0); +} + +static void +_cb_sysbg_files_selection_change(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + Evas_List *selected; + E_Fm2_Icon_Info *ici; + const char *realpath; + char buf[4096]; + + cfdata = data; + if (!cfdata->o_sysbg_fm) return; + selected = e_fm2_selected_list_get(cfdata->o_sysbg_fm); + if (!selected) return; + ici = selected->data; + realpath = e_fm2_real_path_get(cfdata->o_sysbg_fm); + if (!strcmp(realpath, "/")) + snprintf(buf, sizeof(buf), "/%s", ici->file); + else + snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file); + evas_list_free(selected); + if (ecore_file_is_dir(buf)) return; + E_FREE(cfdata->bg); + cfdata->bg = strdup(buf); + if (cfdata->o_preview) + e_widget_preview_edje_set(cfdata->o_preview, buf, "desktop/background"); + if (cfdata->o_theme_bg) + e_widget_check_checked_set(cfdata->o_theme_bg, 0); + cfdata->use_theme_bg = 0; + if (cfdata->o_sysbg_frame) + e_widget_change(cfdata->o_sysbg_frame); + e_fm2_select_set(cfdata->o_usrbg_fm, "", 0); +} + +static void +_cb_sysbg_files_selected(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data; +} + +static void +_cb_sysbg_files_files_changed(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + char *p, buf[4096]; + + cfdata = data; + if (!cfdata->bg) return; + if (!cfdata->o_sysbg_fm) return; + p = (char *)e_fm2_real_path_get(cfdata->o_sysbg_fm); + if (p) + { + if (strncmp(p, cfdata->bg, strlen(p))) return; + } + snprintf(buf, sizeof(buf), "%s/data/backgrounds", e_prefix_data_get()); + if (!strncmp(cfdata->bg, buf, strlen(buf))) + p = cfdata->bg + strlen(buf) + 1; + else + p = cfdata->bg; + if (!p) return; + e_fm2_select_set(cfdata->o_sysbg_fm, p, 1); + e_fm2_file_show(cfdata->o_sysbg_fm, p); +} + + +static void +_cb_theme_wallpaper(void *data, Evas_Object *obj, void *event_info) +{ + E_Config_Dialog_Data *cfdata; + const char *f; + + cfdata = data; + if (cfdata->use_theme_bg) + { + f = e_theme_edje_file_get("base/theme/backgrounds", "desktop/background"); + if (cfdata->o_preview) + e_widget_preview_edje_set(cfdata->o_preview, f, "desktop/background"); + } + else + { + if (cfdata->bg) + { + if (cfdata->o_preview) + e_widget_preview_edje_set(cfdata->o_preview, cfdata->bg, "desktop/background"); + } + } +} + +static void +_cb_import(void *data1, void *data2) +{ + E_Config_Dialog_Data *cfdata; + + cfdata = data1; + if (cfdata->win_import) + { + e_win_raise(cfdata->win_import); + } + else cfdata->win_import = e_int_config_wallpaper_import(cfdata->cfd); +} + + + + +static void +_fill_data(E_Config_Dialog_Data *cfdata) +{ + E_Zone *z; + E_Desk *d; + Evas_List *l; + + if (e_config->desktop_default_background) + cfdata->bg = strdup(e_config->desktop_default_background); + + z = e_zone_current_get(cfdata->cfd->con); + if (!z) return; + d = e_desk_current_get(z); + if (!d) return; + for (l = e_config->desktop_backgrounds; l; l = l->next) + { + E_Config_Desktop_Background *cfbg; + + cfbg = l->data; + if (((cfbg->container == z->container->num) || + (cfbg->container < 0)) && + ((cfbg->zone == z->num) || + (cfbg->zone < 0)) && + ((cfbg->desk_x == d->x) || + (cfbg->desk_x < 0)) && + ((cfbg->desk_y == d->y) || + (cfbg->desk_y < 0))) + { + E_FREE(cfdata->bg); + cfdata->bg = strdup(cfbg->file); + if ((cfbg->container >= 0) || + (cfbg->zone >= 0)) + cfdata->all_this_desk_screen = 2; + if ((cfbg->desk_x >= 0) || + (cfbg->desk_y >= 0)) + cfdata->all_this_desk_screen = 1; + break; + } + } + + if (!cfdata->bg) cfdata->use_theme_bg = 1; +} + +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); + return cfdata; +} + +static void +_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +{ + if (cfdata->win_import) e_int_config_wallpaper_del(cfdata->win_import); + E_FREE(cfdata->bg); + free(cfdata); +} + +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], *homedir; + const char *f; + E_Fm2_Config fmc; + E_Zone *z; + + homedir = e_user_homedir_get(); + if (!homedir) return NULL; + + z = e_zone_current_get(cfd->con); + + ot = e_widget_table_add(evas, 0); + + + ol = e_widget_frametable_add(evas, _("Personal Wallpapers"), 0); + + o = e_widget_button_add(evas, _("Go up a Directory"), "widget/up_dir", + _cb_usrbg_button_up, cfdata, NULL); + cfdata->o_usrbg_up_button = o; + e_widget_frametable_object_append(ol, o, 0, 0, 1, 1, 0, 0, 0, 0); + + snprintf(path, sizeof(path), "%s/.e/e/backgrounds", homedir); + + o = e_fm2_add(evas); + cfdata->o_usrbg_fm = o; + 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.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); + evas_object_smart_callback_add(o, "dir_changed", + _cb_usrbg_files_changed, cfdata); + evas_object_smart_callback_add(o, "selection_change", + _cb_usrbg_files_selection_change, cfdata); + evas_object_smart_callback_add(o, "selected", + _cb_usrbg_files_selected, cfdata); + evas_object_smart_callback_add(o, "changed", + _cb_usrbg_files_files_changed, cfdata); + 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_usrbg_frame = of; + e_widget_min_size_set(of, 160, 256); + e_widget_frametable_object_append(ol, of, 0, 1, 1, 1, 1, 1, 1, 1); + e_widget_table_object_append(ot, ol, 0, 0, 1, 1, 1, 1, 1, 1); + + + ol = e_widget_frametable_add(evas, _("System Wallpapers"), 0); + + o = e_widget_button_add(evas, _("Go up a Directory"), "widget/up_dir", + _cb_sysbg_button_up, cfdata, NULL); + cfdata->o_sysbg_up_button = o; + e_widget_frametable_object_append(ol, o, 0, 0, 1, 1, 0, 0, 0, 0); + + snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); + + o = e_fm2_add(evas); + cfdata->o_sysbg_fm = o; + 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.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); + evas_object_smart_callback_add(o, "dir_changed", + _cb_sysbg_files_changed, cfdata); + evas_object_smart_callback_add(o, "selection_change", + _cb_sysbg_files_selection_change, cfdata); + evas_object_smart_callback_add(o, "selected", + _cb_sysbg_files_selected, cfdata); + evas_object_smart_callback_add(o, "changed", + _cb_sysbg_files_files_changed, cfdata); + 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_sysbg_frame = of; + e_widget_min_size_set(of, 160, 256); + e_widget_frametable_object_append(ol, of, 0, 1, 1, 1, 1, 1, 1, 1); + e_widget_table_object_append(ot, ol, 2, 0, 1, 1, 1, 1, 1, 1); + + il = e_widget_list_add(evas, 0, 0); + o = e_widget_check_add(evas, _("Theme Wallpaper"), &cfdata->use_theme_bg); + cfdata->o_theme_bg = o; + evas_object_smart_callback_add(o, "changed", + _cb_theme_wallpaper, cfdata); + e_widget_list_object_append(il, o, 1, 0, 0.5); + + ol = e_widget_list_add(evas, 1, 1); + o = e_widget_button_add(evas, _("Picture..."), "enlightenment/picture", + _cb_import, cfdata, NULL); + e_widget_list_object_append(ol, o, 1, 0, 0.5); + o = e_widget_button_add(evas, _("Gradient..."), "enlightenment/gradient", + NULL, cfdata, NULL); + e_widget_list_object_append(ol, o, 1, 0, 0.5); + e_widget_list_object_append(il, ol, 1, 0, 0.5); + + o = e_widget_preview_add(evas, 240, (240 * z->h) / z->w); + cfdata->o_preview = o; + if (cfdata->bg) + f = cfdata->bg; + else + f = e_theme_edje_file_get("base/theme/backgrounds", "desktop/background"); + e_widget_preview_edje_set(o, f, "desktop/background"); + e_widget_list_object_append(il, o, 0, 0, 0.5); + + e_widget_table_object_append(ot, il, 1, 0, 1, 1, 0, 1, 0, 1); + + free(homedir); + e_dialog_resizable_set(cfd->dia, 1); + return ot; +} + +static int +_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +{ + while (e_config->desktop_backgrounds) + { + E_Config_Desktop_Background *cfbg; + cfbg = e_config->desktop_backgrounds->data; + e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y); + } + if (e_config->desktop_default_background) + evas_stringshare_del(e_config->desktop_default_background); + if ((cfdata->use_theme_bg) || (!cfdata->bg)) + e_config->desktop_default_background = NULL; + else + e_config->desktop_default_background = evas_stringshare_add(cfdata->bg); + + cfdata->all_this_desk_screen = 0; + + e_bg_update(); + e_config_save_queue(); + return 1; +} + +static Evas_Object * +_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) +{ + Evas_Object *o, *ot, *of, *il, *ol; + char path[4096], *homedir; + const char *f; + E_Fm2_Config fmc; + E_Zone *z; + E_Radio_Group *rg; + + homedir = e_user_homedir_get(); + if (!homedir) return NULL; + + z = e_zone_current_get(cfd->con); + + ot = e_widget_table_add(evas, 0); + + + ol = e_widget_frametable_add(evas, _("Personal Wallpapers"), 0); + + o = e_widget_button_add(evas, _("Go up a Directory"), "widget/up_dir", + _cb_usrbg_button_up, cfdata, NULL); + cfdata->o_usrbg_up_button = o; + e_widget_frametable_object_append(ol, o, 0, 0, 1, 1, 0, 0, 0, 0); + + snprintf(path, sizeof(path), "%s/.e/e/backgrounds", homedir); + + o = e_fm2_add(evas); + cfdata->o_usrbg_fm = o; + 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.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); + evas_object_smart_callback_add(o, "dir_changed", + _cb_usrbg_files_changed, cfdata); + evas_object_smart_callback_add(o, "selection_change", + _cb_usrbg_files_selection_change, cfdata); + evas_object_smart_callback_add(o, "selected", + _cb_usrbg_files_selected, cfdata); + evas_object_smart_callback_add(o, "changed", + _cb_usrbg_files_files_changed, cfdata); + 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_usrbg_frame = of; + e_widget_min_size_set(of, 160, 256); + e_widget_frametable_object_append(ol, of, 0, 1, 1, 1, 1, 1, 1, 1); + e_widget_table_object_append(ot, ol, 0, 0, 1, 1, 1, 1, 1, 1); + + + ol = e_widget_frametable_add(evas, _("System Wallpapers"), 0); + + o = e_widget_button_add(evas, _("Go up a Directory"), "widget/up_dir", + _cb_sysbg_button_up, cfdata, NULL); + cfdata->o_sysbg_up_button = o; + e_widget_frametable_object_append(ol, o, 0, 0, 1, 1, 0, 0, 0, 0); + + snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); + + o = e_fm2_add(evas); + cfdata->o_sysbg_fm = o; + 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.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); + evas_object_smart_callback_add(o, "dir_changed", + _cb_sysbg_files_changed, cfdata); + evas_object_smart_callback_add(o, "selection_change", + _cb_sysbg_files_selection_change, cfdata); + evas_object_smart_callback_add(o, "selected", + _cb_sysbg_files_selected, cfdata); + evas_object_smart_callback_add(o, "changed", + _cb_sysbg_files_files_changed, cfdata); + 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_sysbg_frame = of; + e_widget_min_size_set(of, 160, 256); + e_widget_frametable_object_append(ol, of, 0, 1, 1, 1, 1, 1, 1, 1); + e_widget_table_object_append(ot, ol, 2, 0, 1, 1, 1, 1, 1, 1); + + il = e_widget_list_add(evas, 0, 0); + o = e_widget_check_add(evas, _("Theme Wallpaper"), &cfdata->use_theme_bg); + cfdata->o_theme_bg = o; + evas_object_smart_callback_add(o, "changed", + _cb_theme_wallpaper, cfdata); + e_widget_list_object_append(il, o, 1, 0, 0.5); + + ol = e_widget_list_add(evas, 1, 1); + o = e_widget_button_add(evas, _("Picture..."), "enlightenment/picture", + _cb_import, cfdata, NULL); + e_widget_list_object_append(ol, o, 1, 0, 0.5); + o = e_widget_button_add(evas, _("Gradient..."), "enlightenment/gradient", + NULL, cfdata, NULL); + e_widget_list_object_append(ol, o, 1, 0, 0.5); + e_widget_list_object_append(il, ol, 1, 0, 0.5); + + o = e_widget_preview_add(evas, 240, (240 * z->h) / z->w); + cfdata->o_preview = o; + if (cfdata->bg) + f = cfdata->bg; + else + f = e_theme_edje_file_get("base/theme/backgrounds", "desktop/background"); + e_widget_preview_edje_set(o, f, "desktop/background"); + e_widget_list_object_append(il, o, 0, 0, 0.5); + + ol = e_widget_framelist_add(evas, _("Where to place the Wallpaper"), 0); + e_widget_framelist_content_align_set(ol, 0.0, 0.0); + rg = e_widget_radio_group_new(&(cfdata->all_this_desk_screen)); + + o = e_widget_radio_add(evas, _("All Desktops"), 0, rg); + e_widget_framelist_object_append(ol, o); + o = e_widget_radio_add(evas, _("This Desktop"), 1, rg); + e_widget_framelist_object_append(ol, o); + o = e_widget_radio_add(evas, _("This Screen"), 2, rg); + if (!((e_util_container_zone_number_get(0, 1)) || + (e_util_container_zone_number_get(1, 0)))) + e_widget_disabled_set(o, 1); + e_widget_framelist_object_append(ol, o); + + e_widget_list_object_append(il, ol, 0, 1, 0.5); + + e_widget_table_object_append(ot, il, 1, 0, 1, 1, 0, 1, 0, 1); + + free(homedir); + e_dialog_resizable_set(cfd->dia, 1); + return ot; +} + +static int +_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +{ + Evas_List *fl = NULL, *l; + E_Zone *z; + E_Desk *d; + + z = e_zone_current_get(cfdata->cfd->con); + if (!z) return 0; + d = e_desk_current_get(z); + if (!d) return 0; + if (cfdata->use_theme_bg) + { + while (e_config->desktop_backgrounds) + { + E_Config_Desktop_Background *cfbg; + cfbg = e_config->desktop_backgrounds->data; + e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y); + } + if (e_config->desktop_default_background) + evas_stringshare_del(e_config->desktop_default_background); + e_config->desktop_default_background = NULL; + } + else + { + if (cfdata->all_this_desk_screen == 0) + { + while (e_config->desktop_backgrounds) + { + E_Config_Desktop_Background *cfbg; + cfbg = e_config->desktop_backgrounds->data; + e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y); + } + if (e_config->desktop_default_background) + evas_stringshare_del(e_config->desktop_default_background); + e_config->desktop_default_background = evas_stringshare_add(cfdata->bg); + } + else if (cfdata->all_this_desk_screen == 1) + { + e_bg_del(z->container->num, z->num, d->x, d->y); + e_bg_del(z->container->num, -1, d->x, d->y); + e_bg_del(-1, z->num, d->x, d->y); + e_bg_del(-1, -1, d->x, d->y); + e_bg_add(z->container->num, z->num, d->x, d->y, cfdata->bg); + + } + else if (cfdata->all_this_desk_screen == 2) + { + for (l = e_config->desktop_backgrounds; l; l = l->next) + { + E_Config_Desktop_Background *cfbg; + + cfbg = l->data; + if ( + (((cfbg->container == z->container->num) || + (cfbg->container < 0)) && + ((cfbg->zone == 0) || + (cfbg->zone < 0))) + || + (((cfbg->zone == z->num) || + (cfbg->zone < 0)) && + ((cfbg->container == 0) || + (cfbg->container < 0))) + ) + fl = evas_list_append(fl, cfbg); + } + while (fl) + { + E_Config_Desktop_Background *cfbg; + cfbg = fl->data; + e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y); + fl = evas_list_remove_list(fl, fl); + } + e_bg_add(z->container->num, z->num, -1, -1, cfdata->bg); + } + } + e_bg_update(); + e_config_save_queue(); + return 1; +} diff --git a/src/bin/e_int_config_wallpaper.h b/src/bin/e_int_config_wallpaper.h new file mode 100644 index 000000000..5ee7652f7 --- /dev/null +++ b/src/bin/e_int_config_wallpaper.h @@ -0,0 +1,14 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifdef E_TYPEDEFS +#else +#ifndef E_INT_CONFIG_WALLPAPER_H +#define E_INT_CONFIG_WALLPAPER_H + +EAPI E_Config_Dialog *e_int_config_wallpaper(E_Container *con); +EAPI void e_int_config_wallpaper_update(E_Config_Dialog *dia, char *file); +EAPI void e_int_config_wallpaper_import_done(E_Config_Dialog *dia); + +#endif +#endif diff --git a/src/bin/e_int_config_wallpaper_import.c b/src/bin/e_int_config_wallpaper_import.c new file mode 100644 index 000000000..988f4343c --- /dev/null +++ b/src/bin/e_int_config_wallpaper_import.c @@ -0,0 +1,483 @@ +#include "e.h" + +/* FIXME: redo this... */ + +#define IMPORT_STRETCH 0 +#define IMPORT_TILE 1 +#define IMPORT_CENTER 2 +#define IMPORT_SCALE_ASPECT_IN 3 +#define IMPORT_SCALE_ASPECT_OUT 4 + +/* Personally I hate having to define this twice, but Tileing needs a fill */ +#define IMG_EDC_TMPL_TILE \ +"images {\n" \ +" image: \"%s\" LOSSY 90;\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\" LOSSY 90;\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" + +typedef struct _Import Import; + +struct _Import +{ + E_Config_Dialog *parent; + E_Config_Dialog_Data *cfdata; + + Evas_Object *bg_obj; + Evas_Object *box_obj; + Evas_Object *event_obj; + Evas_Object *content_obj; + Evas_Object *fsel_obj; + + Evas_Object *ok_obj; + Evas_Object *close_obj; + + E_Win *win; + + Ecore_Exe *exe; + Ecore_Event_Handler *exe_handler; + char *tmpf; + char *fdest; +}; + +struct _E_Config_Dialog_Data +{ + char *file; + int method; +}; + +static Ecore_Event_Handler *_import_edje_cc_exit_handler = NULL; + +static void _import_cb_sel_change(void *data, Evas_Object *obj); +static void _import_edj_gen(Import *import); +static int _import_cb_edje_cc_exit(void *data, int type, void *event); +static void _import_cb_delete(E_Win *win); +static void _import_cb_resize(E_Win *win); +static void _import_cb_close(void *data, void *data2); +static void _import_cb_ok(void *data, void *data2); +static void _import_cb_wid_on_focus(void *data, Evas_Object *obj); +static void _import_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event); + +EAPI E_Win * +e_int_config_wallpaper_import(E_Config_Dialog *parent) +{ + Evas *evas; + E_Win *win; + Import *import; + Evas_Object *o, *of, *ofm, *ord; + E_Radio_Group *rg; + Evas_Coord w, h; + E_Config_Dialog_Data *cfdata; + Evas_Modifier_Mask mask; + + import = E_NEW(Import, 1); + if (!import) return NULL; + + win = e_win_new(parent->con); + if (!win) + { + free(import); + return NULL; + } + + cfdata = E_NEW(E_Config_Dialog_Data, 1); + cfdata->method = 0; + import->cfdata = cfdata; + import->win = win; + + evas = e_win_evas_get(win); + + import->parent = parent; + + e_win_title_set(win, _("Select a Picture...")); + e_win_delete_callback_set(win, _import_cb_delete); + e_win_resize_callback_set(win, _import_cb_resize); + e_win_dialog_set(win, 1); + e_win_name_class_set(win, "E", "_dialog"); + + o = edje_object_add(evas); + import->bg_obj = o; + e_theme_edje_object_set(o, "base/theme/dialog", "widgets/dialog/main"); + evas_object_move(o, 0, 0); + evas_object_show(o); + + o = e_widget_list_add(evas, 1, 1); + e_widget_on_focus_hook_set(o, _import_cb_wid_on_focus, import); + import->box_obj = o; + edje_object_part_swallow(import->bg_obj, "buttons_swallow", o); + + o = evas_object_rectangle_add(evas); + import->event_obj = o; + mask = 0; + evas_object_key_grab(o, "Tab", mask, ~mask, 0); + mask = evas_key_modifier_mask_get(evas, "Shift"); + evas_object_key_grab(o, "Tab", mask, ~mask, 0); + mask = 0; + evas_object_key_grab(o, "Return", mask, ~mask, 0); + mask = 0; + evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0); + mask = 0; + evas_object_key_grab(o, "Space", mask, ~mask, 0); + mask = 0; + evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _import_cb_key_down, import); + + o = e_widget_list_add(evas, 0, 0); + import->content_obj = o; + + ofm = e_widget_fsel_add(evas, "~/", "/", NULL, NULL, + _import_cb_sel_change, import, + _import_cb_sel_change, import + ); + import->fsel_obj = ofm; + e_widget_list_object_append(o, ofm, 1, 1, 0.5); + + of = e_widget_frametable_add(evas, _("Options"), 0); + rg = e_widget_radio_group_new(&cfdata->method); + ord = e_widget_radio_add(evas, _("Center Image"), IMPORT_CENTER, rg); + e_widget_frametable_object_append(of, ord, 0, 0, 1, 1, 1, 0, 1, 0); + ord = e_widget_radio_add(evas, _("Scale Image"), IMPORT_STRETCH, rg); + e_widget_frametable_object_append(of, ord, 0, 1, 1, 1, 1, 0, 1, 0); + ord = e_widget_radio_add(evas, _("Tile Image"), IMPORT_TILE, rg); + e_widget_frametable_object_append(of, ord, 0, 2, 1, 1, 1, 0, 1, 0); + + e_widget_list_object_append(o, of, 0, 0, 0.5); + + e_widget_min_size_get(o, &w, &h); + edje_extern_object_min_size_set(o, w, h); + edje_object_part_swallow(import->bg_obj, "content_swallow", o); + evas_object_show(o); + + import->ok_obj = e_widget_button_add(evas, _("OK"), NULL, _import_cb_ok, win, cfdata); + e_widget_list_object_append(import->box_obj, import->ok_obj, 1, 0, 0.5); + + import->close_obj = e_widget_button_add(evas, _("Cancel"), NULL, _import_cb_close, win, NULL); + e_widget_list_object_append(import->box_obj, import->close_obj, 1, 0, 0.5); + + e_win_centered_set(win, 1); + + o = import->box_obj; + e_widget_min_size_get(o, &w, &h); + edje_extern_object_min_size_set(o, w, h); + edje_object_part_swallow(import->bg_obj, "buttons_swallow", o); + + edje_object_size_min_calc(import->bg_obj, &w, &h); + evas_object_resize(import->bg_obj, w + 64, h + 128); + e_win_resize(win, w + 64, h + 128); + e_win_size_min_set(win, w, h); + e_win_size_max_set(win, 99999, 99999); + e_win_show(win); + + if (!e_widget_focus_get(import->bg_obj)) + e_widget_focus_set(import->box_obj, 1); + + win->data = import; + return win; +} + +EAPI void +e_int_config_wallpaper_del(E_Win *win) +{ + Import *import; + + import = win->data; + if (import->exe_handler) ecore_event_handler_del(import->exe_handler); + import->exe_handler = NULL; + if (import->tmpf) unlink(import->tmpf); + E_FREE(import->tmpf); + E_FREE(import->fdest); + import->exe = NULL; + e_object_del(E_OBJECT(import->win)); + e_int_config_wallpaper_import_done(import->parent); + if (import) free(import); +} + +static void +_import_cb_sel_change(void *data, Evas_Object *obj) +{ + Import *import; + const char *path; + + import = data; + path = e_widget_fsel_selection_path_get(import->fsel_obj); + E_FREE(import->cfdata->file); + if (path) import->cfdata->file = strdup(path); +} + +static void +_import_edj_gen(Import *import) +{ + Evas *evas; + Evas_Object *img; + int fd; + int w = 0, h = 0; + const char *file; + char buf[4096], cmd[4096], tmpn[4096], ipart[4096]; + char *imgdir = NULL, *homedir, *fstrip; + FILE *f; + + evas = e_win_evas_get(import->win); + file = ecore_file_get_file(import->cfdata->file); + homedir = e_user_homedir_get(); + if (!homedir) return; + fstrip = ecore_file_strip_ext(file); + if (!fstrip) + { + free(homedir); + return; + } + snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s.edj", homedir, fstrip); + free(fstrip); + free(homedir); + 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); + + f = fopen(tmpn, "w"); + if (!f) + { + printf("Cannot open %s for writting\n", tmpn); + return; + } + + imgdir = ecore_file_get_dir(import->cfdata->file); + if (!imgdir) ipart[0] = '\0'; + else + { + snprintf(ipart, sizeof(ipart), "-id %s", imgdir); + free(imgdir); + } + + img = evas_object_image_add(evas); + evas_object_image_file_set(img, import->cfdata->file, NULL); + evas_object_image_size_get(img, &w, &h); + evas_object_del(img); + + switch (import->cfdata->method) + { + case IMPORT_CENTER: + fprintf(f, IMG_EDC_TMPL, file, w, h, file); + break; + case IMPORT_TILE: + fprintf(f, IMG_EDC_TMPL_TILE, file, w, h, file, w, h); + break; + case IMPORT_STRETCH: + fprintf(f, IMG_EDC_TMPL, file, w, h, file); + break; + } + + fclose(f); + + snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", + ipart, tmpn, e_util_filename_escape(buf)); + + import->tmpf = strdup(tmpn); + import->fdest = strdup(buf); + import->exe_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _import_cb_edje_cc_exit, import); + import->exe = ecore_exe_run(cmd, NULL); +} + +static int +_import_cb_edje_cc_exit(void *data, int type, void *event) +{ + Import *import; + Ecore_Exe_Event_Del *ev; + + ev = event; + import = data; + if (ev->exe != import->exe) return 1; + + /* FIXME - error code */ + + e_int_config_wallpaper_update(import->parent, import->fdest); + + e_int_config_wallpaper_del(import->win); + return 0; +} + +static void +_import_cb_delete(E_Win *win) +{ + e_int_config_wallpaper_del(win); +} + +static void +_import_cb_resize(E_Win *win) +{ + Import *import; + + import = win->data; + if (!import) return; + evas_object_resize(import->bg_obj, win->w, win->h); +} + +static void +_import_cb_close(void *data, void *data2) +{ + E_Win *win; + + win = data; + e_int_config_wallpaper_del(win); +} + +static void +_import_cb_ok(void *data, void *data2) +{ + Import *import; + E_Win *win; + const char *path; + + win = data; + import = win->data; + if (!import) return; + path = e_widget_fsel_selection_path_get(import->fsel_obj); + E_FREE(import->cfdata->file); + if (path) import->cfdata->file = strdup(path); + if (import->cfdata->file) + { + _import_edj_gen(import); + e_win_hide(win); + return; + } + e_int_config_wallpaper_del(win); +} + +static void +_import_cb_wid_on_focus(void *data, Evas_Object *obj) +{ + Import *import; + + import = data; + if (obj == import->content_obj) + e_widget_focused_object_clear(import->box_obj); + else if (import->content_obj) + e_widget_focused_object_clear(import->content_obj); +} + +static void +_import_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event) +{ + Evas_Event_Key_Down *ev; + Import *import; + + ev = event; + import = data; + if (!strcmp(ev->keyname, "Tab")) + { + if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(import->win)), "Shift")) + { + if (e_widget_focus_get(import->box_obj)) + { + if (!e_widget_focus_jump(import->box_obj, 0)) + { + e_widget_focus_set(import->content_obj, 0); + if (!e_widget_focus_get(import->content_obj)) + e_widget_focus_set(import->box_obj, 0); + } + } + else + { + if (!e_widget_focus_jump(import->content_obj, 0)) + e_widget_focus_set(import->box_obj, 0); + } + } + else + { + if (e_widget_focus_get(import->box_obj)) + { + if (!e_widget_focus_jump(import->box_obj, 1)) + { + e_widget_focus_set(import->content_obj, 1); + if (!e_widget_focus_get(import->content_obj)) + e_widget_focus_set(import->box_obj, 1); + } + } + else + { + if (!e_widget_focus_jump(import->content_obj, 1)) + e_widget_focus_set(import->box_obj, 1); + } + } + } + else if (((!strcmp(ev->keyname, "Return")) || + (!strcmp(ev->keyname, "KP_Enter")) || + (!strcmp(ev->keyname, "space")))) + { + Evas_Object *o = NULL; + + if ((import->content_obj) && (e_widget_focus_get(import->content_obj))) + o = e_widget_focused_object_get(import->content_obj); + else + o = e_widget_focused_object_get(import->box_obj); + if (o) e_widget_activate(o); + } +} diff --git a/src/bin/e_int_config_wallpaper_import.h b/src/bin/e_int_config_wallpaper_import.h new file mode 100644 index 000000000..3d6f0f385 --- /dev/null +++ b/src/bin/e_int_config_wallpaper_import.h @@ -0,0 +1,10 @@ +#ifdef E_TYPEDEFS +#else +#ifndef E_INT_CONFIG_WALLPAPER_IMPORT_H +#define E_INT_CONFIG_WALLPAPER_IMPORT_H + +EAPI E_Win *e_int_config_wallpaper_import(E_Config_Dialog *parent); +EAPI void e_int_config_wallpaper_del(E_Win *win); + +#endif +#endif diff --git a/src/bin/e_int_menus.c b/src/bin/e_int_menus.c index c42276fdc..98f975781 100644 --- a/src/bin/e_int_menus.c +++ b/src/bin/e_int_menus.c @@ -580,7 +580,7 @@ _e_int_menus_eapedit_item_cb(void *data, E_Menu *m, E_Menu_Item *mi) static void _e_int_menus_background_item_cb(void *data, E_Menu *m, E_Menu_Item *mi) { - e_int_config_background(m->zone->container); + e_int_config_wallpaper(m->zone->container); } static void diff --git a/src/bin/e_scrollframe.c b/src/bin/e_scrollframe.c index 536a5d308..e04d887c6 100644 --- a/src/bin/e_scrollframe.c +++ b/src/bin/e_scrollframe.c @@ -42,6 +42,7 @@ struct _E_Smart_Data /* local subsystem functions */ static void _e_smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_pan_changed_hook(void *data, Evas_Object *obj, void *event_info); +static void _e_smart_pan_pan_changed_hook(void *data, Evas_Object *obj, void *event_info); static void _e_smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_event_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_edje_drag_v(void *data, Evas_Object *obj, const char *emission, const char *source); @@ -96,6 +97,7 @@ e_scrollframe_child_set(Evas_Object *obj, Evas_Object *child) o = e_pan_add(evas_object_evas_get(obj)); sd->pan_obj = o; evas_object_smart_callback_add(o, "changed", _e_smart_pan_changed_hook, sd); + evas_object_smart_callback_add(o, "changed", _e_smart_pan_pan_changed_hook, sd); evas_object_show(o); edje_object_part_swallow(sd->edje_obj, "item", o); } @@ -153,6 +155,7 @@ e_scrollframe_extern_pan_set(Evas_Object *obj, Evas_Object *pan, sd->pan_func.child_size_get = pan_child_size_get; sd->extern_pan = 1; evas_object_smart_callback_add(sd->pan_obj, "changed", _e_smart_pan_changed_hook, sd); + evas_object_smart_callback_add(sd->pan_obj, "pan_changed", _e_smart_pan_pan_changed_hook, sd); edje_object_part_swallow(sd->edje_obj, "item", sd->pan_obj); evas_object_show(sd->pan_obj); } @@ -336,6 +339,17 @@ _e_smart_pan_changed_hook(void *data, Evas_Object *obj, void *event_info) } } +static void +_e_smart_pan_pan_changed_hook(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Coord x, y; + E_Smart_Data *sd; + + sd = data; + sd->pan_func.get(sd->pan_obj, &x, &y); + e_scrollframe_child_pos_set(sd->smart_obj, x, y); +} + static void _e_smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info) { diff --git a/src/bin/e_widget_check.c b/src/bin/e_widget_check.c index 49f45cd1a..c108eb8bd 100644 --- a/src/bin/e_widget_check.c +++ b/src/bin/e_widget_check.c @@ -191,6 +191,7 @@ _e_wid_do(Evas_Object *obj) edje_object_signal_emit(wd->o_check, "toggle_off", ""); } } + evas_object_smart_callback_call(obj, "changed", NULL); } static void diff --git a/src/bin/e_widget_fsel.c b/src/bin/e_widget_fsel.c index 09b2ea9ca..e393601b7 100644 --- a/src/bin/e_widget_fsel.c +++ b/src/bin/e_widget_fsel.c @@ -32,8 +32,10 @@ _e_wid_fsel_button_up(void *data1, void *data2) E_Widget_Data *wd; wd = data1; - e_fm2_parent_go(wd->o_files_fm); - e_widget_scrollframe_child_pos_set(wd->o_files_frame, 0, 0); + if (wd->o_files_fm) + e_fm2_parent_go(wd->o_files_fm); + if (wd->o_files_frame) + e_widget_scrollframe_child_pos_set(wd->o_files_frame, 0, 0); } static void @@ -46,6 +48,8 @@ _e_wid_fsel_favorites_files_changed(void *data, Evas_Object *obj, void *event_in char *p1, *p2; wd = data; + if (!wd->o_favorites_fm) return; + if (!wd->o_files_fm) return; icons = e_fm2_all_list_get(wd->o_favorites_fm); if (!icons) return; realpath = e_fm2_real_path_get(wd->o_files_fm); @@ -82,6 +86,8 @@ _e_wid_fsel_favorites_selected(void *data, Evas_Object *obj, void *event_info) E_Fm2_Icon_Info *ici; wd = data; + if (!wd->o_favorites_fm) return; + if (!wd->o_files_frame) return; selected = e_fm2_selected_list_get(wd->o_favorites_fm); if (!selected) return; ici = selected->data; @@ -99,11 +105,19 @@ _e_wid_fsel_files_changed(void *data, Evas_Object *obj, void *event_info) E_Widget_Data *wd; wd = data; + if (!wd->o_files_fm) return; if (!e_fm2_has_parent_get(wd->o_files_fm)) - e_widget_disabled_set(wd->o_up_button, 1); + { + if (wd->o_up_button) + e_widget_disabled_set(wd->o_up_button, 1); + } else - e_widget_disabled_set(wd->o_up_button, 0); - e_widget_scrollframe_child_pos_set(wd->o_files_frame, 0, 0); + { + if (wd->o_up_button) + e_widget_disabled_set(wd->o_up_button, 0); + } + if (wd->o_files_frame) + e_widget_scrollframe_child_pos_set(wd->o_files_frame, 0, 0); E_FREE(wd->path); if (wd->chg_func) wd->chg_func(wd->chg_data, wd->obj); } @@ -118,6 +132,7 @@ _e_wid_fsel_files_selection_change(void *data, Evas_Object *obj, void *event_inf char buf[4096]; wd = data; + if (!wd->o_files_fm) return; selected = e_fm2_selected_list_get(wd->o_files_fm); if (!selected) return; ici = selected->data; @@ -185,7 +200,7 @@ e_widget_fsel_add(Evas *evas, char *dev, char *path, char *selected, char *filte wd->o_table2 = o; e_widget_sub_object_add(obj, o); - o = e_widget_button_add(evas, _("Go up a Directory"), NULL, + o = e_widget_button_add(evas, _("Go up a Directory"), "widget/up_dir", _e_wid_fsel_button_up, wd, NULL); wd->o_up_button = o; e_widget_sub_object_add(obj, o); @@ -211,11 +226,11 @@ e_widget_fsel_add(Evas *evas, char *dev, char *path, char *selected, char *filte fmc.selection.single = 1; fmc.selection.windows_modifiers = 0; e_fm2_config_set(o, &fmc); - e_fm2_path_set(o, "favorites", "/"); - evas_object_smart_callback_add(o, "files_changed", + evas_object_smart_callback_add(o, "changed", _e_wid_fsel_favorites_files_changed, wd); evas_object_smart_callback_add(o, "selected", _e_wid_fsel_favorites_selected, wd); + e_fm2_path_set(o, "favorites", "/"); o = e_widget_scrollframe_pan_add(evas, wd->o_favorites_fm, e_fm2_pan_set, @@ -247,13 +262,13 @@ e_widget_fsel_add(Evas *evas, char *dev, char *path, char *selected, char *filte fmc.selection.single = 1; fmc.selection.windows_modifiers = 0; e_fm2_config_set(o, &fmc); - e_fm2_path_set(o, dev, path); evas_object_smart_callback_add(o, "dir_changed", _e_wid_fsel_files_changed, wd); evas_object_smart_callback_add(o, "selection_change", _e_wid_fsel_files_selection_change, wd); evas_object_smart_callback_add(o, "selected", _e_wid_fsel_files_selected, wd); + e_fm2_path_set(o, dev, path); o = e_widget_scrollframe_pan_add(evas, wd->o_files_fm, e_fm2_pan_set, @@ -293,6 +308,7 @@ e_widget_fsel_selection_path_get(Evas_Object *obj) { E_Widget_Data *wd; + if (!obj) return NULL; wd = e_widget_data_get(obj); return wd->path; } diff --git a/src/bin/e_widget_label.c b/src/bin/e_widget_label.c index 5d73f7ff6..7a066f9c4 100644 --- a/src/bin/e_widget_label.c +++ b/src/bin/e_widget_label.c @@ -2,7 +2,14 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #include "e.h" - + +typedef struct _E_Widget_Data E_Widget_Data; +struct _E_Widget_Data +{ + Evas_Object *text; +}; + +static void _e_wid_del_hook(Evas_Object *obj); /* local subsystem functions */ /* externally accessible functions */ @@ -11,12 +18,17 @@ e_widget_label_add(Evas *evas, const char *label) { Evas_Object *obj, *o; Evas_Coord mw, mh; + E_Widget_Data *wd; obj = e_widget_add(evas); - + e_widget_del_hook_set(obj, _e_wid_del_hook); + wd = calloc(1, sizeof(E_Widget_Data)); + e_widget_data_set(obj, wd); + o = edje_object_add(evas); e_theme_edje_object_set(o, "base/theme/widgets", "widgets/label"); + wd->text = o; edje_object_part_text_set(o, "label", label); evas_object_show(o); edje_object_size_min_calc(o, &mw, &mh); @@ -24,6 +36,29 @@ e_widget_label_add(Evas *evas, const char *label) e_widget_min_size_set(obj, mw, mh); e_widget_sub_object_add(obj, o); e_widget_resize_object_set(obj, o); - + return obj; } + +EAPI void +e_widget_label_text_set(Evas_Object *obj, const char *text) +{ + E_Widget_Data *wd; + Evas_Coord mw, mh; + + wd = e_widget_data_get(obj); + edje_object_part_text_set(wd->text, "label", text); + edje_object_size_min_calc(wd->text, &mw, &mh); + evas_object_resize(wd->text, mw, mh); + return; +} + +static void +_e_wid_del_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + free(wd); +} + diff --git a/src/bin/e_widget_label.h b/src/bin/e_widget_label.h index 733c63260..3c79f6510 100644 --- a/src/bin/e_widget_label.h +++ b/src/bin/e_widget_label.h @@ -7,6 +7,7 @@ #define E_WIDGET_LABEL_H EAPI Evas_Object *e_widget_label_add(Evas *evas, const char *label); +EAPI void e_widget_label_text_set(Evas_Object *obj, const char *text); #endif #endif