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 xx = sd->x - sd->cx + x;
163 if (x > (sd->w - ww))
167 xx = sd->x - sd->cx + x;
169 yy = sd->y - sd->cy + y;
176 sd->sx = it->x + (it->w / 2);
177 sd->sy = it->y + (it->h / 2);
179 if ((x + ww) > mw) mw = x + ww;
180 if ((y + hh) > mh) mh = y + hh;
183 if ((mw != sd->cw) || (mh != sd->ch))
187 if (sd->cx > (sd->cw - sd->w))
189 sd->cx = sd->cw - sd->w;
192 if (sd->cy > (sd->ch - sd->h))
194 sd->cy = sd->ch - sd->h;
210 _e_smart_reconfigure_do(obj);
217 if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2;
219 if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2;
221 EINA_LIST_FOREACH(sd->items, l, it)
223 Evas_Coord dx, dy, vw, vh;
226 if ((sd->sx >= 0) && (sd->selmove > 0.0)
229 ((it->x + it->w) > sd->cx) &&
230 ((it->x) < (sd->cx + sd->w)) &&
231 ((it->y + it->h) > sd->cy) &&
232 ((it->y) < (sd->cy + sd->h))
241 dx = (it->x + (it->w / 2)) - sd->sx;
242 dy = (it->y + (it->h / 2)) - sd->sy;
248 a = -atan(-(double)dy / (double)dx);
252 a = atan((double)dy / (double)dx);
258 if (dy < 0) a = -M_PI / 2;
268 a = -M_PI + atan((double)dy / (double)dx);
272 a = M_PI - atan(-(double)dy / (double)dx);
274 d = sqrt((double)(dx * dx) + (double)(dy * dy));
279 for (p = (char *)it->file; *p; p++) sum += (int)(*p);
281 sum = (sum & 0xff) - 128;
282 a = a + ((double)sum / 1024.0);
283 xx = sd->sx - sd->cx + ox;
284 yy = sd->sy - sd->cy + oy;
285 if (xx < (sd->w / 2)) dx = sd->w - xx;
287 if (yy < (sd->h / 2)) dy = sd->h - yy;
290 if (dy > dx) dd = dy - d;
292 dy = sin(a) * sd->selmove * (dd * 0.9);
293 dx = cos(a) * sd->selmove * (dd * 0.9);
295 xx = sd->x - sd->cx + it->x + ox;
296 yy = sd->y - sd->cy + it->y + oy;
297 evas_output_viewport_get(evas, NULL, NULL, &vw, &vh);
298 if (E_INTERSECTS(xx, yy, it->w, it->h, 0, 0, vw, vh))
304 e_thumb_icon_begin(it->image);
305 it->do_thumb = EINA_TRUE;
312 it->frame = edje_object_add(evas);
314 e_theme_edje_object_set(it->frame, "base/theme/widgets",
315 "e/conf/wallpaper/main/mini-theme");
317 e_theme_edje_object_set(it->frame, "base/theme/widgets",
318 "e/conf/wallpaper/main/mini-remote");
320 e_theme_edje_object_set(it->frame, "base/theme/widgets",
321 "e/conf/wallpaper/main/mini");
324 edje_object_signal_emit(it->frame, "e,state,selected", "e");
325 evas_object_raise(it->frame);
327 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
329 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
332 evas_object_smart_member_add(it->frame, obj);
333 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
334 it->image = e_thumb_icon_add(evas);
335 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
336 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
341 f = e_theme_edje_file_get("base/theme/backgrounds",
342 "e/desktop/background");
343 e_thumb_icon_file_set(it->image, f,
344 "e/desktop/background");
347 e_thumb_icon_file_set(it->image, it->file,
348 "e/desktop/background");
349 e_thumb_icon_size_set(it->image, sd->info->iw,
351 evas_object_show(it->image);
353 e_thumb_icon_begin(it->image);
356 evas_object_move(it->frame, xx + dx, yy + dy);
357 evas_object_resize(it->frame, it->w, it->h);
358 evas_object_show(it->frame);
359 it->visible = EINA_TRUE;
367 e_thumb_icon_end(it->image);
368 it->do_thumb = EINA_FALSE;
370 evas_object_del(it->image);
372 evas_object_del(it->frame);
375 it->visible = EINA_FALSE;
381 e_thumb_icon_end(it->image);
382 it->do_thumb = EINA_FALSE;
384 evas_object_del(it->image);
385 it->have_thumb = EINA_FALSE;
386 it->image = e_thumb_icon_add(evas);
387 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
388 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
391 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
392 "e/desktop/background");
393 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
396 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
397 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
398 evas_object_show(it->image);
399 edje_object_signal_emit(it->frame, "e,action,thumb,ungen", "e");
407 e_thumb_icon_end(it->image);
417 evas_object_smart_callback_call(obj, "changed", NULL);
418 if (recursion == 0) sd->idle_enter = NULL;
419 return ECORE_CALLBACK_CANCEL;
423 _e_smart_reconfigure(Evas_Object *obj)
425 Smart_Data *sd = evas_object_smart_data_get(obj);
427 if (sd->idle_enter) return;
428 sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj);
432 _e_smart_add(Evas_Object *obj)
434 Smart_Data *sd = calloc(1, sizeof(Smart_Data));
438 sd->sx = sd->sy = -1;
439 evas_object_smart_data_set(obj, sd);
443 _e_smart_del(Evas_Object *obj)
445 Smart_Data *sd = evas_object_smart_data_get(obj);
449 ecore_timer_del(sd->seltimer);
451 ecore_idle_enterer_del(sd->idle_enter);
453 ecore_animator_del(sd->animator);
454 // sd->info is just referenced
455 // sd->child_obj is unused
456 EINA_LIST_FREE(sd->items, it)
458 if (it->frame) evas_object_del(it->frame);
459 if (it->image) evas_object_del(it->image);
460 if (it->file) eina_stringshare_del(it->file);
465 evas_object_smart_data_set(obj, NULL);
469 _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
471 Smart_Data *sd = evas_object_smart_data_get(obj);
475 _e_smart_reconfigure(obj);
479 _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
481 Smart_Data *sd = evas_object_smart_data_get(obj);
485 _e_smart_reconfigure(obj);
486 evas_object_smart_callback_call(obj, "changed", NULL);
490 _e_smart_show(Evas_Object *obj __UNUSED__)
492 // Smart_Data *sd = evas_object_smart_data_get(obj);
493 // evas_object_show(sd->child_obj);
497 _e_smart_hide(Evas_Object *obj __UNUSED__)
499 // Smart_Data *sd = evas_object_smart_data_get(obj);
500 // evas_object_hide(sd->child_obj);
504 _e_smart_color_set(Evas_Object *obj __UNUSED__, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__)
506 // Smart_Data *sd = evas_object_smart_data_get(obj);
507 // evas_object_color_set(sd->child_obj, r, g, b, a);
511 _e_smart_clip_set(Evas_Object *obj __UNUSED__, Evas_Object * clip __UNUSED__)
513 // Smart_Data *sd = evas_object_smart_data_get(obj);
514 // evas_object_clip_set(sd->child_obj, clip);
518 _e_smart_clip_unset(Evas_Object *obj __UNUSED__)
520 // Smart_Data *sd = evas_object_smart_data_get(obj);
521 // evas_object_clip_unset(sd->child_obj);
527 static Evas_Smart *smart = NULL;
528 static const Evas_Smart_Class sc =
531 EVAS_SMART_CLASS_VERSION,
549 smart = evas_smart_class_new(&sc);
550 return evas_object_smart_add(evas, smart);
554 _pan_info_set(Evas_Object *obj, Info *info)
556 Smart_Data *sd = evas_object_smart_data_get(obj);
562 _sel_anim(void *data)
564 Evas_Object *obj = data;
565 Smart_Data *sd = evas_object_smart_data_get(obj);
566 double t = ecore_loop_time_get() - sd->seltime;
571 if (p > 1.0) p = 1.0;
592 d = ((1.0 - p) * 2) - 1.0;
608 _e_smart_reconfigure(obj);
613 sd->selin = EINA_TRUE;
614 sd->selout = EINA_FALSE;
615 sd->seltime = ecore_loop_time_get();
616 return ECORE_CALLBACK_RENEW;
618 sd->selout = EINA_FALSE;
619 sd->selin = EINA_FALSE;
621 return ECORE_CALLBACK_CANCEL;
623 return ECORE_CALLBACK_RENEW;
627 _sel_timer(void *data)
629 Evas_Object *obj = data;
630 Smart_Data *sd = evas_object_smart_data_get(obj);
634 sd->seltime = ecore_time_get();
635 sd->animator = ecore_animator_add(_sel_anim, obj);
636 sd->selin = EINA_FALSE;
639 return ECORE_CALLBACK_CANCEL;
643 _pan_unhilight(Evas_Object *obj __UNUSED__, Item *it)
645 // Smart_Data *sd = evas_object_smart_data_get(obj);
646 if (!it->hilighted) return;
649 edje_object_signal_emit(it->frame, "e,state,unselected", "e");
653 _pan_hilight(Evas_Object *obj __UNUSED__, Item *it)
657 Smart_Data *sd = evas_object_smart_data_get(obj);
659 if (it->hilighted) return;
660 EINA_LIST_FOREACH(sd->items, l, it2)
664 _pan_unhilight(obj, it2);
671 edje_object_signal_emit(it->frame, "e,state,selected", "e");
672 evas_object_raise(it->frame);
678 _pan_sel(Evas_Object *obj, Item *it)
680 Smart_Data *sd = evas_object_smart_data_get(obj);
682 if (sd->selmove > 0.0) return;
683 edje_object_signal_emit(it->frame, "e,state,selected", "e");
684 evas_object_raise(it->frame);
690 EINA_LIST_FOREACH(sd->items, l, it2)
692 if (it2->selected) it2->selected = 0;
694 it->selected = EINA_TRUE;
695 if (sd->info->bg_file) free(sd->info->bg_file);
696 evas_object_hide(sd->info->mini);
699 char *name = NULL, *p;
701 sd->info->use_theme_bg = 0;
702 sd->info->bg_file = strdup(it->file);
703 edje_object_file_set(sd->info->mini, sd->info->bg_file,
704 "e/desktop/background");
705 p = strrchr(sd->info->bg_file, '/');
710 p = strrchr(name, '.');
713 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
714 if (name) free(name);
718 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
719 "e/desktop/background");
721 edje_object_file_set(sd->info->mini, f, "e/desktop/background");
722 sd->info->use_theme_bg = 1;
723 sd->info->bg_file = NULL;
724 edje_object_part_text_set(sd->info->bg, "e.text.filename",
725 _("Theme Wallpaper"));
727 evas_object_show(sd->info->mini);
729 if (sd->seltimer) ecore_timer_del(sd->seltimer);
730 sd->seltimer = ecore_timer_add(0.2, _sel_timer, obj);
734 _pan_sel_up(Evas_Object *obj)
736 Smart_Data *sd = evas_object_smart_data_get(obj);
738 if (sd->selmove == 0.0) return;
741 sd->seltime = ecore_loop_time_get();
742 sd->animator = ecore_animator_add(_sel_anim, obj);
743 sd->selin = EINA_TRUE;
747 if (sd->selin) return;
748 sd->selout = EINA_TRUE;
753 _sort_cb(const void *d1, const void *d2)
755 const Item *it1 = d1, *it2 = d2;
757 if ((!it1->sort_id) || (!it2->sort_id)) return 0;
758 return strcmp(it1->sort_id, it2->sort_id);
764 Evas_Object *obj = it->obj;
765 Smart_Data *sd = evas_object_smart_data_get(obj);
770 num = eina_list_count(sd->items);
771 // if (sd->sort_num < sd->id_num)
773 // sd->sort_num = sd->id_num + 10;
776 if ((sd->id_num == num) || (dosort))
778 sd->items = eina_list_sort(sd->items, num, _sort_cb);
779 _e_smart_reconfigure_do(obj);
785 EINA_LIST_FOREACH(sd->items, l, it2)
787 if (it2->hilighted) break;
791 e_scrollframe_child_region_show(sd->info->sframe,
792 it2->x, it2->y, it2->w, it2->h);
796 if (sd->info->scans == 0)
797 edje_object_signal_emit(sd->info->bg, "e,state,busy,off", "e");
801 _thumb_gen(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
805 edje_object_signal_emit(it->frame, "e,action,thumb,gen", "e");
808 const char *id = e_thumb_sort_id_get(it->image);
812 it->sort_id = strdup(id);
816 it->have_thumb = EINA_TRUE;
821 e_thumb_icon_end(it->image);
822 it->do_thumb = EINA_FALSE;
824 evas_object_del(it->image);
826 evas_object_del(it->frame);
832 _item_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
834 // Evas_Event_Mouse_Down *ev = event_info;
836 // _pan_sel(it->obj, it);
840 _item_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
842 Evas_Event_Mouse_Up *ev = event_info;
847 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
849 _pan_hilight(it->obj, it);
850 _pan_sel(it->obj, it);
851 // FIXME: select image!!!
857 _pan_file_add(Evas_Object *obj, const char *file, Eina_Bool remote, Eina_Bool theme)
859 Smart_Data *sd = evas_object_smart_data_get(obj);
860 Item *it = calloc(1, sizeof(Item));
864 evas = evas_object_evas_get(obj);
865 sd->items = eina_list_append(sd->items, it);
869 it->file = eina_stringshare_add(file);
870 it->frame = edje_object_add(evas);
872 e_theme_edje_object_set(it->frame, "base/theme/widgets",
873 "e/conf/wallpaper/main/mini-theme");
875 e_theme_edje_object_set(it->frame, "base/theme/widgets",
876 "e/conf/wallpaper/main/mini-remote");
878 e_theme_edje_object_set(it->frame, "base/theme/widgets",
879 "e/conf/wallpaper/main/mini");
882 edje_object_signal_emit(it->frame, "e,state,selected", "e");
883 evas_object_raise(it->frame);
885 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
887 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
890 evas_object_smart_member_add(it->frame, obj);
891 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
892 evas_object_show(it->frame);
893 it->image = e_thumb_icon_add(evas);
894 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
895 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
898 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
899 "e/desktop/background");
901 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
904 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
905 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
906 evas_object_show(it->image);
908 e_thumb_icon_begin(it->image);
910 // e_thumb_icon_begin(it->image);
914 if (sd->info->use_theme_bg)
916 _pan_hilight(it->obj, it);
917 edje_object_part_text_set(sd->info->bg, "e.text.filename",
918 _("Theme Wallpaper"));
923 if (sd->info->bg_file)
927 if (!strcmp(sd->info->bg_file, it->file)) match = 1;
932 p1 = ecore_file_file_get(sd->info->bg_file);
933 p2 = ecore_file_file_get(it->file);
934 if (!strcmp(p1, p2)) match = 1;
938 char *name = NULL, *p;
941 _pan_hilight(it->obj, it);
942 p = strrchr(sd->info->bg_file, '/');
947 p = strrchr(name, '.');
950 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
951 if (name) free(name);
955 _e_smart_reconfigure(obj);
963 Info *info = wn->data;
965 evas_object_resize(info->bg, wn->w, wn->h);
969 _delete(E_Win *wn __UNUSED__)
975 _bg_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
979 _pan_sel_up(info->span);
983 _ok(void *data, void *data2 __UNUSED__)
990 while (e_config->desktop_backgrounds)
992 E_Config_Desktop_Background *cfbg;
994 cfbg = e_config->desktop_backgrounds->data;
995 e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
997 if ((info->use_theme_bg) || (!info->bg_file))
998 e_bg_default_set(NULL);
1000 e_bg_default_set(info->bg_file);
1002 else if (info->mode == 1)
1005 e_bg_del(info->con_num, info->zone_num, info->desk_x, info->desk_y);
1006 e_bg_add(info->con_num, info->zone_num, info->desk_x, info->desk_y,
1011 Eina_List *dlist = NULL, *l;
1012 E_Config_Desktop_Background *cfbg;
1015 EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
1017 if (cfbg->zone == info->zone_num)
1018 dlist = eina_list_append(dlist, cfbg);
1020 EINA_LIST_FREE(dlist, cfbg)
1021 e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
1022 e_bg_add(info->con_num, info->zone_num, -1, -1, info->bg_file);
1025 e_config_save_queue();
1030 _wp_add(void *data, void *data2 __UNUSED__)
1034 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1038 _wp_delete(void *data, void *data2 __UNUSED__)
1042 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1046 _wp_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1050 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1063 return ECORE_CALLBACK_CANCEL;
1065 dp = readdir(info->dir);
1069 info->curdir = NULL;
1070 closedir(info->dir);
1074 return ECORE_CALLBACK_CANCEL;
1076 if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, "..")))
1077 return ECORE_CALLBACK_RENEW;
1078 if (dp->d_name[0] == '.')
1079 return ECORE_CALLBACK_RENEW;
1080 snprintf(buf, sizeof(buf), "%s/%s", info->curdir, dp->d_name);
1081 if (ecore_file_is_dir(buf))
1083 info->dirs = eina_list_append(info->dirs, strdup(buf));
1084 return ECORE_CALLBACK_RENEW;
1087 _pan_file_add(info->span, buf, 0, 0);
1090 return ECORE_CALLBACK_RENEW;
1098 if (info->scans <= 0)
1101 edje_object_signal_emit(info->bg, "e,state,busy,on", "e");
1102 edje_object_part_text_set(info->bg, "e.text.busy_label",
1103 _("Loading files..."));
1105 if (info->curdir) free(info->curdir);
1106 info->curdir = info->dirs->data;
1107 info->dirs = eina_list_remove_list(info->dirs, info->dirs);
1108 if (!info->dir) info->dir = opendir(info->curdir);
1109 info->idler = ecore_idler_add(_idler, info);
1114 wp_browser_new(E_Container *con)
1120 const E_Config_Desktop_Background *cfbg;
1122 Evas_Object *o, *o2, *ob;
1126 info = calloc(1, sizeof(Info));
1127 if (!info) return NULL;
1129 zone = e_util_zone_current_get(con->manager);
1130 desk = e_desk_current_get(zone);
1131 info->con_num = con->num;
1132 info->zone_num = zone->id;
1133 info->desk_x = desk->x;
1134 info->desk_y = desk->y;
1136 cfbg = e_bg_config_get(con->num, zone->id, desk->x, desk->y);
1139 if ((cfbg->container >= 0) && (cfbg->zone >= 0))
1141 if ((cfbg->desk_x >= 0) && (cfbg->desk_y >= 0))
1146 info->bg_file = strdup(cfbg->file);
1148 if ((!info->bg_file) && (e_config->desktop_default_background))
1149 info->bg_file = strdup(e_config->desktop_default_background);
1151 info->use_theme_bg = 1;
1153 info->iw = (120 * e_scale);
1154 info->ih = (zone->h * info->iw) / (zone->w);
1156 win = e_win_new(con);
1166 e_user_dir_concat_static(buf, "backgrounds");
1167 info->dirs = eina_list_append(info->dirs, strdup(buf));
1168 e_prefix_data_concat_static(buf, "data/backgrounds");
1169 info->dirs = eina_list_append(info->dirs, strdup(buf));
1171 e_win_title_set(win, _("Wallpaper Settings"));
1172 e_win_name_class_set(win, "E", "_config::appearance/wallpaper2");
1173 e_win_resize_callback_set(win, _resize);
1174 e_win_delete_callback_set(win, _delete);
1177 info->bg = edje_object_add(info->win->evas);
1178 e_theme_edje_object_set(info->bg, "base/theme/widgets",
1179 "e/conf/wallpaper/main/window");
1180 edje_object_signal_callback_add(info->bg, "e,action,click", "e",
1184 info->box = e_widget_list_add(info->win->evas, 1, 1);
1186 info->button = e_widget_button_add(info->win->evas, _("OK"), NULL,
1188 evas_object_show(info->button);
1189 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1191 e_widget_size_min_get(info->box, &mw, &mh);
1192 edje_extern_object_min_size_set(info->box, mw, mh);
1193 edje_object_part_swallow(info->bg, "e.swallow.buttons", info->box);
1194 evas_object_show(info->box);
1197 info->preview = e_livethumb_add(info->win->evas);
1198 e_livethumb_vsize_set(info->preview, zone->w, zone->h);
1199 edje_extern_object_aspect_set(info->preview, EDJE_ASPECT_CONTROL_NEITHER,
1201 edje_object_part_swallow(info->bg, "e.swallow.preview", info->preview);
1202 evas_object_show(info->preview);
1204 info->mini = edje_object_add(e_livethumb_evas_get(info->preview));
1205 e_livethumb_thumb_set(info->preview, info->mini);
1206 evas_object_show(info->mini);
1208 edje_object_file_set(info->mini, info->bg_file, "e/desktop/background");
1211 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
1212 "e/desktop/background");
1214 edje_object_file_set(info->mini, f, "e/desktop/background");
1218 info->span = _pan_add(info->win->evas);
1219 _pan_info_set(info->span, info);
1221 // the scrollframe holding the scrolled thumbs
1222 info->sframe = e_scrollframe_add(info->win->evas);
1223 e_scrollframe_custom_theme_set(info->sframe, "base/theme/widgets",
1224 "e/conf/wallpaper/main/scrollframe");
1225 e_scrollframe_extern_pan_set(info->sframe, info->span,
1226 _pan_set, _pan_get, _pan_max_get,
1227 _pan_child_size_get);
1228 edje_object_part_swallow(info->bg, "e.swallow.list", info->sframe);
1229 evas_object_show(info->sframe);
1230 evas_object_show(info->span);
1232 ob = e_widget_list_add(info->win->evas, 0, 1);
1234 o = e_widget_list_add(info->win->evas, 1, 0);
1236 rg = e_widget_radio_group_new(&(info->mode));
1237 o2 = e_widget_radio_add(info->win->evas, _("All Desktops"), 0, rg);
1238 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1239 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1240 e_widget_disabled_set(o2, (e_util_container_desk_count_get(con) < 2));
1241 evas_object_show(o2);
1243 o2 = e_widget_radio_add(info->win->evas, _("This Desktop"), 1, rg);
1244 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1245 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1246 evas_object_show(o2);
1248 o2 = e_widget_radio_add(info->win->evas, _("This Screen"), 2, rg);
1249 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1250 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1251 if (!(e_util_container_zone_number_get(0, 1) ||
1252 (e_util_container_zone_number_get(1, 0))))
1253 e_widget_disabled_set(o2, EINA_TRUE);
1254 evas_object_show(o2);
1256 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1257 evas_object_show(o);
1259 o = e_widget_list_add(info->win->evas, 1, 0);
1261 o2 = e_widget_button_add(info->win->evas, _("Add"), NULL,
1262 _wp_add, info, NULL);
1263 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1264 evas_object_show(o2);
1266 o2 = e_widget_button_add(info->win->evas, _("Delete"), NULL,
1267 _wp_delete, info, NULL);
1268 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1269 evas_object_show(o2);
1271 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1272 evas_object_show(o);
1274 e_widget_size_min_get(ob, &mw, &mh);
1275 edje_extern_object_min_size_set(ob, mw, mh);
1276 edje_object_part_swallow(info->bg, "e.swallow.extras", ob);
1277 evas_object_show(ob);
1280 edje_object_size_min_calc(info->bg, &mw, &mh);
1281 e_win_size_min_set(win, mw, mh);
1282 if ((zone->w / 4) > mw) mw = (zone->w / 4);
1283 if ((zone->h / 4) > mh) mh = (zone->h / 4);
1284 e_win_resize(win, mw, mh);
1285 e_win_centered_set(win, 1);
1287 e_win_border_icon_set(win, "preferences-desktop-wallpaper");
1289 evas_object_resize(info->bg, info->win->w, info->win->h);
1290 evas_object_show(info->bg);
1293 _pan_file_add(info->span, NULL, 0, 1);
1300 wp_broser_free(Info *info)
1305 e_object_del(E_OBJECT(info->win));
1306 if (info->dir) closedir(info->dir);
1307 free(info->bg_file);
1309 EINA_LIST_FREE(info->dirs, s)
1311 if (info->idler) ecore_idler_del(info->idler);
1318 wp_conf_show(E_Container *con, const char *params __UNUSED__)
1322 e_win_show(global_info->win);
1323 e_win_raise(global_info->win);
1325 global_info = wp_browser_new(con);
1335 wp_broser_free(global_info);