summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-04-26 15:06:06 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-04-26 15:06:06 +0000
commitb950085e25ecda773edc7ff3681e4eab475d13c7 (patch)
tree4ae8df7ba0de534dec4767483eeea1d32b2a158e /src
parent106618ca0aefd10bf85ca97227384215a99a559e (diff)
hungarian po
fix zh_CN probs work on bindings code - add actions system framework. it's not ready for sliding in yet as i need to fill out actions but once i do i can slide the current code across and then work on sliding keybindings in. SVN revision: 14378
Diffstat (limited to 'src')
-rw-r--r--src/bin/Makefile.am4
-rw-r--r--src/bin/e_actions.c30
-rw-r--r--src/bin/e_actions.h27
-rw-r--r--src/bin/e_bindings.c177
-rw-r--r--src/bin/e_bindings.h6
-rw-r--r--src/bin/e_includes.h1
-rw-r--r--src/bin/e_intl.c10
-rw-r--r--src/bin/e_main.c7
8 files changed, 254 insertions, 8 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 2d474e3..e9fc9f4 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -49,7 +49,8 @@ e_intl.h \
49e_theme.h \ 49e_theme.h \
50e_dnd.h \ 50e_dnd.h \
51e_bindings.h \ 51e_bindings.h \
52e_moveresize.h 52e_moveresize.h \
53e_actions.h
53 54
54enlightenment_SOURCES = \ 55enlightenment_SOURCES = \
55e_main.c \ 56e_main.c \
@@ -92,6 +93,7 @@ e_theme.c \
92e_dnd.c \ 93e_dnd.c \
93e_bindings.c \ 94e_bindings.c \
94e_moveresize.c \ 95e_moveresize.c \
96e_actions.c \
95$(ENLIGHTENMENTHEADERS) 97$(ENLIGHTENMENTHEADERS)
96 98
97enlightenment_LDFLAGS = -export-dynamic @e_libs@ @dlopen_libs@ 99enlightenment_LDFLAGS = -export-dynamic @e_libs@ @dlopen_libs@
diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c
new file mode 100644
index 0000000..cf5bcd7
--- /dev/null
+++ b/src/bin/e_actions.c
@@ -0,0 +1,30 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#include "e.h"
5
6/* local subsystem functions */
7
8/* local subsystem globals */
9
10/* externally accessible functions */
11
12int
13e_actions_init(void)
14{
15 return 1;
16}
17
18int
19e_actions_shutdown(void)
20{
21 return 1;
22}
23
24E_Action *
25e_action_find(char *name)
26{
27 return NULL;
28}
29
30/* local subsystem functions */
diff --git a/src/bin/e_actions.h b/src/bin/e_actions.h
new file mode 100644
index 0000000..cace8cb
--- /dev/null
+++ b/src/bin/e_actions.h
@@ -0,0 +1,27 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#ifdef E_TYPEDEFS
5
6typedef struct _E_Action E_Action;
7
8struct _E_Action
9{
10 char *name;
11 struct {
12 void (*go) (E_Object *obj, char *params);
13 void (*go_mouse) (E_Object *obj, char *params, Ecore_X_Event_Mouse_Button_Down *ev);
14 } func;
15};
16
17#else
18#ifndef E_ACTIONS_H
19#define E_ACTIONS_H
20
21EAPI int e_actions_init(void);
22EAPI int e_actions_shutdown(void);
23
24EAPI E_Action *e_action_find(char *name);
25
26#endif
27#endif
diff --git a/src/bin/e_bindings.c b/src/bin/e_bindings.c
index 1118d90..01de306 100644
--- a/src/bin/e_bindings.c
+++ b/src/bin/e_bindings.c
@@ -4,9 +4,48 @@
4#include "e.h" 4#include "e.h"
5 5
6/* local subsystem functions */ 6/* local subsystem functions */
7typedef struct _E_Binding_Mouse E_Binding_Mouse;
8typedef struct _E_Binding_Key E_Binding_Key;
9typedef struct _E_Binding_Signal E_Binding_Signal;
10
11struct _E_Binding_Mouse
12{
13 E_Binding_Context ctxt;
14 int button;
15 E_Binding_Modifier mod;
16 unsigned char any_mod : 1;
17 char *action;
18 char *params;
19};
20
21struct _E_Binding_Key
22{
23 E_Binding_Context ctxt;
24 char *key;
25 E_Binding_Modifier mod;
26 unsigned char any_mod : 1;
27 char *action;
28 char *params;
29};
30
31struct _E_Binding_Signal
32{
33 E_Binding_Context ctxt;
34 char *sig;
35 char *src;
36 char *action;
37 char *params;
38};
39
40static void _e_bindings_mouse_free(E_Binding_Mouse *bind);
41static int _e_bindings_context_match(E_Binding_Context bctxt, E_Binding_Context ctxt);
7 42
8/* local subsystem globals */ 43/* local subsystem globals */
9 44
45static Evas_List *mouse_bindings = NULL;
46static Evas_List *key_bindings = NULL;
47static Evas_List *signal_bindings = NULL;
48
10/* externally accessible functions */ 49/* externally accessible functions */
11 50
12int 51int
@@ -22,18 +61,97 @@ e_bindings_shutdown(void)
22} 61}
23 62
24void 63void
25e_bindings_mouse_add(E_Binding_Context ctxt, int button, E_Binding_Modifier mod, int any_mod, char *action, char *param) 64e_bindings_mouse_add(E_Binding_Context ctxt, int button, E_Binding_Modifier mod, int any_mod, char *action, char *params)
26{ 65{
66 E_Binding_Mouse *bind;
67
68 if (!params) params = "";
69 bind = calloc(1, sizeof(E_Binding_Mouse));
70 bind->ctxt = ctxt;
71 bind->button = button;
72 bind->mod = mod;
73 bind->any_mod = any_mod;
74 bind->action = strdup(action);
75 bind->params = strdup(params);
76 mouse_bindings = evas_list_append(mouse_bindings, bind);
27} 77}
28 78
29void 79void
30e_bindings_mouse_grab(Ecore_X_Window win) 80e_bindings_mouse_del(E_Binding_Context ctxt, int button, E_Binding_Modifier mod, int any_mod, char *action, char *params)
31{ 81{
82 Evas_List *l;
83
84 if (!params) params = "";
85 for (l = mouse_bindings; l; l = l->next)
86 {
87 E_Binding_Mouse *bind;
88
89 bind = l->data;
90 if ((bind->ctxt == ctxt) &&
91 (bind->button == button) &&
92 (bind->mod == mod) &&
93 (bind->any_mod == any_mod) &&
94 (!strcmp(bind->action, action)) &&
95 (!strcmp(bind->params, params)))
96 {
97 _e_bindings_mouse_free(bind);
98 mouse_bindings = evas_list_remove_list(mouse_bindings, l);
99 break;
100 }
101 }
102}
103
104void
105e_bindings_mouse_grab(E_Binding_Context ctxt, Ecore_X_Window win)
106{
107 Evas_List *l;
108
109 for (l = mouse_bindings; l; l = l->next)
110 {
111 E_Binding_Mouse *bind;
112
113 bind = l->data;
114 if (bind->ctxt == ctxt)
115 {
116 int mod;
117
118 mod = 0;
119 if (bind->mod & E_BINDING_MODIFIER_SHIFT) mod |= ECORE_X_MODIFIER_SHIFT;
120 if (bind->mod & E_BINDING_MODIFIER_CTRL) mod |= ECORE_X_MODIFIER_CTRL;
121 if (bind->mod & E_BINDING_MODIFIER_ALT) mod |= ECORE_X_MODIFIER_ALT;
122 if (bind->mod & E_BINDING_MODIFIER_WIN) mod |= ECORE_X_MODIFIER_WIN;
123 ecore_x_window_button_grab(win, bind->button,
124 ECORE_X_EVENT_MASK_KEY_DOWN |
125 ECORE_X_EVENT_MASK_MOUSE_UP |
126 ECORE_X_EVENT_MASK_MOUSE_MOVE,
127 mod, bind->any_mod);
128 }
129 }
32} 130}
33 131
34void 132void
35e_bindings_mouse_ungrab(Ecore_X_Window win) 133e_bindings_mouse_ungrab(E_Binding_Context ctxt, Ecore_X_Window win)
36{ 134{
135 Evas_List *l;
136
137 for (l = mouse_bindings; l; l = l->next)
138 {
139 E_Binding_Mouse *bind;
140
141 bind = l->data;
142 if (bind->ctxt == ctxt)
143 {
144 int mod;
145
146 mod = 0;
147 if (bind->mod & E_BINDING_MODIFIER_SHIFT) mod |= ECORE_X_MODIFIER_SHIFT;
148 if (bind->mod & E_BINDING_MODIFIER_CTRL) mod |= ECORE_X_MODIFIER_CTRL;
149 if (bind->mod & E_BINDING_MODIFIER_ALT) mod |= ECORE_X_MODIFIER_ALT;
150 if (bind->mod & E_BINDING_MODIFIER_WIN) mod |= ECORE_X_MODIFIER_WIN;
151 ecore_x_window_button_ungrab(win, bind->button,
152 mod, bind->any_mod);
153 }
154 }
37} 155}
38 156
39int 157int
@@ -46,10 +164,35 @@ e_bindings_mouse_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_
46 if (ev->modifiers & ECORE_X_MODIFIER_CTRL) mod |= E_BINDING_MODIFIER_CTRL; 164 if (ev->modifiers & ECORE_X_MODIFIER_CTRL) mod |= E_BINDING_MODIFIER_CTRL;
47 if (ev->modifiers & ECORE_X_MODIFIER_ALT) mod |= E_BINDING_MODIFIER_ALT; 165 if (ev->modifiers & ECORE_X_MODIFIER_ALT) mod |= E_BINDING_MODIFIER_ALT;
48 if (ev->modifiers & ECORE_X_MODIFIER_WIN) mod |= E_BINDING_MODIFIER_WIN; 166 if (ev->modifiers & ECORE_X_MODIFIER_WIN) mod |= E_BINDING_MODIFIER_WIN;
49 167 for (l = mouse_bindings; l; l = l->next)
168 {
169 E_Binding_Mouse *bind;
170
171 bind = l->data;
172 if ((bind->button == ev->button) &&
173 ((bind->any_mod) || (bind->mod == mod)))
174 {
175 if (_e_bindings_context_match(bind->ctxt, ctxt))
176 {
177 E_Action *act;
178
179 act = e_action_find(bind->action);
180 if (act)
181 {
182 if (act->func.go_mouse)
183 act->func.go_mouse(obj, bind->params, ev);
184 else if (act->func.go)
185 act->func.go(obj, bind->params);
186 return 1;
187 }
188 return 0;
189 }
190 }
191 }
50 return 0; 192 return 0;
51} 193}
52 194
195/* FIXME: finish off key bindings */
53int 196int
54e_bindings_key_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Key_Down *ev) 197e_bindings_key_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Key_Down *ev)
55{ 198{
@@ -64,4 +207,30 @@ e_bindings_key_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_
64 return 0; 207 return 0;
65} 208}
66 209
210/* FIXME: finish off signal bindings */
211int
212e_bindings_signal_handle(E_Binding_Context ctxt, E_Object *obj, char *sig, char *src)
213{
214 Evas_List *l;
215
216 return 0;
217}
218
67/* local subsystem functions */ 219/* local subsystem functions */
220
221static void
222_e_bindings_mouse_free(E_Binding_Mouse *bind)
223{
224 E_FREE(bind->action);
225 E_FREE(bind->params);
226 free(bind);
227}
228
229static int
230_e_bindings_context_match(E_Binding_Context bctxt, E_Binding_Context ctxt)
231{
232 if (bctxt) return 1;
233 if (ctxt == E_BINDING_CONTEXT_UNKNOWN) return 0;
234 if (bctxt == ctxt) return 1;
235 return 0;
236}
diff --git a/src/bin/e_bindings.h b/src/bin/e_bindings.h
index bc10321..fd4e7c5 100644
--- a/src/bin/e_bindings.h
+++ b/src/bin/e_bindings.h
@@ -6,9 +6,10 @@
6typedef enum _E_Binding_Context 6typedef enum _E_Binding_Context
7{ 7{
8 E_BINDING_CONTEXT_NONE, 8 E_BINDING_CONTEXT_NONE,
9 E_BINDING_CONTEXT_UNKOWN, 9 E_BINDING_CONTEXT_UNKNOWN,
10 E_BINDING_CONTEXT_BORDER, 10 E_BINDING_CONTEXT_BORDER,
11 E_BINDING_CONTEXT_ZONE 11 E_BINDING_CONTEXT_ZONE,
12 E_BINDING_CONTEXT_ANY
12} E_Binding_Context; 13} E_Binding_Context;
13 14
14/* why do we do this? config stored bindings must be fixed. x's modifier masks 15/* why do we do this? config stored bindings must be fixed. x's modifier masks
@@ -32,6 +33,7 @@ EAPI int e_bindings_shutdown(void);
32 33
33EAPI int e_bindings_mouse_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Mouse_Button_Down *ev); 34EAPI int e_bindings_mouse_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Mouse_Button_Down *ev);
34EAPI int e_bindings_key_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Key_Down *ev); 35EAPI int e_bindings_key_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Key_Down *ev);
36EAPI int e_bindings_signale_handle(E_Binding_Context ctxt, E_Object *obj, char *sig, char *src);
35 37
36#endif 38#endif
37#endif 39#endif
diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h
index c66fbcc..5ea2514 100644
--- a/src/bin/e_includes.h
+++ b/src/bin/e_includes.h
@@ -39,3 +39,4 @@
39#include "e_dnd.h" 39#include "e_dnd.h"
40#include "e_bindings.h" 40#include "e_bindings.h"
41#include "e_moveresize.h" 41#include "e_moveresize.h"
42#include "e_actions.h"
diff --git a/src/bin/e_intl.c b/src/bin/e_intl.c
index 77e914c..04effd1 100644
--- a/src/bin/e_intl.c
+++ b/src/bin/e_intl.c
@@ -49,6 +49,8 @@ e_intl_init(void)
49 ADD_LANG("bg"); 49 ADD_LANG("bg");
50 ADD_LANG("de"); 50 ADD_LANG("de");
51 ADD_LANG("pl"); 51 ADD_LANG("pl");
52 ADD_LANG("zh_CN");
53 ADD_LANG("hu");
52 54
53 /* FIXME: NULL == use LANG. make this read a config value if it exists */ 55 /* FIXME: NULL == use LANG. make this read a config value if it exists */
54 e_intl_language_set(getenv("LANG")); 56 e_intl_language_set(getenv("LANG"));
@@ -146,7 +148,7 @@ e_intl_language_name_get(const char *lang)
146 IFL("uk") "Ukrainian"; 148 IFL("uk") "Ukrainian";
147 IFL("vi") "Vietnamese"; 149 IFL("vi") "Vietnamese";
148 /* must keep both - politically sensitive */ 150 /* must keep both - politically sensitive */
149 IFL("zh") "Chinese (Simplified)"; 151 IFL("zh_CN") "Chinese (Simplified)";
150 IFL("zh_TW") "Chinese (Traditional)"; 152 IFL("zh_TW") "Chinese (Traditional)";
151 return "Unknown"; 153 return "Unknown";
152} 154}
@@ -191,6 +193,12 @@ e_intl_language_simple_get(const char *lang)
191 return "de"; 193 return "de";
192 if (ISL("pl") || ISL("pl_PL") || ISL("PL") || ISL("pl_PL@euro")) 194 if (ISL("pl") || ISL("pl_PL") || ISL("PL") || ISL("pl_PL@euro"))
193 return "pl"; 195 return "pl";
196 if (ISL("zh") || ISL("zh_CN") || ISL("CN"))
197 return "zh_CN";
198 if (ISL("zh") || ISL("zh_TW") || ISL("TW"))
199 return "zh_TW";
200 if (ISL("hu") || ISL("hu_HU") || ISL("HU"))
201 return "hu";
194 /* this is the default fallback - we have no special cases for this lang 202 /* this is the default fallback - we have no special cases for this lang
195 * so just strip off anything after and including the _ for country region 203 * so just strip off anything after and including the _ for country region
196 * and just return the language encoding 204 * and just return the language encoding
diff --git a/src/bin/e_main.c b/src/bin/e_main.c
index c12915c..8f457a1 100644
--- a/src/bin/e_main.c
+++ b/src/bin/e_main.c
@@ -307,6 +307,13 @@ main(int argc, char **argv)
307 /* tell the error system that it can use gui dialogs now */ 307 /* tell the error system that it can use gui dialogs now */
308 e_error_gui_set(1); 308 e_error_gui_set(1);
309 309
310 /* init actions system */
311 if (!e_actions_init())
312 {
313 e_error_message_show(_("Enlightenment cannot set up its actions system."));
314 _e_main_shutdown(-1);
315 }
316 _e_main_shutdown_push(e_actions_shutdown);
310 /* init bindings system */ 317 /* init bindings system */
311 if (!e_bindings_init()) 318 if (!e_bindings_init())
312 { 319 {