summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannes Janetzek <hannes.janetzek@gmail.com>2011-03-17 17:24:53 +0000
committerHannes Janetzek <hannes.janetzek@gmail.com>2011-03-17 17:24:53 +0000
commit209296a683359009ac027c0eeebfddcd2cb0bf90 (patch)
tree2a2f8bfa4c01522a23327ffea6fc8d19eaddd1fc
parent24b9b99d3f571415f050cc21b940cb8425c2c250 (diff)
e-modules: update do e_gadcon_util_cliet_menu_append api changes. allowing to have settings menu in toplevel again
SVN revision: 57828
-rw-r--r--src/photo_menu.c225
-rw-r--r--src/photo_picture_histo.c175
-rw-r--r--src/photo_picture_histo.h2
3 files changed, 197 insertions, 205 deletions
diff --git a/src/photo_menu.c b/src/photo_menu.c
index 8853c04..8ca8a0e 100644
--- a/src/photo_menu.c
+++ b/src/photo_menu.c
@@ -9,7 +9,21 @@ static void _cb_picture_viewer(void *data, E_Menu *m, E_Menu_Item *mi);
9static void _cb_pause_toggle(void *data, E_Menu *m, E_Menu_Item *mi); 9static void _cb_pause_toggle(void *data, E_Menu *m, E_Menu_Item *mi);
10static void _cb_configure_item(void *data, E_Menu *m, E_Menu_Item *mi); 10static void _cb_configure_item(void *data, E_Menu *m, E_Menu_Item *mi);
11static void _cb_configure_general(void *data, E_Menu *m, E_Menu_Item *mi); 11static void _cb_configure_general(void *data, E_Menu *m, E_Menu_Item *mi);
12static void _cb_hist_menu_populate(void *data, E_Menu *m, E_Menu_Item *mi);
13static void _cb_hist_menu_activate(void *data, E_Menu *m, E_Menu_Item *mi);
14static void _cb_hist_menu_populate(void *data, E_Menu *m, E_Menu_Item *mi);
15static void _cb_hist_menu_activate(void *data, E_Menu *m, E_Menu_Item *mi);
16static void _cb_hist_menu_select(void *data, E_Menu *m, E_Menu_Item *mi);
17static void _cb_hist_menu_pre_select(void *data, Evas *evas, Evas_Object *obj, void *event_info);
18static void _cb_hist_menu_post_select(void *data, Evas *evas, Evas_Object *obj, void *event_info);
19static void _cb_hist_menu_deactivate_post(void *data, E_Menu *m);
20static void _cb_popi_close(void *data);
21
22void photo_picture_histo_menu_append(Photo_Item *pi, E_Menu *mn_main)
23{
24 E_Menu_Item *mi;
12 25
26}
13 27
14/* 28/*
15 * Public functions 29 * Public functions
@@ -17,69 +31,73 @@ static void _cb_configure_general(void *data, E_Menu *m, E_Menu_Item *mi);
17 31
18int photo_menu_show(Photo_Item *pi) 32int photo_menu_show(Photo_Item *pi)
19{ 33{
20 E_Menu *ma, *mg; 34 E_Menu *m;
21 E_Menu_Item *mi; 35 E_Menu_Item *mi;
22 char buf[4096]; 36 char buf[4096];
23 37
24 ma = e_menu_new(); 38 m = e_menu_new();
25 e_menu_post_deactivate_callback_set(ma, _cb_deactivate_post, pi); 39
26 pi->menu = ma; 40 mi = e_menu_item_new(m);
41 e_menu_item_label_set(mi, D_("Module Settings"));
42 e_util_menu_item_theme_icon_set(mi, "preferences-system");
43 e_menu_item_callback_set(mi, _cb_configure_general, NULL);
44 mi = e_menu_item_new(m);
45 e_menu_item_separator_set(mi, 1);
46 mi = e_menu_item_new(m);
47 e_menu_item_label_set(mi, D_("Settings"));
48 e_util_menu_item_theme_icon_set(mi, "preferences-system");
49 e_menu_item_callback_set(mi, _cb_configure_item, pi);
50
51 m = e_gadcon_client_util_menu_items_append(pi->gcc, m, 0);
52 e_menu_post_deactivate_callback_set(m, _cb_deactivate_post, pi);
53 pi->menu = m;
27 54
28 mi = e_menu_item_new(ma); 55 mi = e_menu_item_new_relative(m, NULL);
29 if (pi->config->timer_active) 56 if (pi->config->timer_active)
30 { 57 {
31 e_menu_item_label_set(mi, D_("Pause slideshow")); 58 e_menu_item_label_set(mi, D_("Pause slideshow"));
32 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_PAUSE); 59 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_PAUSE);
33 } 60 }
34 else 61 else
35 { 62 {
36 e_menu_item_label_set(mi, D_("Resume slideshow")); 63 e_menu_item_label_set(mi, D_("Resume slideshow"));
37 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_RESUME); 64 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_RESUME);
38 } 65 }
39 e_menu_item_callback_set(mi, _cb_pause_toggle, pi); 66 e_menu_item_callback_set(mi, _cb_pause_toggle, pi);
40 mi = e_menu_item_new(ma); 67 mi = e_menu_item_new_relative(m, mi);
41 e_menu_item_label_set(mi, D_("Next picture")); 68 e_menu_item_label_set(mi, D_("Next picture"));
42 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_NEXT); 69 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_NEXT);
43 e_menu_item_callback_set(mi, _cb_picture_next, pi); 70 e_menu_item_callback_set(mi, _cb_picture_next, pi);
44 mi = e_menu_item_new(ma); 71 mi = e_menu_item_new_relative(m, mi);
45 e_menu_item_label_set(mi, D_("Previous picture")); 72 e_menu_item_label_set(mi, D_("Previous picture"));
46 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_PREVIOUS); 73 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_PREVIOUS);
47 e_menu_item_callback_set(mi, _cb_picture_prev, pi); 74 e_menu_item_callback_set(mi, _cb_picture_prev, pi);
48 75
49 photo_picture_histo_menu_append(pi, ma);
50 76
51 mi = e_menu_item_new(ma); 77 mi = e_menu_item_new_relative(m, mi);
78 e_menu_item_label_set(mi, D_("Historic"));
79 e_menu_item_submenu_pre_callback_set(mi,
80 _cb_hist_menu_populate, pi);
81 e_menu_item_submenu_post_callback_set(mi,
82 _cb_hist_menu_activate, pi);
83
84 mi = e_menu_item_new_relative(m, mi);
52 e_menu_item_separator_set(mi, 1); 85 e_menu_item_separator_set(mi, 1);
53 86
54 mi = e_menu_item_new(ma); 87 mi = e_menu_item_new_relative(m, mi);
55 e_menu_item_label_set(mi, D_("Picture informations")); 88 e_menu_item_label_set(mi, D_("Picture informations"));
56 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_INFOS); 89 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_INFOS);
57 e_menu_item_callback_set(mi, _cb_picture_info, pi); 90 e_menu_item_callback_set(mi, _cb_picture_info, pi);
58 mi = e_menu_item_new(ma); 91 mi = e_menu_item_new_relative(m, mi);
59 e_menu_item_label_set(mi, D_("Set as background")); 92 e_menu_item_label_set(mi, D_("Set as background"));
60 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_SETBG); 93 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_SETBG);
61 e_menu_item_callback_set(mi, _cb_picture_setbg, pi); 94 e_menu_item_callback_set(mi, _cb_picture_setbg, pi);
62 mi = e_menu_item_new(ma); 95 mi = e_menu_item_new_relative(m, mi);
63 snprintf(buf, sizeof(buf), "%s %s", D_("Open in"), photo->config->pictures_viewer); 96 snprintf(buf, sizeof(buf), "%s %s", D_("Open in"), photo->config->pictures_viewer);
64 e_menu_item_label_set(mi, buf); 97 e_menu_item_label_set(mi, buf);
65 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_VIEWER); 98 photo_util_menu_icon_set(mi, PHOTO_THEME_ICON_VIEWER);
66 e_menu_item_callback_set(mi, _cb_picture_viewer, pi); 99 e_menu_item_callback_set(mi, _cb_picture_viewer, pi);
67 100
68 mg = e_menu_new();
69
70 mi = e_menu_item_new(mg);
71 e_menu_item_label_set(mi, D_("Module Settings"));
72 e_util_menu_item_theme_icon_set(mi, "preferences-system");
73 e_menu_item_callback_set(mi, _cb_configure_general, NULL);
74 mi = e_menu_item_new(mg);
75 e_menu_item_separator_set(mi, 1);
76 mi = e_menu_item_new(mg);
77 e_menu_item_label_set(mi, D_("Settings"));
78 e_util_menu_item_theme_icon_set(mi, "preferences-system");
79 e_menu_item_callback_set(mi, _cb_configure_item, pi);
80
81 e_gadcon_client_util_menu_items_append(pi->gcc, ma, mg, 0);
82
83 return 1; 101 return 1;
84} 102}
85 103
@@ -196,3 +214,152 @@ _cb_configure_general(void *data, E_Menu *m, E_Menu_Item *mi)
196 214
197 photo_config_dialog_show(); 215 photo_config_dialog_show();
198} 216}
217
218static void
219_cb_hist_menu_select(void *data, E_Menu *m, E_Menu_Item *mi)
220{
221 Photo_Item *pi;
222 int no;
223
224 pi = data;
225
226 no = e_menu_item_num_get(mi);
227 photo_item_action_change(pi,
228 pi->histo.pos -
229 (eina_list_count(pi->histo.list) - (no+1)));
230 photo_item_timer_set(pi, pi->config->timer_active, 0);
231}
232
233static void
234_cb_hist_menu_pre_select(void *data, Evas *evas, Evas_Object *obj, void *event_info)
235{
236 E_Menu_Item *mi;
237 Photo_Item *pi;
238 Picture *p;
239 char *text;
240 int number;
241
242 mi = data;
243 if (!mi) return;
244 pi = mi->cb.data;
245 if (!pi) return;
246
247 number = (eina_list_count(pi->histo.list) - (e_menu_item_num_get(mi)+1));
248
249 DPIC(("Histo menu : Select %d in histo list", number));
250
251 p = eina_list_nth(pi->histo.list, number);
252 if (!p) return;
253
254 text = photo_picture_infos_get(p);
255
256 if (pi->histo.popi)
257 photo_popup_info_del(pi->histo.popi);
258
259 pi->histo.popi = photo_popup_info_add(pi, p->infos.name, text, p,
260 PICTURE_HISTO_POPUP_TIMER,
261 POPUP_INFO_PLACEMENT_CENTERED,
262 _cb_popi_close, NULL);
263
264 free(text);
265}
266
267static void
268_cb_hist_menu_post_select(void *data, Evas *evas, Evas_Object *obj, void *event_info)
269{
270 E_Menu_Item *mi;
271 Photo_Item *pi;
272
273 mi = data;
274 if (!mi) return;
275 pi = mi->cb.data;
276 if (!pi) return;
277
278 DPIC(("Histo menu : Post select callback"));
279
280 if (pi->histo.popi)
281 photo_popup_info_del(pi->histo.popi);
282 pi->histo.popi = NULL;
283}
284
285static void
286_cb_hist_menu_deactivate_post(void *data, E_Menu *m)
287{
288 Photo_Item *pi;
289
290 pi = data;
291 pi->menu_histo = NULL;
292
293 DD(("deactivate cb post"));
294
295 e_object_del(E_OBJECT(m));
296}
297
298static void
299_cb_hist_menu_populate(void *data, E_Menu *m, E_Menu_Item *mi)
300{
301 Photo_Item *pi;
302 E_Menu *mn;
303 Picture *p;
304 int pos;
305
306 pi = data;
307
308 mn = e_menu_new();
309 pi->menu_histo = mn;
310 e_menu_post_deactivate_callback_set(mn, _cb_hist_menu_deactivate_post, pi);
311 e_menu_item_submenu_set(mi, mn);
312
313 pos = eina_list_count(pi->histo.list) - 1;
314 while ( (p=eina_list_nth(pi->histo.list, pos)) )
315 {
316 mi = e_menu_item_new(mn);
317 e_menu_item_label_set(mi, p->infos.name);
318 e_menu_item_radio_group_set(mi, 1);
319 e_menu_item_radio_set(mi, 1);
320 if (pi->histo.pos == pos)
321 e_menu_item_toggle_set(mi, 1);
322
323 e_menu_item_callback_set(mi, _cb_hist_menu_select, pi);
324 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_IN,
325 _cb_hist_menu_pre_select, mi);
326 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_OUT,
327 _cb_hist_menu_post_select, mi);
328
329 pos--;
330 }
331}
332
333static void
334_cb_hist_menu_activate(void *data, E_Menu *m, E_Menu_Item *mi)
335{
336 Photo_Item *pi;
337 E_Menu *mn;
338 Eina_List *l;
339
340 pi = data;
341 mn = pi->menu_histo;
342
343 if (!mn) return;
344
345 for (l=mn->items; l; l=eina_list_next(l))
346 {
347 E_Menu_Item *mi;
348
349 mi = eina_list_data_get(l);
350 if (!mi || mi->separator) continue;
351 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_IN,
352 _cb_hist_menu_pre_select, mi);
353 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_OUT,
354 _cb_hist_menu_post_select, mi);
355 }
356}
357
358static void
359_cb_popi_close(void *data)
360{
361 Photo_Item *pi;
362
363 pi = data;
364 pi->histo.popi = NULL;
365}
diff --git a/src/photo_picture_histo.c b/src/photo_picture_histo.c
index 22be225..d5916ed 100644
--- a/src/photo_picture_histo.c
+++ b/src/photo_picture_histo.c
@@ -1,12 +1,6 @@
1#include "Photo.h" 1#include "Photo.h"
2 2
3static void _cb_menu_populate(void *data, E_Menu *m, E_Menu_Item *mi); 3
4static void _cb_menu_activate(void *data, E_Menu *m, E_Menu_Item *mi);
5static void _cb_menu_select(void *data, E_Menu *m, E_Menu_Item *mi);
6static void _cb_menu_pre_select(void *data, Evas *evas, Evas_Object *obj, void *event_info);
7static void _cb_menu_post_select(void *data, Evas *evas, Evas_Object *obj, void *event_info);
8static void _cb_menu_deactivate_post(void *data, E_Menu *m);
9static void _cb_popi_close(void *data);
10 4
11/* 5/*
12 * Public functions 6 * Public functions
@@ -112,170 +106,3 @@ void photo_picture_histo_picture_del(Picture *picture)
112 106
113 eina_list_free(picture->items_histo); 107 eina_list_free(picture->items_histo);
114} 108}
115
116void photo_picture_histo_menu_append(Photo_Item *pi, E_Menu *mn_main)
117{
118 E_Menu_Item *mi;
119
120 mi = e_menu_item_new(mn_main);
121 e_menu_item_label_set(mi, D_("Historic"));
122 e_menu_item_submenu_pre_callback_set(mi,
123 _cb_menu_populate, pi);
124 e_menu_item_submenu_post_callback_set(mi,
125 _cb_menu_activate, pi);
126}
127
128
129/*
130 * Private functions
131 *
132 */
133
134static void
135_cb_menu_populate(void *data, E_Menu *m, E_Menu_Item *mi)
136{
137 Photo_Item *pi;
138 E_Menu *mn;
139 Picture *p;
140 int pos;
141
142 pi = data;
143
144 mn = e_menu_new();
145 pi->menu_histo = mn;
146 e_menu_post_deactivate_callback_set(mn, _cb_menu_deactivate_post, pi);
147 e_menu_item_submenu_set(mi, mn);
148
149 pos = eina_list_count(pi->histo.list) - 1;
150 while ( (p=eina_list_nth(pi->histo.list, pos)) )
151 {
152 mi = e_menu_item_new(mn);
153 e_menu_item_label_set(mi, p->infos.name);
154 e_menu_item_radio_group_set(mi, 1);
155 e_menu_item_radio_set(mi, 1);
156 if (pi->histo.pos == pos)
157 e_menu_item_toggle_set(mi, 1);
158
159 e_menu_item_callback_set(mi, _cb_menu_select, pi);
160 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_IN,
161 _cb_menu_pre_select, mi);
162 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_OUT,
163 _cb_menu_post_select, mi);
164
165 pos--;
166 }
167}
168
169static void
170_cb_menu_activate(void *data, E_Menu *m, E_Menu_Item *mi)
171{
172 Photo_Item *pi;
173 E_Menu *mn;
174 Eina_List *l;
175
176 pi = data;
177 mn = pi->menu_histo;
178
179 if (!mn) return;
180
181 for (l=mn->items; l; l=eina_list_next(l))
182 {
183 E_Menu_Item *mi;
184
185 mi = eina_list_data_get(l);
186 if (!mi || mi->separator) continue;
187 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_IN,
188 _cb_menu_pre_select, mi);
189 evas_object_event_callback_add(mi->event_object, EVAS_CALLBACK_MOUSE_OUT,
190 _cb_menu_post_select, mi);
191 }
192}
193
194static void
195_cb_menu_select(void *data, E_Menu *m, E_Menu_Item *mi)
196{
197 Photo_Item *pi;
198 int no;
199
200 pi = data;
201
202 no = e_menu_item_num_get(mi);
203 photo_item_action_change(pi,
204 pi->histo.pos -
205 (eina_list_count(pi->histo.list) - (no+1)));
206 photo_item_timer_set(pi, pi->config->timer_active, 0);
207}
208
209static void
210_cb_menu_pre_select(void *data, Evas *evas, Evas_Object *obj, void *event_info)
211{
212 E_Menu_Item *mi;
213 Photo_Item *pi;
214 Picture *p;
215 char *text;
216 int number;
217
218 mi = data;
219 if (!mi) return;
220 pi = mi->cb.data;
221 if (!pi) return;
222
223 number = (eina_list_count(pi->histo.list) - (e_menu_item_num_get(mi)+1));
224
225 DPIC(("Histo menu : Select %d in histo list", number));
226
227 p = eina_list_nth(pi->histo.list, number);
228 if (!p) return;
229
230 text = photo_picture_infos_get(p);
231
232 if (pi->histo.popi)
233 photo_popup_info_del(pi->histo.popi);
234
235 pi->histo.popi = photo_popup_info_add(pi, p->infos.name, text, p,
236 PICTURE_HISTO_POPUP_TIMER,
237 POPUP_INFO_PLACEMENT_CENTERED,
238 _cb_popi_close, NULL);
239
240 free(text);
241}
242
243static void
244_cb_menu_post_select(void *data, Evas *evas, Evas_Object *obj, void *event_info)
245{
246 E_Menu_Item *mi;
247 Photo_Item *pi;
248
249 mi = data;
250 if (!mi) return;
251 pi = mi->cb.data;
252 if (!pi) return;
253
254 DPIC(("Histo menu : Post select callback"));
255
256 if (pi->histo.popi)
257 photo_popup_info_del(pi->histo.popi);
258 pi->histo.popi = NULL;
259}
260
261static void
262_cb_menu_deactivate_post(void *data, E_Menu *m)
263{
264 Photo_Item *pi;
265
266 pi = data;
267 pi->menu_histo = NULL;
268
269 DD(("deactivate cb post"));
270
271 e_object_del(E_OBJECT(m));
272}
273
274static void
275_cb_popi_close(void *data)
276{
277 Photo_Item *pi;
278
279 pi = data;
280 pi->histo.popi = NULL;
281}
diff --git a/src/photo_picture_histo.h b/src/photo_picture_histo.h
index 690bbdf..e270839 100644
--- a/src/photo_picture_histo.h
+++ b/src/photo_picture_histo.h
@@ -20,7 +20,5 @@ Picture *photo_picture_histo_change(Photo_Item *pi, int offset);
20 20
21void photo_picture_histo_picture_del(Picture *picture); 21void photo_picture_histo_picture_del(Picture *picture);
22 22
23void photo_picture_histo_menu_append(Photo_Item *pi, E_Menu *mn_main);
24
25#endif 23#endif
26#endif 24#endif