update for beta release
[framework/uifw/e17.git] / src / bin / e_actions.c
1 #include "e.h"
2
3 #ifndef MAX
4 # define MAX(x, y) (((x) > (y)) ? (x) : (y))
5 #endif
6
7 #define INITS
8 #define ACT_GO(name) \
9    { \
10       act = e_action_add(#name); \
11       if (act) act->func.go = _e_actions_act_##name##_go; \
12    }
13 #define ACT_FN_GO(act, use) \
14    static void _e_actions_act_##act##_go(E_Object *obj __UNUSED__, const char *params use)
15
16 #define ACT_GO_MOUSE(name) \
17    { \
18       act = e_action_add(#name); \
19       if (act) act->func.go_mouse = _e_actions_act_##name##_go_mouse; \
20    }
21 #define ACT_FN_GO_MOUSE(act, use) \
22    static void _e_actions_act_##act##_go_mouse(E_Object *obj __UNUSED__, const char *params use, Ecore_Event_Mouse_Button *ev __UNUSED__)
23
24 #define ACT_GO_WHEEL(name) \
25    { \
26       act = e_action_add(#name); \
27       if (act) act->func.go_wheel = _e_actions_act_##name##_go_wheel; \
28    }
29 #define ACT_FN_GO_WHEEL(act, use) \
30    static void _e_actions_act_##act##_go_wheel(E_Object *obj __UNUSED__, const char *params use, Ecore_Event_Mouse_Wheel *ev __UNUSED__)
31
32 #define ACT_GO_EDGE(name) \
33    { \
34       act = e_action_add(#name); \
35       if (act) act->func.go_edge = _e_actions_act_##name##_go_edge; \
36    }
37 #define ACT_FN_GO_EDGE(act, use) \
38    static void _e_actions_act_##act##_go_edge(E_Object *obj __UNUSED__, const char *params use, E_Event_Zone_Edge *ev __UNUSED__)
39
40 #define ACT_GO_SIGNAL(name) \
41    { \
42       act = e_action_add(#name); \
43       if (act) act->func.go_signal = _e_actions_act_##name##_go_signal; \
44    }
45 #define ACT_FN_GO_SIGNAL(act, use) \
46    static void _e_actions_act_##act##_go_signal(E_Object *obj __UNUSED__, const char *params use, const char *sig, const char *src)
47
48 #define ACT_GO_KEY(name) \
49    { \
50       act = e_action_add(#name); \
51       if (act) act->func.go_key = _e_actions_act_##name##_go_key; \
52    }
53 #define ACT_FN_GO_KEY(act, use) \
54    static void _e_actions_act_##act##_go_key(E_Object *obj __UNUSED__, const char *params use, Ecore_Event_Key *ev __UNUSED__)
55
56 #define ACT_END(name) \
57    { \
58       act = e_action_add(#name); \
59       if (act) act->func.end = _e_actions_act_##name##_end; \
60    }
61 #define ACT_FN_END(act, use) \
62    static void _e_actions_act_##act##_end(E_Object *obj __UNUSED__, const char *params use)
63
64 #define ACT_END_MOUSE(name) \
65    { \
66       act = e_action_add(#name); \
67       if (act) act->func.end_mouse = _e_actions_act_##name##_end_mouse; \
68    }
69 #define ACT_FN_END_MOUSE(act, use) \
70    static void _e_actions_act_##act##_end_mouse(E_Object *obj __UNUSED__, const char *params use, Ecore_Event_Mouse_Button *ev __UNUSED__)
71
72 #define ACT_END_KEY(name) \
73    { \
74       act = e_action_add(#name); \
75       if (act) act->func.end_key = _e_actions_act_##name##_end_key; \
76    }
77 #define ACT_FN_END_KEY(act, use) \
78    static void _e_actions_act_##act##_end_key(E_Object *obj __UNUSED__, const char *params use, Ecore_Event_Key *ev __UNUSED__)
79
80 #define ACT_GO_ACPI(name) \
81    { \
82       act = e_action_add(#name); \
83       if (act) act->func.go_acpi = _e_actions_act_##name##_go_acpi; \
84    }
85 #define ACT_FN_GO_ACPI(act, use) \
86    static void _e_actions_act_##act##_go_acpi(E_Object *obj __UNUSED__, const char *params use, E_Event_Acpi *ev __UNUSED__)
87
88 /* local subsystem functions */
89 static void _e_action_free(E_Action *act);
90 static E_Maximize _e_actions_maximize_parse(const char *maximize);
91 static int _action_groups_sort_cb(const void *d1, const void *d2);
92
93 /* to save writing this in N places - the sections are defined here */
94 /***************************************************************************/
95 ACT_FN_GO(window_move, __UNUSED__)
96 {
97    if (!obj) obj = E_OBJECT(e_border_focused_get());
98    if (!obj) return;
99    if (obj->type != E_BORDER_TYPE) return;
100    if (!((E_Border *)obj)->lock_user_location)
101      e_border_act_move_begin((E_Border *)obj, NULL);
102 }
103
104 ACT_FN_GO_MOUSE(window_move, __UNUSED__)
105 {
106    if (!obj) obj = E_OBJECT(e_border_focused_get());
107    if (!obj) return;
108    if (obj->type != E_BORDER_TYPE) return;
109    e_border_act_move_begin((E_Border *)obj, ev);
110 }
111
112 ACT_FN_GO_SIGNAL(window_move, )
113 {
114    if (!obj) obj = E_OBJECT(e_border_focused_get());
115    if (!obj) return;
116    if (obj->type != E_BORDER_TYPE) return;
117    if (!((E_Border *)obj)->lock_user_location)
118      {
119         if ((params) && (!strcmp(params, "end")))
120           e_border_signal_move_end((E_Border *)obj, sig, src);
121         else
122           {
123              if (((E_Border *)obj)->moving)
124                e_border_signal_move_end((E_Border *)obj, sig, src);
125              else
126                e_border_signal_move_begin((E_Border *)obj, sig, src);
127           }
128      }
129 }
130
131 ACT_FN_END(window_move, __UNUSED__)
132 {
133    if (!obj) obj = E_OBJECT(e_border_focused_get());
134    if (!obj) return;
135    if (obj->type != E_BORDER_TYPE) return;
136    e_border_act_move_end((E_Border *)obj, NULL);
137 }
138
139 ACT_FN_END_MOUSE(window_move, __UNUSED__)
140 {
141    if (!obj) obj = E_OBJECT(e_border_focused_get());
142    if (!obj) return;
143    if (obj->type != E_BORDER_TYPE) return;
144    e_border_act_move_end((E_Border *)obj, ev);
145 }
146
147 ACT_FN_GO_KEY(window_move, __UNUSED__)
148 {
149    if (!obj) obj = E_OBJECT(e_border_focused_get());
150    if (!obj) return;
151    if (obj->type != E_BORDER_TYPE)
152      {
153         obj = E_OBJECT(e_border_focused_get());
154         if (!obj) return;
155      }
156    if (!((E_Border *)obj)->lock_user_location)
157      e_border_act_move_keyboard((E_Border *)obj);
158 }
159
160 /***************************************************************************/
161 ACT_FN_GO(window_resize, __UNUSED__)
162 {
163    if (!obj) obj = E_OBJECT(e_border_focused_get());
164    if (!obj) return;
165    if (obj->type != E_BORDER_TYPE) return;
166    if (!((E_Border *)obj)->lock_user_size)
167      e_border_act_resize_begin((E_Border *)obj, NULL);
168 }
169
170 ACT_FN_GO_MOUSE(window_resize, __UNUSED__)
171 {
172    if (!obj) obj = E_OBJECT(e_border_focused_get());
173    if (!obj) return;
174    if (obj->type != E_BORDER_TYPE) return;
175    if (!((E_Border *)obj)->lock_user_size)
176      e_border_act_resize_begin((E_Border *)obj, ev);
177 }
178
179 ACT_FN_GO_SIGNAL(window_resize, )
180 {
181    if (!obj) obj = E_OBJECT(e_border_focused_get());
182    if (!obj) return;
183    if (obj->type != E_BORDER_TYPE) return;
184    if (!((E_Border *)obj)->lock_user_size)
185      {
186         if ((params) && (!strcmp(params, "end")))
187           e_border_signal_resize_end((E_Border *)obj, params, sig, src);
188         else
189           {
190              if (!params) params = "";
191              if (e_border_resizing_get((E_Border *)obj))
192                e_border_signal_resize_end((E_Border *)obj, params, sig, src);
193              else
194                e_border_signal_resize_begin((E_Border *)obj, params, sig, src);
195           }
196      }
197 }
198
199 ACT_FN_END(window_resize, __UNUSED__)
200 {
201    if (!obj) obj = E_OBJECT(e_border_focused_get());
202    if (!obj) return;
203    if (obj->type != E_BORDER_TYPE) return;
204    e_border_act_resize_end((E_Border *)obj, NULL);
205 }
206
207 ACT_FN_END_MOUSE(window_resize, __UNUSED__)
208 {
209    if (!obj) obj = E_OBJECT(e_border_focused_get());
210    if (!obj) return;
211    if (obj->type != E_BORDER_TYPE) return;
212    e_border_act_resize_end((E_Border *)obj, ev);
213 }
214
215 ACT_FN_GO_KEY(window_resize, __UNUSED__)
216 {
217    if (!obj) obj = E_OBJECT(e_border_focused_get());
218    if (!obj) return;
219    if (obj->type != E_BORDER_TYPE)
220      {
221         obj = E_OBJECT(e_border_focused_get());
222         if (!obj) return;
223      }
224    if (!((E_Border *)obj)->lock_user_size)
225      e_border_act_resize_keyboard((E_Border *)obj);
226 }
227
228 /***************************************************************************/
229 ACT_FN_GO(window_menu, __UNUSED__)
230 {
231    if (!obj) obj = E_OBJECT(e_border_focused_get());
232    if (!obj) return;
233    if (obj->type != E_BORDER_TYPE)
234      {
235         obj = E_OBJECT(e_border_focused_get());
236         if (!obj) return;
237      }
238    e_border_act_menu_begin((E_Border *)obj, NULL, 0);
239 }
240
241 ACT_FN_GO_MOUSE(window_menu, __UNUSED__)
242 {
243    if (!obj) obj = E_OBJECT(e_border_focused_get());
244    if (!obj) return;
245    if (obj->type != E_BORDER_TYPE)
246      {
247         obj = E_OBJECT(e_border_focused_get());
248         if (!obj) return;
249      }
250    e_border_act_menu_begin((E_Border *)obj, ev, 0);
251 }
252
253 ACT_FN_GO_KEY(window_menu, __UNUSED__)
254 {
255    if (!obj) obj = E_OBJECT(e_border_focused_get());
256    if (!obj) return;
257    if (obj->type != E_BORDER_TYPE)
258      {
259         obj = E_OBJECT(e_border_focused_get());
260         if (!obj) return;
261      }
262    e_border_act_menu_begin((E_Border *)obj, NULL, 1);
263 }
264
265 /***************************************************************************/
266 ACT_FN_GO(window_raise, __UNUSED__)
267 {
268    if (!obj) obj = E_OBJECT(e_border_focused_get());
269    if (!obj) return;
270    if (obj->type != E_BORDER_TYPE)
271      {
272         obj = E_OBJECT(e_border_focused_get());
273         if (!obj) return;
274      }
275    if (!((E_Border *)obj)->lock_user_stacking)
276      e_border_raise((E_Border *)obj);
277 }
278
279 /***************************************************************************/
280 ACT_FN_GO(window_lower, __UNUSED__)
281 {
282    if (!obj) obj = E_OBJECT(e_border_focused_get());
283    if (!obj) return;
284    if (obj->type != E_BORDER_TYPE)
285      {
286         obj = E_OBJECT(e_border_focused_get());
287         if (!obj) return;
288      }
289    if (!((E_Border *)obj)->lock_user_stacking)
290      e_border_lower((E_Border *)obj);
291 }
292
293 /***************************************************************************/
294 ACT_FN_GO(window_close, __UNUSED__)
295 {
296    if (!obj) obj = E_OBJECT(e_border_focused_get());
297    if (!obj) return;
298    if (obj->type != E_BORDER_TYPE)
299      {
300         obj = E_OBJECT(e_border_focused_get());
301         if (!obj) return;
302      }
303    if (!((E_Border *)obj)->lock_close)
304      e_border_act_close_begin((E_Border *)obj);
305 }
306
307 /***************************************************************************/
308 static E_Dialog *kill_dialog = NULL;
309
310 static void
311 _e_actions_cb_kill_dialog_ok(void *data, E_Dialog *dia)
312 {
313    E_Object *obj;
314
315    obj = data;
316    if (dia)
317      {
318         e_object_del(E_OBJECT(kill_dialog));
319         kill_dialog = NULL;
320      }
321    if ((!((E_Border *)obj)->lock_close) && (!((E_Border *)obj)->internal))
322      e_border_act_kill_begin((E_Border *)obj);
323 }
324
325 static void
326 _e_actions_cb_kill_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
327 {
328    e_object_del(E_OBJECT(kill_dialog));
329    kill_dialog = NULL;
330 }
331
332 static void
333 _e_actions_cb_kill_dialog_delete(E_Win *win)
334 {
335    E_Dialog *dia;
336
337    dia = win->data;
338    _e_actions_cb_kill_dialog_cancel(NULL, dia);
339 }
340
341 ACT_FN_GO(window_kill, __UNUSED__)
342 {
343    E_Border *bd;
344    char dialog_text[1024];
345
346    if (!obj) obj = E_OBJECT(e_border_focused_get());
347    if (!obj) return;
348    if (obj->type != E_BORDER_TYPE)
349      {
350         obj = E_OBJECT(e_border_focused_get());
351         if (!obj) return;
352      }
353    bd = (E_Border *)obj;
354    if ((bd->lock_close) || (bd->internal)) return;
355
356    if (kill_dialog) e_object_del(E_OBJECT(kill_dialog));
357
358    if (e_config->cnfmdlg_disabled)
359      {
360         _e_actions_cb_kill_dialog_ok(obj, NULL);
361         return;
362      }
363
364    snprintf(dialog_text, sizeof(dialog_text),
365             _("You are about to kill %s.<br><br>"
366             "Please keep in mind that all data from this window<br>"
367             "which has not yet been saved will be lost!<br><br>"
368             "Are you sure you want to kill this window?"),
369             bd->client.icccm.name);
370
371    kill_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()),
372                               "E", "_kill_dialog");
373    if (!kill_dialog) return;
374    e_win_delete_callback_set(kill_dialog->win,
375                              _e_actions_cb_kill_dialog_delete);
376    e_dialog_title_set(kill_dialog,
377                       _("Are you sure you want to kill this window?"));
378    e_dialog_text_set(kill_dialog, _(dialog_text));
379    e_dialog_icon_set(kill_dialog, "application-exit", 64);
380    e_dialog_button_add(kill_dialog, _("Yes"), NULL,
381                        _e_actions_cb_kill_dialog_ok, obj);
382    e_dialog_button_add(kill_dialog, _("No"), NULL,
383                        _e_actions_cb_kill_dialog_cancel, NULL);
384    e_dialog_button_focus_num(kill_dialog, 1);
385    e_win_centered_set(kill_dialog->win, 1);
386    e_dialog_show(kill_dialog);
387 }
388
389 /***************************************************************************/
390 ACT_FN_GO(window_sticky_toggle, __UNUSED__)
391 {
392    if (!obj) obj = E_OBJECT(e_border_focused_get());
393    if (!obj) return;
394    if (obj->type != E_BORDER_TYPE)
395      {
396         obj = E_OBJECT(e_border_focused_get());
397         if (!obj) return;
398      }
399    if (!((E_Border *)obj)->lock_user_sticky)
400      {
401         E_Border *bd;
402
403         bd = (E_Border *)obj;
404         if (bd->sticky) e_border_unstick(bd);
405         else e_border_stick(bd);
406      }
407 }
408
409 /***************************************************************************/
410 ACT_FN_GO(window_sticky, )
411 {
412    if (!obj) obj = E_OBJECT(e_border_focused_get());
413    if (!obj) return;
414    if (obj->type != E_BORDER_TYPE)
415      {
416         obj = E_OBJECT(e_border_focused_get());
417         if (!obj) return;
418      }
419    if (!((E_Border *)obj)->lock_user_sticky)
420      {
421         E_Border *bd;
422
423         bd = (E_Border *)obj;
424         if (params)
425           {
426              if (atoi(params) == 1)
427                e_border_stick(bd);      
428              else if (atoi(params) == 0)
429                e_border_unstick(bd);
430           }
431      }
432 }
433
434 /***************************************************************************/
435 ACT_FN_GO(window_iconic_toggle, __UNUSED__)
436 {
437    E_Border *bd;
438
439    if (!obj) obj = E_OBJECT(e_border_focused_get());
440    if (!obj) return;
441    if (obj->type != E_BORDER_TYPE)
442      {
443         obj = E_OBJECT(e_border_focused_get());
444         if (!obj) return;
445      }
446    bd = (E_Border *)obj;
447
448    if ((!bd->lock_user_iconify) && (!bd->fullscreen) &&
449        ((bd->client.netwm.type == ECORE_X_WINDOW_TYPE_NORMAL) ||
450         (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_UNKNOWN)))
451      {
452         if (bd->iconic) e_border_uniconify(bd);
453         else e_border_iconify(bd);
454      }
455 }
456
457 /***************************************************************************/
458 ACT_FN_GO(window_iconic, )
459 {
460    if (!obj) obj = E_OBJECT(e_border_focused_get());
461    if (!obj) return;
462    if (obj->type != E_BORDER_TYPE)
463      {
464         obj = E_OBJECT(e_border_focused_get());
465         if (!obj) return;
466      }
467    if (!((E_Border *)obj)->lock_user_iconify)
468      {
469         E_Border *bd;
470
471         bd = (E_Border *)obj;
472         if (params)
473           {
474              if (atoi(params) == 1)
475                e_border_iconify(bd);
476              else if (atoi(params) == 0)
477                e_border_uniconify(bd);
478           }
479      }
480 }
481
482 /***************************************************************************/
483 ACT_FN_GO(window_fullscreen_toggle, )
484 {
485    if (!obj) obj = E_OBJECT(e_border_focused_get());
486    if (!obj) return;
487    if (obj->type != E_BORDER_TYPE)
488      {
489         obj = E_OBJECT(e_border_focused_get());
490         if (!obj) return;
491      }
492    if (!((E_Border *)obj)->lock_user_fullscreen)
493      {
494         E_Border *bd;
495
496         bd = (E_Border *)obj;
497         if (bd->fullscreen)
498           e_border_unfullscreen(bd);
499         else if (!params || *params == '\0')
500           e_border_fullscreen(bd, e_config->fullscreen_policy);
501         else if (! strcmp(params, "resize"))
502           e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
503         else if (! strcmp(params, "zoom"))
504           e_border_fullscreen(bd, E_FULLSCREEN_ZOOM);
505      }
506 }
507
508 /***************************************************************************/
509 ACT_FN_GO(window_fullscreen, )
510 {
511    if (!obj) obj = E_OBJECT(e_border_focused_get());
512    if (!obj) return;
513    if (obj->type != E_BORDER_TYPE)
514      {
515         obj = E_OBJECT(e_border_focused_get());
516         if (!obj) return;
517      }
518    if (!((E_Border *)obj)->lock_user_fullscreen)
519      {
520         E_Border *bd;
521
522         bd = (E_Border *)obj;
523         if (params)
524           {
525              int v;
526              char buf[32];
527
528              buf[0] = 0;
529              if (sscanf(params, "%i %20s", &v, buf) == 2)
530                {
531                   if (v == 1)
532                     {
533                       if (*buf == '\0')
534                         e_border_fullscreen(bd, e_config->fullscreen_policy);
535                       else if (!strcmp(buf, "resize"))
536                         e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
537                       else if (!strcmp(buf, "zoom"))
538                         e_border_fullscreen(bd, E_FULLSCREEN_ZOOM);
539                     }
540                   else if (v == 0)
541                     e_border_unfullscreen(bd);
542                }
543           }
544      }
545 }
546
547 /***************************************************************************/
548 ACT_FN_GO(window_maximized_toggle, )
549 {
550    E_Border *bd;
551
552    if (!obj) obj = E_OBJECT(e_border_focused_get());
553    if (!obj) return;
554    if (obj->type != E_BORDER_TYPE)
555      {
556         obj = E_OBJECT(e_border_focused_get());
557         if (!obj) return;
558      }
559    bd = (E_Border *)obj;
560
561    if ((!bd->lock_user_maximize) && (!bd->fullscreen) &&
562        ((bd->client.netwm.type == ECORE_X_WINDOW_TYPE_NORMAL) ||
563         (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_UNKNOWN)))
564      {
565         if ((bd->maximized & E_MAXIMIZE_TYPE) != E_MAXIMIZE_NONE)
566           {
567              if (!params)
568                e_border_unmaximize(bd, E_MAXIMIZE_BOTH);
569              else
570                {
571                   E_Maximize max;
572
573                   max = _e_actions_maximize_parse(params);
574                   max &= E_MAXIMIZE_DIRECTION;
575                   if (max == E_MAXIMIZE_VERTICAL)
576                     {
577                        if (bd->maximized & E_MAXIMIZE_VERTICAL)
578                          e_border_unmaximize(bd, E_MAXIMIZE_VERTICAL);
579                        else
580                          goto maximize;
581                     }
582                   else if (max == E_MAXIMIZE_HORIZONTAL)
583                     {
584                        if (bd->maximized & E_MAXIMIZE_HORIZONTAL)
585                          e_border_unmaximize(bd, E_MAXIMIZE_HORIZONTAL);
586                        else
587                          goto maximize;
588                     }
589                   else
590                     e_border_unmaximize(bd, E_MAXIMIZE_BOTH);
591                }
592           }
593         else
594           {
595 maximize:
596              e_border_maximize(bd, _e_actions_maximize_parse(params));
597           }
598      }
599 }
600 /***************************************************************************/
601 ACT_FN_GO(window_maximized, )
602 {
603    if (!obj) obj = E_OBJECT(e_border_focused_get());
604    if (!obj) return;
605    if (obj->type != E_BORDER_TYPE)
606      {
607         obj = E_OBJECT(e_border_focused_get());
608         if (!obj) return;
609      }
610    if (!((E_Border *)obj)->lock_user_maximize)
611      {
612         E_Border *bd;
613
614         bd = (E_Border *)obj;
615         if (params)
616           {
617              E_Maximize max;
618              int v, ret;
619              char s1[32], s2[32];
620
621              max = (e_config->maximize_policy & E_MAXIMIZE_DIRECTION);
622              ret = sscanf(params, "%i %20s %20s", &v, s1, s2);
623              if (ret == 3)
624                {
625                   if (!strcmp(s2, "horizontal"))
626                     max = E_MAXIMIZE_HORIZONTAL;
627                   else if (!strcmp(s2, "vertical"))
628                     max = E_MAXIMIZE_VERTICAL;
629                   else
630                     max = E_MAXIMIZE_BOTH;
631                }
632              if (ret > 1)
633                {
634                   if (v == 1)
635                     {
636                        if (!strcmp(s1, "fullscreen"))
637                          e_border_maximize(bd, E_MAXIMIZE_FULLSCREEN | max);
638                        else if (!strcmp(s1, "smart"))
639                          e_border_maximize(bd, E_MAXIMIZE_SMART | max);
640                        else if (!strcmp(s1, "expand"))
641                          e_border_maximize(bd, E_MAXIMIZE_EXPAND | max);
642                        else if (!strcmp(s1, "fill"))
643                          e_border_maximize(bd, E_MAXIMIZE_FILL | max);
644                        else
645                          e_border_maximize(bd, (e_config->maximize_policy & E_MAXIMIZE_TYPE) | max);
646                     }
647                   else if (v == 0)
648                     e_border_unmaximize(bd, max);
649                }
650           }
651      }
652 }
653
654 /***************************************************************************/
655 ACT_FN_GO(window_shaded_toggle, )
656 {
657    if (!obj) obj = E_OBJECT(e_border_focused_get());
658    if (!obj) return;
659    if (obj->type != E_BORDER_TYPE)
660      {
661         obj = E_OBJECT(e_border_focused_get());
662         if (!obj) return;
663      }
664    if (!((E_Border *)obj)->lock_user_shade)
665      {
666         E_Border *bd;
667
668         bd = (E_Border *)obj;
669         if (bd->shaded)
670           {
671              if (!params)
672                e_border_unshade(bd, E_DIRECTION_UP);
673              else
674                {
675                   if (!strcmp(params, "up"))
676                     e_border_unshade(bd, E_DIRECTION_UP);
677                   else if (!strcmp(params, "down"))
678                     e_border_unshade(bd, E_DIRECTION_DOWN);
679                   else if (!strcmp(params, "left"))
680                     e_border_unshade(bd, E_DIRECTION_LEFT);
681                   else if (!strcmp(params, "right"))
682                     e_border_unshade(bd, E_DIRECTION_RIGHT);
683                   else
684                     e_border_unshade(bd, E_DIRECTION_UP);
685                }
686           }
687         else
688           {
689              if (!params)
690                e_border_shade(bd, E_DIRECTION_UP);
691              else
692                {
693                   if (!strcmp(params, "up"))
694                     e_border_shade(bd, E_DIRECTION_UP);
695                   else if (!strcmp(params, "down"))
696                     e_border_shade(bd, E_DIRECTION_DOWN);
697                   else if (!strcmp(params, "left"))
698                     e_border_shade(bd, E_DIRECTION_LEFT);
699                   else if (!strcmp(params, "right"))
700                     e_border_shade(bd, E_DIRECTION_RIGHT);
701                   else
702                     e_border_shade(bd, E_DIRECTION_UP);
703                }
704           }
705      }
706 }
707
708 /***************************************************************************/
709 ACT_FN_GO(window_shaded, )
710 {
711    if (!obj) obj = E_OBJECT(e_border_focused_get());
712    if (!obj) return;
713    if (obj->type != E_BORDER_TYPE)
714      {
715         obj = E_OBJECT(e_border_focused_get());
716         if (!obj) return;
717      }
718    if (!((E_Border *)obj)->lock_user_shade)
719      {
720         E_Border *bd;
721
722         bd = (E_Border *)obj;
723         if (params)
724           {
725              int v;
726              char buf[32];
727
728              if (sscanf(params, "%i %20s", &v, buf) == 2)
729                {
730                   if (v == 1)
731                     {
732                        if (!strcmp(buf, "up"))
733                          e_border_shade(bd, E_DIRECTION_UP);
734                        else if (!strcmp(buf, "down"))
735                          e_border_shade(bd, E_DIRECTION_DOWN);
736                        else if (!strcmp(buf, "left"))
737                          e_border_shade(bd, E_DIRECTION_LEFT);
738                        else if (!strcmp(buf, "right"))
739                          e_border_shade(bd, E_DIRECTION_RIGHT);
740                     }
741                   else if (v == 0)
742                     {
743                        if (!strcmp(buf, "up"))
744                          e_border_unshade(bd, E_DIRECTION_UP);
745                        else if (!strcmp(buf, "down"))
746                          e_border_unshade(bd, E_DIRECTION_DOWN);
747                        else if (!strcmp(buf, "left"))
748                          e_border_unshade(bd, E_DIRECTION_LEFT);
749                        else if (!strcmp(buf, "right"))
750                          e_border_unshade(bd, E_DIRECTION_RIGHT);
751                     }
752                }
753           }
754      }
755 }
756
757 /***************************************************************************/
758 ACT_FN_GO(window_borderless_toggle, __UNUSED__)
759 {
760    if ((!obj) || (obj->type != E_BORDER_TYPE))
761      obj = E_OBJECT(e_border_focused_get());
762    if (!obj) return;
763    if (!((E_Border *)obj)->lock_border)
764      {
765         E_Border *bd;
766
767         bd = (E_Border *)obj;
768         bd->borderless = !bd->borderless;
769
770         bd->client.border.changed = 1;
771         bd->changed = 1;
772      }
773 }
774
775 /***************************************************************************/
776 ACT_FN_GO(window_border_set, __UNUSED__)
777 {
778    if ((!obj) || (obj->type != E_BORDER_TYPE))
779      obj = E_OBJECT(e_border_focused_get());
780    if (!obj) return;
781    if (!((E_Border *)obj)->lock_border)
782      {
783         E_Border *bd;
784
785         bd = (E_Border *)obj;
786         if (bd && params)
787           {
788              eina_stringshare_replace(&bd->bordername, params);
789              bd->client.border.changed = 1;
790              bd->changed = 1;
791           }
792      }
793 }
794
795 /***************************************************************************/
796 ACT_FN_GO(window_border_cycle, __UNUSED__)
797 {
798    if ((!obj) || (obj->type != E_BORDER_TYPE))
799      obj = E_OBJECT(e_border_focused_get());
800    if (!obj) return;
801    if (!((E_Border *)obj)->lock_border)
802      {
803         E_Border *bd;
804
805         bd = (E_Border *)obj;
806         if (bd && params)
807           {
808              const char *space;
809
810              while (*params == ' ')
811                 params++;
812
813              if (bd->bordername)
814                {
815                   const char *bdname = params;
816
817                   while (bdname && (space = strchr(bdname, ' ')))
818                     {
819                        if (strncmp(bd->bordername, bdname, space - bdname) == 0)
820                          {
821                             bdname = space + 1;
822                             while (*bdname == ' ')
823                                bdname++;
824                             space = strchr(bdname, ' ');
825                             if (space)
826                               eina_stringshare_replace_length(
827                                  &bd->bordername,
828                                  bdname, space - bdname);
829                             else
830                               eina_stringshare_replace(&bd->bordername, bdname);
831                             bd->client.border.changed = 1;
832                             bd->changed = 1;
833                             return;
834                          }
835                        bdname = space + 1;
836                        while (*bdname == ' ')
837                           bdname++;
838                     }
839                }
840
841              space = strchr(params, ' ');
842              if (space)
843                eina_stringshare_replace_length(&bd->bordername,
844                                                params, space - params);
845              else
846                eina_stringshare_replace(&bd->bordername, params);
847              bd->client.border.changed = 1;
848              bd->changed = 1;
849           }
850      }
851 }
852
853  /***************************************************************************/
854 ACT_FN_GO(window_pinned_toggle, __UNUSED__)
855 {
856    if ((!obj) || (obj->type != E_BORDER_TYPE))
857      obj = E_OBJECT(e_border_focused_get());
858    if (!obj) return;
859    if (!((E_Border *)obj)->lock_border)
860      {
861         E_Border *bd;
862
863         bd = (E_Border *)obj;
864         if ((bd->client.netwm.state.stacking == E_STACKING_BELOW) &&
865             (bd->user_skip_winlist) && (bd->borderless))
866           e_border_pinned_set(bd, 0);
867         else
868           e_border_pinned_set(bd, 1);
869      }
870 }
871
872 /***************************************************************************/
873 ACT_FN_GO(window_move_by, )
874 {
875    if (!obj) obj = E_OBJECT(e_border_focused_get());
876    if (!obj) return;
877    if (obj->type != E_BORDER_TYPE)
878      {
879        obj = E_OBJECT(e_border_focused_get());
880        if (!obj) return;
881      }
882    if (params)
883      {
884         int dx, dy;
885
886         if (sscanf(params, "%i %i", &dx, &dy) == 2)
887           {
888              E_Border *bd;
889
890              bd = (E_Border *)obj;
891              e_border_move(bd, bd->x + dx, bd->y + dy);
892
893              if (e_config->focus_policy != E_FOCUS_CLICK)
894                ecore_x_pointer_warp(bd->zone->container->win,
895                                     bd->x + (bd->w / 2),
896                                     bd->y + (bd->h / 2));
897           }
898      }
899 }
900
901 /***************************************************************************/
902 ACT_FN_GO(window_move_to, )
903 {
904    if (!obj) obj = E_OBJECT(e_border_focused_get());
905    if (!obj) return;
906    if (obj->type != E_BORDER_TYPE)
907      {
908        obj = E_OBJECT(e_border_focused_get());
909        if (!obj) return;
910      }
911    if (params)
912      {
913         E_Border *bd;
914         int x, y, zx, zy, zw, zh;
915         char cx, cy;
916
917         bd = (E_Border *)obj;
918         e_zone_useful_geometry_get(bd->zone, &zx, &zy, &zw, &zh);
919
920         if (sscanf(params, "%c%i %c%i", &cx, &x, &cy, &y) == 4)
921           {
922              x += zx;
923              y += zy;
924           }
925         else if (sscanf(params, "* %c%i", &cy, &y) == 2)
926           {
927              /* Updated y, keep x. */
928              y += zy;
929              x = bd->x;
930              cx = 0;
931           }
932         else if (sscanf(params, "%c%i *", &cx, &x) == 2)
933           {
934              /* Updated x, keep y. */
935              x += zx;
936              y = bd->y;
937              cy = 0;
938           }
939         else return;
940
941         if (cx == '-') x = zw - bd->w - x + 2 * zx; /* compensate x with zx */
942         if (cy == '-') y = zh - bd->h - y + 2 * zy; /* compensate y with zy */
943
944         if ((x != bd->x) || (y != bd->y))
945           {
946              e_border_move(bd, x, y);
947
948              if (e_config->focus_policy != E_FOCUS_CLICK)
949                ecore_x_pointer_warp(bd->zone->container->win,
950                                     bd->x + (bd->w / 2),
951                                     bd->y + (bd->h / 2));
952           }
953      }
954 }
955
956 /***************************************************************************/
957 ACT_FN_GO(window_move_to_center, __UNUSED__)
958 {
959    E_Border *bd;
960    int x, y;
961
962    if (!obj) obj = E_OBJECT(e_border_focused_get());
963    if (!obj) return;
964    if (obj->type != E_BORDER_TYPE)
965      {
966        obj = E_OBJECT(e_border_focused_get());
967        if (!obj) return;
968      }
969
970    bd = (E_Border *)obj;
971    e_border_center_pos_get(bd, &x, &y);
972
973    if ((x != bd->x) || (y != bd->y))
974      {
975         e_border_move(bd, x, y);
976
977         if (e_config->focus_policy != E_FOCUS_CLICK)
978           ecore_x_pointer_warp(bd->zone->container->win,
979                                x + (bd->w / 2),
980                                y + (bd->h / 2));
981      }
982 }
983
984 /***************************************************************************/
985 ACT_FN_GO(window_resize_by, )
986 {
987    if (!obj) obj = E_OBJECT(e_border_focused_get());
988    if (!obj) return;
989    if (obj->type != E_BORDER_TYPE)
990      {
991        obj = E_OBJECT(e_border_focused_get());
992        if (!obj) return;
993      }
994
995    if (params)
996      {
997         int dw, dh;
998
999         if (sscanf(params, "%i %i", &dw, &dh) == 2)
1000           {
1001              E_Border *bd;
1002
1003              bd = (E_Border *)obj;
1004
1005              dw += bd->w;
1006              dh += bd->h;
1007              e_border_resize_limit(bd, &dw, &dh);
1008              e_border_resize(bd, dw, dh);
1009
1010              if (e_config->focus_policy != E_FOCUS_CLICK)
1011                ecore_x_pointer_warp(bd->zone->container->win,
1012                                     bd->x + (dw / 2), bd->y + (dh / 2));
1013           }
1014      }
1015 }
1016
1017 /***************************************************************************/
1018 ACT_FN_GO(window_push, )
1019 {
1020    if (!obj) obj = E_OBJECT(e_border_focused_get());
1021    if (!obj) return;
1022    if (obj->type != E_BORDER_TYPE)
1023      {
1024        obj = E_OBJECT(e_border_focused_get());
1025        if (!obj) return;
1026      }
1027
1028    if (params)
1029      {
1030         E_Border *bd, *cur;
1031         E_Border_List *bd_list;
1032         int hdir, vdir;
1033         int x, y, zx, zy, zw, zh;
1034
1035         if (strcmp(params, "left") == 0)
1036           {
1037              hdir = -1;
1038              vdir = 0;
1039           }
1040         else if (strcmp(params, "right") == 0)
1041           {
1042              hdir = +1;
1043              vdir = 0;
1044           }
1045         else if (strcmp(params, "up") == 0)
1046           {
1047              hdir = 0;
1048              vdir = -1;
1049           }
1050         else if (strcmp(params, "down") == 0)
1051           {
1052              hdir = 0;
1053              vdir = +1;
1054           }
1055         else if (strcmp(params, "up-left") == 0)
1056           {
1057              hdir = -1;
1058              vdir = -1;
1059           }
1060         else if (strcmp(params, "up-right") == 0)
1061           {
1062              hdir = +1;
1063              vdir = -1;
1064           }
1065         else if (strcmp(params, "down-left") == 0)
1066           {
1067              hdir = -1;
1068              vdir = +1;
1069           }
1070         else if (strcmp(params, "down-right") == 0)
1071           {
1072              hdir = +1;
1073              vdir = +1;
1074           }
1075         else
1076           return;
1077
1078         bd = (E_Border *)obj;
1079         e_zone_useful_geometry_get(bd->zone, &zx, &zy, &zw, &zh);
1080
1081         if (hdir < 0)      x = zx;
1082         else if (hdir > 0) x = zx + zw - bd->w;
1083         else               x = bd->x;
1084
1085         if (vdir < 0)      y = zy;
1086         else if (vdir > 0) y = zy + zh - bd->h;
1087         else               y = bd->y;
1088
1089         bd_list = e_container_border_list_first(bd->zone->container);
1090         cur = e_container_border_list_next(bd_list);
1091
1092         while (cur)
1093           {
1094             if ((bd->desk == cur->desk) && (bd != cur) && (!cur->iconic))
1095                {
1096                   if ((hdir < 0)
1097                       && (cur->x + cur->w < bd->x)
1098                       && (E_SPANS_COMMON(bd->y, bd->h, cur->y, cur->h)))
1099                     x = MAX(x, cur->x + cur->w);
1100                   else if ((hdir > 0)
1101                            && (cur->x > bd->x + bd->w)
1102                            && (E_SPANS_COMMON(bd->y, bd->h, cur->y, cur->h)))
1103                     x = MIN(x, zx + cur->x - bd->w);
1104
1105                   if ((vdir < 0)
1106                       && (cur->y + cur->h < bd->y)
1107                       && (E_SPANS_COMMON(bd->x, bd->w, cur->x, cur->w)))
1108                     y = MAX(y, cur->y + cur->h);
1109                   else if ((vdir > 0)
1110                            && (cur->y > bd->y + bd->h)
1111                            && (E_SPANS_COMMON(bd->x, bd->w, cur->x, cur->w)))
1112                     y = MIN(y, zy + cur->y - bd->h);
1113                }
1114              cur = e_container_border_list_next(bd_list);
1115           }
1116         e_container_border_list_free(bd_list);
1117
1118         if ((x != bd->x) || (y != bd->y))
1119           {
1120              e_border_move(bd, x, y);
1121              if (e_config->focus_policy != E_FOCUS_CLICK)
1122                ecore_x_pointer_warp(bd->zone->container->win,
1123                                     bd->x + (bd->w / 2), bd->y + (bd->h / 2));
1124           }
1125      }
1126 }
1127
1128 /***************************************************************************/
1129 ACT_FN_GO(window_drag_icon, __UNUSED__)
1130 {
1131    if (!obj) obj = E_OBJECT(e_border_focused_get());
1132    if (!obj) return;
1133    if (obj->type != E_BORDER_TYPE)
1134      {
1135        obj = E_OBJECT(e_border_focused_get());
1136        if (!obj) return;
1137      }
1138      {
1139         E_Border *bd;
1140
1141         bd = (E_Border *)obj;
1142         bd->drag.start = 1;
1143         bd->drag.x = -1;
1144         bd->drag.y = -1;
1145      }
1146 }
1147
1148 /***************************************************************************/
1149 ACT_FN_GO(window_desk_move_by, )
1150 {
1151    E_Border *bd;
1152    int x, y;
1153
1154    if (!params) return;
1155    if (!obj) obj = E_OBJECT(e_border_focused_get());
1156    if (!obj) return;
1157    if (obj->type != E_BORDER_TYPE)
1158      {
1159        obj = E_OBJECT(e_border_focused_get());
1160        if (!obj) return;
1161      }
1162
1163    bd = (E_Border *)obj;
1164    if ((!bd->zone) || (!bd->desk)) return;
1165    if (sscanf(params, "%d %d", &x, &y) == 2)
1166      {
1167         E_Desk *desk;
1168         int dx, dy;
1169         int to_x = 0, to_y = 0;
1170
1171         e_desk_xy_get(bd->desk, &dx, &dy);
1172
1173         to_x = dx + x;
1174         to_y = dy + y;
1175         while (!(desk = e_desk_at_xy_get(bd->zone, to_x, to_y)))
1176           {
1177              /* here we are out of our desktop range */
1178              while (to_x >= bd->zone->desk_x_count)
1179                {
1180                   to_x -= bd->zone->desk_x_count;
1181                   to_y++;
1182                }
1183              while (to_x < 0)
1184                {
1185                   to_x += bd->zone->desk_x_count;
1186                   to_y--;
1187                }
1188
1189              while (to_y >= bd->zone->desk_y_count)
1190                to_y -= bd->zone->desk_y_count;
1191              while (to_y < 0)
1192                to_y += bd->zone->desk_y_count;
1193           }
1194         
1195         if (desk)
1196           {
1197              /* switch desktop. Quite useful from the interface point of view. */
1198              e_zone_desk_flip_by(bd->zone, to_x - dx, to_y - dy);
1199              /* send the border to the required desktop. */
1200              e_border_desk_set(bd, desk);
1201              if (!bd->lock_user_stacking)
1202                e_border_raise(bd);
1203              e_border_focus_set(bd, 1, 1);
1204           }
1205      }
1206 }
1207
1208 /***************************************************************************/
1209 ACT_FN_GO(window_desk_move_to, )
1210 {
1211    E_Border *bd;
1212    int x, y;
1213
1214    if (!params) return;
1215    if (!obj) obj = E_OBJECT(e_border_focused_get());
1216    if (!obj) return;
1217    if (obj->type != E_BORDER_TYPE)
1218      {
1219        obj = E_OBJECT(e_border_focused_get());
1220        if (!obj) return;
1221      }
1222
1223    bd = (E_Border *)obj;
1224    if ((!bd->zone) || (!bd->desk)) return;
1225    if (sscanf(params, "%d %d", &x, &y) == 2)
1226      {
1227         E_Desk *desk;
1228
1229         desk = e_desk_at_xy_get(bd->zone, x, y);
1230         if (desk) e_border_desk_set(bd, desk);
1231      }
1232 }
1233
1234 /***************************************************************************/
1235 static E_Zone *
1236 _e_actions_zone_get(E_Object *obj)
1237 {
1238    if (obj)
1239      {
1240         if      (obj->type == (int)E_MANAGER_TYPE)   return e_util_zone_current_get((E_Manager *)obj);
1241         else if (obj->type == (int)E_CONTAINER_TYPE) return e_util_zone_current_get(((E_Container *)obj)->manager);
1242         else if (obj->type == (int)E_ZONE_TYPE)      return (E_Zone *)obj;
1243         else if (obj->type == (int)E_BORDER_TYPE)    return ((E_Border *)obj)->zone;
1244         else if (obj->type == (int)E_SHELF_TYPE)     return ((E_Shelf *)obj)->zone;
1245         else if (obj->type == (int)E_POPUP_TYPE)     return ((E_Popup *)obj)->zone;
1246         else if (obj->type == (int)E_WIN_TYPE)       return ((E_Win *)obj)->border->zone;
1247      }
1248    return e_util_zone_current_get(e_manager_current_get());
1249 }
1250
1251 ACT_FN_GO(desk_flip_by, )
1252 {
1253    E_Zone *zone;
1254
1255    zone = _e_actions_zone_get(obj);
1256    if (zone)
1257      {
1258         if (params)
1259           {
1260              int dx = 0, dy = 0;
1261
1262              if (sscanf(params, "%i %i", &dx, &dy) == 2)
1263                e_zone_desk_flip_by(zone, dx, dy);
1264           }
1265      }
1266 }
1267
1268 /***************************************************************************/
1269 ACT_FN_GO(desk_flip_to, )
1270 {
1271    E_Zone *zone;
1272
1273    zone = _e_actions_zone_get(obj);
1274    if (zone)
1275      {
1276         if (params)
1277           {
1278              int dx = 0, dy = 0;
1279
1280              if (sscanf(params, "%i %i", &dx, &dy) == 2)
1281                e_zone_desk_flip_to(zone, dx, dy);
1282           }
1283      }
1284 }
1285
1286 /***************************************************************************/
1287 #define ACT_FLIP_LEFT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1)) || ((zone)->desk_x_current > 0))
1288 #define ACT_FLIP_RIGHT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1)) || (((zone)->desk_x_current + 1) < (zone)->desk_x_count))
1289 #define ACT_FLIP_UP(zone) ((e_config->desk_flip_wrap && ((zone)->desk_y_count > 1)) || ((zone)->desk_y_current > 0))
1290 #define ACT_FLIP_DOWN(zone) ((e_config->desk_flip_wrap && ((zone)->desk_y_count > 1)) || (((zone)->desk_y_current + 1) < (zone)->desk_y_count))
1291 #define ACT_FLIP_UP_LEFT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1) && ((zone)->desk_y_count > 1)) || (((zone)->desk_x_current > 0) && ((zone)->desk_y_current > 0)))
1292 #define ACT_FLIP_UP_RIGHT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1) && ((zone)->desk_y_count > 1)) || ((((zone)->desk_x_current + 1) < (zone)->desk_x_count) && ((zone)->desk_y_current > 0)))
1293 #define ACT_FLIP_DOWN_RIGHT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1) && ((zone)->desk_y_count > 1)) || ((((zone)->desk_x_current + 1) < (zone)->desk_x_count) && (((zone)->desk_y_current + 1) < (zone)->desk_y_count)))
1294 #define ACT_FLIP_DOWN_LEFT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1) && ((zone)->desk_y_count > 1)) || (((zone)->desk_x_current > 0) && (((zone)->desk_y_current + 1) < (zone)->desk_y_count)))
1295
1296 ACT_FN_GO_EDGE(desk_flip_in_direction, )
1297 {
1298    E_Zone *zone;
1299    E_Desk *current = NULL;
1300    E_Event_Pointer_Warp *wev;
1301    int x, y, offset = 25;
1302
1303    if (!ev) return; // with flip on _e_zone_cb_edge_timer we don't have ev!!!
1304    zone = _e_actions_zone_get(obj);
1305    wev = E_NEW(E_Event_Pointer_Warp, 1);
1306    if ((!wev) || (!zone)) return;
1307    ecore_x_pointer_xy_get(zone->container->win, &x, &y);
1308    wev->prev.x = x;
1309    wev->prev.y = y;
1310    if (params)
1311      {
1312         if (sscanf(params, "%i", &offset) != 1)
1313           offset = 25;
1314      }
1315    switch (ev->edge)
1316      {
1317      case E_ZONE_EDGE_LEFT:
1318         if (ACT_FLIP_LEFT(zone))
1319           {
1320              e_zone_desk_flip_by(zone, -1, 0);
1321              ecore_x_pointer_warp(zone->container->win, zone->container->x + zone->x + zone->w - offset, y);
1322              wev->curr.y = y;
1323              wev->curr.x = zone->w - offset;
1324           }
1325         break;
1326      case E_ZONE_EDGE_RIGHT:
1327         if (ACT_FLIP_RIGHT(zone))
1328           {
1329              e_zone_desk_flip_by(zone, 1, 0);
1330              ecore_x_pointer_warp(zone->container->win, zone->container->x + zone->x + offset, y);
1331              wev->curr.y = y;
1332              wev->curr.x = offset;
1333           }
1334         break;
1335      case E_ZONE_EDGE_TOP:
1336         if (ACT_FLIP_UP(zone))
1337           {
1338              e_zone_desk_flip_by(zone, 0, -1);
1339              ecore_x_pointer_warp(zone->container->win, x, zone->container->y + zone->y + zone->h - offset);
1340              wev->curr.x = x;
1341              wev->curr.y = zone->h - offset;
1342           }
1343         break;
1344      case E_ZONE_EDGE_BOTTOM:
1345         if (ACT_FLIP_DOWN(zone))
1346           {
1347              e_zone_desk_flip_by(zone, 0, 1);
1348              ecore_x_pointer_warp(zone->container->win, x, zone->container->y + zone->y + offset);
1349              wev->curr.x = x;
1350              wev->curr.y = offset;
1351           }
1352         break;
1353      case E_ZONE_EDGE_TOP_LEFT:
1354         if (ACT_FLIP_UP_LEFT(zone))
1355           {
1356              e_zone_desk_flip_by(zone, -1, -1);
1357              ecore_x_pointer_warp(zone->container->win, zone->container->x + zone->x + zone->w - offset, zone->container->y + zone->y + zone->h - offset);
1358              wev->curr.x = zone->w - offset;
1359              wev->curr.y = zone->h - offset;
1360           }
1361         break;
1362      case E_ZONE_EDGE_TOP_RIGHT:
1363         if (ACT_FLIP_UP_RIGHT(zone))
1364           {
1365              e_zone_desk_flip_by(zone, 1, -1);
1366              ecore_x_pointer_warp(zone->container->win, zone->container->x + zone->x + offset, zone->container->y + zone->y + zone->h - offset);
1367              wev->curr.x = offset;
1368              wev->curr.y = zone->h - offset;
1369           }
1370         break;
1371      case E_ZONE_EDGE_BOTTOM_LEFT:
1372         if (ACT_FLIP_DOWN_LEFT(zone))
1373           {
1374              e_zone_desk_flip_by(zone, -1, 1);
1375              ecore_x_pointer_warp(zone->container->win, zone->container->x + zone->x + zone->w - offset, zone->container->y + zone->y + offset);
1376              wev->curr.y = offset;
1377              wev->curr.x = zone->w - offset;
1378           }
1379         break;
1380      case E_ZONE_EDGE_BOTTOM_RIGHT:
1381         if (ACT_FLIP_DOWN_RIGHT(zone))
1382           {
1383              e_zone_desk_flip_by(zone, 1, 1);
1384              ecore_x_pointer_warp(zone->container->win, zone->container->x + zone->x + offset, zone->container->y + zone->y + offset);
1385              wev->curr.y = offset;
1386              wev->curr.x = offset;
1387           }
1388         break;
1389      default:
1390         break;
1391      }
1392
1393    current = e_desk_current_get(zone);
1394    if (current)
1395      ecore_event_add(E_EVENT_POINTER_WARP, wev, NULL, NULL);
1396    else
1397      free(wev);
1398 }
1399
1400 /***************************************************************************/
1401 ACT_FN_GO(desk_linear_flip_by, )
1402 {
1403    E_Zone *zone;
1404
1405    zone = _e_actions_zone_get(obj);
1406    if (zone)
1407      {
1408         if (params)
1409           {
1410              int dx = 0;
1411
1412              if (sscanf(params, "%i", &dx) == 1)
1413                e_zone_desk_linear_flip_by(zone, dx);
1414           }
1415      }
1416 }
1417
1418 /***************************************************************************/
1419 ACT_FN_GO(desk_linear_flip_to, )
1420 {
1421    E_Zone *zone;
1422
1423    zone = _e_actions_zone_get(obj);
1424    if (zone)
1425      {
1426         if (params)
1427           {
1428              int dx = 0;
1429
1430              if (sscanf(params, "%i", &dx) == 1)
1431                e_zone_desk_linear_flip_to(zone, dx);
1432           }
1433      }
1434 }
1435
1436
1437 #define DESK_ACTION_ALL(zone, act) \
1438   E_Zone *zone;                    \
1439   Eina_List *lm, *lc, *lz;         \
1440   E_Container *con;                \
1441   E_Manager *man;                               \
1442   \
1443   EINA_LIST_FOREACH(e_manager_list(), lm, man) {           \
1444     EINA_LIST_FOREACH(man->containers, lc, con) {          \
1445       EINA_LIST_FOREACH(con->zones, lz, zone) {            \
1446         act;                                               \
1447       }                                                    \
1448     }                                                      \
1449   }
1450
1451
1452 /***************************************************************************/
1453 ACT_FN_GO(desk_flip_by_all, )
1454 {
1455    if (params)
1456      {
1457         int dx = 0, dy = 0;
1458
1459         if (sscanf(params, "%i %i", &dx, &dy) == 2)
1460           {
1461              DESK_ACTION_ALL(zone, e_zone_desk_flip_by(zone, dx, dy));
1462           }
1463      }
1464 }
1465
1466 /***************************************************************************/
1467 ACT_FN_GO(desk_flip_to_all, )
1468 {
1469    if (params)
1470      {
1471         int dx = 0, dy = 0;
1472
1473         if (sscanf(params, "%i %i", &dx, &dy) == 2)
1474           {
1475              DESK_ACTION_ALL(zone, e_zone_desk_flip_to(zone, dx, dy));
1476           }
1477      }
1478 }
1479
1480 /***************************************************************************/
1481 ACT_FN_GO(desk_linear_flip_by_all, )
1482 {
1483    if (params)
1484      {
1485         int dx = 0;
1486
1487         if (sscanf(params, "%i", &dx) == 1)
1488           {
1489              DESK_ACTION_ALL(zone, e_zone_desk_linear_flip_by(zone, dx));
1490           }
1491      }
1492 }
1493
1494 /***************************************************************************/
1495 ACT_FN_GO(desk_linear_flip_to_all, )
1496 {
1497    if (params)
1498      {
1499         int dx = 0;
1500
1501         if (sscanf(params, "%i", &dx) == 1)
1502           {
1503              DESK_ACTION_ALL(zone, e_zone_desk_linear_flip_to(zone, dx));
1504           }
1505      }
1506 }
1507
1508 /***************************************************************************/
1509 ACT_FN_GO(screen_send_to, )
1510 {
1511    E_Zone *zone;
1512
1513    zone = _e_actions_zone_get(obj);
1514    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1515    if (zone)
1516      {
1517         if (params)
1518           {
1519              int scr = 0;
1520
1521              if (sscanf(params, "%i", &scr) == 1)
1522                {
1523                   E_Zone *zone2 = NULL;
1524
1525                   if (eina_list_count(e_manager_list()) > 1)
1526                     {
1527                        scr = scr % eina_list_count(e_manager_list());
1528                        if (scr < 0) scr += eina_list_count(e_manager_list());
1529                        zone2 = e_util_container_zone_number_get(scr, 0);
1530                     }
1531                   else
1532                     {
1533                        scr = scr % eina_list_count(zone->container->zones);
1534                        if (scr < 0) scr += eina_list_count(zone->container->zones);
1535                        zone2 = e_util_container_zone_number_get(0, scr);
1536                     }
1537                   if ((zone2) && (zone != zone2))
1538                     ecore_x_pointer_warp(zone2->container->win,
1539                                          zone2->x + (zone2->w / 2),
1540                                          zone2->y + (zone2->h / 2));
1541                }
1542           }
1543      }
1544 }
1545
1546 ACT_FN_GO(screen_send_by, )
1547 {
1548    E_Zone *zone;
1549
1550    zone = _e_actions_zone_get(obj);
1551    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1552    if (zone)
1553      {
1554         if (params)
1555           {
1556              int scr = 0;
1557
1558              if (sscanf(params, "%i", &scr) == 1)
1559                {
1560                   E_Zone *zone2 = NULL;
1561
1562                   if (eina_list_count(e_manager_list()) > 1)
1563                     {
1564                        scr += zone->container->num;
1565                        scr = scr % eina_list_count(e_manager_list());
1566                        if (scr < 0) scr += eina_list_count(e_manager_list());
1567                        zone2 = e_util_container_zone_number_get(scr, 0);
1568                     }
1569                   else
1570                     {
1571                        scr += zone->num;
1572                        scr = scr % eina_list_count(zone->container->zones);
1573                        if (scr < 0) scr += eina_list_count(zone->container->zones);
1574                        zone2 = e_util_container_zone_number_get(0, scr);
1575                     }
1576                   if ((zone2) && (zone != zone2))
1577                     ecore_x_pointer_warp(zone2->container->win,
1578                                          zone2->x + (zone2->w / 2),
1579                                          zone2->y + (zone2->h / 2));
1580                }
1581           }
1582      }
1583 }
1584
1585 #define ZONE_DESK_ACTION(con_num, zone_num, zone, act) \
1586    E_Zone *zone; \
1587    if ((con_num < 0) || (zone_num < 0)) { \
1588       Eina_List *l, *ll, *lll; \
1589       E_Container *con; \
1590       E_Manager *man; \
1591       if ((con_num >= 0) && (zone_num < 0)) /* con=1 zone=all */ { \
1592          con = e_util_container_number_get(con_num); \
1593          EINA_LIST_FOREACH(con->zones, l, zone) { \
1594             act; \
1595          } } \
1596       else if ((con_num < 0) && (zone_num >= 0)) /* con=all zone=1 */ { \
1597          EINA_LIST_FOREACH(e_manager_list(), l, man) { \
1598             EINA_LIST_FOREACH(man->containers, ll, con) { \
1599                zone = e_container_zone_number_get(con, zone_num); \
1600                if (zone) \
1601                  act; \
1602             } } } \
1603       else if ((con_num < 0) && (zone_num < 0)) /* con=all zone=all */ { \
1604          EINA_LIST_FOREACH(e_manager_list(), l, man) { \
1605             EINA_LIST_FOREACH(man->containers, ll, con) { \
1606                EINA_LIST_FOREACH(con->zones, lll, zone) { \
1607                   act; \
1608                } } } } } \
1609    else { \
1610       zone = e_util_container_zone_number_get(con_num, zone_num); \
1611       if (zone) act; \
1612    }
1613
1614 /***************************************************************************/
1615 #if 0
1616 ACT_FN_GO(zone_desk_flip_by, )
1617 {
1618    if (params)
1619      {
1620         int con_num = 0, zone_num = 0;
1621         int dx = 0, dy = 0;
1622
1623         if (sscanf(params, "%i %i %i %i", &con_num, &zone_num, &dx, &dy) == 4)
1624           ZONE_DESK_ACTION(con_num, zone_num, zone,
1625                            e_zone_desk_flip_by(zone, dx, dy));
1626      }
1627 }
1628 #endif
1629
1630 /***************************************************************************/
1631 #if 0
1632 ACT_FN_GO(zone_desk_flip_to, )
1633 {
1634    if (params)
1635      {
1636         int con_num = 0, zone_num = 0;
1637         int dx = 0, dy = 0;
1638
1639         if (sscanf(params, "%i %i %i %i", &con_num, &zone_num, &dx, &dy) == 4)
1640           ZONE_DESK_ACTION(con_num, zone_num, zone,
1641                            e_zone_desk_flip_to(zone, dx, dy));
1642      }
1643 }
1644 #endif
1645
1646 /***************************************************************************/
1647 #if 0
1648 ACT_FN_GO(zone_desk_linear_flip_by, )
1649 {
1650    if (params)
1651      {
1652         int con_num = 0, zone_num = 0;
1653         int dx = 0;
1654
1655         if (sscanf(params, "%i %i %i", &con_num, &zone_num, &dx) == 3)
1656           ZONE_DESK_ACTION(con_num, zone_num, zone,
1657                            e_zone_desk_linear_flip_by(zone, dx));
1658      }
1659 }
1660 #endif
1661
1662 /***************************************************************************/
1663 #if 0
1664 ACT_FN_GO(zone_desk_linear_flip_to, )
1665 {
1666    if (params)
1667      {
1668         int con_num = 0, zone_num = 0;
1669         int dx = 0;
1670
1671         if (sscanf(params, "%i %i %i", &con_num, &zone_num, &dx) == 3)
1672           ZONE_DESK_ACTION(con_num, zone_num, zone,
1673                            e_zone_desk_linear_flip_to(zone, dx));
1674      }
1675 }
1676 #endif
1677
1678 /***************************************************************************/
1679 static void
1680 _e_actions_cb_menu_end(void *data __UNUSED__, E_Menu *m)
1681 {
1682    e_object_del(E_OBJECT(m));
1683 }
1684
1685 static E_Menu *
1686 _e_actions_menu_find(const char *name)
1687 {
1688    if (!strcmp(name, "main"))
1689      return e_int_menus_main_new();
1690    else if (!strcmp(name, "favorites"))
1691      return e_int_menus_favorite_apps_new();
1692    else if (!strcmp(name, "all"))
1693      return e_int_menus_all_apps_new();
1694    else if (!strcmp(name, "clients"))
1695      return e_int_menus_clients_new();
1696    else if (!strcmp(name, "lost_clients"))
1697      return e_int_menus_lost_clients_new();
1698    else if (!strcmp(name, "configuration"))
1699      return e_int_menus_config_new();
1700    return NULL;
1701 }
1702
1703 ACT_FN_GO(menu_show, )
1704 {
1705    E_Zone *zone;
1706
1707    /* menu is active - abort */
1708    if (e_menu_grab_window_get()) return;
1709    zone = _e_actions_zone_get(obj);
1710    if (zone)
1711      {
1712         if (params)
1713           {
1714              E_Menu *m = NULL;
1715
1716              m = _e_actions_menu_find(params);  
1717              if (m)
1718                {
1719                   int x, y;
1720
1721                   /* FIXME: this is a bit of a hack... setting m->con - bad hack */
1722                   m->zone = zone;
1723                   ecore_x_pointer_xy_get(zone->container->win, &x, &y);
1724                   e_menu_post_deactivate_callback_set(m, _e_actions_cb_menu_end, NULL);
1725                   e_menu_activate_mouse(m, zone, x, y, 1, 1,
1726                                         E_MENU_POP_DIRECTION_DOWN,
1727                                         ecore_x_current_time_get());
1728                }
1729           }
1730      }
1731 }
1732
1733 ACT_FN_GO_MOUSE(menu_show, )
1734 {
1735    E_Zone *zone;
1736
1737    /* menu is active - abort */
1738    if (e_menu_grab_window_get()) return;
1739    zone = _e_actions_zone_get(obj);
1740    if (zone)
1741      {
1742         if (params)
1743           {
1744              E_Menu *m = NULL;
1745
1746              m = _e_actions_menu_find(params);  
1747              if (m)
1748                {
1749                   int x, y;
1750
1751                   /* FIXME: this is a bit of a hack... setting m->con - bad hack */
1752                   m->zone = zone;
1753                   x = ev->root.x;
1754                   y = ev->root.y;
1755                   x -= zone->container->x;
1756                   y -= zone->container->y;
1757                   e_menu_post_deactivate_callback_set(m, _e_actions_cb_menu_end, NULL);
1758                   e_menu_activate_mouse(m, zone, x, y, 1, 1,
1759                                         E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
1760                }
1761           }
1762      }
1763 }
1764
1765 ACT_FN_GO_KEY(menu_show, )
1766 {
1767    E_Zone *zone;
1768
1769    /* menu is active - abort */
1770    if (e_menu_grab_window_get()) return;
1771    zone = _e_actions_zone_get(obj);
1772    if (zone)
1773      {
1774         if (params)
1775           {
1776              E_Menu *m = NULL;
1777
1778              m = _e_actions_menu_find(params);  
1779              if (m)
1780                {
1781                   int x, y;
1782
1783                   /* FIXME: this is a bit of a hack... setting m->con - bad hack */
1784                   m->zone = zone;
1785                   ecore_x_pointer_xy_get(zone->container->win, &x, &y);
1786                   e_menu_post_deactivate_callback_set(m, _e_actions_cb_menu_end, NULL);
1787                   e_menu_activate_key(m, zone, x, y, 1, 1,
1788                                       E_MENU_POP_DIRECTION_DOWN);
1789                }
1790           }
1791      }
1792 }
1793
1794 /***************************************************************************/
1795 ACT_FN_GO(exec, )
1796 {
1797    E_Zone *zone;
1798
1799    zone = _e_actions_zone_get(obj);
1800    if (zone)
1801      {
1802         if (params)
1803           e_exec(zone, NULL, params, NULL, "action/exec");
1804      }
1805 }
1806
1807 /***************************************************************************/
1808 ACT_FN_GO(app, )
1809 {
1810    E_Zone *zone;
1811
1812    zone = _e_actions_zone_get(obj);
1813    if (zone)
1814      {
1815         if (params)
1816           {
1817              Efreet_Desktop *desktop = NULL;
1818              char *p, *p2;
1819
1820              p2 = alloca(strlen(params) + 1);
1821              strcpy(p2, params);
1822              p = strchr(p2, ' ');
1823              if (p)
1824                {
1825                   *p = 0;
1826                   if (!strcmp(p2, "file:"))
1827                     desktop = efreet_util_desktop_file_id_find(p + 1);
1828                   else if (!strcmp(p2, "name:"))
1829                     desktop = efreet_util_desktop_name_find(p + 1);
1830                   else if (!strcmp(p2, "generic:"))
1831                     desktop = efreet_util_desktop_generic_name_find(p + 1);
1832                   else if (!strcmp(p2, "exe:"))
1833                     desktop = efreet_util_desktop_exec_find(p + 1);
1834                   if (desktop)
1835                     {
1836                        e_exec(zone, desktop, NULL, NULL, "action/app");
1837                        efreet_desktop_free(desktop);
1838                     }
1839                }
1840           }
1841      }
1842 }
1843
1844 /***************************************************************************/
1845 ACT_FN_GO(desk_deskshow_toggle, __UNUSED__)
1846 {
1847    E_Zone *zone;
1848
1849    zone = _e_actions_zone_get(obj);
1850    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1851    if (zone) e_desk_deskshow(zone);
1852 }
1853
1854 ACT_FN_GO(cleanup_windows, __UNUSED__)
1855 {
1856    E_Zone *zone;
1857
1858    zone = _e_actions_zone_get(obj);
1859    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1860    if (zone) e_place_zone_region_smart_cleanup(zone);
1861 }
1862
1863 /***************************************************************************/
1864 static E_Dialog *exit_dialog = NULL;
1865
1866 static void
1867 _e_actions_cb_exit_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
1868 {
1869    if (dia)
1870      {
1871         e_object_del(E_OBJECT(exit_dialog));
1872         exit_dialog = NULL;
1873      }
1874    e_sys_action_do(E_SYS_EXIT, NULL);
1875 }
1876
1877 static void
1878 _e_actions_cb_exit_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
1879 {
1880    e_object_del(E_OBJECT(exit_dialog));
1881    exit_dialog = NULL;
1882 }
1883
1884 static void
1885 _e_actions_cb_exit_dialog_delete(E_Win *win)
1886 {
1887    E_Dialog *dia;
1888
1889    dia = win->data;
1890    _e_actions_cb_exit_dialog_cancel(NULL, dia);
1891 }
1892
1893 ACT_FN_GO(exit, )
1894 {
1895    if ((params) && (!strcmp(params, "now")))
1896      {
1897         e_sys_action_do(E_SYS_EXIT, NULL);
1898         return;
1899      }
1900    if (exit_dialog) e_object_del(E_OBJECT(exit_dialog));
1901
1902    if (e_config->cnfmdlg_disabled)
1903      {
1904         _e_actions_cb_exit_dialog_ok(NULL, NULL);
1905         return;
1906      }
1907
1908    exit_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_exit_dialog");
1909    if (!exit_dialog) return;
1910    e_win_delete_callback_set(exit_dialog->win, _e_actions_cb_exit_dialog_delete);
1911    e_dialog_title_set(exit_dialog, _("Are you sure you want to exit?"));
1912    e_dialog_text_set(exit_dialog,
1913                      _("You requested to exit Enlightenment.<br>"
1914                        "<br>"
1915                        "Are you sure you want to exit?"));
1916    e_dialog_icon_set(exit_dialog, "application-exit", 64);
1917    e_dialog_button_add(exit_dialog, _("Yes"), NULL,
1918                        _e_actions_cb_exit_dialog_ok, NULL);
1919    e_dialog_button_add(exit_dialog, _("No"), NULL,
1920                        _e_actions_cb_exit_dialog_cancel, NULL);
1921    e_dialog_button_focus_num(exit_dialog, 1);
1922    e_win_centered_set(exit_dialog->win, 1);
1923    e_dialog_show(exit_dialog);
1924 }
1925
1926 /***************************************************************************/
1927 ACT_FN_GO(restart, __UNUSED__)
1928 {
1929    e_sys_action_do(E_SYS_RESTART, NULL);
1930 }
1931
1932 /***************************************************************************/
1933 ACT_FN_GO(exit_now, __UNUSED__)
1934 {
1935    e_sys_action_do(E_SYS_EXIT_NOW, NULL);
1936 }
1937
1938 /***************************************************************************/
1939 ACT_FN_GO(halt_now, __UNUSED__)
1940 {
1941    e_sys_action_do(E_SYS_HALT_NOW, NULL);
1942 }
1943
1944 /***************************************************************************/
1945 ACT_FN_GO(mode_presentation_toggle, __UNUSED__)
1946 {
1947    e_config->mode.presentation = !e_config->mode.presentation;
1948    e_config_mode_changed();
1949    e_config_save_queue();
1950 }
1951
1952 /***************************************************************************/
1953 ACT_FN_GO(mode_offline_toggle, __UNUSED__)
1954 {
1955    e_config->mode.offline = !e_config->mode.offline;
1956    e_config_mode_changed();
1957    e_config_save_queue();
1958 }
1959
1960 /***************************************************************************/
1961 static E_Dialog *logout_dialog = NULL;
1962
1963 static void
1964 _e_actions_cb_logout_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
1965 {
1966    if (dia)
1967      {
1968         e_object_del(E_OBJECT(logout_dialog));
1969         logout_dialog = NULL;
1970      }
1971    e_sys_action_do(E_SYS_LOGOUT, NULL);
1972 }
1973
1974 static void
1975 _e_actions_cb_logout_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
1976 {
1977    e_object_del(E_OBJECT(logout_dialog));
1978    logout_dialog = NULL;
1979 }
1980
1981 static void
1982 _e_actions_cb_logout_dialog_delete(E_Win *win)
1983 {
1984    E_Dialog *dia;
1985
1986    dia = win->data;
1987    _e_actions_cb_logout_dialog_cancel(NULL, dia);
1988 }
1989
1990 ACT_FN_GO(logout, )
1991 {
1992    if ((params) && (!strcmp(params, "now")))
1993      {
1994         e_sys_action_do(E_SYS_LOGOUT, NULL);
1995         return;
1996      }
1997    if (logout_dialog) e_object_del(E_OBJECT(logout_dialog));
1998
1999    if (e_config->cnfmdlg_disabled)
2000      {
2001         _e_actions_cb_logout_dialog_ok(NULL, NULL);
2002         return;
2003      }
2004
2005    logout_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_logout_dialog");
2006    if (!logout_dialog) return;
2007    e_win_delete_callback_set(logout_dialog->win, _e_actions_cb_logout_dialog_delete);
2008    e_dialog_title_set(logout_dialog, _("Are you sure you want to log out?"));
2009    e_dialog_text_set(logout_dialog,
2010                      _("You are about to log out.<br>"
2011                        "<br>"
2012                        "Are you sure you want to do this?"));
2013    e_dialog_icon_set(logout_dialog, "system-log-out", 64);
2014    e_dialog_button_add(logout_dialog, _("Yes"), NULL,
2015                        _e_actions_cb_logout_dialog_ok, NULL);
2016    e_dialog_button_add(logout_dialog, _("No"), NULL,
2017                        _e_actions_cb_logout_dialog_cancel, NULL);
2018    e_dialog_button_focus_num(logout_dialog, 1);
2019    e_win_centered_set(logout_dialog->win, 1);
2020    e_dialog_show(logout_dialog);
2021 }
2022
2023 /***************************************************************************/
2024 static E_Dialog *halt_dialog = NULL;
2025
2026 static void
2027 _e_actions_cb_halt_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2028 {
2029    if (dia)
2030      {
2031         e_object_del(E_OBJECT(halt_dialog));
2032         halt_dialog = NULL;
2033      }
2034    e_sys_action_do(E_SYS_HALT, NULL);
2035 }
2036
2037 static void
2038 _e_actions_cb_halt_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2039 {
2040    e_object_del(E_OBJECT(halt_dialog));
2041    halt_dialog = NULL;
2042 }
2043
2044 static void
2045 _e_actions_cb_halt_dialog_delete(E_Win *win)
2046 {
2047    E_Dialog *dia;
2048
2049    dia = win->data;
2050    _e_actions_cb_halt_dialog_cancel(NULL, dia);
2051 }
2052
2053 ACT_FN_GO(halt, )
2054 {
2055    if ((params) && (!strcmp(params, "now")))
2056      {
2057         e_sys_action_do(E_SYS_HALT, NULL);
2058         return;
2059      }
2060    if (halt_dialog) e_object_del(E_OBJECT(halt_dialog));
2061
2062    if (e_config->cnfmdlg_disabled)
2063      {
2064         _e_actions_cb_halt_dialog_ok(NULL, NULL);
2065         return;
2066      }
2067
2068    halt_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_halt_dialog");
2069    if (!halt_dialog) return;
2070    e_win_delete_callback_set(halt_dialog->win, _e_actions_cb_halt_dialog_delete);
2071    e_dialog_title_set(halt_dialog, _("Are you sure you want to turn off?"));
2072    e_dialog_text_set(halt_dialog,
2073                      _("You requested to turn off your Computer.<br>"
2074                        "<br>"
2075                        "Are you sure you want to shut down?"));
2076    e_dialog_icon_set(halt_dialog, "system-shutdown", 64);
2077    e_dialog_button_add(halt_dialog, _("Yes"), NULL,
2078                        _e_actions_cb_halt_dialog_ok, NULL);
2079    e_dialog_button_add(halt_dialog, _("No"), NULL,
2080                        _e_actions_cb_halt_dialog_cancel, NULL);
2081    e_dialog_button_focus_num(halt_dialog, 1);
2082    e_win_centered_set(halt_dialog->win, 1);
2083    e_dialog_show(halt_dialog);
2084 }
2085
2086 /***************************************************************************/
2087 static E_Dialog *reboot_dialog = NULL;
2088
2089 static void
2090 _e_actions_cb_reboot_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2091 {
2092    if (dia)
2093      {
2094         e_object_del(E_OBJECT(reboot_dialog));
2095         reboot_dialog = NULL;
2096      }
2097    e_sys_action_do(E_SYS_REBOOT, NULL);
2098 }
2099
2100 static void
2101 _e_actions_cb_reboot_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2102 {
2103    e_object_del(E_OBJECT(reboot_dialog));
2104    reboot_dialog = NULL;
2105 }
2106
2107 static void
2108 _e_actions_cb_reboot_dialog_delete(E_Win *win)
2109 {
2110    E_Dialog *dia;
2111
2112    dia = win->data;
2113    _e_actions_cb_reboot_dialog_cancel(NULL, dia);
2114 }
2115
2116 ACT_FN_GO(reboot, )
2117 {
2118    if ((params) && (!strcmp(params, "now")))
2119      {
2120         e_sys_action_do(E_SYS_REBOOT, NULL);
2121         return;
2122      }
2123    if (reboot_dialog) e_object_del(E_OBJECT(reboot_dialog));
2124
2125    if (e_config->cnfmdlg_disabled)
2126      {
2127         _e_actions_cb_reboot_dialog_ok(NULL, NULL);
2128         return;
2129      }
2130
2131    reboot_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_reboot_dialog");
2132    if (!reboot_dialog) return;
2133    e_win_delete_callback_set(reboot_dialog->win, _e_actions_cb_reboot_dialog_delete);
2134    e_dialog_title_set(reboot_dialog, _("Are you sure you want to reboot?"));
2135    e_dialog_text_set(reboot_dialog,
2136                      _("You requested to reboot your Computer.<br>"
2137                        "<br>"
2138                        "Are you sure you want to restart it?"));
2139    e_dialog_icon_set(reboot_dialog, "system-restart", 64);
2140    e_dialog_button_add(reboot_dialog, _("Yes"), NULL,
2141                        _e_actions_cb_reboot_dialog_ok, NULL);
2142    e_dialog_button_add(reboot_dialog, _("No"), NULL,
2143                        _e_actions_cb_reboot_dialog_cancel, NULL);
2144    e_dialog_button_focus_num(reboot_dialog, 1);
2145    e_win_centered_set(reboot_dialog->win, 1);
2146    e_dialog_show(reboot_dialog);
2147 }
2148
2149 /***************************************************************************/
2150 static E_Dialog *suspend_dialog = NULL;
2151
2152 static void
2153 _e_actions_cb_suspend_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2154 {
2155    if (dia)
2156      {
2157         e_object_del(E_OBJECT(suspend_dialog));
2158         suspend_dialog = NULL;
2159      }
2160    e_sys_action_do(E_SYS_SUSPEND, NULL);
2161 }
2162
2163 static void
2164 _e_actions_cb_suspend_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2165 {
2166    e_object_del(E_OBJECT(suspend_dialog));
2167    suspend_dialog = NULL;
2168 }
2169
2170 static void
2171 _e_actions_cb_suspend_dialog_delete(E_Win *win)
2172 {
2173    E_Dialog *dia;
2174
2175    dia = win->data;
2176    _e_actions_cb_suspend_dialog_cancel(NULL, dia);
2177 }
2178
2179 ACT_FN_GO(suspend_now, __UNUSED__)
2180 {
2181    e_sys_action_do(E_SYS_SUSPEND, NULL);
2182 }
2183
2184 ACT_FN_GO(suspend, )
2185 {
2186    if ((params) && (!strcmp(params, "now")))
2187      {
2188         e_sys_action_do(E_SYS_SUSPEND, NULL);
2189         return;
2190      }
2191    if (suspend_dialog) e_object_del(E_OBJECT(suspend_dialog));
2192
2193    if (e_config->cnfmdlg_disabled)
2194      {
2195         _e_actions_cb_suspend_dialog_ok(NULL, NULL);
2196         return;
2197      }
2198
2199    suspend_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_suspend_dialog");
2200    if (!suspend_dialog) return;
2201    e_win_delete_callback_set(suspend_dialog->win, _e_actions_cb_suspend_dialog_delete);
2202    e_dialog_title_set(suspend_dialog, _("Are you sure you want to turn off?"));
2203    e_dialog_text_set(suspend_dialog,
2204                      _("You requested to suspend your Computer.<br>"
2205                        "<br>"
2206                        "Are you sure you want to suspend?"));
2207    e_dialog_icon_set(suspend_dialog, "system-suspend", 64);
2208    e_dialog_button_add(suspend_dialog, _("Yes"), NULL,
2209                        _e_actions_cb_suspend_dialog_ok, NULL);
2210    e_dialog_button_add(suspend_dialog, _("No"), NULL,
2211                        _e_actions_cb_suspend_dialog_cancel, NULL);
2212    e_dialog_button_focus_num(suspend_dialog, 1);
2213    e_win_centered_set(suspend_dialog->win, 1);
2214    e_dialog_show(suspend_dialog);
2215 }
2216
2217 /***************************************************************************/
2218 static E_Dialog *hibernate_dialog = NULL;
2219
2220 static void
2221 _e_actions_cb_hibernate_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2222 {
2223    if (dia)
2224      {
2225         e_object_del(E_OBJECT(hibernate_dialog));
2226         hibernate_dialog = NULL;
2227      }
2228    e_sys_action_do(E_SYS_HIBERNATE, NULL);
2229 }
2230
2231 static void
2232 _e_actions_cb_hibernate_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2233 {
2234    e_object_del(E_OBJECT(hibernate_dialog));
2235    hibernate_dialog = NULL;
2236 }
2237
2238 static void
2239 _e_actions_cb_hibernate_dialog_delete(E_Win *win)
2240 {
2241    E_Dialog *dia;
2242
2243    dia = win->data;
2244    _e_actions_cb_hibernate_dialog_cancel(NULL, dia);
2245 }
2246
2247 ACT_FN_GO(hibernate, )
2248 {
2249    if ((params) && (!strcmp(params, "now")))
2250      {
2251         e_sys_action_do(E_SYS_HIBERNATE, NULL);
2252         return;
2253      }
2254    if (hibernate_dialog) e_object_del(E_OBJECT(hibernate_dialog));
2255
2256    if (e_config->cnfmdlg_disabled)
2257      {
2258         _e_actions_cb_hibernate_dialog_ok(NULL, NULL);
2259         return;
2260      }
2261
2262    hibernate_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_hibernate_dialog");
2263    if (!hibernate_dialog) return;
2264    e_win_delete_callback_set(hibernate_dialog->win, _e_actions_cb_hibernate_dialog_delete);
2265    e_dialog_title_set(hibernate_dialog, _("Are you sure you want to hibernate?"));
2266    e_dialog_text_set(hibernate_dialog,
2267                      _("You requested to hibernate your Computer.<br>"
2268                        "<br>"
2269                        "Are you sure you want to suspend to disk?"));
2270    e_dialog_icon_set(hibernate_dialog, "system-suspend-hibernate", 64);
2271    e_dialog_button_add(hibernate_dialog, _("Yes"), NULL,
2272                        _e_actions_cb_hibernate_dialog_ok, NULL);
2273    e_dialog_button_add(hibernate_dialog, _("No"), NULL,
2274                        _e_actions_cb_hibernate_dialog_cancel, NULL);
2275    e_dialog_button_focus_num(hibernate_dialog, 1);
2276    e_win_centered_set(hibernate_dialog->win, 1);
2277    e_dialog_show(hibernate_dialog);
2278 }
2279
2280 /***************************************************************************/
2281 ACT_FN_GO(pointer_resize_push, )
2282 {
2283    if (!obj) return;
2284    if (obj->type == E_BORDER_TYPE)
2285      {
2286         E_Border *bd;
2287
2288         bd = (E_Border *)obj;
2289         if ((bd->lock_user_size) || (bd->shaded) || (bd->shading) ||
2290             (bd->fullscreen) || ((bd->maximized) && (!e_config->allow_manip)))
2291           return;
2292         e_pointer_type_push(bd->pointer, bd, params);
2293      }
2294 }
2295
2296 /***************************************************************************/
2297 ACT_FN_GO(pointer_resize_pop, )
2298 {
2299    if (!obj) return;
2300    if (obj->type == E_BORDER_TYPE)
2301      {
2302         E_Border *bd;
2303
2304         bd = (E_Border *)obj;
2305         if ((bd->lock_user_size) || (bd->shaded) || (bd->shading) ||
2306             (bd->fullscreen) || ((bd->maximized) && (!e_config->allow_manip)))
2307           return;
2308         e_pointer_type_pop(bd->pointer, bd, params);
2309      }
2310 }
2311
2312 /***************************************************************************/
2313 ACT_FN_GO(desk_lock, __UNUSED__)
2314 {
2315 /*  E_Zone *zone;
2316
2317   zone = _e_actions_zone_get(obj);
2318   if (zone)*/
2319   e_desklock_show();
2320 }
2321
2322 /***************************************************************************/
2323 ACT_FN_GO(shelf_show, )
2324 {
2325    Eina_List *l;
2326    E_Shelf *es;
2327
2328    if (params)
2329      {
2330         for (; *params != '\0'; params++)
2331           if (!isspace(*params))
2332             break;
2333         if (*params == '\0')
2334           params = NULL;
2335      }
2336
2337    EINA_LIST_FOREACH(e_shelf_list(), l, es)
2338      {
2339         if ((!params) || (params && (fnmatch(params, es->name, 0) == 0)))
2340           {
2341              e_shelf_toggle(es, 1);
2342              e_shelf_toggle(es, 0);
2343           }
2344      }
2345 }
2346 /***************************************************************************/
2347 #define ACT_SHELF_SHOW(params, es) \
2348 if ((!params) || (params && (fnmatch(params, es->name, 0) == 0))) \
2349   { \
2350      e_shelf_toggle(es, 1); \
2351      e_shelf_toggle(es, 0); \
2352   }
2353
2354 ACT_FN_GO_EDGE(shelf_show, )
2355 {
2356    Eina_List *l;
2357    E_Shelf *es;
2358
2359    if (params)
2360      {
2361         for (; *params != '\0'; params++)
2362           {
2363              if (!isspace(*params))
2364                break;
2365           }
2366         if (*params == '\0')
2367           params = NULL;
2368      }
2369
2370    EINA_LIST_FOREACH(e_shelf_list(), l, es)
2371      {
2372         switch(ev->edge)
2373           {
2374           case E_ZONE_EDGE_LEFT:
2375              if ((es->gadcon->orient == E_GADCON_ORIENT_LEFT ||
2376                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_LT ||
2377                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_LB) &&
2378                  (ev->y >= es->y) && (ev->y <= (es->y + es->h)))
2379                ACT_SHELF_SHOW(params, es);
2380              break;
2381           case E_ZONE_EDGE_RIGHT:
2382              if ((es->gadcon->orient == E_GADCON_ORIENT_RIGHT ||
2383                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_RT ||
2384                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_RB) &&
2385                  (ev->y >= es->y) && (ev->y <= (es->y + es->h)))
2386                ACT_SHELF_SHOW(params, es);
2387              break;
2388           case E_ZONE_EDGE_TOP:
2389              if ((es->gadcon->orient == E_GADCON_ORIENT_TOP ||
2390                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_TL ||
2391                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_TR) &&
2392                  (ev->x >= es->x) && (ev->x <= (es->x + es->w)))
2393                ACT_SHELF_SHOW(params, es);
2394              break;
2395           case E_ZONE_EDGE_BOTTOM:
2396              if ((es->gadcon->orient == E_GADCON_ORIENT_BOTTOM ||
2397                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_BL ||
2398                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_BR) &&
2399                  (ev->x >= es->x) && (ev->x <= (es->x + es->w)))
2400                ACT_SHELF_SHOW(params, es);
2401              break;
2402           default:
2403              break;
2404           }
2405      }
2406 }
2407 #undef ACT_SHELF_SHOW
2408
2409 /***************************************************************************/
2410 typedef struct _Delayed_Action Delayed_Action;
2411
2412 struct _Delayed_Action
2413 {
2414    int mouse, button;
2415    const char *keyname;
2416    E_Object *obj;
2417    Ecore_Timer *timer;
2418    struct
2419      {
2420         const char *action, *params;
2421      } def, delayed;
2422 };
2423
2424 static Eina_List *_delayed_actions = NULL;
2425
2426 static void
2427 _delayed_action_free(Delayed_Action *da)
2428 {
2429    if (da->obj) e_object_unref(da->obj);
2430    if (da->keyname) eina_stringshare_del(da->keyname);
2431    if (da->timer) ecore_timer_del(da->timer);
2432    if (da->def.action) eina_stringshare_del(da->def.action);
2433    if (da->def.params) eina_stringshare_del(da->def.params);
2434    if (da->delayed.action) eina_stringshare_del(da->delayed.action);
2435    if (da->delayed.params) eina_stringshare_del(da->delayed.params);
2436    free(da);
2437 }
2438
2439 static Eina_Bool
2440 _delayed_action_cb_timer(void *data)
2441 {
2442    Delayed_Action *da;
2443    E_Action *act;
2444
2445    da = data;
2446    da->timer = NULL;
2447    act = e_action_find(da->delayed.action);
2448    if (act)
2449      {
2450         if (act->func.go) act->func.go(da->obj, da->delayed.params);
2451      }
2452    _delayed_actions = eina_list_remove(_delayed_actions, da);
2453    _delayed_action_free(da);
2454    return ECORE_CALLBACK_CANCEL;
2455 }
2456
2457 static void
2458 _delayed_action_do(Delayed_Action *da)
2459 {
2460    E_Action *act;
2461
2462    act = e_action_find(da->def.action);
2463    if (act)
2464      {
2465         if (act->func.go) act->func.go(da->obj, da->def.params);
2466      }
2467 }
2468
2469 static void
2470 _delayed_action_list_parse_action(const char *str, double *delay, const char **action, const char **params)
2471 {
2472    char fbuf[16];
2473    char buf[1024];
2474    const char *p;
2475
2476    buf[0] = 0;
2477    sscanf(str, "%10s %1000s", fbuf, buf);
2478    *action = eina_stringshare_add(buf);
2479    *delay = atof(fbuf);
2480    p = strchr(str, ' ');
2481    if (p)
2482      {
2483         p++;
2484         p = strchr(p, ' ');
2485         if (p)
2486           {
2487              p++;
2488              *params = eina_stringshare_add(p);
2489           }
2490      }
2491 }
2492
2493 static void
2494 _delayed_action_list_parse(Delayed_Action *da, const char *params)
2495 {
2496    double delay = 2.0;
2497    const char *p, *a1start = NULL, *a1stop = NULL;
2498    const char *a2start = NULL, *a2stop = NULL;
2499
2500    // FORMAT: "[0.0 default_action param1 param2] [x.x action2 param1 param2]"
2501    p = params;
2502    while (*p)
2503      {
2504         if ((*p == '[') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a1start = p + 1; break;}
2505         p++;
2506      }
2507    while (*p)
2508      {
2509         if ((*p == ']') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a1stop = p; break;}
2510         p++;
2511      }
2512    while (*p)
2513      {
2514         if ((*p == '[') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a2start = p + 1; break;}
2515         p++;
2516      }
2517    while (*p)
2518      {
2519         if ((*p == ']') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a2stop = p; break;}
2520         p++;
2521      }
2522    if ((a1start) && (a2start) && (a1stop) && (a2stop))
2523      {
2524         char *a1, *a2;
2525         const char *action, *params;
2526
2527         a1 = alloca(a1stop - a1start + 1);
2528         eina_strlcpy(a1, a1start, a1stop - a1start + 1);
2529         action = NULL;
2530         params = NULL;
2531         _delayed_action_list_parse_action(a1, &delay, &da->def.action, &da->def.params);
2532
2533         a2 = alloca(a1stop - a1start + 1);
2534         eina_strlcpy(a2, a2start, a2stop - a2start + 1);
2535         _delayed_action_list_parse_action(a2, &delay, &da->delayed.action, &da->delayed.params);
2536      }
2537    da->timer = ecore_timer_add(delay, _delayed_action_cb_timer, da);
2538 }
2539
2540 static void
2541 _delayed_action_key_add(E_Object *obj, const char *params, Ecore_Event_Key *ev)
2542 {
2543    Delayed_Action *da;
2544
2545    da = E_NEW(Delayed_Action, 1);
2546    if (!da) return;
2547    if (obj)
2548      {
2549         da->obj = obj;
2550         e_object_ref(da->obj);
2551      }
2552    da->mouse = 0;
2553    da->keyname = eina_stringshare_add(ev->keyname);
2554    if (params) _delayed_action_list_parse(da, params);
2555    _delayed_actions = eina_list_append(_delayed_actions, da);
2556 }
2557
2558 static void
2559 _delayed_action_key_del(E_Object *obj, const char *params __UNUSED__, Ecore_Event_Key *ev)
2560 {
2561    Eina_List *l;
2562    Delayed_Action *da;
2563
2564    EINA_LIST_FOREACH(_delayed_actions, l, da)
2565      {
2566         if ((da->obj == obj) && (!da->mouse) &&
2567             (!strcmp(da->keyname, ev->keyname)))
2568           {
2569              _delayed_action_do(da);
2570              _delayed_action_free(da);
2571              _delayed_actions = eina_list_remove_list(_delayed_actions, l);
2572              return;
2573           }
2574      }
2575 }
2576
2577 static void
2578 _delayed_action_mouse_add(E_Object *obj, const char *params, Ecore_Event_Mouse_Button *ev)
2579 {
2580    Delayed_Action *da;
2581
2582    da = E_NEW(Delayed_Action, 1);
2583    if (!da) return;
2584    if (obj)
2585      {
2586         da->obj = obj;
2587         e_object_ref(da->obj);
2588      }
2589    da->mouse = 1;
2590    da->button = ev->buttons;
2591    if (params) _delayed_action_list_parse(da, params);
2592    _delayed_actions = eina_list_append(_delayed_actions, da);
2593 }
2594
2595 static void
2596 _delayed_action_mouse_del(E_Object *obj, const char *params __UNUSED__, Ecore_Event_Mouse_Button *ev)
2597 {
2598    Eina_List *l;
2599    Delayed_Action *da;
2600
2601    EINA_LIST_FOREACH(_delayed_actions, l, da)
2602      {
2603         if ((da->obj == obj) && (da->mouse) &&
2604             ((int) ev->buttons == da->button))
2605           {
2606              _delayed_action_do(da);
2607              _delayed_action_free(da);
2608              _delayed_actions = eina_list_remove_list(_delayed_actions, l);
2609              return;
2610           }
2611      }
2612 }
2613
2614 // obj , params  , ev
2615 ACT_FN_GO_KEY(delayed_action, )
2616 {
2617    _delayed_action_key_add(obj, params, ev);
2618 }
2619
2620 ACT_FN_GO_MOUSE(delayed_action, )
2621 {
2622    _delayed_action_mouse_add(obj, params, ev);
2623 }
2624
2625 ACT_FN_END_KEY(delayed_action, )
2626 {
2627    _delayed_action_key_del(obj, params, ev);
2628 }
2629
2630 ACT_FN_END_MOUSE(delayed_action, )
2631 {
2632    _delayed_action_mouse_del(obj, params, ev);
2633 }
2634
2635 ACT_FN_GO_ACPI(dim_screen, __UNUSED__)
2636 {
2637    E_Zone *zone = _e_actions_zone_get(obj);
2638    e_backlight_mode_set(zone, E_BACKLIGHT_MODE_DIM);
2639 }
2640
2641 ACT_FN_GO_ACPI(undim_screen, __UNUSED__)
2642 {
2643    E_Zone *zone = _e_actions_zone_get(obj);
2644    e_backlight_mode_set(zone, E_BACKLIGHT_MODE_NORMAL);
2645 }
2646
2647 ACT_FN_GO(backlight_set, )
2648 {
2649    E_Zone *zone = _e_actions_zone_get(obj);
2650    int v;
2651    if (params)
2652       v = atoi(params);
2653    else
2654      {
2655         v = e_backlight_level_get(zone) * 100.0;
2656         if (v == 0) v = 100;
2657         else v = 0;
2658      }
2659    e_backlight_mode_set(zone, E_BACKLIGHT_MODE_NORMAL);
2660    e_backlight_level_set(zone, ((double)v / 100.0), -1.0);
2661 }
2662
2663 ACT_FN_GO(backlight_adjust, )
2664 {
2665    E_Zone *zone = _e_actions_zone_get(obj);
2666    int v;
2667    if (!params) return;
2668    v = atoi(params);
2669    e_backlight_mode_set(zone, E_BACKLIGHT_MODE_NORMAL);
2670    e_backlight_level_set(zone, e_backlight_level_get(zone) + ((double)v / 100.0), -1.0);
2671 }
2672
2673 /* local subsystem globals */
2674 static Eina_Hash *actions = NULL;
2675 static Eina_List *action_list = NULL;
2676 static Eina_List *action_names = NULL;
2677 static Eina_List *action_groups = NULL;
2678
2679 /* externally accessible functions */
2680
2681 EINTERN int
2682 e_actions_init(void)
2683 {
2684    E_Action *act;
2685
2686    actions = eina_hash_string_superfast_new(NULL);
2687    ACT_GO(window_move);
2688    e_action_predef_name_set(N_("Window : Actions"), N_("Move"),
2689                             "window_move", NULL, NULL, 0);
2690
2691    ACT_GO_MOUSE(window_move);
2692    ACT_GO_SIGNAL(window_move);
2693    ACT_END(window_move);
2694    ACT_END_MOUSE(window_move);
2695    ACT_GO_KEY(window_move);
2696
2697    /* window_resize */
2698    ACT_GO(window_resize);
2699    e_action_predef_name_set(N_("Window : Actions"), N_("Resize"),
2700                             "window_resize", NULL, NULL, 0);
2701
2702    ACT_GO_MOUSE(window_resize);
2703    ACT_GO_SIGNAL(window_resize);
2704    ACT_END(window_resize);
2705    ACT_END_MOUSE(window_resize);
2706    ACT_GO_KEY(window_resize);
2707
2708    /* window_menu */
2709    ACT_GO(window_menu);
2710    e_action_predef_name_set(N_("Menu"), N_("Window Menu"),
2711                             "window_menu", NULL, NULL, 0);
2712
2713    ACT_GO_MOUSE(window_menu);
2714    ACT_GO_KEY(window_menu);
2715
2716    /* window_raise */
2717    ACT_GO(window_raise);
2718    e_action_predef_name_set(N_("Window : Actions"), N_("Raise"),
2719                             "window_raise", NULL, NULL, 0);
2720
2721    /* window_lower */
2722    ACT_GO(window_lower);
2723    e_action_predef_name_set(N_("Window : Actions"), N_("Lower"),
2724                             "window_lower", NULL, NULL, 0);
2725
2726    /* window_close */
2727    ACT_GO(window_close);
2728    e_action_predef_name_set(N_("Window : Actions"), N_("Close"),
2729                             "window_close", NULL, NULL, 0);
2730
2731    /* window_kill */
2732    ACT_GO(window_kill);
2733    e_action_predef_name_set(N_("Window : Actions"), N_("Kill"),
2734                             "window_kill", NULL, NULL, 0);
2735
2736    /* window_sticky_toggle */
2737    ACT_GO(window_sticky_toggle);
2738    e_action_predef_name_set(N_("Window : State"), N_("Sticky Mode Toggle"),
2739                             "window_sticky_toggle", NULL, NULL, 0);
2740
2741    ACT_GO(window_sticky);
2742
2743    /* window_iconic_toggle */
2744    ACT_GO(window_iconic_toggle);
2745    e_action_predef_name_set(N_("Window : State"), N_("Iconic Mode Toggle"),
2746                             "window_iconic_toggle", NULL, NULL, 0);
2747
2748    ACT_GO(window_iconic);
2749
2750    /* window_fullscreen_toggle */
2751    ACT_GO(window_fullscreen_toggle);
2752    e_action_predef_name_set(N_("Window : State"), N_("Fullscreen Mode Toggle"),
2753                             "window_fullscreen_toggle", NULL, NULL, 0);
2754
2755    ACT_GO(window_fullscreen);
2756
2757    /* window_maximized_toggle */
2758    ACT_GO(window_maximized_toggle);
2759    e_action_predef_name_set(N_("Window : State"), N_("Maximize"),
2760                             "window_maximized_toggle", NULL, NULL, 0);
2761    e_action_predef_name_set(N_("Window : State"), N_("Maximize Vertically"),
2762                             "window_maximized_toggle", "default vertical",
2763                             NULL, 0);
2764    e_action_predef_name_set(N_("Window : State"), N_("Maximize Horizontally"),
2765                             "window_maximized_toggle", "default horizontal",
2766                             NULL, 0);
2767    e_action_predef_name_set(N_("Window : State"), N_("Maximize Fullscreen"),
2768                             "window_maximized_toggle", "fullscreen", NULL, 0);
2769    e_action_predef_name_set(N_("Window : State"), N_("Maximize Mode \"Smart\""),
2770                             "window_maximized_toggle", "smart", NULL, 0);
2771    e_action_predef_name_set(N_("Window : State"), N_("Maximize Mode \"Expand\""),
2772                             "window_maximized_toggle", "expand", NULL, 0);
2773    e_action_predef_name_set(N_("Window : State"), N_("Maximize Mode \"Fill\""),
2774                             "window_maximized_toggle", "fill", NULL, 0);
2775
2776    ACT_GO(window_maximized);
2777
2778    /* window_shaded_toggle */
2779    ACT_GO(window_shaded_toggle);
2780    e_action_predef_name_set(N_("Window : State"), N_("Shade Up Mode Toggle"),
2781                             "window_shaded_toggle", "up", NULL, 0);
2782    e_action_predef_name_set(N_("Window : State"), N_("Shade Down Mode Toggle"),
2783                             "window_shaded_toggle", "down", NULL, 0);
2784    e_action_predef_name_set(N_("Window : State"), N_("Shade Left Mode Toggle"),
2785                             "window_shaded_toggle", "left", NULL, 0);
2786    e_action_predef_name_set(N_("Window : State"), N_("Shade Right Mode Toggle"),
2787                             "window_shaded_toggle", "right", NULL, 0);
2788    e_action_predef_name_set(N_("Window : State"), N_("Shade Mode Toggle"),
2789                             "window_shaded_toggle", NULL, NULL, 0);
2790
2791    ACT_GO(window_shaded);
2792
2793    /* window_borderless_toggle */
2794    ACT_GO(window_borderless_toggle);
2795    e_action_predef_name_set(N_("Window : State"), N_("Toggle Borderless State"),
2796                             "window_borderless_toggle", NULL, NULL, 0);
2797
2798    /* window_border_set */
2799    ACT_GO(window_border_set);
2800    e_action_predef_name_set(N_("Window : State"), N_("Set Border"),
2801                             "window_border_set", NULL,
2802                             "syntax: BorderName, example: pixel", 1);
2803
2804    /* window_border_cycle */
2805    ACT_GO(window_border_cycle);
2806    e_action_predef_name_set(N_("Window : State"), N_("Cycle between Borders"),
2807                             "window_border_cycle", NULL,
2808                             "syntax: BorderNames, example: default pixel", 1);
2809
2810    /* window_pinned_toggle */
2811    ACT_GO(window_pinned_toggle);
2812    e_action_predef_name_set(N_("Window : State"), N_("Toggle Pinned State"),
2813                             "window_pinned_toggle", NULL, NULL, 0);
2814
2815    /* desk_flip_by */
2816    ACT_GO(desk_flip_by);
2817    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Left"),
2818                             "desk_flip_by", "-1 0", NULL, 0);
2819    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Right"),
2820                             "desk_flip_by", "1 0", NULL, 0);
2821    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Up"),
2822                             "desk_flip_by", "0 -1", NULL, 0);
2823    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Down"),
2824                             "desk_flip_by", "0 1", NULL, 0);
2825    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop By..."),
2826                             "desk_flip_by", NULL,
2827                             "syntax: X-offset Y-offset, example: -1 0", 1);
2828
2829    /* desk_deskshow_toggle */
2830    ACT_GO(desk_deskshow_toggle);
2831    e_action_predef_name_set(N_("Desktop"), N_("Show The Desktop"),
2832                             "desk_deskshow_toggle", NULL, NULL, 0);
2833
2834    /* shelf_show */
2835    ACT_GO(shelf_show);
2836    ACT_GO_EDGE(shelf_show);
2837    e_action_predef_name_set(N_("Desktop"), N_("Show The Shelf"), "shelf_show",
2838                             NULL, "shelf name glob: Shelf-* ", 1);
2839
2840    /* desk_linear_flip_to */
2841    ACT_GO(desk_flip_to);
2842    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop To..."),
2843                             "desk_flip_to", NULL,
2844                             "syntax: X Y, example: 1 2", 1);
2845
2846    /* desk_linear_flip_by */
2847    ACT_GO(desk_linear_flip_by);
2848    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Linearly..."),
2849                             "desk_linear_flip_by",
2850                             NULL, "syntax: N-offset, example: -2", 1);
2851
2852    /* desk_linear_flip_to */
2853    ACT_GO(desk_linear_flip_to);
2854    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 0"),
2855                             "desk_linear_flip_to", "0", NULL, 0);
2856    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 1"),
2857                             "desk_linear_flip_to", "1", NULL, 0);
2858    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 2"),
2859                             "desk_linear_flip_to", "2", NULL, 0);
2860    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 3"),
2861                             "desk_linear_flip_to", "3", NULL, 0);
2862    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 4"),
2863                             "desk_linear_flip_to", "4", NULL, 0);
2864    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 5"),
2865                             "desk_linear_flip_to", "5", NULL, 0);
2866    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 6"),
2867                             "desk_linear_flip_to", "6", NULL, 0);
2868    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 7"),
2869                             "desk_linear_flip_to", "7", NULL, 0);
2870    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 8"),
2871                             "desk_linear_flip_to", "8", NULL, 0);
2872    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 9"),
2873                             "desk_linear_flip_to", "9", NULL, 0);
2874    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 10"),
2875                             "desk_linear_flip_to", "10", NULL, 0);
2876    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 11"),
2877                             "desk_linear_flip_to", "11", NULL, 0);
2878    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop..."),
2879                             "desk_linear_flip_to", NULL,
2880                             "syntax: N, example: 1", 1);
2881
2882    /* desk_flip_by_all */
2883    ACT_GO(desk_flip_by_all);
2884    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Left (All Screens)"),
2885                             "desk_flip_by_all", "-1 0", NULL, 0);
2886    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Right (All Screens)"),
2887                             "desk_flip_by_all", "1 0", NULL, 0);
2888    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Up (All Screens)"),
2889                             "desk_flip_by_all", "0 -1", NULL, 0);
2890    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Down (All Screens)"),
2891                             "desk_flip_by_all", "0 1", NULL, 0);
2892    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop By... (All Screens)"),
2893                             "desk_flip_by_all", NULL,
2894                             "syntax: X-offset Y-offset, example: -1 0", 1);
2895
2896    /* desk_flip_to_all */
2897    ACT_GO(desk_flip_to_all);
2898    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop To... (All Screens)"),
2899                             "desk_flip_to_all", NULL,
2900                             "syntax: X Y, example: 1 2", 1);
2901
2902    /* desk_linear_flip_by_all */
2903    ACT_GO(desk_linear_flip_by_all);
2904    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Linearly... (All Screens)"),
2905                             "desk_linear_flip_by_all",
2906                             NULL, "syntax: N-offset, example: -2", 1);
2907
2908    /* desk_flip_in_direction */
2909    ACT_GO_EDGE(desk_flip_in_direction);
2910    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop In Direction..."),
2911                             "desk_flip_in_direction", NULL, "syntax: N-pixel-offset, example: 25", 1);
2912
2913    /* desk_linear_flip_to_all */
2914    ACT_GO(desk_linear_flip_to_all);
2915    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 0 (All Screens)"),
2916                             "desk_linear_flip_to_all", "0", NULL, 0);
2917    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 1 (All Screens)"),
2918                             "desk_linear_flip_to_all", "1", NULL, 0);
2919    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 2 (All Screens)"),
2920                             "desk_linear_flip_to_all", "2", NULL, 0);
2921    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 3 (All Screens)"),
2922                             "desk_linear_flip_to_all", "3", NULL, 0);
2923    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 4 (All Screens)"),
2924                             "desk_linear_flip_to_all", "4", NULL, 0);
2925    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 5 (All Screens)"),
2926                             "desk_linear_flip_to_all", "5", NULL, 0);
2927    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 6 (All Screens)"),
2928                             "desk_linear_flip_to_all", "6", NULL, 0);
2929    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 7 (All Screens)"),
2930                             "desk_linear_flip_to_all", "7", NULL, 0);
2931    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 8 (All Screens)"),
2932                             "desk_linear_flip_to_all", "8", NULL, 0);
2933    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 9 (All Screens)"),
2934                             "desk_linear_flip_to_all", "9", NULL, 0);
2935    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 10 (All Screens)"),
2936                             "desk_linear_flip_to_all", "10", NULL, 0);
2937    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 11 (All Screens)"),
2938                             "desk_linear_flip_to_all", "11", NULL, 0);
2939    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop... (All Screens)"),
2940                             "desk_linear_flip_to_all", NULL,
2941                             "syntax: N, example: 1", 1);
2942
2943    /* screen_send_to */
2944    ACT_GO(screen_send_to);
2945    e_action_predef_name_set(N_("Screen"), N_("Send Mouse To Screen 0"),
2946                             "screen_send_to", "0", NULL, 0);
2947    e_action_predef_name_set(N_("Screen"), N_("Send Mouse To Screen 1"),
2948                             "screen_send_to", "1", NULL, 0);
2949    e_action_predef_name_set(N_("Screen"), N_("Send Mouse To Screen..."),
2950                             "screen_send_to", NULL,
2951                             "syntax: N, example: 0", 1);
2952
2953    /* screen_send_by */
2954    ACT_GO(screen_send_by);
2955    e_action_predef_name_set(N_("Screen"), N_("Send Mouse Forward 1 Screen"),
2956                             "screen_send_by", "1", NULL, 0);
2957    e_action_predef_name_set(N_("Screen"), N_("Send Mouse Back 1 Screen"),
2958                             "screen_send_by", "-1", NULL, 0);
2959    e_action_predef_name_set(N_("Screen"), N_("Send Mouse Forward/Back Screens..."),
2960                             "screen_send_by", NULL,
2961                             "syntax: N-offset, example: -2", 1);
2962
2963    ACT_GO_ACPI(dim_screen);
2964    e_action_predef_name_set(N_("Screen"), N_("Dim"), "dim_screen",
2965                             NULL, NULL, 0);
2966    ACT_GO_ACPI(undim_screen);
2967    e_action_predef_name_set(N_("Screen"), N_("Undim"), "undim_screen",
2968                             NULL, NULL, 0);
2969    ACT_GO(backlight_set);
2970    e_action_predef_name_set(N_("Screen"), N_("Backlight Set"), "backlight_set",
2971                             NULL, "syntax: brightness(0 - 100), example: 50", 1);
2972    e_action_predef_name_set(N_("Screen"), N_("Backlight Min"), "backlight_set",
2973                             "0", NULL, 0);
2974    e_action_predef_name_set(N_("Screen"), N_("Backlight Mid"), "backlight_set",
2975                             "50", NULL, 0);
2976    e_action_predef_name_set(N_("Screen"), N_("Backlight Max"), "backlight_set",
2977                             "100", NULL, 0);
2978    ACT_GO(backlight_adjust);
2979    e_action_predef_name_set(N_("Screen"), N_("Backlight Adjust"), "backlight_adjust",
2980                             NULL, "syntax: brightness(-100 - 100), example: -20", 1);
2981    e_action_predef_name_set(N_("Screen"), N_("Backlight Up"), "backlight_adjust",
2982                             "10", NULL, 0);
2983    e_action_predef_name_set(N_("Screen"), N_("Backlight Down"), "backlight_adjust",
2984                             "-10", NULL, 0);
2985
2986    /* window_move_to_center */
2987    ACT_GO(window_move_to_center);
2988    e_action_predef_name_set(N_("Window : Actions"), N_("Move To Center"),
2989                             "window_move_to_center", NULL, NULL, 0);
2990    /* window_move_to */
2991    ACT_GO(window_move_to);
2992    e_action_predef_name_set(N_("Window : Actions"), N_("Move To..."),
2993                             "window_move_to", NULL,
2994                             "syntax: [+,-]X [+,-]Y or * [+,-]Y or [+,-]X *, example: -1 +1", 1);
2995    /* window_move_by */
2996    ACT_GO(window_move_by);
2997    e_action_predef_name_set(N_("Window : Actions"), N_("Move By..."),
2998                             "window_move_by", NULL,
2999                             "syntax: X-offset Y-offset, example: -1 0", 1);
3000
3001    /* window_resize_by */
3002    ACT_GO(window_resize_by);
3003    e_action_predef_name_set(N_("Window : Actions"), N_("Resize By..."),
3004                             "window_resize_by", NULL,
3005                             "syntax: W H, example: 100 150", 1);
3006
3007    /* window_push */
3008    ACT_GO(window_push);
3009    e_action_predef_name_set(N_("Window : Actions"), N_("Push in Direction..."),
3010                             "window_push", NULL,
3011                             "syntax: direction, example: up, down, left, right, up-left, up-right, down-left, down-right", 1);
3012
3013    /* window_drag_icon */
3014    ACT_GO(window_drag_icon);
3015    e_action_predef_name_set(N_("Window : Actions"), N_("Drag Icon..."),
3016                             "window_drag_icon", NULL, NULL, 0);
3017
3018    /* window_desk_move_by */
3019    ACT_GO(window_desk_move_by);
3020    e_action_predef_name_set(N_("Window : Moving"), N_("To Next Desktop"),
3021                             "window_desk_move_by", "1 0", NULL, 0);
3022    e_action_predef_name_set(N_("Window : Moving"), N_("To Previous Desktop"),
3023                             "window_desk_move_by", "-1 0", NULL, 0);
3024    e_action_predef_name_set(N_("Window : Moving"), N_("By Desktop #..."),
3025                             "window_desk_move_by", NULL,
3026                             "syntax: X-offset Y-offset, example: -2 2", 1);
3027
3028    /* window_desk_move_to */
3029    ACT_GO(window_desk_move_to);
3030    e_action_predef_name_set(N_("Window : Moving"), N_("To Desktop..."),
3031                             "window_desk_move_to", NULL,
3032                             "syntax: X Y, example: 0 1", 1);
3033
3034    /* menu_show */
3035    ACT_GO(menu_show);
3036    e_action_predef_name_set(N_("Menu"), N_("Show Main Menu"),
3037                             "menu_show", "main", NULL, 0);
3038    e_action_predef_name_set(N_("Menu"), N_("Show Favorites Menu"), "menu_show",
3039                             "favorites", NULL, 0);
3040    e_action_predef_name_set(N_("Menu"), N_("Show All Applications Menu"),
3041                             "menu_show", "all", NULL, 0);
3042    e_action_predef_name_set(N_("Menu"), N_("Show Clients Menu"), "menu_show",
3043                             "clients", NULL, 0);
3044    e_action_predef_name_set(N_("Menu"), N_("Show Menu..."), "menu_show", NULL,
3045                             "syntax: MenuName, example: MyMenu", 1);
3046    ACT_GO_MOUSE(menu_show);
3047    ACT_GO_KEY(menu_show);
3048
3049    /* exec */
3050    ACT_GO(exec);
3051    e_action_predef_name_set(N_("Launch"), N_("Command"), "exec", NULL,
3052                             "syntax: CommandName, example: /usr/bin/xmms", 1);
3053
3054    /* app */
3055    ACT_GO(app);
3056    e_action_predef_name_set(N_("Launch"), N_("Application"), "app", NULL,
3057                             "syntax: , example:", 1);
3058
3059    ACT_GO(restart);
3060    e_action_predef_name_set(N_("Enlightenment"), N_("Restart"), "restart",
3061                             NULL, NULL, 0);
3062
3063    ACT_GO(exit);
3064    e_action_predef_name_set(N_("Enlightenment"), N_("Exit"), "exit",
3065                             NULL, NULL, 0);
3066
3067    ACT_GO(exit_now);
3068    e_action_predef_name_set(N_("Enlightenment"), N_("Exit Now"),
3069                             "exit_now", NULL, NULL, 0);
3070
3071    ACT_GO(mode_presentation_toggle);
3072    e_action_predef_name_set(N_("Enlightenment : Mode"),
3073                             N_("Presentation Mode Toggle"),
3074                             "mode_presentation_toggle", NULL, NULL, 0);
3075
3076    ACT_GO(mode_offline_toggle);
3077    e_action_predef_name_set(N_("Enlightenment : Mode"),
3078                             N_("Offline Mode Toggle"),
3079                             "mode_offline_toggle", NULL, NULL, 0);
3080
3081    ACT_GO(logout);
3082    e_action_predef_name_set(N_("System"), N_("Log Out"), "logout",
3083                             NULL, NULL, 0);
3084
3085    ACT_GO(halt_now);
3086    e_action_predef_name_set(N_("System"), N_("Power Off Now"),
3087                             "halt_now", NULL, NULL, 0);
3088
3089    ACT_GO(halt);
3090    e_action_predef_name_set(N_("System"), N_("Power Off"), "halt",
3091                             NULL, NULL, 0);
3092
3093    ACT_GO(reboot);
3094    e_action_predef_name_set(N_("System"), N_("Reboot"), "reboot",
3095                             NULL, NULL, 0);
3096
3097    ACT_GO(suspend_now);
3098    e_action_predef_name_set(N_("System"), N_("Suspend Now"), "suspend_now",
3099                             NULL, NULL, 0);
3100
3101    ACT_GO(suspend);
3102    e_action_predef_name_set(N_("System"), N_("Suspend"), "suspend",
3103                             NULL, NULL, 0);
3104
3105    ACT_GO(hibernate);
3106    e_action_predef_name_set(N_("System"), N_("Hibernate"), "hibernate",
3107                             NULL, NULL, 0);
3108
3109    ACT_GO(pointer_resize_push);
3110    ACT_GO(pointer_resize_pop);
3111
3112    /* desk_lock */
3113    ACT_GO(desk_lock);
3114    e_action_predef_name_set(N_("Desktop"), N_("Lock"), "desk_lock",
3115                             NULL, NULL, 0);
3116
3117    /* cleanup_windows */
3118    ACT_GO(cleanup_windows);
3119    e_action_predef_name_set(N_("Desktop"), N_("Cleanup Windows"),
3120                             "cleanup_windows", NULL, NULL, 0);
3121
3122    /* delayed_action */
3123    ACT_GO_KEY(delayed_action);
3124    e_action_predef_name_set(N_("Generic : Actions"), N_("Delayed Action"),
3125                             "delayed_action", NULL, "[0.0 exec xterm] [0.3 exec xev]", 1);
3126    ACT_GO_MOUSE(delayed_action);
3127    ACT_END_KEY(delayed_action);
3128    ACT_END_MOUSE(delayed_action);
3129
3130    return 1;
3131 }
3132
3133 EINTERN int
3134 e_actions_shutdown(void)
3135 {
3136    e_action_predef_name_all_del();
3137
3138    while(action_list)
3139      e_object_del(action_list->data);
3140
3141    action_names = eina_list_free(action_names);
3142    eina_hash_free(actions);
3143    actions = NULL;
3144
3145    return 1;
3146 }
3147
3148 EAPI Eina_List *
3149 e_action_name_list(void)
3150 {
3151    return action_names;
3152 }
3153
3154 EAPI E_Action *
3155 e_action_add(const char *name)
3156 {
3157    E_Action *act;
3158
3159    act = e_action_find(name);
3160    if (!act)
3161      {
3162         act = E_OBJECT_ALLOC(E_Action, E_ACTION_TYPE, _e_action_free);
3163         if (!act) return NULL;
3164         act->name = name;
3165         eina_hash_direct_add(actions, act->name, act);
3166         action_names = eina_list_append(action_names, name);
3167         action_list = eina_list_append(action_list, act);
3168      }
3169    return act;
3170 }
3171
3172 EAPI void
3173 e_action_del(const char *name)
3174 {
3175    E_Action *act;
3176
3177    act = eina_hash_find(actions, name);
3178    if (act) _e_action_free(act);
3179 }
3180
3181 EAPI E_Action *
3182 e_action_find(const char *name)
3183 {
3184    E_Action *act;
3185
3186    act = eina_hash_find(actions, name);
3187    return act;
3188 }
3189
3190 EAPI const char *
3191 e_action_predef_label_get(const char *action, const char *params)
3192 {
3193    E_Action_Group *actg = NULL;
3194    E_Action_Description *actd = NULL;
3195    Eina_List *l, *l2;
3196
3197    EINA_LIST_FOREACH(action_groups, l, actg)
3198      {
3199         EINA_LIST_FOREACH(actg->acts, l2, actd)
3200           {
3201              if (!strcmp(actd->act_cmd, action))
3202                {
3203                   if ((params) && (actd->act_params))
3204                     {
3205                        if (!strcmp(params, actd->act_params))
3206                          return actd->act_name;
3207                     }
3208                   else return actd->act_name;
3209                }
3210           }
3211      }
3212    if (params) return e_action_predef_label_get(action, NULL);
3213    return NULL;
3214 }
3215
3216 EAPI void
3217 e_action_predef_name_set(const char *act_grp, const char *act_name, const char *act_cmd, const char *act_params, const char *param_example, int editable)
3218 {
3219    E_Action_Group *actg = NULL;
3220    E_Action_Description *actd = NULL;
3221    Eina_List *l;
3222
3223    if ((!act_grp) || (!act_name)) return;
3224
3225    EINA_LIST_FOREACH(action_groups, l, actg)
3226      {
3227         if (!strcmp(actg->act_grp, act_grp)) break;
3228         actg = NULL;
3229      }
3230
3231    if (!actg)
3232      {
3233         actg = E_NEW(E_Action_Group, 1);
3234         if (!actg) return;
3235
3236         actg->act_grp = eina_stringshare_add(act_grp);
3237         actg->acts = NULL;
3238
3239         action_groups = eina_list_append(action_groups, actg);
3240         action_groups =
3241           eina_list_sort(action_groups, -1, _action_groups_sort_cb);
3242      }
3243
3244    EINA_LIST_FOREACH(actg->acts, l, actd)
3245      {
3246         if (!strcmp(actd->act_name, act_name)) break;
3247         actd = NULL;
3248      }
3249
3250    if (actd) return;
3251
3252    actd = E_NEW(E_Action_Description, 1);
3253    if (!actd) return;
3254
3255    actd->act_name = eina_stringshare_add(act_name);
3256    actd->act_cmd = !act_cmd ? NULL : eina_stringshare_add(act_cmd);
3257    actd->act_params = !act_params ? NULL : eina_stringshare_add(act_params);
3258    actd->param_example = !param_example ? NULL : eina_stringshare_add(param_example);
3259    actd->editable = editable;
3260
3261    actg->acts = eina_list_append(actg->acts, actd);
3262 }
3263
3264 EAPI void
3265 e_action_predef_name_del(const char *act_grp, const char *act_name)
3266 {
3267    E_Action_Group *actg = NULL;
3268    E_Action_Description *actd = NULL;
3269    Eina_List *l;
3270
3271    EINA_LIST_FOREACH(action_groups, l, actg)
3272      {
3273         if (!strcmp(actg->act_grp, act_grp)) break;
3274         actg = NULL;
3275      }
3276
3277    if (!actg) return;
3278
3279    EINA_LIST_FOREACH(actg->acts, l, actd)
3280      {
3281         if (!strcmp(actd->act_name, act_name))
3282           {
3283              actg->acts = eina_list_remove(actg->acts, actd);
3284
3285              if (actd->act_name) eina_stringshare_del(actd->act_name);
3286              if (actd->act_cmd) eina_stringshare_del(actd->act_cmd);
3287              if (actd->act_params) eina_stringshare_del(actd->act_params);
3288              if (actd->param_example) eina_stringshare_del(actd->param_example);
3289
3290              E_FREE(actd);
3291
3292              if (!eina_list_count(actg->acts))
3293                {
3294                   action_groups = eina_list_remove(action_groups, actg);
3295                   if (actg->act_grp) eina_stringshare_del(actg->act_grp);
3296                   E_FREE(actg);
3297                }
3298              break;
3299           }
3300      }
3301 }
3302
3303 EAPI void
3304 e_action_predef_name_all_del(void)
3305 {
3306    E_Action_Group *actg = NULL;
3307    E_Action_Description *actd = NULL;
3308
3309    EINA_LIST_FREE(action_groups, actg)
3310      {
3311         EINA_LIST_FREE(actg->acts, actd)
3312           {
3313              if (actd->act_name) eina_stringshare_del(actd->act_name);
3314              if (actd->act_cmd) eina_stringshare_del(actd->act_cmd);
3315              if (actd->act_params) eina_stringshare_del(actd->act_params);
3316              if (actd->param_example) eina_stringshare_del(actd->param_example);
3317
3318              E_FREE(actd);
3319           }
3320         if (actg->act_grp) eina_stringshare_del(actg->act_grp);
3321         E_FREE(actg);
3322      }
3323    action_groups = NULL;
3324 }
3325
3326 EAPI Eina_List *
3327 e_action_groups_get(void)
3328 {
3329    return action_groups;
3330 }
3331
3332 /* local subsystem functions */
3333
3334 static void
3335 _e_action_free(E_Action *act)
3336 {
3337    eina_hash_del(actions, act->name, act);
3338    action_names = eina_list_remove(action_names, act->name);
3339    action_list = eina_list_remove(action_list, act);
3340    free(act);
3341 }
3342
3343 static E_Maximize
3344 _e_actions_maximize_parse(const char *params)
3345 {
3346    E_Maximize max = 0;
3347    int ret;
3348    char s1[32], s2[32];
3349
3350    if (!params) return e_config->maximize_policy;
3351    ret = sscanf(params, "%20s %20s", s1, s2);
3352    if (ret == 2)
3353      {
3354         if (!strcmp(s2, "horizontal"))
3355           max = E_MAXIMIZE_HORIZONTAL;
3356         else if (!strcmp(s2, "vertical"))
3357           max = E_MAXIMIZE_VERTICAL;
3358         else
3359           max = E_MAXIMIZE_BOTH;
3360      }
3361    if (ret >= 1)
3362      {
3363         if (!strcmp(s1, "fullscreen"))
3364           max |= E_MAXIMIZE_FULLSCREEN;
3365         else if (!strcmp(s1, "smart"))
3366           max |= E_MAXIMIZE_SMART;
3367         else if (!strcmp(s1, "expand"))
3368           max |= E_MAXIMIZE_EXPAND;
3369         else if (!strcmp(s1, "fill"))
3370           max |= E_MAXIMIZE_FILL;
3371         else
3372           max |= (e_config->maximize_policy & E_MAXIMIZE_TYPE);
3373      }
3374    else
3375      max = e_config->maximize_policy;
3376    return max;
3377 }
3378
3379 static int
3380 _action_groups_sort_cb(const void *d1, const void *d2)
3381 {
3382    const E_Action_Group *g1, *g2;
3383
3384    if (!(g1 = d1)) return 1;
3385    if (!(g2 = d2)) return -1;
3386    return strcmp(g1->act_grp, g2->act_grp);
3387 }