summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2013-09-21 15:41:23 +0200
committerBoris Faure <billiob@gmail.com>2013-09-21 15:46:01 +0200
commit6430b0c494009bf421b97f0293838836f4fbfe18 (patch)
treef7e1814eff42dd1ee38c82222bc1a3b61e2e19ab
parent230c484f3f3eda8b20f365af31ebc6984359b046 (diff)
cleanup app-server codeā€¦
* should make terminology compile with efl 1.7 * add header guards * fix prototypes * remove unused variables * add some EINA_UNUSED * prefix global variables with _ and some shadow potential issues * functions starting with _ should be static I didn't have a look at the meaning of the code.
-rw-r--r--src/bin/app_server.c61
-rw-r--r--src/bin/app_server.h11
-rw-r--r--src/bin/main.c1
-rw-r--r--src/bin/win.c2
4 files changed, 48 insertions, 27 deletions
diff --git a/src/bin/app_server.c b/src/bin/app_server.c
index d96b08b..17bba43 100644
--- a/src/bin/app_server.c
+++ b/src/bin/app_server.c
@@ -6,7 +6,9 @@
6#include "termio.h" 6#include "termio.h"
7#include "app_server_eet.h" 7#include "app_server_eet.h"
8 8
9static Elm_App_Server *server = NULL; 9#if (ELM_VERSION_MAJOR > 1) || (ELM_VERSION_MINOR >= 8)
10
11static Elm_App_Server *_server = NULL;
10static Eina_Bool _ignore_term_add = EINA_FALSE; 12static Eina_Bool _ignore_term_add = EINA_FALSE;
11static Terminology_Item *views_eet = NULL; 13static Terminology_Item *views_eet = NULL;
12 14
@@ -48,7 +50,6 @@ _view_closed_cb(void *data, Eo *view,
48{ 50{
49 Term *term = data; 51 Term *term = data;
50 const char *id; 52 const char *id;
51 char eet_dir[PATH_MAX];
52 53
53 if (term) 54 if (term)
54 { 55 {
@@ -84,11 +85,11 @@ _term_icon_changed_cb(void *data, Evas_Object *obj,
84} 85}
85 86
86static Eina_Bool 87static Eina_Bool
87_view_save_cb(void *data, Eo *view, 88_view_save_cb(void *data EINA_UNUSED,
89 Eo *view,
88 const Eo_Event_Description *desc EINA_UNUSED, 90 const Eo_Event_Description *desc EINA_UNUSED,
89 void *event_info EINA_UNUSED) 91 void *event_info EINA_UNUSED)
90{ 92{
91 Term *term = data;
92 char dir[PATH_MAX]; 93 char dir[PATH_MAX];
93 Evas_Object *term_object; 94 Evas_Object *term_object;
94 const char *id; 95 const char *id;
@@ -137,7 +138,7 @@ _view_resumed_cb(void *data, Eo *view,
137 return EINA_TRUE; 138 return EINA_TRUE;
138 } 139 }
139 140
140 eo_do(server, eo_base_data_get("wins", (void **)&wins)); 141 eo_do(_server, eo_base_data_get("wins", (void **)&wins));
141 wn = eina_list_data_get(*wins); 142 wn = eina_list_data_get(*wins);
142 if (!wn) 143 if (!wn)
143 { 144 {
@@ -198,7 +199,7 @@ _view_resumed_cb(void *data, Eo *view,
198} 199}
199 200
200static Eina_Bool 201static Eina_Bool
201_server_terminate_cb(void *data, Eo *obj, 202_server_terminate_cb(void *data, Eo *obj EINA_UNUSED,
202 const Eo_Event_Description *desc EINA_UNUSED, 203 const Eo_Event_Description *desc EINA_UNUSED,
203 void *event_info EINA_UNUSED) 204 void *event_info EINA_UNUSED)
204{ 205{
@@ -216,13 +217,13 @@ app_server_shutdown(void)
216{ 217{
217 char lock_file[PATH_MAX]; 218 char lock_file[PATH_MAX];
218 219
219 if (!server) 220 if (!_server)
220 return; 221 return;
221 222
222 _user_config_file_path_build(lock_file, sizeof(lock_file), ".lock"); 223 _user_config_file_path_build(lock_file, sizeof(lock_file), ".lock");
223 ecore_file_remove(lock_file); 224 ecore_file_remove(lock_file);
224 225
225 eo_do(server, elm_app_server_save()); 226 eo_do(_server, elm_app_server_save());
226 227
227 if (views_eet) 228 if (views_eet)
228 { 229 {
@@ -235,19 +236,21 @@ app_server_shutdown(void)
235 } 236 }
236 app_server_eet_shutdown(); 237 app_server_eet_shutdown();
237 238
238 eo_unref(server); 239 eo_unref(_server);
239 server = NULL; 240 _server = NULL;
240} 241}
241 242
242void 243void
243_app_server_win_del_request_cb(void *data, Evas_Object *obj, void *event_info) 244app_server_win_del_request_cb(void *data EINA_UNUSED,
245 Evas_Object *obj EINA_UNUSED,
246 void *event_info EINA_UNUSED)
244{ 247{
245 Eina_List **wins; 248 Eina_List **wins;
246 249
247 if (!server) 250 if (!_server)
248 return; 251 return;
249 252
250 eo_do(server, eo_base_data_get("wins", (void **)&wins)); 253 eo_do(_server, eo_base_data_get("wins", (void **)&wins));
251 254
252 if (eina_list_count(*wins) > 1) 255 if (eina_list_count(*wins) > 1)
253 return; 256 return;
@@ -269,7 +272,7 @@ _app_server_term_add(Term *term)
269 if (_ignore_term_add) 272 if (_ignore_term_add)
270 return NULL; 273 return NULL;
271 274
272 view = eo_add_custom(ELM_APP_SERVER_VIEW_CLASS, server, 275 view = eo_add_custom(ELM_APP_SERVER_VIEW_CLASS, _server,
273 elm_app_server_view_constructor(NULL)); 276 elm_app_server_view_constructor(NULL));
274 277
275 term_object = main_term_evas_object_get(term); 278 term_object = main_term_evas_object_get(term);
@@ -301,13 +304,14 @@ app_server_term_add(Term *term)
301{ 304{
302 Elm_App_Server_View *view; 305 Elm_App_Server_View *view;
303 306
304 if (!server) 307 if (!_server)
305 return; 308 return;
306 309
307 view = _app_server_term_add(term); 310 view = _app_server_term_add(term);
308 if (!view) 311 if (!view)
309 return; 312 return;
310 eo_do(server, elm_app_server_view_add(view)); 313
314 eo_do(_server, elm_app_server_view_add(view));
311} 315}
312 316
313static Elm_App_Server_View * 317static Elm_App_Server_View *
@@ -317,7 +321,6 @@ _app_server_create_view_cb(Elm_App_Server *server, const Eina_Value *args EINA_U
317{ 321{
318 Win *wn; 322 Win *wn;
319 Term *term; 323 Term *term;
320 Elm_App_Server_View *view;
321 Eina_List **wins; 324 Eina_List **wins;
322 325
323 eo_do(server, eo_base_data_get("wins", (void **)&wins)); 326 eo_do(server, eo_base_data_get("wins", (void **)&wins));
@@ -383,12 +386,12 @@ app_server_init(Eina_List **wins, Eina_Bool restore_views)
383 title = elm_win_title_get(main_win_evas_object_get(wn)); 386 title = elm_win_title_get(main_win_evas_object_get(wn));
384 387
385 388
386 server = eo_add_custom(ELM_APP_SERVER_CLASS, NULL, 389 _server = eo_add_custom(ELM_APP_SERVER_CLASS, NULL,
387 elm_app_server_constructor( 390 elm_app_server_constructor(
388 "org.enlightenment.Terminology", 391 "org.enlightenment.Terminology",
389 _app_server_create_view_cb)); 392 _app_server_create_view_cb));
390 393
391 eo_do(server, elm_app_server_title_set(title), 394 eo_do(_server, elm_app_server_title_set(title),
392 eo_base_data_set("wins", wins, NULL), 395 eo_base_data_set("wins", wins, NULL),
393 elm_app_server_views_get(&views), 396 elm_app_server_views_get(&views),
394 eo_event_callback_add(ELM_APP_SERVER_EV_TERMINATE, 397 eo_event_callback_add(ELM_APP_SERVER_EV_TERMINATE,
@@ -406,3 +409,17 @@ app_server_init(Eina_List **wins, Eina_Bool restore_views)
406 } 409 }
407 eina_iterator_free(views); 410 eina_iterator_free(views);
408} 411}
412
413
414#else
415
416void app_server_init(Eina_List **wins EINA_UNUSED,
417 Eina_Bool restore_views EINA_UNUSED) {}
418void app_server_shutdown(void) {}
419void app_server_term_add(Term *term EINA_UNUSED) {}
420void app_server_term_del(Evas_Object *term EINA_UNUSED) {}
421void app_server_win_del_request_cb(void *data EINA_UNUSED,
422 Evas_Object *obj EINA_UNUSED,
423 void *event_info EINA_UNUSED) {}
424
425#endif
diff --git a/src/bin/app_server.h b/src/bin/app_server.h
index 44be376..8b36851 100644
--- a/src/bin/app_server.h
+++ b/src/bin/app_server.h
@@ -1,8 +1,11 @@
1void app_server_init(Eina_List **wins); 1#ifndef _APP_SERVER_H__
2void app_server_shutdown(void); 2#define _APP_SERVER_H__ 1
3 3
4void app_server_term_add(Term *term);
5 4
5void app_server_init(Eina_List **wins, Eina_Bool restore_views);
6void app_server_shutdown(void);
7void app_server_term_add(Term *term);
6void app_server_term_del(Evas_Object *term); 8void app_server_term_del(Evas_Object *term);
9void app_server_win_del_request_cb(void *data, Evas_Object *obj, void *event_info);
7 10
8void _app_server_win_del_request_cb(void *data, Evas_Object *obj, void *event_info); 11#endif
diff --git a/src/bin/main.c b/src/bin/main.c
index 625f286..b530cdf 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -14,6 +14,7 @@
14#include "ipc.h" 14#include "ipc.h"
15#include "sel.h" 15#include "sel.h"
16#include "dbus.h" 16#include "dbus.h"
17#include "app_server.h"
17 18
18#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8) 19#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8)
19 #define PANES_TOP "left" 20 #define PANES_TOP "left"
diff --git a/src/bin/win.c b/src/bin/win.c
index 51c2e3c..8657769 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -20,7 +20,7 @@ tg_win_add(const char *name, const char *role, const char *title, const char *ic
20 if (role) elm_win_role_set(win, role); 20 if (role) elm_win_role_set(win, role);
21 21
22 evas_object_smart_callback_add(win, "delete,request", 22 evas_object_smart_callback_add(win, "delete,request",
23 _app_server_win_del_request_cb, win); 23 app_server_win_del_request_cb, win);
24 24
25 elm_win_autodel_set(win, EINA_TRUE); 25 elm_win_autodel_set(win, EINA_TRUE);
26 26