]> Dogcows Code - chaz/openbox/blob - plugins/keyboard/keyaction.c
e3b9aca4cacbb39db1dc9d89bd1d43f9ddc380fd
[chaz/openbox] / plugins / keyboard / keyaction.c
1 #include "keyaction.h"
2 #include <glib.h>
3
4 void keyaction_set_none(KeyAction *a, guint index)
5 {
6 a->type[index] = DataType_Bool;
7 }
8
9 void keyaction_set_bool(KeyAction *a, guint index, gboolean b)
10 {
11 a->type[index] = DataType_Bool;
12 a->data[index].b = b;
13 }
14
15 void keyaction_set_int(KeyAction *a, guint index, int i)
16 {
17 a->type[index] = DataType_Int;
18 a->data[index].i = i;
19 }
20
21 void keyaction_set_uint(KeyAction *a, guint index, guint u)
22 {
23 a->type[index] = DataType_Uint;
24 a->data[index].u = u;
25 }
26
27 void keyaction_set_string(KeyAction *a, guint index, char *s)
28 {
29 a->type[index] = DataType_String;
30 a->data[index].s = g_strdup(s);
31 }
32
33 void keyaction_free(KeyAction *a)
34 {
35 guint i;
36
37 for (i = 0; i < 2; ++i)
38 if (a->type[i] == DataType_String)
39 g_free(a->data[i].s);
40 }
41
42 void keyaction_do(KeyAction *a, Client *c)
43 {
44 switch (a->action) {
45 case Action_Execute:
46 g_assert(a->type[0] == DataType_String);
47 action_execute(a->data[0].s);
48 break;
49 case Action_Iconify:
50 if (c != NULL) action_iconify(c);
51 break;
52 case Action_Raise:
53 if (c != NULL) action_raise(c);
54 break;
55 case Action_Lower:
56 if (c != NULL) action_lower(c);
57 break;
58 case Action_Close:
59 if (c != NULL) action_close(c);
60 break;
61 case Action_Shade:
62 if (c != NULL) action_shade(c);
63 break;
64 case Action_Unshade:
65 if (c != NULL) action_unshade(c);
66 break;
67 case Action_ToggleShade:
68 if (c != NULL) action_toggle_shade(c);
69 break;
70 case Action_ToggleOmnipresent:
71 if (c != NULL) action_toggle_omnipresent(c);
72 break;
73 case Action_MoveRelative:
74 g_assert(a->type[0] == DataType_Int);
75 g_assert(a->type[1] == DataType_Int);
76 if (c != NULL) action_move_relative(c, a->data[0].i, a->data[1].i);
77 break;
78 case Action_ResizeRelative:
79 g_assert(a->type[0] == DataType_Int);
80 g_assert(a->type[1] == DataType_Int);
81 if (c != NULL) action_resize_relative(c, a->data[0].i, a->data[1].i);
82 break;
83 case Action_MaximizeFull:
84 if (c != NULL) action_maximize_full(c);
85 break;
86 case Action_UnmaximizeFull:
87 if (c != NULL) action_unmaximize_full(c);
88 break;
89 case Action_ToggleMaximizeFull:
90 if (c != NULL) action_toggle_maximize_full(c);
91 break;
92 case Action_MaximizeHorz:
93 if (c != NULL) action_maximize_horz(c);
94 break;
95 case Action_UnmaximizeHorz:
96 if (c != NULL) action_unmaximize_horz(c);
97 break;
98 case Action_ToggleMaximizeHorz:
99 if (c != NULL) action_toggle_maximize_horz(c);
100 break;
101 case Action_MaximizeVert:
102 if (c != NULL) action_maximize_vert(c);
103 break;
104 case Action_UnmaximizeVert:
105 if (c != NULL) action_unmaximize_vert(c);
106 break;
107 case Action_ToggleMaximizeVert:
108 if (c != NULL) action_toggle_maximize_vert(c);
109 break;
110 case Action_SendToDesktop:
111 g_assert(a->type[0] == DataType_Uint);
112 if (c != NULL) action_send_to_desktop(c, a->data[0].u);
113 break;
114 case Action_SendToNextDesktop:
115 g_assert(a->type[0] == DataType_Bool);
116 g_assert(a->type[1] == DataType_Bool);
117 if (c != NULL) action_send_to_next_desktop(c, a->data[0].b,
118 a->data[1].b);
119 break;
120 case Action_SendToPreviousDesktop:
121 g_assert(a->type[0] == DataType_Bool);
122 g_assert(a->type[1] == DataType_Bool);
123 if (c != NULL) action_send_to_previous_desktop(c, a->data[0].b,
124 a->data[1].b);
125 break;
126 case Action_Desktop:
127 g_assert(a->type[0] == DataType_Uint);
128 action_desktop(a->data[0].u);
129 break;
130 case Action_NextDesktop:
131 g_assert(a->type[0] == DataType_Bool);
132 action_next_desktop(a->data[0].b);
133 break;
134 case Action_PreviousDesktop:
135 g_assert(a->type[0] == DataType_Bool);
136 action_previous_desktop(a->data[0].b);
137 break;
138 case Action_NextDesktopColumn:
139 g_assert(a->type[0] == DataType_Bool);
140 action_next_desktop_column(a->data[0].b);
141 break;
142 case Action_PreviousDesktopColumn:
143 g_assert(a->type[0] == DataType_Bool);
144 action_previous_desktop_column(a->data[0].b);
145 break;
146 case Action_NextDesktopRow:
147 g_assert(a->type[0] == DataType_Bool);
148 action_next_desktop_row(a->data[0].b);
149 break;
150 case Action_PreviousDesktopRow:
151 g_assert(a->type[0] == DataType_Bool);
152 action_previous_desktop_row(a->data[0].b);
153 break;
154 case Action_ToggleDecorations:
155 if (c != NULL) action_toggle_decorations(c);
156 break;
157 }
158 }
159
This page took 0.041409 seconds and 3 git commands to generate.