summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Roberto de Souza <jose.souza@intel.com>2013-09-06 15:39:37 -0300
committerJosé Roberto de Souza <jose.souza@intel.com>2013-09-19 15:54:32 -0300
commit230c484f3f3eda8b20f365af31ebc6984359b046 (patch)
tree1542bbbd02ae18eb939328f988c342a4e8056627
parentf5687a7e32deaab6481b3dabf426c172cd7789a8 (diff)
Implementation of elm_app_server
This is disabled by default, and enabled in settings. Also there a option to automatic restore opened terminals.
-rw-r--r--configure.ac3
-rw-r--r--m4/efl_beta.m45
-rw-r--r--m4/efl_eo.m46
-rw-r--r--src/bin/Makefile.am4
-rw-r--r--src/bin/app_server.c408
-rw-r--r--src/bin/app_server.h8
-rw-r--r--src/bin/app_server_eet.c255
-rw-r--r--src/bin/app_server_eet.h41
-rw-r--r--src/bin/config.c11
-rw-r--r--src/bin/config.h2
-rw-r--r--src/bin/main.c11
-rw-r--r--src/bin/options_behavior.c72
-rw-r--r--src/bin/win.c5
13 files changed, 829 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index cc2c80b..13b259a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,9 @@ requirements="\
36 ethumb_client >= 1.7.0 \ 36 ethumb_client >= 1.7.0 \
37 " 37 "
38 38
39EFL_ENABLE_EO_API_SUPPORT
40EFL_ENABLE_BETA_API_SUPPORT
41
39PKG_CHECK_MODULES([TERMINOLOGY], [${requirements}]) 42PKG_CHECK_MODULES([TERMINOLOGY], [${requirements}])
40 43
41PKG_CHECK_MODULES([ELDBUS], 44PKG_CHECK_MODULES([ELDBUS],
diff --git a/m4/efl_beta.m4 b/m4/efl_beta.m4
new file mode 100644
index 0000000..c804729
--- /dev/null
+++ b/m4/efl_beta.m4
@@ -0,0 +1,5 @@
1dnl use: EFL_ENABLE_BETA_API_SUPPORT
2AC_DEFUN([EFL_ENABLE_BETA_API_SUPPORT],
3[
4 AC_DEFINE([EFL_BETA_API_SUPPORT], [1], [Enable access to unstable EFL API that are still in beta])
5])
diff --git a/m4/efl_eo.m4 b/m4/efl_eo.m4
new file mode 100644
index 0000000..864baf5
--- /dev/null
+++ b/m4/efl_eo.m4
@@ -0,0 +1,6 @@
1dnl use: EFL_ENABLE_EO_API_SUPPORT
2AC_DEFUN([EFL_ENABLE_EO_API_SUPPORT],
3[
4 AC_DEFINE([EFL_EO_API_SUPPORT], [1], [Enable access to unstable EFL Eo API])
5])
6
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index e95dae7..b18e440 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -42,7 +42,9 @@ utf8.c utf8.h \
42win.c win.h \ 42win.c win.h \
43utils.c utils.h \ 43utils.c utils.h \
44dbus.c dbus.h \ 44dbus.c dbus.h \
45extns.h 45extns.h \
46app_server.c app_server.h \
47app_server_eet.c app_server_eet.h
46 48
47tybg_SOURCES = \ 49tybg_SOURCES = \
48tybg.c 50tybg.c
diff --git a/src/bin/app_server.c b/src/bin/app_server.c
new file mode 100644
index 0000000..d96b08b
--- /dev/null
+++ b/src/bin/app_server.c
@@ -0,0 +1,408 @@
1#include "private.h"
2
3#include <Elementary.h>
4
5#include "main.h"
6#include "termio.h"
7#include "app_server_eet.h"
8
9static Elm_App_Server *server = NULL;
10static Eina_Bool _ignore_term_add = EINA_FALSE;
11static Terminology_Item *views_eet = NULL;
12
13static void
14_user_config_file_path_build(char *dir, unsigned int size, const char *id)
15{
16 const char *home = getenv("HOME");
17
18 if (!home)
19 home = "";
20
21 snprintf(dir, size, "%s/.terminology/", home);
22 if (!ecore_file_is_dir(dir))
23 ecore_file_mkpath(dir);
24
25 snprintf(dir, size, "%s/.terminology/%s", home, id);
26}
27
28void
29app_server_term_del(Evas_Object *term)
30{
31 Elm_App_Server_View *view;
32 const char *id;
33
34 view = evas_object_data_del(term, "app_view");
35 if (!view)
36 return;
37
38 eo_do(view, elm_app_server_view_id_get(&id));
39 terminology_item_term_entries_del(views_eet, id);
40
41 eo_del(view);
42}
43
44static Eina_Bool
45_view_closed_cb(void *data, Eo *view,
46 const Eo_Event_Description *desc EINA_UNUSED,
47 void *event_info EINA_UNUSED)
48{
49 Term *term = data;
50 const char *id;
51 char eet_dir[PATH_MAX];
52
53 if (term)
54 {
55 Evas_Object *term_object;
56
57 term_object = main_term_evas_object_get(term);
58 evas_object_data_del(term_object, "app_view");
59 main_close(main_win_evas_object_get(main_term_win_get(term)),
60 term_object);
61 }
62
63 eo_do(view, elm_app_server_view_id_get(&id));
64 terminology_item_term_entries_del(views_eet, id);
65
66 eo_del(view);
67 return EINA_TRUE;
68}
69
70static void
71_term_title_changed_cb(void *data, Evas_Object *obj,
72 void *event_info EINA_UNUSED)
73{
74 const char *title = termio_title_get(obj);
75 eo_do(data, elm_app_server_view_title_set(title));
76}
77
78static void
79_term_icon_changed_cb(void *data, Evas_Object *obj,
80 void *event_info EINA_UNUSED)
81{
82 const char *icon = termio_icon_name_get(obj);
83 eo_do(data, elm_app_server_view_icon_set(icon));
84}
85
86static Eina_Bool
87_view_save_cb(void *data, Eo *view,
88 const Eo_Event_Description *desc EINA_UNUSED,
89 void *event_info EINA_UNUSED)
90{
91 Term *term = data;
92 char dir[PATH_MAX];
93 Evas_Object *term_object;
94 const char *id;
95 Term_Item *term_eet;
96
97 term_object = main_term_evas_object_get(data);
98
99 /*
100 * if we call elm_app_server_save() in some case that the terminology
101 * will continue run, this data_del will lead to issues.
102 */
103 evas_object_data_del(term_object, "app_view");
104
105 termio_cwd_get(term_object, dir, sizeof(dir));
106 eo_do(view, elm_app_server_view_id_get(&id));
107
108 term_eet = terminology_item_term_entries_get(views_eet, id);
109 if (term_eet)
110 {
111 term_item_dir_set(term_eet, dir);
112 return EINA_TRUE;
113 }
114
115 term_eet = term_item_new(id, dir);
116 terminology_item_term_entries_add(views_eet, id, term_eet);
117
118 return EINA_TRUE;
119}
120
121static Eina_Bool
122_view_resumed_cb(void *data, Eo *view,
123 const Eo_Event_Description *desc EINA_UNUSED,
124 void *event_info EINA_UNUSED)
125{
126 Term *term = data;
127 Win *wn;
128 Eina_List **wins;
129 const char *title, *id;
130 Evas_Object *term_object;
131 const char *dir = NULL;
132 Term_Item *term_eet;
133
134 if (term)
135 {
136 main_term_focus(term);
137 return EINA_TRUE;
138 }
139
140 eo_do(server, eo_base_data_get("wins", (void **)&wins));
141 wn = eina_list_data_get(*wins);
142 if (!wn)
143 {
144 ERR("There is no window open");
145 return EINA_TRUE;
146 }
147
148 term = eina_list_data_get(main_win_terms_get(wn));
149
150 eo_do(view, elm_app_server_view_id_get(&id));
151 term_eet = terminology_item_term_entries_get(views_eet, id);
152 if (term_eet)
153 {
154 dir = term_item_dir_get(term_eet);
155 //not valid data saved
156 if (!dir || dir[0] != '/')
157 {
158 terminology_item_term_entries_del(views_eet, id);
159 dir = NULL;
160 }
161 }
162
163 _ignore_term_add = EINA_TRUE;
164 if (dir)
165 main_new_with_dir(main_win_evas_object_get(wn),
166 main_term_evas_object_get(term), dir);
167 else
168 main_new(main_win_evas_object_get(wn), main_term_evas_object_get(term));
169 _ignore_term_add = EINA_FALSE;
170
171 //just add term
172 term = eina_list_last_data_get(main_win_terms_get(wn));
173 term_object = main_term_evas_object_get(term);
174 title = termio_title_get(term_object);
175
176 evas_object_data_set(term_object, "app_view", view);
177
178 eo_do(view, elm_app_server_view_title_set(title),
179 elm_app_server_view_window_set(
180 main_win_evas_object_get(main_term_win_get(term))),
181 eo_event_callback_del(ELM_APP_SERVER_VIEW_EV_CLOSED, _view_closed_cb,
182 NULL),
183 eo_event_callback_del(ELM_APP_SERVER_VIEW_EV_RESUMED, _view_resumed_cb,
184 NULL),
185 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_CLOSED, _view_closed_cb,
186 term),
187 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_RESUMED, _view_resumed_cb,
188 term),
189 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_SAVE, _view_save_cb,
190 term));
191
192 evas_object_smart_callback_add(term_object, "title,change",
193 _term_title_changed_cb, view);
194 evas_object_smart_callback_add(term_object, "icon,change",
195 _term_icon_changed_cb, term);
196
197 return EINA_TRUE;
198}
199
200static Eina_Bool
201_server_terminate_cb(void *data, Eo *obj,
202 const Eo_Event_Description *desc EINA_UNUSED,
203 void *event_info EINA_UNUSED)
204{
205 Eina_List **wins = data, *l, *l2;
206 Win *wn;
207
208 EINA_LIST_FOREACH_SAFE(*wins, l, l2, wn)
209 evas_object_del(main_win_evas_object_get(wn));
210
211 return EINA_TRUE;
212}
213
214void
215app_server_shutdown(void)
216{
217 char lock_file[PATH_MAX];
218
219 if (!server)
220 return;
221
222 _user_config_file_path_build(lock_file, sizeof(lock_file), ".lock");
223 ecore_file_remove(lock_file);
224
225 eo_do(server, elm_app_server_save());
226
227 if (views_eet)
228 {
229 char eet_dir[PATH_MAX];
230
231 _user_config_file_path_build(eet_dir, sizeof(eet_dir), "terms.eet");
232 terminology_item_save(views_eet, eet_dir);
233
234 terminology_item_free(views_eet);
235 }
236 app_server_eet_shutdown();
237
238 eo_unref(server);
239 server = NULL;
240}
241
242void
243_app_server_win_del_request_cb(void *data, Evas_Object *obj, void *event_info)
244{
245 Eina_List **wins;
246
247 if (!server)
248 return;
249
250 eo_do(server, eo_base_data_get("wins", (void **)&wins));
251
252 if (eina_list_count(*wins) > 1)
253 return;
254
255 /*
256 * this way the terms of view are already alive
257 * and we can get pwd and backlog
258 */
259 app_server_shutdown();
260}
261
262static Elm_App_Server_View *
263_app_server_term_add(Term *term)
264{
265 Elm_App_Server_View *view;
266 const char *title;
267 Evas_Object *term_object;
268
269 if (_ignore_term_add)
270 return NULL;
271
272 view = eo_add_custom(ELM_APP_SERVER_VIEW_CLASS, server,
273 elm_app_server_view_constructor(NULL));
274
275 term_object = main_term_evas_object_get(term);
276
277 title = termio_title_get(term_object);
278
279 eo_do(view, elm_app_server_view_title_set(title),
280 elm_app_server_view_window_set(
281 main_win_evas_object_get(main_term_win_get(term))),
282 elm_app_server_view_resume(),
283 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_CLOSED,
284 _view_closed_cb, term),
285 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_RESUMED,
286 _view_resumed_cb, term),
287 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_SAVE,
288 _view_save_cb, term));
289
290 evas_object_smart_callback_add(term_object, "title,change",
291 _term_title_changed_cb, view);
292 evas_object_smart_callback_add(term_object, "icon,change",
293 _term_icon_changed_cb, term);
294 evas_object_data_set(term_object, "app_view", view);
295
296 return view;
297}
298
299void
300app_server_term_add(Term *term)
301{
302 Elm_App_Server_View *view;
303
304 if (!server)
305 return;
306
307 view = _app_server_term_add(term);
308 if (!view)
309 return;
310 eo_do(server, elm_app_server_view_add(view));
311}
312
313static Elm_App_Server_View *
314_app_server_create_view_cb(Elm_App_Server *server, const Eina_Value *args EINA_UNUSED,
315 Eina_Stringshare **error_name,
316 Eina_Stringshare **error_message EINA_UNUSED)
317{
318 Win *wn;
319 Term *term;
320 Elm_App_Server_View *view;
321 Eina_List **wins;
322
323 eo_do(server, eo_base_data_get("wins", (void **)&wins));
324 wn = eina_list_data_get(*wins);
325 if (!wn)
326 {
327 ERR("There is no window open");
328 *error_name = eina_stringshare_add("There is no window open");
329 return NULL;
330 }
331 term = eina_list_data_get(main_win_terms_get(wn));
332
333 _ignore_term_add = EINA_TRUE;
334 main_new(main_win_evas_object_get(wn), main_term_evas_object_get(term));
335 _ignore_term_add = EINA_FALSE;
336
337 //Term just added by main_new()
338 term = eina_list_last_data_get(main_win_terms_get(wn));
339
340 return _app_server_term_add(term);
341}
342
343static Eina_Bool
344_restore_view_cb(void *data)
345{
346 Elm_App_Server_View *view = data;
347 eo_do(view, elm_app_server_view_resume());
348 return EINA_FALSE;
349}
350
351void
352app_server_init(Eina_List **wins, Eina_Bool restore_views)
353{
354 Win *wn;
355 Eina_Iterator *views;
356 Elm_App_Server_View *view;
357 const char *title;
358 char lock_file[PATH_MAX], eet_dir[PATH_MAX];
359 FILE *f;
360
361 wn = eina_list_data_get(*wins);
362 if (!wn)
363 return;
364
365 //we only can have one instance of Terminology running app_server
366 _user_config_file_path_build(lock_file, sizeof(lock_file), ".lock");
367 if (ecore_file_exists(lock_file))
368 return;
369
370 //create lock file
371 f = fopen(lock_file, "w");
372 if (!f)
373 return;
374 fprintf(f, "locked");
375 fclose(f);
376
377 app_server_eet_init();
378 _user_config_file_path_build(eet_dir, sizeof(eet_dir), "terms.eet");
379 views_eet = terminology_item_load(eet_dir);
380 if (!views_eet)
381 views_eet = terminology_item_new(1);
382
383 title = elm_win_title_get(main_win_evas_object_get(wn));
384
385
386 server = eo_add_custom(ELM_APP_SERVER_CLASS, NULL,
387 elm_app_server_constructor(
388 "org.enlightenment.Terminology",
389 _app_server_create_view_cb));
390
391 eo_do(server, elm_app_server_title_set(title),
392 eo_base_data_set("wins", wins, NULL),
393 elm_app_server_views_get(&views),
394 eo_event_callback_add(ELM_APP_SERVER_EV_TERMINATE,
395 _server_terminate_cb, wins));
396 //views saved
397 EINA_ITERATOR_FOREACH(views, view)
398 {
399 if (restore_views)
400 ecore_idler_add(_restore_view_cb, view);
401 eo_do(view,
402 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_CLOSED,
403 _view_closed_cb, NULL),
404 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_RESUMED,
405 _view_resumed_cb, NULL));
406 }
407 eina_iterator_free(views);
408}
diff --git a/src/bin/app_server.h b/src/bin/app_server.h
new file mode 100644
index 0000000..44be376
--- /dev/null
+++ b/src/bin/app_server.h
@@ -0,0 +1,8 @@
1void app_server_init(Eina_List **wins);
2void app_server_shutdown(void);
3
4void app_server_term_add(Term *term);
5
6void app_server_term_del(Evas_Object *term);
7
8void _app_server_win_del_request_cb(void *data, Evas_Object *obj, void *event_info);
diff --git a/src/bin/app_server_eet.c b/src/bin/app_server_eet.c
new file mode 100644
index 0000000..0339741
--- /dev/null
+++ b/src/bin/app_server_eet.c
@@ -0,0 +1,255 @@
1/* This file has been automatically generated by geneet.py */
2/* DO NOT MODIFY */
3
4#include <limits.h>
5#include <stdio.h>
6#include <sys/stat.h>
7#include <sys/types.h>
8#include <unistd.h>
9
10#include "app_server_eet.h"
11
12struct _Term_Item {
13 const char * id;
14 const char * dir;
15};
16
17struct _Terminology_Item {
18 unsigned int version;
19 Eina_Hash * term_entries;
20 const char *__eet_filename;
21};
22
23static const char TERM_ITEM_ENTRY[] = "term_item";
24static const char TERMINOLOGY_ITEM_ENTRY[] = "terminology_item";
25
26static Eet_Data_Descriptor *_term_item_descriptor = NULL;
27static Eet_Data_Descriptor *_terminology_item_descriptor = NULL;
28
29static inline void
30_term_item_init(void)
31{
32 Eet_Data_Descriptor_Class eddc;
33
34 if (_term_item_descriptor) return;
35
36 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Term_Item);
37 _term_item_descriptor = eet_data_descriptor_stream_new(&eddc);
38
39 EET_DATA_DESCRIPTOR_ADD_BASIC(_term_item_descriptor, Term_Item, "id", id, EET_T_STRING);
40 EET_DATA_DESCRIPTOR_ADD_BASIC(_term_item_descriptor, Term_Item, "dir", dir, EET_T_STRING);
41}
42
43static inline void
44_term_item_shutdown(void)
45{
46 if (!_term_item_descriptor) return;
47 eet_data_descriptor_free(_term_item_descriptor);
48 _term_item_descriptor = NULL;
49}
50
51Term_Item *
52term_item_new(const char * id, const char * dir)
53{
54 Term_Item *term_item = calloc(1, sizeof(Term_Item));
55
56 if (!term_item)
57 {
58 fprintf(stderr, "ERROR: could not calloc Term_Item\n");
59 return NULL;
60 }
61
62 term_item->id = eina_stringshare_add(id ? id : "");
63 term_item->dir = eina_stringshare_add(dir ? dir : "/");
64
65 return term_item;
66}
67
68void
69term_item_free(Term_Item *term_item)
70{
71 eina_stringshare_del(term_item->id);
72 eina_stringshare_del(term_item->dir);
73 free(term_item);
74}
75
76inline const char *
77term_item_id_get(const Term_Item *term_item)
78{
79 return term_item->id;
80}
81
82inline void
83term_item_id_set(Term_Item *term_item, const char *id)
84{
85 EINA_SAFETY_ON_NULL_RETURN(term_item);
86 eina_stringshare_replace(&(term_item->id), id);
87}
88
89inline const char *
90term_item_dir_get(const Term_Item *term_item)
91{
92 return term_item->dir;
93}
94
95inline void
96term_item_dir_set(Term_Item *term_item, const char *dir)
97{
98 EINA_SAFETY_ON_NULL_RETURN(term_item);
99 eina_stringshare_replace(&(term_item->dir), dir);
100}
101
102
103static inline void
104_terminology_item_init(void)
105{
106 Eet_Data_Descriptor_Class eddc;
107
108 if (_terminology_item_descriptor) return;
109
110 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Terminology_Item);
111 _terminology_item_descriptor = eet_data_descriptor_stream_new(&eddc);
112
113 EET_DATA_DESCRIPTOR_ADD_BASIC(_terminology_item_descriptor, Terminology_Item, "version", version, EET_T_UINT);
114 EET_DATA_DESCRIPTOR_ADD_HASH(_terminology_item_descriptor, Terminology_Item, "term_entries", term_entries, _term_item_descriptor);
115}
116
117static inline void
118_terminology_item_shutdown(void)
119{
120 if (!_terminology_item_descriptor) return;
121 eet_data_descriptor_free(_terminology_item_descriptor);
122 _terminology_item_descriptor = NULL;
123}
124
125Terminology_Item *
126terminology_item_new(unsigned int version)
127{
128 Terminology_Item *terminology_item = calloc(1, sizeof(Terminology_Item));
129
130 if (!terminology_item)
131 {
132 fprintf(stderr, "ERROR: could not calloc Terminology_Item\n");
133 return NULL;
134 }
135
136 terminology_item->version = version;
137 terminology_item->term_entries = eina_hash_stringshared_new(EINA_FREE_CB(term_item_free));
138
139 return terminology_item;
140}
141
142void
143terminology_item_free(Terminology_Item *terminology_item)
144{
145 if (terminology_item->term_entries) eina_hash_free(terminology_item->term_entries);
146 free(terminology_item);
147}
148
149inline unsigned int
150terminology_item_version_get(const Terminology_Item *terminology_item)
151{
152 return terminology_item->version;
153}
154
155inline void
156terminology_item_version_set(Terminology_Item *terminology_item, unsigned int version)
157{
158 EINA_SAFETY_ON_NULL_RETURN(terminology_item);
159 terminology_item->version = version;
160}
161
162void
163terminology_item_term_entries_add(Terminology_Item *terminology_item, const char * id, Term_Item *term_item)
164{
165 EINA_SAFETY_ON_NULL_RETURN(terminology_item);
166 eina_hash_add(terminology_item->term_entries, id, term_item);
167}
168
169void
170terminology_item_term_entries_del(Terminology_Item *terminology_item, const char * id)
171{
172 EINA_SAFETY_ON_NULL_RETURN(terminology_item);
173 eina_hash_del(terminology_item->term_entries, id, NULL);
174}
175
176inline Term_Item *
177terminology_item_term_entries_get(const Terminology_Item *terminology_item, const char * id)
178{
179 EINA_SAFETY_ON_NULL_RETURN_VAL(terminology_item, NULL);
180 return eina_hash_find(terminology_item->term_entries, id);
181}
182
183inline Eina_Hash *
184terminology_item_term_entries_hash_get(const Terminology_Item *terminology_item)
185{
186 EINA_SAFETY_ON_NULL_RETURN_VAL(terminology_item, NULL);
187 return terminology_item->term_entries;
188}
189
190void
191terminology_item_term_entries_modify(Terminology_Item *terminology_item, const char * key, void *value)
192{
193 EINA_SAFETY_ON_NULL_RETURN(terminology_item);
194 eina_hash_modify(terminology_item->term_entries, key, value);
195}
196
197Terminology_Item *
198terminology_item_load(const char *filename)
199{
200 Terminology_Item *terminology_item = NULL;
201 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
202 if (!ef)
203 {
204 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
205 return NULL;
206 }
207
208 terminology_item = eet_data_read(ef, _terminology_item_descriptor, TERMINOLOGY_ITEM_ENTRY);
209 if (!terminology_item) goto end;
210 terminology_item->__eet_filename = eina_stringshare_add(filename);
211
212 if (!terminology_item->term_entries) terminology_item->term_entries = eina_hash_stringshared_new(EINA_FREE_CB(term_item_free));
213
214end:
215 eet_close(ef);
216 return terminology_item;
217}
218
219Eina_Bool
220terminology_item_save(Terminology_Item *terminology_item, const char *filename)
221{
222 Eet_File *ef;
223 Eina_Bool ret;
224
225 if (filename) eina_stringshare_replace(&(terminology_item->__eet_filename), filename);
226 else if (terminology_item->__eet_filename) filename = terminology_item->__eet_filename;
227 else return EINA_FALSE;
228
229 ef = eet_open(filename, EET_FILE_MODE_READ_WRITE);
230 if (!ef)
231 {
232 fprintf(stderr, "ERROR: could not open '%s' for write\n", filename);
233 return EINA_FALSE;
234 }
235
236 ret = !!eet_data_write(ef, _terminology_item_descriptor, TERMINOLOGY_ITEM_ENTRY, terminology_item, EINA_TRUE);
237 eet_close(ef);
238
239 return ret;
240}
241
242void
243app_server_eet_init(void)
244{
245 _term_item_init();
246 _terminology_item_init();
247}
248
249void
250app_server_eet_shutdown(void)
251{
252 _term_item_shutdown();
253 _terminology_item_shutdown();
254}
255
diff --git a/src/bin/app_server_eet.h b/src/bin/app_server_eet.h
new file mode 100644
index 0000000..3809caa
--- /dev/null
+++ b/src/bin/app_server_eet.h
@@ -0,0 +1,41 @@
1/* This file has been automatically generated by geneet.py */
2/* DO NOT MODIFY */
3
4#ifndef __TERMINOLOGY_EET_H__
5#define __TERMINOLOGY_EET_H__
6
7#include <Eina.h>
8#include <Eet.h>
9
10typedef struct _Term_Item Term_Item;
11typedef struct _Terminology_Item Terminology_Item;
12
13/* Term_Item */
14Term_Item *term_item_new(const char * id, const char * dir);
15void term_item_free(Term_Item *term_item);
16
17void term_item_id_set(Term_Item *term_item, const char * id);
18const char * term_item_id_get(const Term_Item *term_item);
19void term_item_dir_set(Term_Item *term_item, const char * dir);
20const char * term_item_dir_get(const Term_Item *term_item);
21
22/* Terminology_Item */
23Terminology_Item *terminology_item_new(unsigned int version);
24void terminology_item_free(Terminology_Item *terminology_item);
25
26void terminology_item_version_set(Terminology_Item *terminology_item, unsigned int version);
27unsigned int terminology_item_version_get(const Terminology_Item *terminology_item);
28void terminology_item_term_entries_add(Terminology_Item *terminology_item, const char * id, Term_Item *term_item);
29void terminology_item_term_entries_del(Terminology_Item *terminology_item, const char * id);
30Term_Item *terminology_item_term_entries_get(const Terminology_Item *terminology_item, const char * key);
31Eina_Hash *terminology_item_term_entries_hash_get(const Terminology_Item *terminology_item);
32void terminology_item_term_entries_modify(Terminology_Item *terminology_item, const char * key, void *value);
33
34Terminology_Item *terminology_item_load(const char *filename);
35Eina_Bool terminology_item_save(Terminology_Item *terminology_item, const char *filename);
36
37/* Global initializer / shutdown functions */
38void app_server_eet_init(void);
39void app_server_eet_shutdown(void);
40
41#endif /* __TERMINOLOGY_EET_H__ */
diff --git a/src/bin/config.c b/src/bin/config.c
index 2244120..34a9e0d 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -91,6 +91,11 @@ config_init(void)
91 (edd_base, Config, "cg_height", cg_height, EET_T_INT); 91 (edd_base, Config, "cg_height", cg_height, EET_T_INT);
92 EET_DATA_DESCRIPTOR_ADD_BASIC 92 EET_DATA_DESCRIPTOR_ADD_BASIC
93 (edd_base, Config, "drag_links", drag_links, EET_T_UCHAR); 93 (edd_base, Config, "drag_links", drag_links, EET_T_UCHAR);
94 EET_DATA_DESCRIPTOR_ADD_BASIC
95 (edd_base, Config, "application_server", application_server, EET_T_UCHAR);
96 EET_DATA_DESCRIPTOR_ADD_BASIC
97 (edd_base, Config, "application_server_restore_views",
98 application_server_restore_views, EET_T_UCHAR);
94} 99}
95 100
96void 101void
@@ -169,6 +174,8 @@ config_sync(const Config *config_src, Config *config)
169 config->mute = config_src->mute; 174 config->mute = config_src->mute;
170 config->urg_bell = config_src->urg_bell; 175 config->urg_bell = config_src->urg_bell;
171 config->multi_instance = config_src->multi_instance; 176 config->multi_instance = config_src->multi_instance;
177 config->application_server = config_src->application_server;
178 config->application_server_restore_views = config_src->application_server_restore_views;
172 config->temporary = config_src->temporary; 179 config->temporary = config_src->temporary;
173 config->custom_geometry = config_src->custom_geometry; 180 config->custom_geometry = config_src->custom_geometry;
174 config->cg_width = config_src->cg_width; 181 config->cg_width = config_src->cg_width;
@@ -425,6 +432,8 @@ config_load(const char *key)
425 config->mute = EINA_FALSE; 432 config->mute = EINA_FALSE;
426 config->urg_bell = EINA_TRUE; 433 config->urg_bell = EINA_TRUE;
427 config->multi_instance = EINA_FALSE; 434 config->multi_instance = EINA_FALSE;
435 config->application_server = EINA_FALSE;
436 config->application_server_restore_views = EINA_FALSE;
428 config->custom_geometry = EINA_FALSE; 437 config->custom_geometry = EINA_FALSE;
429 config->cg_width = 80; 438 config->cg_width = 80;
430 config->cg_height = 24; 439 config->cg_height = 24;
@@ -473,6 +482,8 @@ config_fork(Config *config)
473 CPY(mute); 482 CPY(mute);
474 CPY(urg_bell); 483 CPY(urg_bell);
475 CPY(multi_instance); 484 CPY(multi_instance);
485 CPY(application_server);
486 CPY(application_server_restore_views);
476 CPY(custom_geometry); 487 CPY(custom_geometry);
477 CPY(cg_width); 488 CPY(cg_width);
478 CPY(cg_height); 489 CPY(cg_height);
diff --git a/src/bin/config.h b/src/bin/config.h
index a40b207..78446f5 100644
--- a/src/bin/config.h
+++ b/src/bin/config.h
@@ -40,6 +40,8 @@ struct _Config
40 Eina_Bool mute; 40 Eina_Bool mute;
41 Eina_Bool urg_bell; 41 Eina_Bool urg_bell;
42 Eina_Bool multi_instance; 42 Eina_Bool multi_instance;
43 Eina_Bool application_server;
44 Eina_Bool application_server_restore_views;
43 Eina_Bool custom_geometry; 45 Eina_Bool custom_geometry;
44 Eina_Bool drag_links; 46 Eina_Bool drag_links;
45 int cg_width; 47 int cg_width;
diff --git a/src/bin/main.c b/src/bin/main.c
index fa65df3..625f286 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -592,6 +592,8 @@ main_close(Evas_Object *win, Evas_Object *term)
592 Eina_List *l; 592 Eina_List *l;
593 const char *slot = PANES_TOP; 593 const char *slot = PANES_TOP;
594 594
595 app_server_term_del(term);
596
595 if (!sp) return; 597 if (!sp) return;
596 if (!sp->term) return; 598 if (!sp->term) return;
597 if (sp->sel) _sel_restore(sp); 599 if (sp->sel) _sel_restore(sp);
@@ -2194,6 +2196,7 @@ main_term_new(Win *wn, Config *config, const char *cmd,
2194// edje_object_signal_emit(term->base, "focus,in", "terminology"); 2196// edje_object_signal_emit(term->base, "focus,in", "terminology");
2195 } 2197 }
2196 wn->terms = eina_list_append(wn->terms, term); 2198 wn->terms = eina_list_append(wn->terms, term);
2199 app_server_term_add(term);
2197 2200
2198 return term; 2201 return term;
2199} 2202}
@@ -2935,6 +2938,10 @@ remote:
2935 } 2938 }
2936 2939
2937 config = config_fork(config); 2940 config = config_fork(config);
2941
2942 if (config->application_server)
2943 app_server_init(&wins, config->application_server_restore_views);
2944
2938 term = main_term_new(wn, config, cmd, login_shell, cd, 2945 term = main_term_new(wn, config, cmd, login_shell, cd,
2939 size_w, size_h, hold); 2946 size_w, size_h, hold);
2940 if (!term) 2947 if (!term)
@@ -2947,7 +2954,7 @@ remote:
2947 edje_object_part_swallow(wn->base, "terminology.content", term->bg); 2954 edje_object_part_swallow(wn->base, "terminology.content", term->bg);
2948 _cb_size_hint(term, evas_object_evas_get(wn->win), term->term, NULL); 2955 _cb_size_hint(term, evas_object_evas_get(wn->win), term->term, NULL);
2949 } 2956 }
2950 2957
2951 sp = wn->split = calloc(1, sizeof(Split)); 2958 sp = wn->split = calloc(1, sizeof(Split));
2952 sp->wn = wn; 2959 sp->wn = wn;
2953 sp->term = term; 2960 sp->term = term;
@@ -2976,6 +2983,8 @@ remote:
2976 2983
2977 elm_run(); 2984 elm_run();
2978 2985
2986 app_server_shutdown();
2987
2979 ty_dbus_shutdown(); 2988 ty_dbus_shutdown();
2980 end: 2989 end:
2981#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8) 2990#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
diff --git a/src/bin/options_behavior.c b/src/bin/options_behavior.c
index 00ebcd9..47b39d0 100644
--- a/src/bin/options_behavior.c
+++ b/src/bin/options_behavior.c
@@ -86,6 +86,64 @@ _cb_op_behavior_multi_instance_chg(void *data, Evas_Object *obj, void *event EIN
86} 86}
87 87
88static void 88static void
89_cb_op_behavior_application_server_restore_views_chg(void *data, Evas_Object *obj,
90 void *event EINA_UNUSED)
91{
92 Evas_Object *term = data;
93 Config *config = termio_config_get(term);
94 config->application_server_restore_views = elm_check_state_get(obj);
95 config_save(config, NULL);
96}
97
98static void
99_behavior_option_restore_opened_views_add(Evas_Object *term,
100 Evas_Object *check)
101{
102 Evas_Object *bx = evas_object_data_get(check, "box");
103 Evas_Object *o;
104 Config *config = termio_config_get(term);
105
106 o = elm_check_add(bx);
107 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
108 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
109 elm_object_text_set(o, "Restore opened views");
110 elm_check_state_set(o, config->application_server_restore_views);
111 elm_box_pack_after(bx, o, check);
112 evas_object_show(o);
113 evas_object_data_set(check, "restore_views", o);
114 evas_object_smart_callback_add(o, "changed",
115 _cb_op_behavior_application_server_restore_views_chg,
116 term);
117}
118
119
120static void
121_behavior_option_restore_opened_views_del(Evas_Object *check)
122{
123 Evas_Object *o = evas_object_data_del(check, "restore_views");
124 if (o)
125 evas_object_del(o);
126}
127
128static void
129_cb_op_behavior_application_server_chg(void *data, Evas_Object *obj, void *event EINA_UNUSED)
130{
131 Evas_Object *term = data;
132 Config *config = termio_config_get(term);
133 Eina_Bool old = config->application_server;
134 config->application_server = elm_check_state_get(obj);
135
136 if (old == config->application_server)
137 return;
138
139 if (!config->application_server)
140 _behavior_option_restore_opened_views_del(obj);
141 else
142 _behavior_option_restore_opened_views_add(term, obj);
143 config_save(config, NULL);
144}
145
146static void
89_cb_op_behavior_wsep_chg(void *data, Evas_Object *obj, void *event EINA_UNUSED) 147_cb_op_behavior_wsep_chg(void *data, Evas_Object *obj, void *event EINA_UNUSED)
90{ 148{
91 Evas_Object *term = data; 149 Evas_Object *term = data;
@@ -267,6 +325,20 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
267 o = elm_check_add(bx); 325 o = elm_check_add(bx);
268 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); 326 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
269 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5); 327 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
328 elm_object_text_set(o, "Enable application server");
329 elm_check_state_set(o, config->application_server);
330 elm_box_pack_end(bx, o);
331 evas_object_show(o);
332 evas_object_smart_callback_add(o, "changed",
333 _cb_op_behavior_application_server_chg, term);
334
335 evas_object_data_set(o, "box", bx);
336 if (config->application_server)
337 _behavior_option_restore_opened_views_add(term, o);
338
339 o = elm_check_add(bx);
340 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
341 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
270 elm_object_text_set(o, "Multiple instances, one process"); 342 elm_object_text_set(o, "Multiple instances, one process");
271 elm_check_state_set(o, config->multi_instance); 343 elm_check_state_set(o, config->multi_instance);
272 elm_box_pack_end(bx, o); 344 elm_box_pack_end(bx, o);
diff --git a/src/bin/win.c b/src/bin/win.c
index f5ca624..51c2e3c 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -1,6 +1,8 @@
1#include <Elementary.h> 1#include <Elementary.h>
2#include "win.h" 2#include "win.h"
3#include "config.h" 3#include "config.h"
4#include "main.h"
5#include "app_server.h"
4 6
5Evas_Object * 7Evas_Object *
6tg_win_add(const char *name, const char *role, const char *title, const char *icon_name) 8tg_win_add(const char *name, const char *role, const char *title, const char *icon_name)
@@ -17,6 +19,9 @@ tg_win_add(const char *name, const char *role, const char *title, const char *ic
17 elm_win_icon_name_set(win, icon_name); 19 elm_win_icon_name_set(win, icon_name);
18 if (role) elm_win_role_set(win, role); 20 if (role) elm_win_role_set(win, role);
19 21
22 evas_object_smart_callback_add(win, "delete,request",
23 _app_server_win_del_request_cb, win);
24
20 elm_win_autodel_set(win, EINA_TRUE); 25 elm_win_autodel_set(win, EINA_TRUE);
21 26
22 o = evas_object_image_add(evas_object_evas_get(win)); 27 o = evas_object_image_add(evas_object_evas_get(win));