1a5eced354c3f5655df69850857531b2b8011cd8
[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 == E_MANAGER_TYPE)
1241           return e_util_zone_current_get((E_Manager *)obj);
1242         else if (obj->type == E_CONTAINER_TYPE)
1243           return e_util_zone_current_get(((E_Container *)obj)->manager);
1244         else if (obj->type == E_ZONE_TYPE)
1245           return e_util_zone_current_get(((E_Zone *)obj)->container->manager);
1246         else
1247           return e_util_zone_current_get(e_manager_current_get());
1248      }
1249    return e_util_zone_current_get(e_manager_current_get());
1250 }
1251
1252 ACT_FN_GO(desk_flip_by, )
1253 {
1254    E_Zone *zone;
1255
1256    zone = _e_actions_zone_get(obj);
1257    if (zone)
1258      {
1259         if (params)
1260           {
1261              int dx = 0, dy = 0;
1262
1263              if (sscanf(params, "%i %i", &dx, &dy) == 2)
1264                e_zone_desk_flip_by(zone, dx, dy);
1265           }
1266      }
1267 }
1268
1269 /***************************************************************************/
1270 ACT_FN_GO(desk_flip_to, )
1271 {
1272    E_Zone *zone;
1273
1274    zone = _e_actions_zone_get(obj);
1275    if (zone)
1276      {
1277         if (params)
1278           {
1279              int dx = 0, dy = 0;
1280
1281              if (sscanf(params, "%i %i", &dx, &dy) == 2)
1282                e_zone_desk_flip_to(zone, dx, dy);
1283           }
1284      }
1285 }
1286
1287 /***************************************************************************/
1288 #define ACT_FLIP_LEFT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1)) || ((zone)->desk_x_current > 0))
1289 #define ACT_FLIP_RIGHT(zone) ((e_config->desk_flip_wrap && ((zone)->desk_x_count > 1)) || (((zone)->desk_x_current + 1) < (zone)->desk_x_count))
1290 #define ACT_FLIP_UP(zone) ((e_config->desk_flip_wrap && ((zone)->desk_y_count > 1)) || ((zone)->desk_y_current > 0))
1291 #define ACT_FLIP_DOWN(zone) ((e_config->desk_flip_wrap && ((zone)->desk_y_count > 1)) || (((zone)->desk_y_current + 1) < (zone)->desk_y_count))
1292 #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)))
1293 #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)))
1294 #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)))
1295 #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)))
1296
1297 ACT_FN_GO_EDGE(desk_flip_in_direction, )
1298 {
1299    E_Zone *zone;
1300    E_Desk *current = NULL;
1301    E_Event_Pointer_Warp *wev;
1302    int x, y, offset = 25;
1303
1304    if (!ev) return; // with flip on _e_zone_cb_edge_timer we don't have ev!!!
1305    zone = _e_actions_zone_get(obj);
1306    wev = E_NEW(E_Event_Pointer_Warp, 1);
1307    if ((!wev) || (!zone)) return;
1308    ecore_x_pointer_xy_get(zone->container->win, &x, &y);
1309    wev->prev.x = x;
1310    wev->prev.y = y;
1311    if (params)
1312      {
1313         if (sscanf(params, "%i", &offset) != 1)
1314           offset = 25;
1315      }
1316    switch (ev->edge)
1317      {
1318      case E_ZONE_EDGE_LEFT:
1319         if (ACT_FLIP_LEFT(zone))
1320           {
1321              e_zone_desk_flip_by(zone, -1, 0);
1322              ecore_x_pointer_warp(zone->container->win, zone->w - offset, y);
1323              wev->curr.y = y;
1324              wev->curr.x = zone->w - offset;
1325           }
1326         break;
1327      case E_ZONE_EDGE_RIGHT:
1328         if (ACT_FLIP_RIGHT(zone))
1329           {
1330              e_zone_desk_flip_by(zone, 1, 0);
1331              ecore_x_pointer_warp(zone->container->win, offset, y);
1332              wev->curr.y = y;
1333              wev->curr.x = offset;
1334           }
1335         break;
1336      case E_ZONE_EDGE_TOP:
1337         if (ACT_FLIP_UP(zone))
1338           {
1339              e_zone_desk_flip_by(zone, 0, -1);
1340              ecore_x_pointer_warp(zone->container->win, x, zone->h - offset);
1341              wev->curr.x = x;
1342              wev->curr.y = zone->h - offset;
1343           }
1344         break;
1345      case E_ZONE_EDGE_BOTTOM:
1346         if (ACT_FLIP_DOWN(zone))
1347           {
1348              e_zone_desk_flip_by(zone, 0, 1);
1349              ecore_x_pointer_warp(zone->container->win, x, offset);
1350              wev->curr.x = x;
1351              wev->curr.y = offset;
1352           }
1353         break;
1354      case E_ZONE_EDGE_TOP_LEFT:
1355         if (ACT_FLIP_UP_LEFT(zone))
1356           {
1357              e_zone_desk_flip_by(zone, -1, -1);
1358              ecore_x_pointer_warp(zone->container->win, zone->w - offset, zone->h - offset);
1359              wev->curr.x = zone->w - offset;
1360              wev->curr.y = zone->h - offset;
1361           }
1362         break;
1363      case E_ZONE_EDGE_TOP_RIGHT:
1364         if (ACT_FLIP_UP_RIGHT(zone))
1365           {
1366              e_zone_desk_flip_by(zone, 1, -1);
1367              ecore_x_pointer_warp(zone->container->win, offset, zone->h - offset);
1368              wev->curr.x = offset;
1369              wev->curr.y = zone->h - offset;
1370           }
1371         break;
1372      case E_ZONE_EDGE_BOTTOM_LEFT:
1373         if (ACT_FLIP_DOWN_LEFT(zone))
1374           {
1375              e_zone_desk_flip_by(zone, -1, 1);
1376              ecore_x_pointer_warp(zone->container->win, zone->w - offset, offset);
1377              wev->curr.y = offset;
1378              wev->curr.x = zone->w - offset;
1379           }
1380         break;
1381      case E_ZONE_EDGE_BOTTOM_RIGHT:
1382         if (ACT_FLIP_DOWN_RIGHT(zone))
1383           {
1384              e_zone_desk_flip_by(zone, 1, 1);
1385              ecore_x_pointer_warp(zone->container->win, offset, offset);
1386              wev->curr.y = offset;
1387              wev->curr.x = offset;
1388           }
1389         break;
1390      default:
1391         break;
1392      }
1393
1394    current = e_desk_current_get(zone);
1395    if (current)
1396      ecore_event_add(E_EVENT_POINTER_WARP, wev, NULL, NULL);
1397    else
1398      free(wev);
1399 }
1400
1401 /***************************************************************************/
1402 ACT_FN_GO(desk_linear_flip_by, )
1403 {
1404    E_Zone *zone;
1405
1406    zone = _e_actions_zone_get(obj);
1407    if (zone)
1408      {
1409         if (params)
1410           {
1411              int dx = 0;
1412
1413              if (sscanf(params, "%i", &dx) == 1)
1414                e_zone_desk_linear_flip_by(zone, dx);
1415           }
1416      }
1417 }
1418
1419 /***************************************************************************/
1420 ACT_FN_GO(desk_linear_flip_to, )
1421 {
1422    E_Zone *zone;
1423
1424    zone = _e_actions_zone_get(obj);
1425    if (zone)
1426      {
1427         if (params)
1428           {
1429              int dx = 0;
1430
1431              if (sscanf(params, "%i", &dx) == 1)
1432                e_zone_desk_linear_flip_to(zone, dx);
1433           }
1434      }
1435 }
1436
1437
1438 #define DESK_ACTION_ALL(zone, act) \
1439   E_Zone *zone;                    \
1440   Eina_List *lm, *lc, *lz;         \
1441   E_Container *con;                \
1442   E_Manager *man;                               \
1443   \
1444   EINA_LIST_FOREACH(e_manager_list(), lm, man) {           \
1445     EINA_LIST_FOREACH(man->containers, lc, con) {          \
1446       EINA_LIST_FOREACH(con->zones, lz, zone) {            \
1447         act;                                               \
1448       }                                                    \
1449     }                                                      \
1450   }
1451
1452
1453 /***************************************************************************/
1454 ACT_FN_GO(desk_flip_by_all, )
1455 {
1456    if (params)
1457      {
1458         int dx = 0, dy = 0;
1459
1460         if (sscanf(params, "%i %i", &dx, &dy) == 2)
1461           {
1462              DESK_ACTION_ALL(zone, e_zone_desk_flip_by(zone, dx, dy));
1463           }
1464      }
1465 }
1466
1467 /***************************************************************************/
1468 ACT_FN_GO(desk_flip_to_all, )
1469 {
1470    if (params)
1471      {
1472         int dx = 0, dy = 0;
1473
1474         if (sscanf(params, "%i %i", &dx, &dy) == 2)
1475           {
1476              DESK_ACTION_ALL(zone, e_zone_desk_flip_to(zone, dx, dy));
1477           }
1478      }
1479 }
1480
1481 /***************************************************************************/
1482 ACT_FN_GO(desk_linear_flip_by_all, )
1483 {
1484    if (params)
1485      {
1486         int dx = 0;
1487
1488         if (sscanf(params, "%i", &dx) == 1)
1489           {
1490              DESK_ACTION_ALL(zone, e_zone_desk_linear_flip_by(zone, dx));
1491           }
1492      }
1493 }
1494
1495 /***************************************************************************/
1496 ACT_FN_GO(desk_linear_flip_to_all, )
1497 {
1498    if (params)
1499      {
1500         int dx = 0;
1501
1502         if (sscanf(params, "%i", &dx) == 1)
1503           {
1504              DESK_ACTION_ALL(zone, e_zone_desk_linear_flip_to(zone, dx));
1505           }
1506      }
1507 }
1508
1509 /***************************************************************************/
1510 ACT_FN_GO(screen_send_to, )
1511 {
1512    E_Zone *zone;
1513
1514    zone = _e_actions_zone_get(obj);
1515    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1516    if (zone)
1517      {
1518         if (params)
1519           {
1520              int scr = 0;
1521
1522              if (sscanf(params, "%i", &scr) == 1)
1523                {
1524                   E_Zone *zone2 = NULL;
1525
1526                   if (eina_list_count(e_manager_list()) > 1)
1527                     {
1528                        scr = scr % eina_list_count(e_manager_list());
1529                        if (scr < 0) scr += eina_list_count(e_manager_list());
1530                        zone2 = e_util_container_zone_number_get(scr, 0);
1531                     }
1532                   else
1533                     {
1534                        scr = scr % eina_list_count(zone->container->zones);
1535                        if (scr < 0) scr += eina_list_count(zone->container->zones);
1536                        zone2 = e_util_container_zone_number_get(0, scr);
1537                     }
1538                   if ((zone2) && (zone != zone2))
1539                     ecore_x_pointer_warp(zone2->container->win,
1540                                          zone2->x + (zone2->w / 2),
1541                                          zone2->y + (zone2->h / 2));
1542                }
1543           }
1544      }
1545 }
1546
1547 ACT_FN_GO(screen_send_by, )
1548 {
1549    E_Zone *zone;
1550
1551    zone = _e_actions_zone_get(obj);
1552    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1553    if (zone)
1554      {
1555         if (params)
1556           {
1557              int scr = 0;
1558
1559              if (sscanf(params, "%i", &scr) == 1)
1560                {
1561                   E_Zone *zone2 = NULL;
1562
1563                   if (eina_list_count(e_manager_list()) > 1)
1564                     {
1565                        scr += zone->container->num;
1566                        scr = scr % eina_list_count(e_manager_list());
1567                        if (scr < 0) scr += eina_list_count(e_manager_list());
1568                        zone2 = e_util_container_zone_number_get(scr, 0);
1569                     }
1570                   else
1571                     {
1572                        scr += zone->num;
1573                        scr = scr % eina_list_count(zone->container->zones);
1574                        if (scr < 0) scr += eina_list_count(zone->container->zones);
1575                        zone2 = e_util_container_zone_number_get(0, scr);
1576                     }
1577                   if ((zone2) && (zone != zone2))
1578                     ecore_x_pointer_warp(zone2->container->win,
1579                                          zone2->x + (zone2->w / 2),
1580                                          zone2->y + (zone2->h / 2));
1581                }
1582           }
1583      }
1584 }
1585
1586 #define ZONE_DESK_ACTION(con_num, zone_num, zone, act) \
1587    E_Zone *zone; \
1588    if ((con_num < 0) || (zone_num < 0)) { \
1589       Eina_List *l, *ll, *lll; \
1590       E_Container *con; \
1591       E_Manager *man; \
1592       if ((con_num >= 0) && (zone_num < 0)) /* con=1 zone=all */ { \
1593          con = e_util_container_number_get(con_num); \
1594          EINA_LIST_FOREACH(con->zones, l, zone) { \
1595             act; \
1596          } } \
1597       else if ((con_num < 0) && (zone_num >= 0)) /* con=all zone=1 */ { \
1598          EINA_LIST_FOREACH(e_manager_list(), l, man) { \
1599             EINA_LIST_FOREACH(man->containers, ll, con) { \
1600                zone = e_container_zone_number_get(con, zone_num); \
1601                if (zone) \
1602                  act; \
1603             } } } \
1604       else if ((con_num < 0) && (zone_num < 0)) /* con=all zone=all */ { \
1605          EINA_LIST_FOREACH(e_manager_list(), l, man) { \
1606             EINA_LIST_FOREACH(man->containers, ll, con) { \
1607                EINA_LIST_FOREACH(con->zones, lll, zone) { \
1608                   act; \
1609                } } } } } \
1610    else { \
1611       zone = e_util_container_zone_number_get(con_num, zone_num); \
1612       if (zone) act; \
1613    }
1614
1615 /***************************************************************************/
1616 #if 0
1617 ACT_FN_GO(zone_desk_flip_by, )
1618 {
1619    if (params)
1620      {
1621         int con_num = 0, zone_num = 0;
1622         int dx = 0, dy = 0;
1623
1624         if (sscanf(params, "%i %i %i %i", &con_num, &zone_num, &dx, &dy) == 4)
1625           ZONE_DESK_ACTION(con_num, zone_num, zone,
1626                            e_zone_desk_flip_by(zone, dx, dy));
1627      }
1628 }
1629 #endif
1630
1631 /***************************************************************************/
1632 #if 0
1633 ACT_FN_GO(zone_desk_flip_to, )
1634 {
1635    if (params)
1636      {
1637         int con_num = 0, zone_num = 0;
1638         int dx = 0, dy = 0;
1639
1640         if (sscanf(params, "%i %i %i %i", &con_num, &zone_num, &dx, &dy) == 4)
1641           ZONE_DESK_ACTION(con_num, zone_num, zone,
1642                            e_zone_desk_flip_to(zone, dx, dy));
1643      }
1644 }
1645 #endif
1646
1647 /***************************************************************************/
1648 #if 0
1649 ACT_FN_GO(zone_desk_linear_flip_by, )
1650 {
1651    if (params)
1652      {
1653         int con_num = 0, zone_num = 0;
1654         int dx = 0;
1655
1656         if (sscanf(params, "%i %i %i", &con_num, &zone_num, &dx) == 3)
1657           ZONE_DESK_ACTION(con_num, zone_num, zone,
1658                            e_zone_desk_linear_flip_by(zone, dx));
1659      }
1660 }
1661 #endif
1662
1663 /***************************************************************************/
1664 #if 0
1665 ACT_FN_GO(zone_desk_linear_flip_to, )
1666 {
1667    if (params)
1668      {
1669         int con_num = 0, zone_num = 0;
1670         int dx = 0;
1671
1672         if (sscanf(params, "%i %i %i", &con_num, &zone_num, &dx) == 3)
1673           ZONE_DESK_ACTION(con_num, zone_num, zone,
1674                            e_zone_desk_linear_flip_to(zone, dx));
1675      }
1676 }
1677 #endif
1678
1679 /***************************************************************************/
1680 static void
1681 _e_actions_cb_menu_end(void *data __UNUSED__, E_Menu *m)
1682 {
1683    e_object_del(E_OBJECT(m));
1684 }
1685
1686 static E_Menu *
1687 _e_actions_menu_find(const char *name)
1688 {
1689    if (!strcmp(name, "main"))
1690      return e_int_menus_main_new();
1691    else if (!strcmp(name, "favorites"))
1692      return e_int_menus_favorite_apps_new();
1693    else if (!strcmp(name, "all"))
1694      return e_int_menus_all_apps_new();
1695    else if (!strcmp(name, "clients"))
1696      return e_int_menus_clients_new();
1697    else if (!strcmp(name, "lost_clients"))
1698      return e_int_menus_lost_clients_new();
1699    else if (!strcmp(name, "configuration"))
1700      return e_int_menus_config_new();
1701    return NULL;
1702 }
1703
1704 ACT_FN_GO(menu_show, )
1705 {
1706    E_Zone *zone;
1707
1708    /* menu is active - abort */
1709    if (e_menu_grab_window_get()) return;
1710    zone = _e_actions_zone_get(obj);
1711    if (zone)
1712      {
1713         if (params)
1714           {
1715              E_Menu *m = NULL;
1716
1717              m = _e_actions_menu_find(params);  
1718              if (m)
1719                {
1720                   int x, y;
1721
1722                   /* FIXME: this is a bit of a hack... setting m->con - bad hack */
1723                   m->zone = zone;
1724                   ecore_x_pointer_xy_get(zone->container->win, &x, &y);
1725                   e_menu_post_deactivate_callback_set(m, _e_actions_cb_menu_end, NULL);
1726                   e_menu_activate_mouse(m, zone, x, y, 1, 1,
1727                                         E_MENU_POP_DIRECTION_DOWN,
1728                                         ecore_x_current_time_get());
1729                }
1730           }
1731      }
1732 }
1733
1734 ACT_FN_GO_MOUSE(menu_show, )
1735 {
1736    E_Zone *zone;
1737
1738    /* menu is active - abort */
1739    if (e_menu_grab_window_get()) return;
1740    zone = _e_actions_zone_get(obj);
1741    if (zone)
1742      {
1743         if (params)
1744           {
1745              E_Menu *m = NULL;
1746
1747              m = _e_actions_menu_find(params);  
1748              if (m)
1749                {
1750                   int x, y;
1751
1752                   /* FIXME: this is a bit of a hack... setting m->con - bad hack */
1753                   m->zone = zone;
1754                   x = ev->root.x;
1755                   y = ev->root.y;
1756                   x -= zone->container->x;
1757                   y -= zone->container->y;
1758                   e_menu_post_deactivate_callback_set(m, _e_actions_cb_menu_end, NULL);
1759                   e_menu_activate_mouse(m, zone, x, y, 1, 1,
1760                                         E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
1761                }
1762           }
1763      }
1764 }
1765
1766 ACT_FN_GO_KEY(menu_show, )
1767 {
1768    E_Zone *zone;
1769
1770    /* menu is active - abort */
1771    if (e_menu_grab_window_get()) return;
1772    zone = _e_actions_zone_get(obj);
1773    if (zone)
1774      {
1775         if (params)
1776           {
1777              E_Menu *m = NULL;
1778
1779              m = _e_actions_menu_find(params);  
1780              if (m)
1781                {
1782                   int x, y;
1783
1784                   /* FIXME: this is a bit of a hack... setting m->con - bad hack */
1785                   m->zone = zone;
1786                   ecore_x_pointer_xy_get(zone->container->win, &x, &y);
1787                   e_menu_post_deactivate_callback_set(m, _e_actions_cb_menu_end, NULL);
1788                   e_menu_activate_key(m, zone, x, y, 1, 1,
1789                                       E_MENU_POP_DIRECTION_DOWN);
1790                }
1791           }
1792      }
1793 }
1794
1795 /***************************************************************************/
1796 ACT_FN_GO(exec, )
1797 {
1798    E_Zone *zone;
1799
1800    zone = _e_actions_zone_get(obj);
1801    if (zone)
1802      {
1803         if (params)
1804           e_exec(zone, NULL, params, NULL, "action/exec");
1805      }
1806 }
1807
1808 /***************************************************************************/
1809 ACT_FN_GO(app, )
1810 {
1811    E_Zone *zone;
1812
1813    zone = _e_actions_zone_get(obj);
1814    if (zone)
1815      {
1816         if (params)
1817           {
1818              Efreet_Desktop *desktop = NULL;
1819              char *p, *p2;
1820
1821              p2 = alloca(strlen(params) + 1);
1822              strcpy(p2, params);
1823              p = strchr(p2, ' ');
1824              if (p)
1825                {
1826                   *p = 0;
1827                   if (!strcmp(p2, "file:"))
1828                     desktop = efreet_util_desktop_file_id_find(p + 1);
1829                   else if (!strcmp(p2, "name:"))
1830                     desktop = efreet_util_desktop_name_find(p + 1);
1831                   else if (!strcmp(p2, "generic:"))
1832                     desktop = efreet_util_desktop_generic_name_find(p + 1);
1833                   else if (!strcmp(p2, "exe:"))
1834                     desktop = efreet_util_desktop_exec_find(p + 1);
1835                   if (desktop)
1836                     {
1837                        e_exec(zone, desktop, NULL, NULL, "action/app");
1838                        efreet_desktop_free(desktop);
1839                     }
1840                }
1841           }
1842      }
1843 }
1844
1845 /***************************************************************************/
1846 ACT_FN_GO(desk_deskshow_toggle, __UNUSED__)
1847 {
1848    E_Zone *zone;
1849
1850    zone = _e_actions_zone_get(obj);
1851    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1852    if (zone) e_desk_deskshow(zone);
1853 }
1854
1855 ACT_FN_GO(cleanup_windows, __UNUSED__)
1856 {
1857    E_Zone *zone;
1858
1859    zone = _e_actions_zone_get(obj);
1860    if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
1861    if (zone) e_place_zone_region_smart_cleanup(zone);
1862 }
1863
1864 /***************************************************************************/
1865 static E_Dialog *exit_dialog = NULL;
1866
1867 static void
1868 _e_actions_cb_exit_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
1869 {
1870    if (dia)
1871      {
1872         e_object_del(E_OBJECT(exit_dialog));
1873         exit_dialog = NULL;
1874      }
1875    e_sys_action_do(E_SYS_EXIT, NULL);
1876 }
1877
1878 static void
1879 _e_actions_cb_exit_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
1880 {
1881    e_object_del(E_OBJECT(exit_dialog));
1882    exit_dialog = NULL;
1883 }
1884
1885 static void
1886 _e_actions_cb_exit_dialog_delete(E_Win *win)
1887 {
1888    E_Dialog *dia;
1889
1890    dia = win->data;
1891    _e_actions_cb_exit_dialog_cancel(NULL, dia);
1892 }
1893
1894 ACT_FN_GO(exit, )
1895 {
1896    if ((params) && (!strcmp(params, "now")))
1897      {
1898         e_sys_action_do(E_SYS_EXIT, NULL);
1899         return;
1900      }
1901    if (exit_dialog) e_object_del(E_OBJECT(exit_dialog));
1902
1903    if (e_config->cnfmdlg_disabled)
1904      {
1905         _e_actions_cb_exit_dialog_ok(NULL, NULL);
1906         return;
1907      }
1908
1909    exit_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_exit_dialog");
1910    if (!exit_dialog) return;
1911    e_win_delete_callback_set(exit_dialog->win, _e_actions_cb_exit_dialog_delete);
1912    e_dialog_title_set(exit_dialog, _("Are you sure you want to exit?"));
1913    e_dialog_text_set(exit_dialog,
1914                      _("You requested to exit Enlightenment.<br>"
1915                        "<br>"
1916                        "Are you sure you want to exit?"));
1917    e_dialog_icon_set(exit_dialog, "application-exit", 64);
1918    e_dialog_button_add(exit_dialog, _("Yes"), NULL,
1919                        _e_actions_cb_exit_dialog_ok, NULL);
1920    e_dialog_button_add(exit_dialog, _("No"), NULL,
1921                        _e_actions_cb_exit_dialog_cancel, NULL);
1922    e_dialog_button_focus_num(exit_dialog, 1);
1923    e_win_centered_set(exit_dialog->win, 1);
1924    e_dialog_show(exit_dialog);
1925 }
1926
1927 /***************************************************************************/
1928 ACT_FN_GO(restart, __UNUSED__)
1929 {
1930    e_sys_action_do(E_SYS_RESTART, NULL);
1931 }
1932
1933 /***************************************************************************/
1934 ACT_FN_GO(exit_now, __UNUSED__)
1935 {
1936    e_sys_action_do(E_SYS_EXIT_NOW, NULL);
1937 }
1938
1939 /***************************************************************************/
1940 ACT_FN_GO(halt_now, __UNUSED__)
1941 {
1942    e_sys_action_do(E_SYS_HALT_NOW, NULL);
1943 }
1944
1945 /***************************************************************************/
1946 ACT_FN_GO(mode_presentation_toggle, __UNUSED__)
1947 {
1948    e_config->mode.presentation = !e_config->mode.presentation;
1949    e_config_mode_changed();
1950    e_config_save_queue();
1951 }
1952
1953 /***************************************************************************/
1954 ACT_FN_GO(mode_offline_toggle, __UNUSED__)
1955 {
1956    e_config->mode.offline = !e_config->mode.offline;
1957    e_config_mode_changed();
1958    e_config_save_queue();
1959 }
1960
1961 /***************************************************************************/
1962 static E_Dialog *logout_dialog = NULL;
1963
1964 static void
1965 _e_actions_cb_logout_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
1966 {
1967    if (dia)
1968      {
1969         e_object_del(E_OBJECT(logout_dialog));
1970         logout_dialog = NULL;
1971      }
1972    e_sys_action_do(E_SYS_LOGOUT, NULL);
1973 }
1974
1975 static void
1976 _e_actions_cb_logout_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
1977 {
1978    e_object_del(E_OBJECT(logout_dialog));
1979    logout_dialog = NULL;
1980 }
1981
1982 static void
1983 _e_actions_cb_logout_dialog_delete(E_Win *win)
1984 {
1985    E_Dialog *dia;
1986
1987    dia = win->data;
1988    _e_actions_cb_logout_dialog_cancel(NULL, dia);
1989 }
1990
1991 ACT_FN_GO(logout, )
1992 {
1993    if ((params) && (!strcmp(params, "now")))
1994      {
1995         e_sys_action_do(E_SYS_LOGOUT, NULL);
1996         return;
1997      }
1998    if (logout_dialog) e_object_del(E_OBJECT(logout_dialog));
1999
2000    if (e_config->cnfmdlg_disabled)
2001      {
2002         _e_actions_cb_logout_dialog_ok(NULL, NULL);
2003         return;
2004      }
2005
2006    logout_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_logout_dialog");
2007    if (!logout_dialog) return;
2008    e_win_delete_callback_set(logout_dialog->win, _e_actions_cb_logout_dialog_delete);
2009    e_dialog_title_set(logout_dialog, _("Are you sure you want to log out?"));
2010    e_dialog_text_set(logout_dialog,
2011                      _("You are about to log out.<br>"
2012                        "<br>"
2013                        "Are you sure you want to do this?"));
2014    e_dialog_icon_set(logout_dialog, "system-log-out", 64);
2015    e_dialog_button_add(logout_dialog, _("Yes"), NULL,
2016                        _e_actions_cb_logout_dialog_ok, NULL);
2017    e_dialog_button_add(logout_dialog, _("No"), NULL,
2018                        _e_actions_cb_logout_dialog_cancel, NULL);
2019    e_dialog_button_focus_num(logout_dialog, 1);
2020    e_win_centered_set(logout_dialog->win, 1);
2021    e_dialog_show(logout_dialog);
2022 }
2023
2024 /***************************************************************************/
2025 static E_Dialog *halt_dialog = NULL;
2026
2027 static void
2028 _e_actions_cb_halt_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2029 {
2030    if (dia)
2031      {
2032         e_object_del(E_OBJECT(halt_dialog));
2033         halt_dialog = NULL;
2034      }
2035    e_sys_action_do(E_SYS_HALT, NULL);
2036 }
2037
2038 static void
2039 _e_actions_cb_halt_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2040 {
2041    e_object_del(E_OBJECT(halt_dialog));
2042    halt_dialog = NULL;
2043 }
2044
2045 static void
2046 _e_actions_cb_halt_dialog_delete(E_Win *win)
2047 {
2048    E_Dialog *dia;
2049
2050    dia = win->data;
2051    _e_actions_cb_halt_dialog_cancel(NULL, dia);
2052 }
2053
2054 ACT_FN_GO(halt, )
2055 {
2056    if ((params) && (!strcmp(params, "now")))
2057      {
2058         e_sys_action_do(E_SYS_HALT, NULL);
2059         return;
2060      }
2061    if (halt_dialog) e_object_del(E_OBJECT(halt_dialog));
2062
2063    if (e_config->cnfmdlg_disabled)
2064      {
2065         _e_actions_cb_halt_dialog_ok(NULL, NULL);
2066         return;
2067      }
2068
2069    halt_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_halt_dialog");
2070    if (!halt_dialog) return;
2071    e_win_delete_callback_set(halt_dialog->win, _e_actions_cb_halt_dialog_delete);
2072    e_dialog_title_set(halt_dialog, _("Are you sure you want to turn off?"));
2073    e_dialog_text_set(halt_dialog,
2074                      _("You requested to turn off your Computer.<br>"
2075                        "<br>"
2076                        "Are you sure you want to shut down?"));
2077    e_dialog_icon_set(halt_dialog, "system-shutdown", 64);
2078    e_dialog_button_add(halt_dialog, _("Yes"), NULL,
2079                        _e_actions_cb_halt_dialog_ok, NULL);
2080    e_dialog_button_add(halt_dialog, _("No"), NULL,
2081                        _e_actions_cb_halt_dialog_cancel, NULL);
2082    e_dialog_button_focus_num(halt_dialog, 1);
2083    e_win_centered_set(halt_dialog->win, 1);
2084    e_dialog_show(halt_dialog);
2085 }
2086
2087 /***************************************************************************/
2088 static E_Dialog *reboot_dialog = NULL;
2089
2090 static void
2091 _e_actions_cb_reboot_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2092 {
2093    if (dia)
2094      {
2095         e_object_del(E_OBJECT(reboot_dialog));
2096         reboot_dialog = NULL;
2097      }
2098    e_sys_action_do(E_SYS_REBOOT, NULL);
2099 }
2100
2101 static void
2102 _e_actions_cb_reboot_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2103 {
2104    e_object_del(E_OBJECT(reboot_dialog));
2105    reboot_dialog = NULL;
2106 }
2107
2108 static void
2109 _e_actions_cb_reboot_dialog_delete(E_Win *win)
2110 {
2111    E_Dialog *dia;
2112
2113    dia = win->data;
2114    _e_actions_cb_reboot_dialog_cancel(NULL, dia);
2115 }
2116
2117 ACT_FN_GO(reboot, )
2118 {
2119    if ((params) && (!strcmp(params, "now")))
2120      {
2121         e_sys_action_do(E_SYS_REBOOT, NULL);
2122         return;
2123      }
2124    if (reboot_dialog) e_object_del(E_OBJECT(reboot_dialog));
2125
2126    if (e_config->cnfmdlg_disabled)
2127      {
2128         _e_actions_cb_reboot_dialog_ok(NULL, NULL);
2129         return;
2130      }
2131
2132    reboot_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_reboot_dialog");
2133    if (!reboot_dialog) return;
2134    e_win_delete_callback_set(reboot_dialog->win, _e_actions_cb_reboot_dialog_delete);
2135    e_dialog_title_set(reboot_dialog, _("Are you sure you want to reboot?"));
2136    e_dialog_text_set(reboot_dialog,
2137                      _("You requested to reboot your Computer.<br>"
2138                        "<br>"
2139                        "Are you sure you want to restart it?"));
2140    e_dialog_icon_set(reboot_dialog, "system-restart", 64);
2141    e_dialog_button_add(reboot_dialog, _("Yes"), NULL,
2142                        _e_actions_cb_reboot_dialog_ok, NULL);
2143    e_dialog_button_add(reboot_dialog, _("No"), NULL,
2144                        _e_actions_cb_reboot_dialog_cancel, NULL);
2145    e_dialog_button_focus_num(reboot_dialog, 1);
2146    e_win_centered_set(reboot_dialog->win, 1);
2147    e_dialog_show(reboot_dialog);
2148 }
2149
2150 /***************************************************************************/
2151 static E_Dialog *suspend_dialog = NULL;
2152
2153 static void
2154 _e_actions_cb_suspend_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2155 {
2156    if (dia)
2157      {
2158         e_object_del(E_OBJECT(suspend_dialog));
2159         suspend_dialog = NULL;
2160      }
2161    e_sys_action_do(E_SYS_SUSPEND, NULL);
2162 }
2163
2164 static void
2165 _e_actions_cb_suspend_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2166 {
2167    e_object_del(E_OBJECT(suspend_dialog));
2168    suspend_dialog = NULL;
2169 }
2170
2171 static void
2172 _e_actions_cb_suspend_dialog_delete(E_Win *win)
2173 {
2174    E_Dialog *dia;
2175
2176    dia = win->data;
2177    _e_actions_cb_suspend_dialog_cancel(NULL, dia);
2178 }
2179
2180 ACT_FN_GO(suspend_now, __UNUSED__)
2181 {
2182    e_sys_action_do(E_SYS_SUSPEND, NULL);
2183 }
2184
2185 ACT_FN_GO(suspend, )
2186 {
2187    if ((params) && (!strcmp(params, "now")))
2188      {
2189         e_sys_action_do(E_SYS_SUSPEND, NULL);
2190         return;
2191      }
2192    if (suspend_dialog) e_object_del(E_OBJECT(suspend_dialog));
2193
2194    if (e_config->cnfmdlg_disabled)
2195      {
2196         _e_actions_cb_suspend_dialog_ok(NULL, NULL);
2197         return;
2198      }
2199
2200    suspend_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_suspend_dialog");
2201    if (!suspend_dialog) return;
2202    e_win_delete_callback_set(suspend_dialog->win, _e_actions_cb_suspend_dialog_delete);
2203    e_dialog_title_set(suspend_dialog, _("Are you sure you want to turn off?"));
2204    e_dialog_text_set(suspend_dialog,
2205                      _("You requested to suspend your Computer.<br>"
2206                        "<br>"
2207                        "Are you sure you want to suspend?"));
2208    e_dialog_icon_set(suspend_dialog, "system-suspend", 64);
2209    e_dialog_button_add(suspend_dialog, _("Yes"), NULL,
2210                        _e_actions_cb_suspend_dialog_ok, NULL);
2211    e_dialog_button_add(suspend_dialog, _("No"), NULL,
2212                        _e_actions_cb_suspend_dialog_cancel, NULL);
2213    e_dialog_button_focus_num(suspend_dialog, 1);
2214    e_win_centered_set(suspend_dialog->win, 1);
2215    e_dialog_show(suspend_dialog);
2216 }
2217
2218 /***************************************************************************/
2219 static E_Dialog *hibernate_dialog = NULL;
2220
2221 static void
2222 _e_actions_cb_hibernate_dialog_ok(void *data __UNUSED__, E_Dialog *dia)
2223 {
2224    if (dia)
2225      {
2226         e_object_del(E_OBJECT(hibernate_dialog));
2227         hibernate_dialog = NULL;
2228      }
2229    e_sys_action_do(E_SYS_HIBERNATE, NULL);
2230 }
2231
2232 static void
2233 _e_actions_cb_hibernate_dialog_cancel(void *data __UNUSED__, E_Dialog *dia __UNUSED__)
2234 {
2235    e_object_del(E_OBJECT(hibernate_dialog));
2236    hibernate_dialog = NULL;
2237 }
2238
2239 static void
2240 _e_actions_cb_hibernate_dialog_delete(E_Win *win)
2241 {
2242    E_Dialog *dia;
2243
2244    dia = win->data;
2245    _e_actions_cb_hibernate_dialog_cancel(NULL, dia);
2246 }
2247
2248 ACT_FN_GO(hibernate, )
2249 {
2250    if ((params) && (!strcmp(params, "now")))
2251      {
2252         e_sys_action_do(E_SYS_HIBERNATE, NULL);
2253         return;
2254      }
2255    if (hibernate_dialog) e_object_del(E_OBJECT(hibernate_dialog));
2256
2257    if (e_config->cnfmdlg_disabled)
2258      {
2259         _e_actions_cb_hibernate_dialog_ok(NULL, NULL);
2260         return;
2261      }
2262
2263    hibernate_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_hibernate_dialog");
2264    if (!hibernate_dialog) return;
2265    e_win_delete_callback_set(hibernate_dialog->win, _e_actions_cb_hibernate_dialog_delete);
2266    e_dialog_title_set(hibernate_dialog, _("Are you sure you want to hibernate?"));
2267    e_dialog_text_set(hibernate_dialog,
2268                      _("You requested to hibernate your Computer.<br>"
2269                        "<br>"
2270                        "Are you sure you want to suspend to disk?"));
2271    e_dialog_icon_set(hibernate_dialog, "system-suspend-hibernate", 64);
2272    e_dialog_button_add(hibernate_dialog, _("Yes"), NULL,
2273                        _e_actions_cb_hibernate_dialog_ok, NULL);
2274    e_dialog_button_add(hibernate_dialog, _("No"), NULL,
2275                        _e_actions_cb_hibernate_dialog_cancel, NULL);
2276    e_dialog_button_focus_num(hibernate_dialog, 1);
2277    e_win_centered_set(hibernate_dialog->win, 1);
2278    e_dialog_show(hibernate_dialog);
2279 }
2280
2281 /***************************************************************************/
2282 ACT_FN_GO(pointer_resize_push, )
2283 {
2284    if (!obj) return;
2285    if (obj->type == E_BORDER_TYPE)
2286      {
2287         E_Border *bd;
2288
2289         bd = (E_Border *)obj;
2290         if ((bd->lock_user_size) || (bd->shaded) || (bd->shading) ||
2291             (bd->fullscreen) || ((bd->maximized) && (!e_config->allow_manip)))
2292           return;
2293         e_pointer_type_push(bd->pointer, bd, params);
2294      }
2295 }
2296
2297 /***************************************************************************/
2298 ACT_FN_GO(pointer_resize_pop, )
2299 {
2300    if (!obj) return;
2301    if (obj->type == E_BORDER_TYPE)
2302      {
2303         E_Border *bd;
2304
2305         bd = (E_Border *)obj;
2306         if ((bd->lock_user_size) || (bd->shaded) || (bd->shading) ||
2307             (bd->fullscreen) || ((bd->maximized) && (!e_config->allow_manip)))
2308           return;
2309         e_pointer_type_pop(bd->pointer, bd, params);
2310      }
2311 }
2312
2313 /***************************************************************************/
2314 ACT_FN_GO(desk_lock, __UNUSED__)
2315 {
2316 /*  E_Zone *zone;
2317
2318   zone = _e_actions_zone_get(obj);
2319   if (zone)*/
2320   e_desklock_show();
2321 }
2322
2323 /***************************************************************************/
2324 ACT_FN_GO(shelf_show, )
2325 {
2326    Eina_List *l;
2327    E_Shelf *es;
2328
2329    if (params)
2330      {
2331         for (; *params != '\0'; params++)
2332           if (!isspace(*params))
2333             break;
2334         if (*params == '\0')
2335           params = NULL;
2336      }
2337
2338    EINA_LIST_FOREACH(e_shelf_list(), l, es)
2339      {
2340         if ((!params) || (params && (fnmatch(params, es->name, 0) == 0)))
2341           {
2342              e_shelf_toggle(es, 1);
2343              e_shelf_toggle(es, 0);
2344           }
2345      }
2346 }
2347 /***************************************************************************/
2348 #define ACT_SHELF_SHOW(params, es) \
2349 if ((!params) || (params && (fnmatch(params, es->name, 0) == 0))) \
2350   { \
2351      e_shelf_toggle(es, 1); \
2352      e_shelf_toggle(es, 0); \
2353   }
2354
2355 ACT_FN_GO_EDGE(shelf_show, )
2356 {
2357    Eina_List *l;
2358    E_Shelf *es;
2359
2360    if (params)
2361      {
2362         for (; *params != '\0'; params++)
2363           {
2364              if (!isspace(*params))
2365                break;
2366           }
2367         if (*params == '\0')
2368           params = NULL;
2369      }
2370
2371    EINA_LIST_FOREACH(e_shelf_list(), l, es)
2372      {
2373         switch(ev->edge)
2374           {
2375           case E_ZONE_EDGE_LEFT:
2376              if ((es->gadcon->orient == E_GADCON_ORIENT_LEFT ||
2377                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_LT ||
2378                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_LB) &&
2379                  (ev->y >= es->y) && (ev->y <= (es->y + es->h)))
2380                ACT_SHELF_SHOW(params, es);
2381              break;
2382           case E_ZONE_EDGE_RIGHT:
2383              if ((es->gadcon->orient == E_GADCON_ORIENT_RIGHT ||
2384                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_RT ||
2385                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_RB) &&
2386                  (ev->y >= es->y) && (ev->y <= (es->y + es->h)))
2387                ACT_SHELF_SHOW(params, es);
2388              break;
2389           case E_ZONE_EDGE_TOP:
2390              if ((es->gadcon->orient == E_GADCON_ORIENT_TOP ||
2391                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_TL ||
2392                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_TR) &&
2393                  (ev->x >= es->x) && (ev->x <= (es->x + es->w)))
2394                ACT_SHELF_SHOW(params, es);
2395              break;
2396           case E_ZONE_EDGE_BOTTOM:
2397              if ((es->gadcon->orient == E_GADCON_ORIENT_BOTTOM ||
2398                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_BL ||
2399                   es->gadcon->orient == E_GADCON_ORIENT_CORNER_BR) &&
2400                  (ev->x >= es->x) && (ev->x <= (es->x + es->w)))
2401                ACT_SHELF_SHOW(params, es);
2402              break;
2403           default:
2404              break;
2405           }
2406      }
2407 }
2408 #undef ACT_SHELF_SHOW
2409
2410 /***************************************************************************/
2411 typedef struct _Delayed_Action Delayed_Action;
2412
2413 struct _Delayed_Action
2414 {
2415    int mouse, button;
2416    const char *keyname;
2417    E_Object *obj;
2418    Ecore_Timer *timer;
2419    struct
2420      {
2421         const char *action, *params;
2422      } def, delayed;
2423 };
2424
2425 static Eina_List *_delayed_actions = NULL;
2426
2427 static void
2428 _delayed_action_free(Delayed_Action *da)
2429 {
2430    if (da->obj) e_object_unref(da->obj);
2431    if (da->keyname) eina_stringshare_del(da->keyname);
2432    if (da->timer) ecore_timer_del(da->timer);
2433    if (da->def.action) eina_stringshare_del(da->def.action);
2434    if (da->def.params) eina_stringshare_del(da->def.params);
2435    if (da->delayed.action) eina_stringshare_del(da->delayed.action);
2436    if (da->delayed.params) eina_stringshare_del(da->delayed.params);
2437    free(da);
2438 }
2439
2440 static Eina_Bool
2441 _delayed_action_cb_timer(void *data)
2442 {
2443    Delayed_Action *da;
2444    E_Action *act;
2445
2446    da = data;
2447    da->timer = NULL;
2448    act = e_action_find(da->delayed.action);
2449    if (act)
2450      {
2451         if (act->func.go) act->func.go(da->obj, da->delayed.params);
2452      }
2453    _delayed_actions = eina_list_remove(_delayed_actions, da);
2454    _delayed_action_free(da);
2455    return ECORE_CALLBACK_CANCEL;
2456 }
2457
2458 static void
2459 _delayed_action_do(Delayed_Action *da)
2460 {
2461    E_Action *act;
2462
2463    act = e_action_find(da->def.action);
2464    if (act)
2465      {
2466         if (act->func.go) act->func.go(da->obj, da->def.params);
2467      }
2468 }
2469
2470 static void
2471 _delayed_action_list_parse_action(const char *str, double *delay, const char **action, const char **params)
2472 {
2473    char fbuf[16];
2474    char buf[1024];
2475    const char *p;
2476
2477    buf[0] = 0;
2478    sscanf(str, "%10s %1000s", fbuf, buf);
2479    *action = eina_stringshare_add(buf);
2480    *delay = atof(fbuf);
2481    p = strchr(str, ' ');
2482    if (p)
2483      {
2484         p++;
2485         p = strchr(p, ' ');
2486         if (p)
2487           {
2488              p++;
2489              *params = eina_stringshare_add(p);
2490           }
2491      }
2492 }
2493
2494 static void
2495 _delayed_action_list_parse(Delayed_Action *da, const char *params)
2496 {
2497    double delay = 2.0;
2498    const char *p, *a1start = NULL, *a1stop = NULL;
2499    const char *a2start = NULL, *a2stop = NULL;
2500
2501    // FORMAT: "[0.0 default_action param1 param2] [x.x action2 param1 param2]"
2502    p = params;
2503    while (*p)
2504      {
2505         if ((*p == '[') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a1start = p + 1; break;}
2506         p++;
2507      }
2508    while (*p)
2509      {
2510         if ((*p == ']') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a1stop = p; break;}
2511         p++;
2512      }
2513    while (*p)
2514      {
2515         if ((*p == '[') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a2start = p + 1; break;}
2516         p++;
2517      }
2518    while (*p)
2519      {
2520         if ((*p == ']') && ((p == params) || ((p > params) && (p[-1] != '\\')))) {a2stop = p; break;}
2521         p++;
2522      }
2523    if ((a1start) && (a2start) && (a1stop) && (a2stop))
2524      {
2525         char *a1, *a2;
2526         const char *action, *params;
2527
2528         a1 = alloca(a1stop - a1start + 1);
2529         eina_strlcpy(a1, a1start, a1stop - a1start + 1);
2530         action = NULL;
2531         params = NULL;
2532         _delayed_action_list_parse_action(a1, &delay, &da->def.action, &da->def.params);
2533
2534         a2 = alloca(a1stop - a1start + 1);
2535         eina_strlcpy(a2, a2start, a2stop - a2start + 1);
2536         _delayed_action_list_parse_action(a2, &delay, &da->delayed.action, &da->delayed.params);
2537      }
2538    da->timer = ecore_timer_add(delay, _delayed_action_cb_timer, da);
2539 }
2540
2541 static void
2542 _delayed_action_key_add(E_Object *obj, const char *params, Ecore_Event_Key *ev)
2543 {
2544    Delayed_Action *da;
2545
2546    da = E_NEW(Delayed_Action, 1);
2547    if (!da) return;
2548    if (obj)
2549      {
2550         da->obj = obj;
2551         e_object_ref(da->obj);
2552      }
2553    da->mouse = 0;
2554    da->keyname = eina_stringshare_add(ev->keyname);
2555    if (params) _delayed_action_list_parse(da, params);
2556    _delayed_actions = eina_list_append(_delayed_actions, da);
2557 }
2558
2559 static void
2560 _delayed_action_key_del(E_Object *obj, const char *params __UNUSED__, Ecore_Event_Key *ev)
2561 {
2562    Eina_List *l;
2563    Delayed_Action *da;
2564
2565    EINA_LIST_FOREACH(_delayed_actions, l, da)
2566      {
2567         if ((da->obj == obj) && (!da->mouse) &&
2568             (!strcmp(da->keyname, ev->keyname)))
2569           {
2570              _delayed_action_do(da);
2571              _delayed_action_free(da);
2572              _delayed_actions = eina_list_remove_list(_delayed_actions, l);
2573              return;
2574           }
2575      }
2576 }
2577
2578 static void
2579 _delayed_action_mouse_add(E_Object *obj, const char *params, Ecore_Event_Mouse_Button *ev)
2580 {
2581    Delayed_Action *da;
2582
2583    da = E_NEW(Delayed_Action, 1);
2584    if (!da) return;
2585    if (obj)
2586      {
2587         da->obj = obj;
2588         e_object_ref(da->obj);
2589      }
2590    da->mouse = 1;
2591    da->button = ev->buttons;
2592    if (params) _delayed_action_list_parse(da, params);
2593    _delayed_actions = eina_list_append(_delayed_actions, da);
2594 }
2595
2596 static void
2597 _delayed_action_mouse_del(E_Object *obj, const char *params __UNUSED__, Ecore_Event_Mouse_Button *ev)
2598 {
2599    Eina_List *l;
2600    Delayed_Action *da;
2601
2602    EINA_LIST_FOREACH(_delayed_actions, l, da)
2603      {
2604         if ((da->obj == obj) && (da->mouse) &&
2605             ((int) ev->buttons == da->button))
2606           {
2607              _delayed_action_do(da);
2608              _delayed_action_free(da);
2609              _delayed_actions = eina_list_remove_list(_delayed_actions, l);
2610              return;
2611           }
2612      }
2613 }
2614
2615 // obj , params  , ev
2616 ACT_FN_GO_KEY(delayed_action, )
2617 {
2618    _delayed_action_key_add(obj, params, ev);
2619 }
2620
2621 ACT_FN_GO_MOUSE(delayed_action, )
2622 {
2623    _delayed_action_mouse_add(obj, params, ev);
2624 }
2625
2626 ACT_FN_END_KEY(delayed_action, )
2627 {
2628    _delayed_action_key_del(obj, params, ev);
2629 }
2630
2631 ACT_FN_END_MOUSE(delayed_action, )
2632 {
2633    _delayed_action_mouse_del(obj, params, ev);
2634 }
2635
2636 ACT_FN_GO_ACPI(dim_screen, __UNUSED__)
2637 {
2638    printf("Dim Screen\n");
2639 }
2640
2641 ACT_FN_GO_ACPI(undim_screen, __UNUSED__)
2642 {
2643    printf("Undim Screen\n");
2644 }
2645
2646 /* local subsystem globals */
2647 static Eina_Hash *actions = NULL;
2648 static Eina_List *action_list = NULL;
2649 static Eina_List *action_names = NULL;
2650 static Eina_List *action_groups = NULL;
2651
2652 /* externally accessible functions */
2653
2654 EINTERN int
2655 e_actions_init(void)
2656 {
2657    E_Action *act;
2658
2659    actions = eina_hash_string_superfast_new(NULL);
2660    ACT_GO(window_move);
2661    e_action_predef_name_set(N_("Window : Actions"), N_("Move"),
2662                             "window_move", NULL, NULL, 0);
2663
2664    ACT_GO_MOUSE(window_move);
2665    ACT_GO_SIGNAL(window_move);
2666    ACT_END(window_move);
2667    ACT_END_MOUSE(window_move);
2668    ACT_GO_KEY(window_move);
2669
2670    /* window_resize */
2671    ACT_GO(window_resize);
2672    e_action_predef_name_set(N_("Window : Actions"), N_("Resize"),
2673                             "window_resize", NULL, NULL, 0);
2674
2675    ACT_GO_MOUSE(window_resize);
2676    ACT_GO_SIGNAL(window_resize);
2677    ACT_END(window_resize);
2678    ACT_END_MOUSE(window_resize);
2679    ACT_GO_KEY(window_resize);
2680
2681    /* window_menu */
2682    ACT_GO(window_menu);
2683    e_action_predef_name_set(N_("Menu"), N_("Window Menu"),
2684                             "window_menu", NULL, NULL, 0);
2685
2686    ACT_GO_MOUSE(window_menu);
2687    ACT_GO_KEY(window_menu);
2688
2689    /* window_raise */
2690    ACT_GO(window_raise);
2691    e_action_predef_name_set(N_("Window : Actions"), N_("Raise"),
2692                             "window_raise", NULL, NULL, 0);
2693
2694    /* window_lower */
2695    ACT_GO(window_lower);
2696    e_action_predef_name_set(N_("Window : Actions"), N_("Lower"),
2697                             "window_lower", NULL, NULL, 0);
2698
2699    /* window_close */
2700    ACT_GO(window_close);
2701    e_action_predef_name_set(N_("Window : Actions"), N_("Close"),
2702                             "window_close", NULL, NULL, 0);
2703
2704    /* window_kill */
2705    ACT_GO(window_kill);
2706    e_action_predef_name_set(N_("Window : Actions"), N_("Kill"),
2707                             "window_kill", NULL, NULL, 0);
2708
2709    /* window_sticky_toggle */
2710    ACT_GO(window_sticky_toggle);
2711    e_action_predef_name_set(N_("Window : State"), N_("Sticky Mode Toggle"),
2712                             "window_sticky_toggle", NULL, NULL, 0);
2713
2714    ACT_GO(window_sticky);
2715
2716    /* window_iconic_toggle */
2717    ACT_GO(window_iconic_toggle);
2718    e_action_predef_name_set(N_("Window : State"), N_("Iconic Mode Toggle"),
2719                             "window_iconic_toggle", NULL, NULL, 0);
2720
2721    ACT_GO(window_iconic);
2722
2723    /* window_fullscreen_toggle */
2724    ACT_GO(window_fullscreen_toggle);
2725    e_action_predef_name_set(N_("Window : State"), N_("Fullscreen Mode Toggle"),
2726                             "window_fullscreen_toggle", NULL, NULL, 0);
2727
2728    ACT_GO(window_fullscreen);
2729
2730    /* window_maximized_toggle */
2731    ACT_GO(window_maximized_toggle);
2732    e_action_predef_name_set(N_("Window : State"), N_("Maximize"),
2733                             "window_maximized_toggle", NULL, NULL, 0);
2734    e_action_predef_name_set(N_("Window : State"), N_("Maximize Vertically"),
2735                             "window_maximized_toggle", "default vertical",
2736                             NULL, 0);
2737    e_action_predef_name_set(N_("Window : State"), N_("Maximize Horizontally"),
2738                             "window_maximized_toggle", "default horizontal",
2739                             NULL, 0);
2740    e_action_predef_name_set(N_("Window : State"), N_("Maximize Fullscreen"),
2741                             "window_maximized_toggle", "fullscreen", NULL, 0);
2742    e_action_predef_name_set(N_("Window : State"), N_("Maximize Mode \"Smart\""),
2743                             "window_maximized_toggle", "smart", NULL, 0);
2744    e_action_predef_name_set(N_("Window : State"), N_("Maximize Mode \"Expand\""),
2745                             "window_maximized_toggle", "expand", NULL, 0);
2746    e_action_predef_name_set(N_("Window : State"), N_("Maximize Mode \"Fill\""),
2747                             "window_maximized_toggle", "fill", NULL, 0);
2748
2749    ACT_GO(window_maximized);
2750
2751    /* window_shaded_toggle */
2752    ACT_GO(window_shaded_toggle);
2753    e_action_predef_name_set(N_("Window : State"), N_("Shade Up Mode Toggle"),
2754                             "window_shaded_toggle", "up", NULL, 0);
2755    e_action_predef_name_set(N_("Window : State"), N_("Shade Down Mode Toggle"),
2756                             "window_shaded_toggle", "down", NULL, 0);
2757    e_action_predef_name_set(N_("Window : State"), N_("Shade Left Mode Toggle"),
2758                             "window_shaded_toggle", "left", NULL, 0);
2759    e_action_predef_name_set(N_("Window : State"), N_("Shade Right Mode Toggle"),
2760                             "window_shaded_toggle", "right", NULL, 0);
2761    e_action_predef_name_set(N_("Window : State"), N_("Shade Mode Toggle"),
2762                             "window_shaded_toggle", NULL, NULL, 0);
2763
2764    ACT_GO(window_shaded);
2765
2766    /* window_borderless_toggle */
2767    ACT_GO(window_borderless_toggle);
2768    e_action_predef_name_set(N_("Window : State"), N_("Toggle Borderless State"),
2769                             "window_borderless_toggle", NULL, NULL, 0);
2770
2771    /* window_border_set */
2772    ACT_GO(window_border_set);
2773    e_action_predef_name_set(N_("Window : State"), N_("Set Border"),
2774                             "window_border_set", NULL,
2775                             "syntax: BorderName, example: pixel", 1);
2776
2777    /* window_border_cycle */
2778    ACT_GO(window_border_cycle);
2779    e_action_predef_name_set(N_("Window : State"), N_("Cycle between Borders"),
2780                             "window_border_cycle", NULL,
2781                             "syntax: BorderNames, example: default pixel", 1);
2782
2783    /* window_pinned_toggle */
2784    ACT_GO(window_pinned_toggle);
2785    e_action_predef_name_set(N_("Window : State"), N_("Toggle Pinned State"),
2786                             "window_pinned_toggle", NULL, NULL, 0);
2787
2788    /* desk_flip_by */
2789    ACT_GO(desk_flip_by);
2790    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Left"),
2791                             "desk_flip_by", "-1 0", NULL, 0);
2792    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Right"),
2793                             "desk_flip_by", "1 0", NULL, 0);
2794    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Up"),
2795                             "desk_flip_by", "0 -1", NULL, 0);
2796    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Down"),
2797                             "desk_flip_by", "0 1", NULL, 0);
2798    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop By..."),
2799                             "desk_flip_by", NULL,
2800                             "syntax: X-offset Y-offset, example: -1 0", 1);
2801
2802    /* desk_deskshow_toggle */
2803    ACT_GO(desk_deskshow_toggle);
2804    e_action_predef_name_set(N_("Desktop"), N_("Show The Desktop"),
2805                             "desk_deskshow_toggle", NULL, NULL, 0);
2806
2807    /* shelf_show */
2808    ACT_GO(shelf_show);
2809    ACT_GO_EDGE(shelf_show);
2810    e_action_predef_name_set(N_("Desktop"), N_("Show The Shelf"), "shelf_show",
2811                             NULL, "shelf name glob: Shelf-* ", 1);
2812
2813    /* desk_linear_flip_to */
2814    ACT_GO(desk_flip_to);
2815    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop To..."),
2816                             "desk_flip_to", NULL,
2817                             "syntax: X Y, example: 1 2", 1);
2818
2819    /* desk_linear_flip_by */
2820    ACT_GO(desk_linear_flip_by);
2821    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Linearly..."),
2822                             "desk_linear_flip_by",
2823                             NULL, "syntax: N-offset, example: -2", 1);
2824
2825    /* desk_linear_flip_to */
2826    ACT_GO(desk_linear_flip_to);
2827    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 0"),
2828                             "desk_linear_flip_to", "0", NULL, 0);
2829    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 1"),
2830                             "desk_linear_flip_to", "1", NULL, 0);
2831    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 2"),
2832                             "desk_linear_flip_to", "2", NULL, 0);
2833    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 3"),
2834                             "desk_linear_flip_to", "3", NULL, 0);
2835    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 4"),
2836                             "desk_linear_flip_to", "4", NULL, 0);
2837    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 5"),
2838                             "desk_linear_flip_to", "5", NULL, 0);
2839    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 6"),
2840                             "desk_linear_flip_to", "6", NULL, 0);
2841    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 7"),
2842                             "desk_linear_flip_to", "7", NULL, 0);
2843    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 8"),
2844                             "desk_linear_flip_to", "8", NULL, 0);
2845    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 9"),
2846                             "desk_linear_flip_to", "9", NULL, 0);
2847    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 10"),
2848                             "desk_linear_flip_to", "10", NULL, 0);
2849    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 11"),
2850                             "desk_linear_flip_to", "11", NULL, 0);
2851    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop..."),
2852                             "desk_linear_flip_to", NULL,
2853                             "syntax: N, example: 1", 1);
2854
2855    /* desk_flip_by_all */
2856    ACT_GO(desk_flip_by_all);
2857    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Left (All Screens)"),
2858                             "desk_flip_by_all", "-1 0", NULL, 0);
2859    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Right (All Screens)"),
2860                             "desk_flip_by_all", "1 0", NULL, 0);
2861    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Up (All Screens)"),
2862                             "desk_flip_by_all", "0 -1", NULL, 0);
2863    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Down (All Screens)"),
2864                             "desk_flip_by_all", "0 1", NULL, 0);
2865    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop By... (All Screens)"),
2866                             "desk_flip_by_all", NULL,
2867                             "syntax: X-offset Y-offset, example: -1 0", 1);
2868
2869    /* desk_flip_to_all */
2870    ACT_GO(desk_flip_to_all);
2871    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop To... (All Screens)"),
2872                             "desk_flip_to_all", NULL,
2873                             "syntax: X Y, example: 1 2", 1);
2874
2875    /* desk_linear_flip_by_all */
2876    ACT_GO(desk_linear_flip_by_all);
2877    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop Linearly... (All Screens)"),
2878                             "desk_linear_flip_by_all",
2879                             NULL, "syntax: N-offset, example: -2", 1);
2880
2881    /* desk_flip_in_direction */
2882    ACT_GO_EDGE(desk_flip_in_direction);
2883    e_action_predef_name_set(N_("Desktop"), N_("Flip Desktop In Direction..."),
2884                             "desk_flip_in_direction", NULL, "syntax: N-pixel-offset, example: 25", 1);
2885
2886    /* desk_linear_flip_to_all */
2887    ACT_GO(desk_linear_flip_to_all);
2888    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 0 (All Screens)"),
2889                             "desk_linear_flip_to_all", "0", NULL, 0);
2890    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 1 (All Screens)"),
2891                             "desk_linear_flip_to_all", "1", NULL, 0);
2892    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 2 (All Screens)"),
2893                             "desk_linear_flip_to_all", "2", NULL, 0);
2894    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 3 (All Screens)"),
2895                             "desk_linear_flip_to_all", "3", NULL, 0);
2896    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 4 (All Screens)"),
2897                             "desk_linear_flip_to_all", "4", NULL, 0);
2898    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 5 (All Screens)"),
2899                             "desk_linear_flip_to_all", "5", NULL, 0);
2900    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 6 (All Screens)"),
2901                             "desk_linear_flip_to_all", "6", NULL, 0);
2902    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 7 (All Screens)"),
2903                             "desk_linear_flip_to_all", "7", NULL, 0);
2904    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 8 (All Screens)"),
2905                             "desk_linear_flip_to_all", "8", NULL, 0);
2906    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 9 (All Screens)"),
2907                             "desk_linear_flip_to_all", "9", NULL, 0);
2908    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 10 (All Screens)"),
2909                             "desk_linear_flip_to_all", "10", NULL, 0);
2910    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop 11 (All Screens)"),
2911                             "desk_linear_flip_to_all", "11", NULL, 0);
2912    e_action_predef_name_set(N_("Desktop"), N_("Switch To Desktop... (All Screens)"),
2913                             "desk_linear_flip_to_all", NULL,
2914                             "syntax: N, example: 1", 1);
2915
2916    /* screen_send_to */
2917    ACT_GO(screen_send_to);
2918    e_action_predef_name_set(N_("Screen"), N_("Send Mouse To Screen 0"),
2919                             "screen_send_to", "0", NULL, 0);
2920    e_action_predef_name_set(N_("Screen"), N_("Send Mouse To Screen 1"),
2921                             "screen_send_to", "1", NULL, 0);
2922    e_action_predef_name_set(N_("Screen"), N_("Send Mouse To Screen..."),
2923                             "screen_send_to", NULL,
2924                             "syntax: N, example: 0", 1);
2925
2926    /* screen_send_by */
2927    ACT_GO(screen_send_by);
2928    e_action_predef_name_set(N_("Screen"), N_("Send Mouse Forward 1 Screen"),
2929                             "screen_send_by", "1", NULL, 0);
2930    e_action_predef_name_set(N_("Screen"), N_("Send Mouse Back 1 Screen"),
2931                             "screen_send_by", "-1", NULL, 0);
2932    e_action_predef_name_set(N_("Screen"), N_("Send Mouse Forward/Back Screens..."),
2933                             "screen_send_by", NULL,
2934                             "syntax: N-offset, example: -2", 1);
2935
2936    /* window_move_to_center */
2937    ACT_GO(window_move_to_center);
2938    e_action_predef_name_set(N_("Window : Actions"), N_("Move To Center"),
2939                             "window_move_to_center", NULL, NULL, 0);
2940    /* window_move_to */
2941    ACT_GO(window_move_to);
2942    e_action_predef_name_set(N_("Window : Actions"), N_("Move To..."),
2943                             "window_move_to", NULL,
2944                             "syntax: [+,-]X [+,-]Y or * [+,-]Y or [+,-]X *, example: -1 +1", 1);
2945    /* window_move_by */
2946    ACT_GO(window_move_by);
2947    e_action_predef_name_set(N_("Window : Actions"), N_("Move By..."),
2948                             "window_move_by", NULL,
2949                             "syntax: X-offset Y-offset, example: -1 0", 1);
2950
2951    /* window_resize_by */
2952    ACT_GO(window_resize_by);
2953    e_action_predef_name_set(N_("Window : Actions"), N_("Resize By..."),
2954                             "window_resize_by", NULL,
2955                             "syntax: W H, example: 100 150", 1);
2956
2957    /* window_push */
2958    ACT_GO(window_push);
2959    e_action_predef_name_set(N_("Window : Actions"), N_("Push in Direction..."),
2960                             "window_push", NULL,
2961                             "syntax: direction, example: up, down, left, right, up-left, up-right, down-left, down-right", 1);
2962
2963    /* window_drag_icon */
2964    ACT_GO(window_drag_icon);
2965    e_action_predef_name_set(N_("Window : Actions"), N_("Drag Icon..."),
2966                             "window_drag_icon", NULL, NULL, 0);
2967
2968    /* window_desk_move_by */
2969    ACT_GO(window_desk_move_by);
2970    e_action_predef_name_set(N_("Window : Moving"), N_("To Next Desktop"),
2971                             "window_desk_move_by", "1 0", NULL, 0);
2972    e_action_predef_name_set(N_("Window : Moving"), N_("To Previous Desktop"),
2973                             "window_desk_move_by", "-1 0", NULL, 0);
2974    e_action_predef_name_set(N_("Window : Moving"), N_("By Desktop #..."),
2975                             "window_desk_move_by", NULL,
2976                             "syntax: X-offset Y-offset, example: -2 2", 1);
2977
2978    /* window_desk_move_to */
2979    ACT_GO(window_desk_move_to);
2980    e_action_predef_name_set(N_("Window : Moving"), N_("To Desktop..."),
2981                             "window_desk_move_to", NULL,
2982                             "syntax: X Y, example: 0 1", 1);
2983
2984    /* menu_show */
2985    ACT_GO(menu_show);
2986    e_action_predef_name_set(N_("Menu"), N_("Show Main Menu"),
2987                             "menu_show", "main", NULL, 0);
2988    e_action_predef_name_set(N_("Menu"), N_("Show Favorites Menu"), "menu_show",
2989                             "favorites", NULL, 0);
2990    e_action_predef_name_set(N_("Menu"), N_("Show All Applications Menu"),
2991                             "menu_show", "all", NULL, 0);
2992    e_action_predef_name_set(N_("Menu"), N_("Show Clients Menu"), "menu_show",
2993                             "clients", NULL, 0);
2994    e_action_predef_name_set(N_("Menu"), N_("Show Menu..."), "menu_show", NULL,
2995                             "syntax: MenuName, example: MyMenu", 1);
2996    ACT_GO_MOUSE(menu_show);
2997    ACT_GO_KEY(menu_show);
2998
2999    /* exec */
3000    ACT_GO(exec);
3001    e_action_predef_name_set(N_("Launch"), N_("Command"), "exec", NULL,
3002                             "syntax: CommandName, example: /usr/bin/xmms", 1);
3003
3004    /* app */
3005    ACT_GO(app);
3006    e_action_predef_name_set(N_("Launch"), N_("Application"), "app", NULL,
3007                             "syntax: , example:", 1);
3008
3009    ACT_GO(restart);
3010    e_action_predef_name_set(N_("Enlightenment"), N_("Restart"), "restart",
3011                             NULL, NULL, 0);
3012
3013    ACT_GO(exit);
3014    e_action_predef_name_set(N_("Enlightenment"), N_("Exit"), "exit",
3015                             NULL, NULL, 0);
3016
3017    ACT_GO(exit_now);
3018    e_action_predef_name_set(N_("Enlightenment"), N_("Exit Now"),
3019                             "exit_now", NULL, NULL, 0);
3020
3021    ACT_GO(mode_presentation_toggle);
3022    e_action_predef_name_set(N_("Enlightenment : Mode"),
3023                             N_("Presentation Mode Toggle"),
3024                             "mode_presentation_toggle", NULL, NULL, 0);
3025
3026    ACT_GO(mode_offline_toggle);
3027    e_action_predef_name_set(N_("Enlightenment : Mode"),
3028                             N_("Offline Mode Toggle"),
3029                             "mode_offline_toggle", NULL, NULL, 0);
3030
3031    ACT_GO(logout);
3032    e_action_predef_name_set(N_("System"), N_("Log Out"), "logout",
3033                             NULL, NULL, 0);
3034
3035    ACT_GO(halt_now);
3036    e_action_predef_name_set(N_("System"), N_("Power Off Now"),
3037                             "halt_now", NULL, NULL, 0);
3038
3039    ACT_GO(halt);
3040    e_action_predef_name_set(N_("System"), N_("Power Off"), "halt",
3041                             NULL, NULL, 0);
3042
3043    ACT_GO(reboot);
3044    e_action_predef_name_set(N_("System"), N_("Reboot"), "reboot",
3045                             NULL, NULL, 0);
3046
3047    ACT_GO(suspend_now);
3048    e_action_predef_name_set(N_("System"), N_("Suspend Now"), "suspend_now",
3049                             NULL, NULL, 0);
3050
3051    ACT_GO(suspend);
3052    e_action_predef_name_set(N_("System"), N_("Suspend"), "suspend",
3053                             NULL, NULL, 0);
3054
3055    ACT_GO(hibernate);
3056    e_action_predef_name_set(N_("System"), N_("Hibernate"), "hibernate",
3057                             NULL, NULL, 0);
3058
3059    ACT_GO(pointer_resize_push);
3060    ACT_GO(pointer_resize_pop);
3061
3062    /* desk_lock */
3063    ACT_GO(desk_lock);
3064    e_action_predef_name_set(N_("Desktop"), N_("Lock"), "desk_lock",
3065                             NULL, NULL, 0);
3066
3067    /* cleanup_windows */
3068    ACT_GO(cleanup_windows);
3069    e_action_predef_name_set(N_("Desktop"), N_("Cleanup Windows"),
3070                             "cleanup_windows", NULL, NULL, 0);
3071
3072    /* delayed_action */
3073    ACT_GO_KEY(delayed_action);
3074    e_action_predef_name_set(N_("Generic : Actions"), N_("Delayed Action"),
3075                             "delayed_action", NULL, "[0.0 exec xterm] [0.3 exec xev]", 1);
3076    ACT_GO_MOUSE(delayed_action);
3077    ACT_END_KEY(delayed_action);
3078    ACT_END_MOUSE(delayed_action);
3079
3080    ACT_GO_ACPI(dim_screen);
3081    e_action_predef_name_set(N_("Acpi"), N_("Dim Screen"), "dim_screen",
3082                             NULL, NULL, 0);
3083
3084    ACT_GO_ACPI(undim_screen);
3085    e_action_predef_name_set(N_("Acpi"), N_("Undim Screen"), "undim_screen",
3086                             NULL, NULL, 0);
3087
3088    return 1;
3089 }
3090
3091 EINTERN int
3092 e_actions_shutdown(void)
3093 {
3094    e_action_predef_name_all_del();
3095
3096    E_FREE_LIST(action_list, e_object_del);
3097
3098    action_names = eina_list_free(action_names);
3099    eina_hash_free(actions);
3100    actions = NULL;
3101
3102    return 1;
3103 }
3104
3105 EAPI Eina_List *
3106 e_action_name_list(void)
3107 {
3108    return action_names;
3109 }
3110
3111 EAPI E_Action *
3112 e_action_add(const char *name)
3113 {
3114    E_Action *act;
3115
3116    act = e_action_find(name);
3117    if (!act)
3118      {
3119         act = E_OBJECT_ALLOC(E_Action, E_ACTION_TYPE, _e_action_free);
3120         if (!act) return NULL;
3121         act->name = name;
3122         eina_hash_direct_add(actions, act->name, act);
3123         action_names = eina_list_append(action_names, name);
3124         action_list = eina_list_append(action_list, act);
3125      }
3126    return act;
3127 }
3128
3129 EAPI void
3130 e_action_del(const char *name)
3131 {
3132    E_Action *act;
3133
3134    act = eina_hash_find(actions, name);
3135    if (act) _e_action_free(act);
3136 }
3137
3138 EAPI E_Action *
3139 e_action_find(const char *name)
3140 {
3141    E_Action *act;
3142
3143    act = eina_hash_find(actions, name);
3144    return act;
3145 }
3146
3147 EAPI const char *
3148 e_action_predef_label_get(const char *action, const char *params)
3149 {
3150    E_Action_Group *actg = NULL;
3151    E_Action_Description *actd = NULL;
3152    Eina_List *l, *l2;
3153
3154    EINA_LIST_FOREACH(action_groups, l, actg)
3155      {
3156         EINA_LIST_FOREACH(actg->acts, l2, actd)
3157           {
3158              if (!strcmp(actd->act_cmd, action))
3159                {
3160                   if ((params) && (actd->act_params))
3161                     {
3162                        if (!strcmp(params, actd->act_params))
3163                          return actd->act_name;
3164                     }
3165                   else return actd->act_name;
3166                }
3167           }
3168      }
3169    if (params) return e_action_predef_label_get(action, NULL);
3170    return NULL;
3171 }
3172
3173 EAPI void
3174 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)
3175 {
3176    E_Action_Group *actg = NULL;
3177    E_Action_Description *actd = NULL;
3178    Eina_List *l;
3179
3180    if ((!act_grp) || (!act_name)) return;
3181
3182    EINA_LIST_FOREACH(action_groups, l, actg)
3183      {
3184         if (!strcmp(actg->act_grp, act_grp)) break;
3185         actg = NULL;
3186      }
3187
3188    if (!actg)
3189      {
3190         actg = E_NEW(E_Action_Group, 1);
3191         if (!actg) return;
3192
3193         actg->act_grp = eina_stringshare_add(act_grp);
3194         actg->acts = NULL;
3195
3196         action_groups = eina_list_append(action_groups, actg);
3197         action_groups =
3198           eina_list_sort(action_groups, -1, _action_groups_sort_cb);
3199      }
3200
3201    EINA_LIST_FOREACH(actg->acts, l, actd)
3202      {
3203         if (!strcmp(actd->act_name, act_name)) break;
3204         actd = NULL;
3205      }
3206
3207    if (actd) return;
3208
3209    actd = E_NEW(E_Action_Description, 1);
3210    if (!actd) return;
3211
3212    actd->act_name = eina_stringshare_add(act_name);
3213    actd->act_cmd = !act_cmd ? NULL : eina_stringshare_add(act_cmd);
3214    actd->act_params = !act_params ? NULL : eina_stringshare_add(act_params);
3215    actd->param_example = !param_example ? NULL : eina_stringshare_add(param_example);
3216    actd->editable = editable;
3217
3218    actg->acts = eina_list_append(actg->acts, actd);
3219 }
3220
3221 EAPI void
3222 e_action_predef_name_del(const char *act_grp, const char *act_name)
3223 {
3224    E_Action_Group *actg = NULL;
3225    E_Action_Description *actd = NULL;
3226    Eina_List *l;
3227
3228    EINA_LIST_FOREACH(action_groups, l, actg)
3229      {
3230         if (!strcmp(actg->act_grp, act_grp)) break;
3231         actg = NULL;
3232      }
3233
3234    if (!actg) return;
3235
3236    EINA_LIST_FOREACH(actg->acts, l, actd)
3237      {
3238         if (!strcmp(actd->act_name, act_name))
3239           {
3240              actg->acts = eina_list_remove(actg->acts, actd);
3241
3242              if (actd->act_name) eina_stringshare_del(actd->act_name);
3243              if (actd->act_cmd) eina_stringshare_del(actd->act_cmd);
3244              if (actd->act_params) eina_stringshare_del(actd->act_params);
3245              if (actd->param_example) eina_stringshare_del(actd->param_example);
3246
3247              E_FREE(actd);
3248
3249              if (!eina_list_count(actg->acts))
3250                {
3251                   action_groups = eina_list_remove(action_groups, actg);
3252                   if (actg->act_grp) eina_stringshare_del(actg->act_grp);
3253                   E_FREE(actg);
3254                }
3255              break;
3256           }
3257      }
3258 }
3259
3260 EAPI void
3261 e_action_predef_name_all_del(void)
3262 {
3263    E_Action_Group *actg = NULL;
3264    E_Action_Description *actd = NULL;
3265
3266    EINA_LIST_FREE(action_groups, actg)
3267      {
3268         EINA_LIST_FREE(actg->acts, actd)
3269           {
3270              if (actd->act_name) eina_stringshare_del(actd->act_name);
3271              if (actd->act_cmd) eina_stringshare_del(actd->act_cmd);
3272              if (actd->act_params) eina_stringshare_del(actd->act_params);
3273              if (actd->param_example) eina_stringshare_del(actd->param_example);
3274
3275              E_FREE(actd);
3276           }
3277         if (actg->act_grp) eina_stringshare_del(actg->act_grp);
3278         E_FREE(actg);
3279      }
3280    action_groups = NULL;
3281 }
3282
3283 EAPI Eina_List *
3284 e_action_groups_get(void)
3285 {
3286    return action_groups;
3287 }
3288
3289 /* local subsystem functions */
3290
3291 static void
3292 _e_action_free(E_Action *act)
3293 {
3294    eina_hash_del(actions, act->name, act);
3295    action_names = eina_list_remove(action_names, act->name);
3296    action_list = eina_list_remove(action_list, act);
3297    free(act);
3298 }
3299
3300 static E_Maximize
3301 _e_actions_maximize_parse(const char *params)
3302 {
3303    E_Maximize max = 0;
3304    int ret;
3305    char s1[32], s2[32];
3306
3307    if (!params) return e_config->maximize_policy;
3308    ret = sscanf(params, "%20s %20s", s1, s2);
3309    if (ret == 2)
3310      {
3311         if (!strcmp(s2, "horizontal"))
3312           max = E_MAXIMIZE_HORIZONTAL;
3313         else if (!strcmp(s2, "vertical"))
3314           max = E_MAXIMIZE_VERTICAL;
3315         else
3316           max = E_MAXIMIZE_BOTH;
3317      }
3318    if (ret >= 1)
3319      {
3320         if (!strcmp(s1, "fullscreen"))
3321           max |= E_MAXIMIZE_FULLSCREEN;
3322         else if (!strcmp(s1, "smart"))
3323           max |= E_MAXIMIZE_SMART;
3324         else if (!strcmp(s1, "expand"))
3325           max |= E_MAXIMIZE_EXPAND;
3326         else if (!strcmp(s1, "fill"))
3327           max |= E_MAXIMIZE_FILL;
3328         else
3329           max |= (e_config->maximize_policy & E_MAXIMIZE_TYPE);
3330      }
3331    else
3332      max = e_config->maximize_policy;
3333    return max;
3334 }
3335
3336 static int
3337 _action_groups_sort_cb(const void *d1, const void *d2)
3338 {
3339    const E_Action_Group *g1, *g2;
3340
3341    if (!(g1 = d1)) return 1;
3342    if (!(g2 = d2)) return -1;
3343    return strcmp(g1->act_grp, g2->act_grp);
3344 }