1 #include "e_mod_main.h"
2
3 static Evas_Object *o_img = NULL;
4
5 Evas_Object *win = NULL;
6 int quality = 90;
7 Eina_Rectangle crop = { 0, 0, 0, 0 };
8
9 static void
_win_save_cb(void * data EINA_UNUSED,void * data2 EINA_UNUSED)10 _win_save_cb(void *data EINA_UNUSED, void *data2 EINA_UNUSED)
11 {
12 save_show();
13 }
14
15 static void
_win_share_cb(void * d EINA_UNUSED,void * d2 EINA_UNUSED)16 _win_share_cb(void *d EINA_UNUSED, void *d2 EINA_UNUSED)
17 {
18 share_confirm();
19 }
20
21 static void
_win_delay_cb(void * d EINA_UNUSED,void * d2 EINA_UNUSED)22 _win_delay_cb(void *d EINA_UNUSED, void *d2 EINA_UNUSED)
23 {
24 E_FREE_FUNC(win, evas_object_del);
25 win_delay();
26 }
27
28 static void
_win_cancel_cb(void * data EINA_UNUSED,void * data2 EINA_UNUSED)29 _win_cancel_cb(void *data EINA_UNUSED, void *data2 EINA_UNUSED)
30 {
31 E_FREE_FUNC(win, evas_object_del);
32 }
33
34 static void
_win_delete_cb(void * data EINA_UNUSED,Evas * e EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event EINA_UNUSED)35 _win_delete_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
36 {
37 win = NULL;
38 }
39
40 static void
_quality_change_cb(void * data EINA_UNUSED,Evas_Object * obj,void * event_info EINA_UNUSED)41 _quality_change_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
42 {
43 quality = elm_slider_value_get(obj);
44 }
45
46 void
preview_dialog_show(E_Zone * zone,E_Client * ec,const char * params,void * dst,int sx,int sy,int sw,int sh)47 preview_dialog_show(E_Zone *zone, E_Client *ec, const char *params, void *dst,
48 int sx, int sy, int sw, int sh)
49 {
50 Evas *evas;
51 Evas_Object *o, *o_bg, *o_box, *o_sl;
52 Evas_Object *o_bx;
53 int w, h;
54 char smode[128], squal[128], sscreen[128];
55
56 win = o = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
57 evas = evas_object_evas_get(o);
58 elm_win_title_set(o, _("Select action to take with screenshot"));
59 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _win_delete_cb, NULL);
60 ecore_evas_name_class_set(e_win_ee_get(o), "E", "_shot_dialog");
61
62 o_bg = o = elm_layout_add(e_win_evas_win_get(evas));
63 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
64 elm_win_resize_object_add(win, o);
65 e_theme_edje_object_set(o, "base/theme/dialog", "e/widgets/dialog/main");
66 evas_object_show(o);
67
68 o_bx = o = ui_edit(win, o_bg, zone, ec, dst, sx, sy, sw, sh, &o_img);
69
70 o_sl = o = elm_slider_add(win);
71 elm_object_text_set(o, _("Quality"));
72 elm_slider_indicator_show_set(o, EINA_FALSE);
73 elm_slider_unit_format_set(o, "%1.0f%%");
74 elm_slider_min_max_set(o, 10, 100);
75 elm_slider_step_set(o, 5);
76 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 1.0);
77 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
78 elm_box_pack_end(o_bx, o);
79 evas_object_show(o);
80 evas_object_smart_callback_add(o, "delay,changed", _quality_change_cb, NULL);
81
82 ///////////////////////////////////////////////////////////////////////
83
84 o_box = o = e_widget_list_add(evas, 1, 1);
85 elm_object_part_content_set(o_bg, "e.swallow.buttons", o);
86
87 o = e_widget_button_add(evas, _("Save"), NULL, _win_save_cb, win, NULL);
88 e_widget_list_object_append(o_box, o, 1, 0, 0.5);
89 o = e_widget_button_add(evas, _("Share"), NULL, _win_share_cb, win, NULL);
90 e_widget_list_object_append(o_box, o, 1, 0, 0.5);
91 if (!ec)
92 {
93 o = e_widget_button_add(evas, _("Delay"), NULL, _win_delay_cb, win, NULL);
94 e_widget_list_object_append(o_box, o, 1, 0, 0.5);
95 }
96 o = e_widget_button_add(evas, _("Cancel"), NULL, _win_cancel_cb, win, NULL);
97 e_widget_list_object_append(o_box, o, 1, 0, 0.5);
98
99 o = o_box;
100 e_widget_size_min_get(o, &w, &h);
101 evas_object_size_hint_min_set(o, w, h);
102 elm_object_part_content_set(o_bg, "e.swallow.buttons", o);
103 evas_object_size_hint_min_get(o_bg, &w, &h);
104 evas_object_resize(win, w, h);
105 evas_object_size_hint_min_set(win, w, h);
106 evas_object_size_hint_max_set(win, 99999, 99999);
107
108 ///////////////////////////////////////////////////////////////////////
109
110 crop.x = crop.y = crop.w = crop.h = 0;
111
112 if ((params) &&
113 (sscanf(params, "%100s %100s %100s", smode, squal, sscreen) == 3))
114 {
115 if ((zone) && (!strcmp(sscreen, "current")))
116 {
117 E_Zone *z = e_zone_current_get();
118 ui_edit_crop_screen_set(z->x, z->y, z->w, z->h);
119 }
120 else if (!strcmp(sscreen, "all"))
121 {
122 }
123 else
124 {
125 E_Zone *z = eina_list_nth(e_comp->zones, atoi(sscreen));
126 if (z) ui_edit_crop_screen_set(z->x, z->y, z->w, z->h);
127 }
128 quality = 90;
129 if (!strcmp(squal, "perfect")) quality = 100;
130 else if (!strcmp(squal, "high")) quality = 90;
131 else if (!strcmp(squal, "medium")) quality = 70;
132 else if (!strcmp(squal, "low")) quality = 50;
133 else quality = atoi(squal);
134
135 elm_slider_value_set(o_sl, quality);
136 if (!strcmp(smode, "save")) _win_save_cb(NULL, NULL);
137 else if (!strcmp(smode, "share")) _win_share_cb(NULL, NULL);
138 }
139 else
140 {
141 elm_slider_value_set(o_sl, quality);
142 elm_win_center(win, 1, 1);
143 evas_object_show(win);
144 e_win_client_icon_set(win, "screenshot");
145 if (!e_widget_focus_get(o_bg)) e_widget_focus_set(o_box, 1);
146 if (ec)
147 {
148 E_Client *c = e_win_client_get(win);
149 if (c) evas_object_layer_set(c->frame, ec->layer);
150 }
151 }
152 }
153
154 Eina_Bool
preview_have(void)155 preview_have(void)
156 {
157 if (win) return EINA_TRUE;
158 else return EINA_FALSE;
159 }
160
161 void
preview_abort(void)162 preview_abort(void)
163 {
164 E_FREE_FUNC(win, evas_object_del);
165 }
166
167 Evas_Object *
preview_image_get(void)168 preview_image_get(void)
169 {
170 return o_img;
171 }
172