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 Eina_Bool _e_smart_reconfigure_do(void *data);
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;
140 if (!sd) return ECORE_CALLBACK_CANCEL;
141 if (sd->cx > (sd->cw - sd->w)) sd->cx = sd->cw - sd->w;
142 if (sd->cy > (sd->ch - sd->h)) sd->cy = sd->ch - sd->h;
143 if (sd->cx < 0) sd->cx = 0;
144 if (sd->cy < 0) sd->cy = 0;
147 if (iw > (120 * e_scale)) iw = (120 * e_scale);
150 if (iw < (60 * e_scale)) iw = (sd->w / 3);
151 if (iw < (60 * e_scale)) iw = (sd->w / 2);
152 if (iw < (60 * e_scale)) iw = sd->w;
157 hh = (sd->info->ih * iw) / (sd->info->iw);
160 evas = evas_object_evas_get(obj);
161 evas_output_viewport_get(evas, NULL, NULL, &vw, &vh);
163 EINA_LIST_FOREACH(sd->items, l, it)
165 if (x > (sd->w - ww))
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)
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 if (E_INTERSECTS(xx, yy, it->w, it->h, 0, 0, vw, vh))
303 e_thumb_icon_begin(it->image);
304 it->do_thumb = EINA_TRUE;
311 it->frame = edje_object_add(evas);
313 e_theme_edje_object_set(it->frame, "base/theme/widgets",
314 "e/conf/wallpaper/main/mini-theme");
316 e_theme_edje_object_set(it->frame, "base/theme/widgets",
317 "e/conf/wallpaper/main/mini-remote");
319 e_theme_edje_object_set(it->frame, "base/theme/widgets",
320 "e/conf/wallpaper/main/mini");
323 edje_object_signal_emit(it->frame, "e,state,selected", "e");
324 evas_object_raise(it->frame);
326 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
328 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
331 evas_object_smart_member_add(it->frame, obj);
332 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
333 it->image = e_thumb_icon_add(evas);
334 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
335 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
340 f = e_theme_edje_file_get("base/theme/backgrounds",
341 "e/desktop/background");
342 e_thumb_icon_file_set(it->image, f,
343 "e/desktop/background");
346 e_thumb_icon_file_set(it->image, it->file,
347 "e/desktop/background");
348 e_thumb_icon_size_set(it->image, sd->info->iw,
350 evas_object_show(it->image);
352 e_thumb_icon_begin(it->image);
355 evas_object_move(it->frame, xx + dx, yy + dy);
356 evas_object_resize(it->frame, it->w, it->h);
357 evas_object_show(it->frame);
358 it->visible = EINA_TRUE;
366 e_thumb_icon_end(it->image);
367 it->do_thumb = EINA_FALSE;
369 evas_object_del(it->image);
371 evas_object_del(it->frame);
374 it->visible = EINA_FALSE;
380 e_thumb_icon_end(it->image);
381 it->do_thumb = EINA_FALSE;
383 evas_object_del(it->image);
384 it->have_thumb = EINA_FALSE;
385 it->image = e_thumb_icon_add(evas);
386 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
387 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
390 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
391 "e/desktop/background");
392 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
395 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
396 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
397 evas_object_show(it->image);
398 edje_object_signal_emit(it->frame, "e,action,thumb,ungen", "e");
406 e_thumb_icon_end(it->image);
416 evas_object_smart_callback_call(obj, "changed", NULL);
417 if (recursion == 0) sd->idle_enter = NULL;
418 return ECORE_CALLBACK_CANCEL;
422 _e_smart_reconfigure(Evas_Object *obj)
424 Smart_Data *sd = evas_object_smart_data_get(obj);
426 if (sd->idle_enter) return;
427 sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj);
431 _e_smart_add(Evas_Object *obj)
433 Smart_Data *sd = calloc(1, sizeof(Smart_Data));
437 sd->sx = sd->sy = -1;
438 evas_object_smart_data_set(obj, sd);
442 _e_smart_del(Evas_Object *obj)
444 Smart_Data *sd = evas_object_smart_data_get(obj);
448 ecore_timer_del(sd->seltimer);
450 ecore_idle_enterer_del(sd->idle_enter);
452 ecore_animator_del(sd->animator);
453 // sd->info is just referenced
454 // sd->child_obj is unused
455 EINA_LIST_FREE(sd->items, it)
457 if (it->frame) evas_object_del(it->frame);
458 if (it->image) evas_object_del(it->image);
459 if (it->file) eina_stringshare_del(it->file);
464 evas_object_smart_data_set(obj, NULL);
468 _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
470 Smart_Data *sd = evas_object_smart_data_get(obj);
474 _e_smart_reconfigure(obj);
478 _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
480 Smart_Data *sd = evas_object_smart_data_get(obj);
484 _e_smart_reconfigure(obj);
485 evas_object_smart_callback_call(obj, "changed", NULL);
489 _e_smart_show(Evas_Object *obj __UNUSED__)
491 // Smart_Data *sd = evas_object_smart_data_get(obj);
492 // evas_object_show(sd->child_obj);
496 _e_smart_hide(Evas_Object *obj __UNUSED__)
498 // Smart_Data *sd = evas_object_smart_data_get(obj);
499 // evas_object_hide(sd->child_obj);
503 _e_smart_color_set(Evas_Object *obj __UNUSED__, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__)
505 // Smart_Data *sd = evas_object_smart_data_get(obj);
506 // evas_object_color_set(sd->child_obj, r, g, b, a);
510 _e_smart_clip_set(Evas_Object *obj __UNUSED__, Evas_Object * clip __UNUSED__)
512 // Smart_Data *sd = evas_object_smart_data_get(obj);
513 // evas_object_clip_set(sd->child_obj, clip);
517 _e_smart_clip_unset(Evas_Object *obj __UNUSED__)
519 // Smart_Data *sd = evas_object_smart_data_get(obj);
520 // evas_object_clip_unset(sd->child_obj);
526 static Evas_Smart *smart = NULL;
527 static const Evas_Smart_Class sc =
530 EVAS_SMART_CLASS_VERSION,
548 smart = evas_smart_class_new(&sc);
549 return evas_object_smart_add(evas, smart);
553 _pan_info_set(Evas_Object *obj, Info *info)
555 Smart_Data *sd = evas_object_smart_data_get(obj);
561 _sel_anim(void *data)
563 Evas_Object *obj = data;
564 Smart_Data *sd = evas_object_smart_data_get(obj);
565 double t = ecore_loop_time_get() - sd->seltime;
570 if (p > 1.0) p = 1.0;
591 d = ((1.0 - p) * 2) - 1.0;
607 _e_smart_reconfigure(obj);
612 sd->selin = EINA_TRUE;
613 sd->selout = EINA_FALSE;
614 sd->seltime = ecore_loop_time_get();
615 return ECORE_CALLBACK_RENEW;
617 sd->selout = EINA_FALSE;
618 sd->selin = EINA_FALSE;
620 return ECORE_CALLBACK_CANCEL;
622 return ECORE_CALLBACK_RENEW;
626 _sel_timer(void *data)
628 Evas_Object *obj = data;
629 Smart_Data *sd = evas_object_smart_data_get(obj);
633 sd->seltime = ecore_time_get();
634 sd->animator = ecore_animator_add(_sel_anim, obj);
635 sd->selin = EINA_FALSE;
638 return ECORE_CALLBACK_CANCEL;
642 _pan_unhilight(Evas_Object *obj __UNUSED__, Item *it)
644 // Smart_Data *sd = evas_object_smart_data_get(obj);
645 if (!it->hilighted) return;
648 edje_object_signal_emit(it->frame, "e,state,unselected", "e");
652 _pan_hilight(Evas_Object *obj __UNUSED__, Item *it)
656 Smart_Data *sd = evas_object_smart_data_get(obj);
658 if (it->hilighted) return;
659 EINA_LIST_FOREACH(sd->items, l, it2)
663 _pan_unhilight(obj, it2);
670 edje_object_signal_emit(it->frame, "e,state,selected", "e");
671 evas_object_raise(it->frame);
677 _pan_sel(Evas_Object *obj, Item *it)
679 Smart_Data *sd = evas_object_smart_data_get(obj);
681 if (sd->selmove > 0.0) return;
682 edje_object_signal_emit(it->frame, "e,state,selected", "e");
683 evas_object_raise(it->frame);
689 EINA_LIST_FOREACH(sd->items, l, it2)
691 if (it2->selected) it2->selected = 0;
693 it->selected = EINA_TRUE;
694 if (sd->info->bg_file) free(sd->info->bg_file);
695 evas_object_hide(sd->info->mini);
698 char *name = NULL, *p;
700 sd->info->use_theme_bg = 0;
701 sd->info->bg_file = strdup(it->file);
702 edje_object_file_set(sd->info->mini, sd->info->bg_file,
703 "e/desktop/background");
704 p = strrchr(sd->info->bg_file, '/');
709 p = strrchr(name, '.');
712 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
713 if (name) free(name);
717 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
718 "e/desktop/background");
720 edje_object_file_set(sd->info->mini, f, "e/desktop/background");
721 sd->info->use_theme_bg = 1;
722 sd->info->bg_file = NULL;
723 edje_object_part_text_set(sd->info->bg, "e.text.filename",
724 _("Theme Wallpaper"));
726 evas_object_show(sd->info->mini);
728 if (sd->seltimer) ecore_timer_del(sd->seltimer);
729 sd->seltimer = ecore_timer_add(0.2, _sel_timer, obj);
733 _pan_sel_up(Evas_Object *obj)
735 Smart_Data *sd = evas_object_smart_data_get(obj);
737 if (sd->selmove == 0.0) return;
740 sd->seltime = ecore_loop_time_get();
741 sd->animator = ecore_animator_add(_sel_anim, obj);
742 sd->selin = EINA_TRUE;
746 if (sd->selin) return;
747 sd->selout = EINA_TRUE;
752 _sort_cb(const void *d1, const void *d2)
754 const Item *it1 = d1, *it2 = d2;
756 if ((!it1->sort_id) || (!it2->sort_id)) return 0;
757 return strcmp(it1->sort_id, it2->sort_id);
763 Evas_Object *obj = it->obj;
764 Smart_Data *sd = evas_object_smart_data_get(obj);
769 num = eina_list_count(sd->items);
770 // if (sd->sort_num < sd->id_num)
772 // sd->sort_num = sd->id_num + 10;
775 if ((sd->id_num == num) || (dosort))
777 sd->items = eina_list_sort(sd->items, num, _sort_cb);
778 _e_smart_reconfigure_do(obj);
784 EINA_LIST_FOREACH(sd->items, l, it2)
786 if (it2->hilighted) break;
790 e_scrollframe_child_region_show(sd->info->sframe,
791 it2->x, it2->y, it2->w, it2->h);
795 if (sd->info->scans == 0)
796 edje_object_signal_emit(sd->info->bg, "e,state,busy,off", "e");
800 _thumb_gen(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
804 edje_object_signal_emit(it->frame, "e,action,thumb,gen", "e");
807 const char *id = e_thumb_sort_id_get(it->image);
811 it->sort_id = strdup(id);
815 it->have_thumb = EINA_TRUE;
820 e_thumb_icon_end(it->image);
821 it->do_thumb = EINA_FALSE;
823 evas_object_del(it->image);
825 evas_object_del(it->frame);
831 _item_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
833 // Evas_Event_Mouse_Down *ev = event_info;
835 // _pan_sel(it->obj, it);
839 _item_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
841 Evas_Event_Mouse_Up *ev = event_info;
846 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
848 _pan_hilight(it->obj, it);
849 _pan_sel(it->obj, it);
850 // FIXME: select image!!!
856 _pan_file_add(Evas_Object *obj, const char *file, Eina_Bool remote, Eina_Bool theme)
858 Smart_Data *sd = evas_object_smart_data_get(obj);
859 Item *it = calloc(1, sizeof(Item));
863 evas = evas_object_evas_get(obj);
864 sd->items = eina_list_append(sd->items, it);
868 it->file = eina_stringshare_add(file);
869 it->frame = edje_object_add(evas);
871 e_theme_edje_object_set(it->frame, "base/theme/widgets",
872 "e/conf/wallpaper/main/mini-theme");
874 e_theme_edje_object_set(it->frame, "base/theme/widgets",
875 "e/conf/wallpaper/main/mini-remote");
877 e_theme_edje_object_set(it->frame, "base/theme/widgets",
878 "e/conf/wallpaper/main/mini");
881 edje_object_signal_emit(it->frame, "e,state,selected", "e");
882 evas_object_raise(it->frame);
884 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_DOWN,
886 evas_object_event_callback_add(it->frame, EVAS_CALLBACK_MOUSE_UP,
889 evas_object_smart_member_add(it->frame, obj);
890 evas_object_clip_set(it->frame, evas_object_clip_get(obj));
891 evas_object_show(it->frame);
892 it->image = e_thumb_icon_add(evas);
893 edje_object_part_swallow(it->frame, "e.swallow.content", it->image);
894 evas_object_smart_callback_add(it->image, "e_thumb_gen", _thumb_gen, it);
897 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
898 "e/desktop/background");
900 e_thumb_icon_file_set(it->image, f, "e/desktop/background");
903 e_thumb_icon_file_set(it->image, it->file, "e/desktop/background");
904 e_thumb_icon_size_set(it->image, sd->info->iw, sd->info->ih);
905 evas_object_show(it->image);
907 e_thumb_icon_begin(it->image);
909 // e_thumb_icon_begin(it->image);
913 if (sd->info->use_theme_bg)
915 _pan_hilight(it->obj, it);
916 edje_object_part_text_set(sd->info->bg, "e.text.filename",
917 _("Theme Wallpaper"));
922 if (sd->info->bg_file)
926 if (!strcmp(sd->info->bg_file, it->file)) match = 1;
931 p1 = ecore_file_file_get(sd->info->bg_file);
932 p2 = ecore_file_file_get(it->file);
933 if (!strcmp(p1, p2)) match = 1;
937 char *name = NULL, *p;
940 _pan_hilight(it->obj, it);
941 p = strrchr(sd->info->bg_file, '/');
946 p = strrchr(name, '.');
949 edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
950 if (name) free(name);
954 _e_smart_reconfigure(obj);
962 Info *info = wn->data;
964 evas_object_resize(info->bg, wn->w, wn->h);
968 _delete(E_Win *wn __UNUSED__)
974 _bg_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
978 _pan_sel_up(info->span);
982 _apply(void *data, void *data2 __UNUSED__)
989 while (e_config->desktop_backgrounds)
991 E_Config_Desktop_Background *cfbg;
993 cfbg = e_config->desktop_backgrounds->data;
994 e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
996 if ((info->use_theme_bg) || (!info->bg_file))
997 e_bg_default_set(NULL);
999 e_bg_default_set(info->bg_file);
1001 else if (info->mode == 1)
1004 e_bg_del(info->con_num, info->zone_num, info->desk_x, info->desk_y);
1005 e_bg_add(info->con_num, info->zone_num, info->desk_x, info->desk_y,
1010 Eina_List *dlist = NULL, *l;
1011 E_Config_Desktop_Background *cfbg;
1014 EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
1016 if (cfbg->zone == info->zone_num)
1017 dlist = eina_list_append(dlist, cfbg);
1019 EINA_LIST_FREE(dlist, cfbg)
1020 e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
1021 e_bg_add(info->con_num, info->zone_num, -1, -1, info->bg_file);
1024 e_config_save_queue();
1028 _close(void *data __UNUSED__, void *data2 __UNUSED__)
1034 _ok(void *data, void *data2 __UNUSED__)
1036 _apply(data, data2);
1041 _wp_add(void *data, void *data2 __UNUSED__)
1045 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1049 _wp_delete(void *data, void *data2 __UNUSED__)
1053 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1057 _wp_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1061 edje_object_signal_emit(info->bg, "e,action,panel,hide", "e");
1067 Eina_File_Direct_Info *st;
1073 return ECORE_CALLBACK_CANCEL;
1075 if (!eina_iterator_next(info->dir, (void**) &st))
1078 info->curdir = NULL;
1079 eina_iterator_free(info->dir);
1083 return ECORE_CALLBACK_CANCEL;
1085 if ((st->path[st->name_start]) == '.')
1086 return ECORE_CALLBACK_RENEW;
1087 if (st->type == EINA_FILE_DIR)
1089 info->dirs = eina_list_append(info->dirs, strdup(st->path));
1090 return ECORE_CALLBACK_RENEW;
1093 _pan_file_add(info->span, st->path, 0, 0);
1096 return ECORE_CALLBACK_RENEW;
1104 if (info->scans <= 0)
1107 edje_object_signal_emit(info->bg, "e,state,busy,on", "e");
1108 edje_object_part_text_set(info->bg, "e.text.busy_label",
1109 _("Loading files..."));
1111 if (info->curdir) free(info->curdir);
1112 info->curdir = info->dirs->data;
1113 info->dirs = eina_list_remove_list(info->dirs, info->dirs);
1114 if (!info->dir) info->dir = eina_file_stat_ls(info->curdir);
1115 info->idler = ecore_idler_add(_idler, info);
1120 wp_browser_new(E_Container *con)
1126 const E_Config_Desktop_Background *cfbg;
1128 Evas_Object *o, *o2, *ob;
1132 info = calloc(1, sizeof(Info));
1133 if (!info) return NULL;
1135 zone = e_util_zone_current_get(con->manager);
1136 desk = e_desk_current_get(zone);
1137 info->con_num = con->num;
1138 info->zone_num = zone->num;
1139 info->desk_x = desk->x;
1140 info->desk_y = desk->y;
1142 cfbg = e_bg_config_get(con->num, zone->num, desk->x, desk->y);
1145 if ((cfbg->container >= 0) && (cfbg->zone >= 0))
1147 if ((cfbg->desk_x >= 0) && (cfbg->desk_y >= 0))
1152 info->bg_file = strdup(cfbg->file);
1154 if ((!info->bg_file) && (e_config->desktop_default_background))
1155 info->bg_file = strdup(e_config->desktop_default_background);
1157 info->use_theme_bg = 1;
1159 info->iw = (120 * e_scale);
1160 info->ih = (zone->h * info->iw) / (zone->w);
1162 win = e_win_new(con);
1172 e_user_dir_concat_static(buf, "backgrounds");
1173 info->dirs = eina_list_append(info->dirs, strdup(buf));
1174 e_prefix_data_concat_static(buf, "data/backgrounds");
1175 info->dirs = eina_list_append(info->dirs, strdup(buf));
1177 e_win_title_set(win, _("Wallpaper Settings"));
1178 e_win_name_class_set(win, "E", "_config::appearance/wallpaper2");
1179 e_win_resize_callback_set(win, _resize);
1180 e_win_delete_callback_set(win, _delete);
1183 info->bg = edje_object_add(info->win->evas);
1184 e_theme_edje_object_set(info->bg, "base/theme/widgets",
1185 "e/conf/wallpaper/main/window");
1186 edje_object_signal_callback_add(info->bg, "e,action,click", "e",
1189 info->box = e_widget_list_add(info->win->evas, 1, 1);
1192 info->button = e_widget_button_add(info->win->evas, _("OK"), NULL,
1194 evas_object_show(info->button);
1195 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1198 info->button = e_widget_button_add(info->win->evas, _("Apply"), NULL,
1199 _apply, info, NULL);
1200 evas_object_show(info->button);
1201 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1204 info->button = e_widget_button_add(info->win->evas, _("Close"), NULL,
1205 _close, info, NULL);
1206 evas_object_show(info->button);
1207 e_widget_list_object_append(info->box, info->button, 1, 0, 0.5);
1209 e_widget_size_min_get(info->box, &mw, &mh);
1210 edje_extern_object_min_size_set(info->box, mw, mh);
1211 edje_object_part_swallow(info->bg, "e.swallow.buttons", info->box);
1212 evas_object_show(info->box);
1215 info->preview = e_livethumb_add(info->win->evas);
1216 e_livethumb_vsize_set(info->preview, zone->w, zone->h);
1217 edje_extern_object_aspect_set(info->preview, EDJE_ASPECT_CONTROL_NEITHER,
1219 edje_object_part_swallow(info->bg, "e.swallow.preview", info->preview);
1220 evas_object_show(info->preview);
1222 info->mini = edje_object_add(e_livethumb_evas_get(info->preview));
1223 e_livethumb_thumb_set(info->preview, info->mini);
1224 evas_object_show(info->mini);
1226 edje_object_file_set(info->mini, info->bg_file, "e/desktop/background");
1229 const char *f = e_theme_edje_file_get("base/theme/backgrounds",
1230 "e/desktop/background");
1232 edje_object_file_set(info->mini, f, "e/desktop/background");
1236 info->span = _pan_add(info->win->evas);
1237 _pan_info_set(info->span, info);
1239 // the scrollframe holding the scrolled thumbs
1240 info->sframe = e_scrollframe_add(info->win->evas);
1241 e_scrollframe_custom_theme_set(info->sframe, "base/theme/widgets",
1242 "e/conf/wallpaper/main/scrollframe");
1243 e_scrollframe_extern_pan_set(info->sframe, info->span,
1244 _pan_set, _pan_get, _pan_max_get,
1245 _pan_child_size_get);
1246 edje_object_part_swallow(info->bg, "e.swallow.list", info->sframe);
1247 evas_object_show(info->sframe);
1248 evas_object_show(info->span);
1250 ob = e_widget_list_add(info->win->evas, 0, 1);
1252 o = e_widget_list_add(info->win->evas, 1, 0);
1254 rg = e_widget_radio_group_new(&(info->mode));
1255 o2 = e_widget_radio_add(info->win->evas, _("All Desktops"), 0, rg);
1256 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1257 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1258 e_widget_disabled_set(o2, (e_util_container_desk_count_get(con) < 2));
1259 evas_object_show(o2);
1261 o2 = e_widget_radio_add(info->win->evas, _("This Desktop"), 1, rg);
1262 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1263 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1264 evas_object_show(o2);
1266 o2 = e_widget_radio_add(info->win->evas, _("This Screen"), 2, rg);
1267 evas_object_smart_callback_add(o2, "changed", _wp_changed, info);
1268 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1269 if (!(e_util_container_zone_number_get(0, 1) ||
1270 (e_util_container_zone_number_get(1, 0))))
1271 e_widget_disabled_set(o2, EINA_TRUE);
1272 evas_object_show(o2);
1274 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1275 evas_object_show(o);
1277 o = e_widget_list_add(info->win->evas, 1, 0);
1279 o2 = e_widget_button_add(info->win->evas, _("Add"), NULL,
1280 _wp_add, info, NULL);
1281 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1282 evas_object_show(o2);
1284 o2 = e_widget_button_add(info->win->evas, _("Delete"), NULL,
1285 _wp_delete, info, NULL);
1286 e_widget_list_object_append(o, o2, 1, 0, 0.5);
1287 evas_object_show(o2);
1289 e_widget_list_object_append(ob, o, 1, 0, 0.5);
1290 evas_object_show(o);
1292 e_widget_size_min_get(ob, &mw, &mh);
1293 edje_extern_object_min_size_set(ob, mw, mh);
1294 edje_object_part_swallow(info->bg, "e.swallow.extras", ob);
1295 evas_object_show(ob);
1298 edje_object_size_min_calc(info->bg, &mw, &mh);
1299 e_win_size_min_set(win, mw, mh);
1300 if ((zone->w / 4) > mw) mw = (zone->w / 4);
1301 if ((zone->h / 4) > mh) mh = (zone->h / 4);
1302 e_win_resize(win, mw, mh);
1303 e_win_centered_set(win, 1);
1305 e_win_border_icon_set(win, "preferences-desktop-wallpaper");
1307 evas_object_resize(info->bg, info->win->w, info->win->h);
1308 evas_object_show(info->bg);
1311 _pan_file_add(info->span, NULL, 0, 1);
1318 wp_broser_free(Info *info)
1323 e_object_del(E_OBJECT(info->win));
1324 if (info->dir) eina_iterator_free(info->dir);
1325 free(info->bg_file);
1327 EINA_LIST_FREE(info->dirs, s)
1329 if (info->idler) ecore_idler_del(info->idler);
1336 wp_conf_show(E_Container *con, const char *params __UNUSED__)
1340 e_win_show(global_info->win);
1341 e_win_raise(global_info->win);
1343 global_info = wp_browser_new(con);
1353 wp_broser_free(global_info);