2 #include "e_mod_main.h"
5 // need choice after add (file, gradient, online source)
6 // need delete select mode
7 // need after select on delete an ok/cancel if file or "ok to remove whole online source" if online
8 // need to make "exchange" wallpapers have a different look
9 // bug: animated wp doesn't workon first show
10 // need to be able to "type name to search/filter"
12 typedef struct _Info Info;
13 typedef struct _Smart_Data Smart_Data;
14 typedef struct _Item Item;
19 Evas_Object *bg, *preview, *mini, *button, *box, *sframe, *span;
27 int con_num, zone_num, desk_x, desk_y;
35 Ecore_Idle_Enterer *idle_enter;
36 Ecore_Animator *animator;
37 Ecore_Timer *seltimer;
39 Evas_Coord x, y, w, h;
40 Evas_Coord cx, cy, cw, ch;
48 Eina_Bool jump2hi : 1;
54 Evas_Coord x, y, w, h;
57 Evas_Object *frame, *image;
58 Eina_Bool selected : 1;
59 Eina_Bool have_thumb : 1;
60 Eina_Bool do_thumb : 1;
63 Eina_Bool visible : 1;
64 Eina_Bool hilighted : 1;
67 static Info *global_info = NULL;
69 static void _e_smart_reconfigure(Evas_Object *obj);
70 static void _e_smart_reconfigure(Evas_Object *obj);
71 static void _thumb_gen(void *data, Evas_Object *obj, void *event_info);
72 static void _item_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
73 static void _item_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
74 static int _sort_cb(const void *d1, const void *d2);
75 static void _scan(Info *info);
78 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
80 Smart_Data *sd = evas_object_smart_data_get(obj);
82 if (x > (sd->cw - sd->w)) x = sd->cw - sd->w;
83 if (y > (sd->ch - sd->h)) y = sd->ch - sd->h;
86 if ((sd->cx == x) && (sd->cy == y)) return;
89 _e_smart_reconfigure(obj);
93 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
95 Smart_Data *sd = evas_object_smart_data_get(obj);
102 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
104 Smart_Data *sd = evas_object_smart_data_get(obj);
108 if (sd->w < sd->cw) *x = sd->cw - sd->w;
113 if (sd->h < sd->ch) *y = sd->ch - sd->h;
119 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
121 Smart_Data *sd = evas_object_smart_data_get(obj);
128 _e_smart_reconfigure_do(void *data)
130 Evas_Object *obj = data;
131 Smart_Data *sd = evas_object_smart_data_get(obj);
134 int iw, redo = 0, changed = 0;
135 static int recursion = 0;
136 Evas_Coord x, y, xx, yy, ww, hh, mw, mh, ox, oy, dd;
139 if (!sd) return ECORE_CALLBACK_CANCEL;
140 if (sd->cx > (sd->cw - sd->w)) sd->cx = sd->cw - sd->w;
141 if (sd->cy > (sd->ch - sd->h)) sd->cy = sd->ch - sd->h;
142 if (sd->cx < 0) sd->cx = 0;
143 if (sd->cy < 0) sd->cy = 0;
146 if (iw > (120 * e_scale)) iw = (120 * e_scale);
149 if (iw < (60 * e_scale)) iw = (sd->w / 3);
150 if (iw < (60 * e_scale)) iw = (sd->w / 2);
151 if (iw < (60 * e_scale)) iw = sd->w;
156 hh = (sd->info->ih * iw) / (sd->info->iw);
159 evas = evas_object_evas_get(obj);
160 EINA_LIST_FOREACH(sd->items, l, it)
162 if (x > (sd->w - ww))
173 sd->sx = it->x + (it->w / 2);
174 sd->sy = it->y + (it->h / 2);
176 if ((x + ww) > mw) mw = x + ww;
177 if ((y + hh) > mh) mh = y + hh;
180 if ((mw != sd->cw) || (mh != sd->ch))
184 if (sd->cx > (sd->cw - sd->w))
186 sd->cx = sd->cw - sd->w;
189 if (sd->cy > (sd->ch - sd->h))
191 sd->cy = sd->ch - sd->h;
207 _e_smart_reconfigure_do(obj);
214 if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2;
216 if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2;
218 EINA_LIST_FOREACH(sd->items, l, it)
220 Evas_Coord dx, dy, vw, vh;
223 if ((sd->sx >= 0) && (sd->selmove > 0.0)
226 ((it->x + it->w) > sd->cx) &&
227 ((it->x) < (sd->cx + sd->w)) &&
228 ((it->y + it->h) > sd->cy) &&
229 ((it->y) < (sd->cy + sd->h))
238 dx = (it->x + (it->w / 2)) - sd->sx;
239 dy = (it->y + (it->h / 2)) - sd->sy;
245 a = -atan(-(double)dy / (double)dx);
249 a = atan((double)dy / (double)dx);
255 if (dy < 0) a = -M_PI / 2;
265 a = -M_PI + atan((double)dy / (double)dx);
269 a = M_PI - atan(-(double)dy / (double)dx);
271 d = sqrt((double)(dx * dx) + (double)(dy * dy));
276 for (p = (char *)it->file; *p; p++) sum += (int)(*p);
278 sum = (sum & 0xff) - 128;
279 a = a + ((double)sum / 1024.0);
280 xx = sd->sx - sd->cx + ox;
281 yy = sd->sy - sd->cy + oy;
282 if (xx < (sd->w / 2)) dx = sd->w - xx;
284 if (yy < (sd->h / 2)) dy = sd->h - yy;
287 if (dy > dx) dd = dy - d;
289 dy = sin(a) * sd->selmove * (dd * 0.9);
290 dx = cos(a) * sd->selmove * (dd * 0.9);
292 xx = sd->x - sd->cx + it->x + ox;
293 yy = sd->y - sd->cy + it->y + oy;
294 evas_output_viewport_get(evas, NULL, NULL, &vw, &vh);
295 if (E_INTERSECTS(xx, yy, it->w, it->h, 0, 0, vw, vh))
301 e_thumb_icon_begin(it->image);
302 it->do_thumb = EINA_TRUE;
309 it->frame = edje_object_add(evas);
311 e_theme_edje_object_set(it->frame, "base/theme/widgets",
312 "e/conf/wallpaper/main/mini-theme");
314 e_theme_edje_object_set(it->frame, "base/theme/widgets",
315 "e/conf/wallpaper/main/mini-remote");
317 e_theme_edje_object_set(it->frame, "base/theme/widgets",
318 "e/conf/wallpaper/main/mini");
321 edje_object_signal_emit(it->frame, "e,state,selected", "e");
322 evas_object_raise(it->frame);
324 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
326 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
329 evas_object_smart_member_add(it->frame, obj);
330 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
331 it->image = e_thumb_icon_add(evas);
332 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
333 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
338 f = e_theme_edje_file_get("base/theme/backgrounds",
339 "e/desktop/background");
340 e_thumb_icon_file_set(it->image, f,
341 "e/desktop/background");
344 e_thumb_icon_file_set(it->image, it->file,
345 "e/desktop/background");
346 e_thumb_icon_size_set(it->image, sd->info->iw,
348 evas_object_show(it->image);
350 e_thumb_icon_begin(it->image);
353 evas_object_move(it->frame, xx + dx, yy + dy);
354 evas_object_resize(it->frame, it->w, it->h);
355 evas_object_show(it->frame);
356 it->visible = EINA_TRUE;
364 e_thumb_icon_end(it->image);
365 it->do_thumb = EINA_FALSE;
367 evas_object_del(it->image);
369 evas_object_del(it->frame);
372 it->visible = EINA_FALSE;
378 e_thumb_icon_end(it->image);
379 it->do_thumb = EINA_FALSE;
381 evas_object_del(it->image);
382 it->have_thumb = EINA_FALSE;
383 it->image = e_thumb_icon_add(evas);
384 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
385 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
388 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
389 "e/desktop/background");
390 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
393 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
394 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
395 evas_object_show(it->image);
396 edje_object_signal_emit(it->frame, "e,action,thumb,ungen", "e");
404 e_thumb_icon_end(it->image);
414 evas_object_smart_callback_call(obj, "changed", NULL);
415 if (recursion == 0) sd->idle_enter = NULL;
416 return ECORE_CALLBACK_CANCEL;
420 _e_smart_reconfigure(Evas_Object *obj)
422 Smart_Data *sd = evas_object_smart_data_get(obj);
424 if (sd->idle_enter) return;
425 sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj);
429 _e_smart_add(Evas_Object *obj)
431 Smart_Data *sd = calloc(1, sizeof(Smart_Data));
435 sd->sx = sd->sy = -1;
436 evas_object_smart_data_set(obj, sd);
440 _e_smart_del(Evas_Object *obj)
442 Smart_Data *sd = evas_object_smart_data_get(obj);
446 ecore_timer_del(sd->seltimer);
448 ecore_idle_enterer_del(sd->idle_enter);
450 ecore_animator_del(sd->animator);
451 // sd->info is just referenced
452 // sd->child_obj is unused
453 EINA_LIST_FREE(sd->items, it)
455 if (it->frame) evas_object_del(it->frame);
456 if (it->image) evas_object_del(it->image);
457 if (it->file) eina_stringshare_del(it->file);
462 evas_object_smart_data_set(obj, NULL);
466 _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
468 Smart_Data *sd = evas_object_smart_data_get(obj);
472 _e_smart_reconfigure(obj);
476 _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
478 Smart_Data *sd = evas_object_smart_data_get(obj);
482 _e_smart_reconfigure(obj);
483 evas_object_smart_callback_call(obj, "changed", NULL);
487 _e_smart_show(Evas_Object *obj __UNUSED__)
489 // Smart_Data *sd = evas_object_smart_data_get(obj);
490 // evas_object_show(sd->child_obj);
494 _e_smart_hide(Evas_Object *obj __UNUSED__)
496 // Smart_Data *sd = evas_object_smart_data_get(obj);
497 // evas_object_hide(sd->child_obj);
501 _e_smart_color_set(Evas_Object *obj __UNUSED__, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__)
503 // Smart_Data *sd = evas_object_smart_data_get(obj);
504 // evas_object_color_set(sd->child_obj, r, g, b, a);
508 _e_smart_clip_set(Evas_Object *obj __UNUSED__, Evas_Object * clip __UNUSED__)
510 // Smart_Data *sd = evas_object_smart_data_get(obj);
511 // evas_object_clip_set(sd->child_obj, clip);
515 _e_smart_clip_unset(Evas_Object *obj __UNUSED__)
517 // Smart_Data *sd = evas_object_smart_data_get(obj);
518 // evas_object_clip_unset(sd->child_obj);
524 static Evas_Smart *smart = NULL;
525 static const Evas_Smart_Class sc =
528 EVAS_SMART_CLASS_VERSION,
546 smart = evas_smart_class_new(&sc);
547 return evas_object_smart_add(evas, smart);
551 _pan_info_set(Evas_Object *obj, Info *info)
553 Smart_Data *sd = evas_object_smart_data_get(obj);
559 _sel_anim(void *data)
561 Evas_Object *obj = data;
562 Smart_Data *sd = evas_object_smart_data_get(obj);
563 double t = ecore_loop_time_get() - sd->seltime;
568 if (p > 1.0) p = 1.0;
589 d = ((1.0 - p) * 2) - 1.0;
605 _e_smart_reconfigure(obj);
610 sd->selin = EINA_TRUE;
611 sd->selout = EINA_FALSE;
612 sd->seltime = ecore_loop_time_get();
613 return ECORE_CALLBACK_RENEW;
615 sd->selout = EINA_FALSE;
616 sd->selin = EINA_FALSE;
618 return ECORE_CALLBACK_CANCEL;
620 return ECORE_CALLBACK_RENEW;
624 _sel_timer(void *data)
626 Evas_Object *obj = data;
627 Smart_Data *sd = evas_object_smart_data_get(obj);
631 sd->seltime = ecore_time_get();
632 sd->animator = ecore_animator_add(_sel_anim, obj);
633 sd->selin = EINA_FALSE;
636 return ECORE_CALLBACK_CANCEL;
640 _pan_unhilight(Evas_Object *obj __UNUSED__, Item *it)
642 // Smart_Data *sd = evas_object_smart_data_get(obj);
643 if (!it->hilighted) return;
646 edje_object_signal_emit(it->frame, "e,state,unselected", "e");
650 _pan_hilight(Evas_Object *obj __UNUSED__, Item *it)
654 Smart_Data *sd = evas_object_smart_data_get(obj);
656 if (it->hilighted) return;
657 EINA_LIST_FOREACH(sd->items, l, it2)
661 _pan_unhilight(obj, it2);
668 edje_object_signal_emit(it->frame, "e,state,selected", "e");
669 evas_object_raise(it->frame);
675 _pan_sel(Evas_Object *obj, Item *it)
677 Smart_Data *sd = evas_object_smart_data_get(obj);
679 if (sd->selmove > 0.0) return;
680 edje_object_signal_emit(it->frame, "e,state,selected", "e");
681 evas_object_raise(it->frame);
687 EINA_LIST_FOREACH(sd->items, l, it2)
689 if (it2->selected) it2->selected = 0;
691 it->selected = EINA_TRUE;
692 if (sd->info->bg_file) free(sd->info->bg_file);
693 evas_object_hide(sd->info->mini);
696 char *name = NULL, *p;
698 sd->info->use_theme_bg = 0;
699 sd->info->bg_file = strdup(it->file);
700 edje_object_file_set(sd->info->mini, sd->info->bg_file,
701 "e/desktop/background");
702 p = strrchr(sd->info->bg_file, '/');
707 p = strrchr(name, '.');
710 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
711 if (name) free(name);
715 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
716 "e/desktop/background");
718 edje_object_file_set(sd->info->mini, f, "e/desktop/background");
719 sd->info->use_theme_bg = 1;
720 sd->info->bg_file = NULL;
721 edje_object_part_text_set(sd->info->bg, "e.text.filename",
722 _("Theme Wallpaper"));
724 evas_object_show(sd->info->mini);
726 if (sd->seltimer) ecore_timer_del(sd->seltimer);
727 sd->seltimer = ecore_timer_add(0.2, _sel_timer, obj);
731 _pan_sel_up(Evas_Object *obj)
733 Smart_Data *sd = evas_object_smart_data_get(obj);
735 if (sd->selmove == 0.0) return;
738 sd->seltime = ecore_loop_time_get();
739 sd->animator = ecore_animator_add(_sel_anim, obj);
740 sd->selin = EINA_TRUE;
744 if (sd->selin) return;
745 sd->selout = EINA_TRUE;
750 _sort_cb(const void *d1, const void *d2)
752 const Item *it1 = d1, *it2 = d2;
754 if ((!it1->sort_id) || (!it2->sort_id)) return 0;
755 return strcmp(it1->sort_id, it2->sort_id);
761 Evas_Object *obj = it->obj;
762 Smart_Data *sd = evas_object_smart_data_get(obj);
767 num = eina_list_count(sd->items);
768 // if (sd->sort_num < sd->id_num)
770 // sd->sort_num = sd->id_num + 10;
773 if ((sd->id_num == num) || (dosort))
775 sd->items = eina_list_sort(sd->items, num, _sort_cb);
776 _e_smart_reconfigure_do(obj);
782 EINA_LIST_FOREACH(sd->items, l, it2)
784 if (it2->hilighted) break;
788 e_scrollframe_child_region_show(sd->info->sframe,
789 it2->x, it2->y, it2->w, it2->h);
793 if (sd->info->scans == 0)
794 edje_object_signal_emit(sd->info->bg, "e,state,busy,off", "e");
798 _thumb_gen(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
802 edje_object_signal_emit(it->frame, "e,action,thumb,gen", "e");
805 const char *id = e_thumb_sort_id_get(it->image);
809 it->sort_id = strdup(id);
813 it->have_thumb = EINA_TRUE;
818 e_thumb_icon_end(it->image);
819 it->do_thumb = EINA_FALSE;
821 evas_object_del(it->image);
823 evas_object_del(it->frame);
829 _item_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
831 // Evas_Event_Mouse_Down *ev = event_info;
833 // _pan_sel(it->obj, it);
837 _item_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
839 Evas_Event_Mouse_Up *ev = event_info;
844 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
846 _pan_hilight(it->obj, it);
847 _pan_sel(it->obj, it);
848 // FIXME: select image!!!
854 _pan_file_add(Evas_Object *obj, const char *file, Eina_Bool remote, Eina_Bool theme)
856 Smart_Data *sd = evas_object_smart_data_get(obj);
857 Item *it = calloc(1, sizeof(Item));
861 evas = evas_object_evas_get(obj);
862 sd->items = eina_list_append(sd->items, it);
866 it->file = eina_stringshare_add(file);
867 it->frame = edje_object_add(evas);
869 e_theme_edje_object_set(it->frame, "base/theme/widgets",
870 "e/conf/wallpaper/main/mini-theme");
872 e_theme_edje_object_set(it->frame, "base/theme/widgets",
873 "e/conf/wallpaper/main/mini-remote");
875 e_theme_edje_object_set(it->frame, "base/theme/widgets",
876 "e/conf/wallpaper/main/mini");
879 edje_object_signal_emit(it->frame, "e,state,selected", "e");
880 evas_object_raise(it->frame);
882 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
884 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
887 evas_object_smart_member_add(it->frame, obj);
888 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
889 evas_object_show(it->frame);
890 it->image = e_thumb_icon_add(evas);
891 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
892 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
895 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
896 "e/desktop/background");
898 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
901 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
902 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
903 evas_object_show(it->image);
905 e_thumb_icon_begin(it->image);
907 // e_thumb_icon_begin(it->image);
911 if (sd->info->use_theme_bg)
913 _pan_hilight(it->obj, it);
914 edje_object_part_text_set(sd->info->bg, "e.text.filename",
915 _("Theme Wallpaper"));
920 if (sd->info->bg_file)
924 if (!strcmp(sd->info->bg_file, it->file)) match = 1;
929 p1 = ecore_file_file_get(sd->info->bg_file);
930 p2 = ecore_file_file_get(it->file);
931 if (!strcmp(p1, p2)) match = 1;
935 char *name = NULL, *p;
938 _pan_hilight(it->obj, it);
939 p = strrchr(sd->info->bg_file, '/');
944 p = strrchr(name, '.');
947 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
948 if (name) free(name);
952 _e_smart_reconfigure(obj);
960 Info *info = wn->data;
962 evas_object_resize(info->bg, wn->w, wn->h);
966 _delete(E_Win *wn __UNUSED__)
972 _bg_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
976 _pan_sel_up(info->span);
980 _ok(void *data, void *data2 __UNUSED__)
987 while (e_config->desktop_backgrounds)
989 E_Config_Desktop_Background *cfbg;
991 cfbg = e_config->desktop_backgrounds->data;
992 e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
994 if ((info->use_theme_bg) || (!info->bg_file))
995 e_bg_default_set(NULL);
997 e_bg_default_set(info->bg_file);
999 else if (info->mode == 1)
1002 e_bg_del(info->con_num, info->zone_num, info->desk_x, info->desk_y);
1003 e_bg_add(info->con_num, info->zone_num, info->desk_x, info->desk_y,
1008 Eina_List *dlist = NULL, *l;
1009 E_Config_Desktop_Background *cfbg;
1012 EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
1014 if (cfbg->zone == info->zone_num)
1015 dlist = eina_list_append(dlist, cfbg);
1017 EINA_LIST_FREE(dlist, cfbg)
1018 e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
1019 e_bg_add(info->con_num, info->zone_num, -1, -1, info->bg_file);
1022 e_config_save_queue();
1027 _wp_add(void *data, void *data2 __UNUSED__)
1031 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1035 _wp_delete(void *data, void *data2 __UNUSED__)
1039 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1043 _wp_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1047 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1060 return ECORE_CALLBACK_CANCEL;
1062 dp = readdir(info->dir);
1066 info->curdir = NULL;
1067 closedir(info->dir);
1071 return ECORE_CALLBACK_CANCEL;
1073 if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, "..")))
1074 return ECORE_CALLBACK_RENEW;
1075 if (dp->d_name[0] == '.')
1076 return ECORE_CALLBACK_RENEW;
1077 snprintf(buf, sizeof(buf), "%s/%s", info->curdir, dp->d_name);
1078 if (ecore_file_is_dir(buf))
1080 info->dirs = eina_list_append(info->dirs, strdup(buf));
1081 return ECORE_CALLBACK_RENEW;
1084 _pan_file_add(info->span, buf, 0, 0);
1087 return ECORE_CALLBACK_RENEW;
1095 if (info->scans <= 0)
1098 edje_object_signal_emit(info->bg, "e,state,busy,on", "e");
1099 edje_object_part_text_set(info->bg, "e.text.busy_label",
1100 _("Loading files..."));
1102 if (info->curdir) free(info->curdir);
1103 info->curdir = info->dirs->data;
1104 info->dirs = eina_list_remove_list(info->dirs, info->dirs);
1105 if (!info->dir) info->dir = opendir(info->curdir);
1106 info->idler = ecore_idler_add(_idler, info);
1111 wp_browser_new(E_Container *con)
1117 const E_Config_Desktop_Background *cfbg;
1119 Evas_Object *o, *o2, *ob;
1123 info = calloc(1, sizeof(Info));
1124 if (!info) return NULL;
1126 zone = e_util_zone_current_get(con->manager);
1127 desk = e_desk_current_get(zone);
1128 info->con_num = con->num;
1129 info->zone_num = zone->id;
1130 info->desk_x = desk->x;
1131 info->desk_y = desk->y;
1133 cfbg = e_bg_config_get(con->num, zone->id, desk->x, desk->y);
1136 if ((cfbg->container >= 0) && (cfbg->zone >= 0))
1138 if ((cfbg->desk_x >= 0) && (cfbg->desk_y >= 0))
1143 info->bg_file = strdup(cfbg->file);
1145 if ((!info->bg_file) && (e_config->desktop_default_background))
1146 info->bg_file = strdup(e_config->desktop_default_background);
1148 info->use_theme_bg = 1;
1150 info->iw = (120 * e_scale);
1151 info->ih = (zone->h * info->iw) / (zone->w);
1153 win = e_win_new(con);
1163 e_user_dir_concat_static(buf, "backgrounds");
1164 info->dirs = eina_list_append(info->dirs, strdup(buf));
1165 e_prefix_data_concat_static(buf, "data/backgrounds");
1166 info->dirs = eina_list_append(info->dirs, strdup(buf));
1168 e_win_title_set(win, _("Wallpaper Settings"));
1169 e_win_name_class_set(win, "E", "_config::appearance/wallpaper2");
1170 e_win_resize_callback_set(win, _resize);
1171 e_win_delete_callback_set(win, _delete);
1174 info->bg = edje_object_add(info->win->evas);
1175 e_theme_edje_object_set(info->bg, "base/theme/widgets",
1176 "e/conf/wallpaper/main/window");
1177 edje_object_signal_callback_add(info->bg, "e,action,click", "e",
1181 info->box = e_widget_list_add(info->win->evas, 1, 1);
1183 info->button = e_widget_button_add(info->win->evas, _("OK"), NULL,
1185 evas_object_show(info->button);
1186 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1188 e_widget_size_min_get(info->box, &mw, &mh);
1189 edje_extern_object_min_size_set(info->box, mw, mh);
1190 edje_object_part_swallow(info->bg, "e.swallow.buttons", info->box);
1191 evas_object_show(info->box);
1194 info->preview = e_livethumb_add(info->win->evas);
1195 e_livethumb_vsize_set(info->preview, zone->w, zone->h);
1196 edje_extern_object_aspect_set(info->preview, EDJE_ASPECT_CONTROL_NEITHER,
1198 edje_object_part_swallow(info->bg, "e.swallow.preview", info->preview);
1199 evas_object_show(info->preview);
1201 info->mini = edje_object_add(e_livethumb_evas_get(info->preview));
1202 e_livethumb_thumb_set(info->preview, info->mini);
1203 evas_object_show(info->mini);
1205 edje_object_file_set(info->mini, info->bg_file, "e/desktop/background");
1208 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
1209 "e/desktop/background");
1211 edje_object_file_set(info->mini, f, "e/desktop/background");
1215 info->span = _pan_add(info->win->evas);
1216 _pan_info_set(info->span, info);
1218 // the scrollframe holding the scrolled thumbs
1219 info->sframe = e_scrollframe_add(info->win->evas);
1220 e_scrollframe_custom_theme_set(info->sframe, "base/theme/widgets",
1221 "e/conf/wallpaper/main/scrollframe");
1222 e_scrollframe_extern_pan_set(info->sframe, info->span,
1223 _pan_set, _pan_get, _pan_max_get,
1224 _pan_child_size_get);
1225 edje_object_part_swallow(info->bg, "e.swallow.list", info->sframe);
1226 evas_object_show(info->sframe);
1227 evas_object_show(info->span);
1229 ob = e_widget_list_add(info->win->evas, 0, 1);
1231 o = e_widget_list_add(info->win->evas, 1, 0);
1233 rg = e_widget_radio_group_new(&(info->mode));
1234 o2 = e_widget_radio_add(info->win->evas, _("All Desktops"), 0, rg);
1235 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1236 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1237 e_widget_disabled_set(o2, (e_util_container_desk_count_get(con) < 2));
1238 evas_object_show(o2);
1240 o2 = e_widget_radio_add(info->win->evas, _("This Desktop"), 1, rg);
1241 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1242 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1243 evas_object_show(o2);
1245 o2 = e_widget_radio_add(info->win->evas, _("This Screen"), 2, rg);
1246 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1247 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1248 if (!(e_util_container_zone_number_get(0, 1) ||
1249 (e_util_container_zone_number_get(1, 0))))
1250 e_widget_disabled_set(o2, EINA_TRUE);
1251 evas_object_show(o2);
1253 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1254 evas_object_show(o);
1256 o = e_widget_list_add(info->win->evas, 1, 0);
1258 o2 = e_widget_button_add(info->win->evas, _("Add"), NULL,
1259 _wp_add, info, NULL);
1260 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1261 evas_object_show(o2);
1263 o2 = e_widget_button_add(info->win->evas, _("Delete"), NULL,
1264 _wp_delete, info, NULL);
1265 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1266 evas_object_show(o2);
1268 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1269 evas_object_show(o);
1271 e_widget_size_min_get(ob, &mw, &mh);
1272 edje_extern_object_min_size_set(ob, mw, mh);
1273 edje_object_part_swallow(info->bg, "e.swallow.extras", ob);
1274 evas_object_show(ob);
1277 edje_object_size_min_calc(info->bg, &mw, &mh);
1278 e_win_size_min_set(win, mw, mh);
1279 if ((zone->w / 4) > mw) mw = (zone->w / 4);
1280 if ((zone->h / 4) > mh) mh = (zone->h / 4);
1281 e_win_resize(win, mw, mh);
1282 e_win_centered_set(win, 1);
1284 e_win_border_icon_set(win, "preferences-desktop-wallpaper");
1286 evas_object_resize(info->bg, info->win->w, info->win->h);
1287 evas_object_show(info->bg);
1290 _pan_file_add(info->span, NULL, 0, 1);
1297 wp_broser_free(Info *info)
1302 e_object_del(E_OBJECT(info->win));
1303 if (info->dir) closedir(info->dir);
1304 free(info->bg_file);
1306 EINA_LIST_FREE(info->dirs, s)
1308 if (info->idler) ecore_idler_del(info->idler);
1315 wp_conf_show(E_Container *con, const char *params __UNUSED__)
1319 e_win_show(global_info->win);
1320 e_win_raise(global_info->win);
1322 global_info = wp_browser_new(con);
1332 wp_broser_free(global_info);