summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-10-02 11:53:56 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-10-19 13:59:12 +0300
commit9b06641f17da00a3243684babf4db5d42257cb39 (patch)
tree177f50366ea2590ac2228426c86debfb972f0fa5
parent7b2c20a358a59bbf305e5cfbf0abe02d2f312659 (diff)
Callbacks: move cb view code to cbview.c
Functions common to cbview and other prop view have moved to props_helper.
-rw-r--r--src/bin/egui_gui/cbview.c507
-rw-r--r--src/bin/egui_gui/cbview.h7
-rw-r--r--src/bin/egui_gui/props_helper.c75
-rw-r--r--src/bin/egui_gui/props_helper.h17
-rw-r--r--src/bin/egui_gui/propview.c512
5 files changed, 611 insertions, 507 deletions
diff --git a/src/bin/egui_gui/cbview.c b/src/bin/egui_gui/cbview.c
index 4918823..8e4871e 100644
--- a/src/bin/egui_gui/cbview.c
+++ b/src/bin/egui_gui/cbview.c
@@ -1,11 +1,514 @@
1 1
2#include <Elementary.h> 2#include <Elementary.h>
3#include <Eolian.h>
3 4
5#include "ffi_glue.h"
6#include "egui_log.h"
7#include "props_helper.h"
8#include "egui_logic_private.h"
9#include "propview_data.h"
10#include "cbview.h"
4 11
12#include "elm_widget_container.h"
13
14static Elm_Genlist_Item_Class *_itc_cb = NULL;
5static Elm_Genlist_Item_Class *_itc_class = NULL; 15static Elm_Genlist_Item_Class *_itc_class = NULL;
16static Eo *cb_list = NULL;
17static Eo *propview_table = NULL;
18
19/* Hash table to keep the list of expanded classes */
20static Eina_Hash *expanded_classes = NULL;
21
22static void
23_callback_item_box_reassign(It_Data *it_data, Eo *box);
24
25static void
26_select_callback_item(Dep_Id *cb_dep_id)
27{
28 Elm_Object_Item *it = elm_genlist_first_item_get(cb_list);
29 for (; it; it = elm_genlist_item_next_get(it))
30 {
31 if (elm_genlist_item_item_class_get(it) != _itc_cb)
32 continue;
33
34 It_Data *it_data = elm_object_item_data_get(it);
35 if (cb_dep_id_get(it_data->cb) == cb_dep_id)
36 {
37 /* In case of Undo/Redo can happen, that Callback in Dep_data was changed,
38 * but It_Data still holds the old one. So need to change CB in It_Data and update the box. */
39 if (it_data->cb != cb_get(cb_dep_id))
40 {
41 it_data->cb = cb_get(cb_dep_id);
42 _callback_item_box_reassign(it_data, it_data->box);
43 }
44 elm_genlist_item_selected_set(it, EINA_TRUE);
45 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
46 break;
47 }
48 }
49}
50
51void
52cbview_item_selected_set(Dep_Id *cb_dep_id)
53{
54 _select_callback_item(cb_dep_id);
55}
56
57static Eina_Bool
58_cb_sequence_modify(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
59{
60 It_Data *it_data = data;
61 Gui_Widget_Callback *cb_old = it_data->cb, *new_cb;
62 Gui_Widget *wdg = (Gui_Widget *) it_data->wdg;
63 Gui_Context *ctx = (Gui_Context *) wdg_context_get(wdg);
64 Dep_Id *prevseq = cb_sequence_id_get(cb_old);
65 const char *seq_name = elm_object_item_part_text_get(event_info, NULL);
66 Dep_Id *new_seq_id = gui_context_dep_id_by_name_get(_active_context_get(), seq_name);
67 if (prevseq == new_seq_id) return EO_CALLBACK_CONTINUE;
68 elm_object_text_set(obj, seq_name);
69
70 Gui_Memento *memento;
71 /* if !prevseq - cb is default field, so there is no real callback behind, so create new. */
72 if (!prevseq)
73 {
74 new_cb = cb_new_full(ctx, cb_type_get(cb_old), new_seq_id);
75 Callback_Container *cc_new = NULL, *cc_old = NULL;
76 cc_old = (Callback_Container *) wdg_cb_container_get(wdg);
77 if (!cc_old)
78 {
79 cc_new = cb_container_new();
80 }
81 else
82 {
83 cc_new = cb_container_copy(cc_old);
84 }
85 /* Add callback to container. */
86 cb_container_cb_add(cc_new, new_cb);
87 /* Save containers into memento*/
88 memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK_ADD_DEL, cc_old, cc_new);
89 /* Unset old container from widget */
90 wdg_cb_container_unset(wdg);
91 wdg_cb_container_set(wdg, cc_new);
92 }
93 else
94 {
95 /* When changing existing callback need to copy old one, in order to have the same old Dep_Id. */
96 new_cb = cb_copy(cb_old);
97 cb_modify(new_cb, cb_type_get(new_cb), new_seq_id);
98 memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK, cb_old, new_cb);
99 Dep_Data *dep_data = gui_context_dep_data_get(cb_dep_id_get(new_cb));
100 dep_data_cb_set(dep_data, new_cb);
101 }
102 gui_context_memento_add(ctx, memento);
103 Egui_Layout_Widgets *g = egui_layout_gui_get();
104 elm_object_item_disabled_set(g->main_win->toolbar_redo_it, EINA_TRUE);
105 elm_object_item_disabled_set(g->main_win->toolbar_undo_it, EINA_FALSE);
106
107 cbview_build(it_data->wdg);
108 _select_callback_item(cb_dep_id_get(new_cb));
109
110 return EO_CALLBACK_CONTINUE;
111}
112
113static Evas_Object *
114_callback_item_content_get(It_Data *it_data)
115{
116 Eo *box = eo_add(ELM_BOX_CLASS, propview_table);
117 eo_do(box, evas_obj_visibility_set(EINA_TRUE),
118 elm_obj_box_horizontal_set(EINA_TRUE),
119 elm_obj_box_padding_set(5, 0),
120 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0),
121 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 0)
122 );
123
124 it_data->box = box;
125
126 Gui_Widget_Callback *cb = it_data->cb;
127
128 Eo *label = props_label_add(box, cb_type_get(cb));
129 eo_do(label, evas_obj_size_hint_align_set(0, 0.5));
130 eo_do(label, evas_obj_size_hint_weight_set(1, 0));
131
132 Dep_Id *dep_id = cb_sequence_id_get(cb);
133 const char *default_str = NULL;
134 if (dep_id)
135
136 default_str = dep_name_get(dep_id);
137 Eo *seqs_list = props_hoversel_seqs_add(box, elm_widget_top_get(propview_table), wdg_context_get(it_data->wdg), default_str, EINA_FALSE);
138
139 eo_do(seqs_list, evas_obj_size_hint_align_set(1, 0));
140 eo_do(seqs_list, evas_obj_size_hint_weight_set(1, 0));
141 eo_do(seqs_list, eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED,
142 _cb_sequence_modify, it_data));
143
144 /* Add callbacks from resources. */
145 Eina_List *res_lst = (Eina_List *) gui_context_resource_list_get(wdg_context_get(it_data->wdg), RESOURCE_EO_CALLBACK);
146 Eina_List *itr;
147 Dep_Id *res_id;
148 EINA_LIST_FOREACH(res_lst, itr, res_id)
149 {
150 const Gui_Resource *res = gui_context_resource_get(res_id);
151 if (res) elm_hoversel_item_add(seqs_list, resource_name_get(res), NULL, ELM_ICON_NONE, NULL, NULL);
152 }
153
154 return box;
155}
156
157static void
158_callback_item_box_reassign(It_Data *it_data, Eo *box)
159{
160 Dep_Id *res_id, *seq_id;
161 const Eina_List *itr, *list;
162
163 it_data->box = box;
164 const Gui_Context *ctx = wdg_context_get(it_data->wdg);
165
166 Eina_List *contents = elm_box_children_get(box);
167
168 Eo *label = eina_list_nth(contents, 0);
169 Eo *seqs_list = eina_list_nth(contents, 1);
170
171 eo_do(label, elm_obj_widget_part_text_set(NULL, cb_type_get(it_data->cb)));
172
173 eo_do(seqs_list, eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED,
174 _cb_sequence_modify, it_data));
175
176 eo_do(seqs_list, elm_obj_hoversel_clear());
177
178 list = gui_context_seq_list_get(ctx);
179 EINA_LIST_FOREACH(list, itr, seq_id)
180 {
181 Gui_Sequence *seq = sequence_get(seq_id);
182 if (seq) eo_do(seqs_list, elm_obj_hoversel_item_add(sequence_name_get(seq), NULL, ELM_ICON_NONE, NULL, NULL));
183 }
184
185 list = gui_context_resource_list_get(ctx, RESOURCE_EO_CALLBACK);
186 EINA_LIST_FOREACH(list, itr, res_id)
187 {
188 const Gui_Resource *res = gui_context_resource_get(res_id);
189 if (res) eo_do(seqs_list, elm_obj_hoversel_item_add(resource_name_get(res), NULL, ELM_ICON_NONE, NULL, NULL));
190 }
191
192 Dep_Id *seqid = cb_sequence_id_get(it_data->cb);
193 const char *txt = (seqid) ? dep_name_get(seqid) : PROP_HOVERSEL_NONE_VALUE;
194
195 eo_do(seqs_list, elm_obj_widget_part_text_set(NULL, txt));
196
197 eina_list_free(contents);
198}
199
200static void
201_callbacks_classname_table_expand(const Gui_Widget *wdg, const char *classname, Elm_Object_Item *parent)
202{
203 const Eolian_Class *class = eolian_class_get_by_name(classname);
204 Eina_Iterator *events = eolian_class_events_get(class);
205 Eolian_Event *event;
206
207 const char *filter = _filter_string_get();
208
209 EINA_ITERATOR_FOREACH(events, event)
210 {
211 const char *event_name = eolian_event_name_get(event);
212
213 // If filter is on and no match, dont add to property list
214 if (filter && !_str_nocase_prefix(event_name, filter))
215 continue;
216
217 Eina_List *wgdcbs = wdg_cb_list_get(wdg);
218 Eina_List *items = NULL;
219 Eina_List *l = NULL;
220 Gui_Widget_Callback *cb;
221
222 Dep_Id *dep_id;
223 EINA_LIST_FOREACH(wgdcbs, l, dep_id)
224 {
225 cb = cb_get(dep_id);
226 if (!strcmp(event_name, cb_type_get(cb)))
227 items = eina_list_append(items, cb);
228 }
229
230 cb = cb_new(event_name, 0);
231 items = eina_list_append(items, cb);
232
233 EINA_LIST_FOREACH(items, l, cb)
234 {
235 It_Data *it_data = IT_DATA_BUILD(CALLBACK_TYPE, wdg);
236 cb_ref(cb);
237 it_data->cb = cb;
238 elm_genlist_item_append(cb_list, _itc_cb, it_data, parent,
239 ELM_GENLIST_ITEM_NONE, NULL, NULL);
240 }
241 eina_list_free(items);
242 }
243 eina_iterator_free(events);
244}
245
246static void
247_callbacks_expanded_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
248{
249 Elm_Object_Item *glit = event_info;
250 Classname_Data *cl = elm_object_item_data_get(glit);
251 eina_hash_set(expanded_classes, cl->classname, (void *)1);
252 _callbacks_classname_table_expand(cl->wdg, cl->classname, glit);
253}
254
255static void
256_callbacks_contracted_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
257{
258 Elm_Object_Item *glit = event_info;
259 Classname_Data *cl = elm_object_item_data_get(glit);
260 eina_hash_del_by_key(expanded_classes, cl->classname);
261 elm_genlist_item_subitems_clear(glit);
262}
263
264static void
265_callbacks_item_del(void *data, Evas_Object *obj EINA_UNUSED)
266{
267 It_Data *it_data = data;
268 cb_unref(it_data->cb);
269
270 // Make box cache ready. Remove the callback event.
271 Eina_List *contents = elm_box_children_get(it_data->box);
272 Eo *hoversel = eina_list_nth(contents, 1);
273 eo_do(hoversel, eo_event_callback_del(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED,
274 _cb_sequence_modify, it_data));
275 eina_list_free(contents);
276
277 _mempool_cache_data_put(CACHE_CALLBACKS, it_data->box);
278 _it_data_free(it_data);
279}
280
281static Evas_Object *
282_callbacks_item_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
283{
284 It_Data *it_data = data;
285
286 // Genlist can call content get without calling delete first
287 // so in that case just return what it already has.
288 if (it_data->box) return it_data->box;
289
290 Dep_Id *dep_id = cb_sequence_id_get(it_data->cb);
291
292 Eo *it_box = _mempool_cache_data_get(CACHE_CALLBACKS);
293
294 if (it_box)
295 {
296 _callback_item_box_reassign(it_data, it_box);
297 }
298 else
299 {
300 it_box = _callback_item_content_get(it_data);
301 eo_ref(it_box);
302 }
303
304 if (dep_id)
305 eo_do(it_box, evas_obj_color_set(255, 255, 255, 255));
306 else
307 eo_do(it_box, evas_obj_color_set(150, 150, 150, 255));
308
309 return it_box;
310}
311
312void
313cbview_build(const Gui_Widget *wdg)
314{
315 eo_do(cb_list, elm_obj_genlist_clear());
316
317 Eina_List *classes = eo_class_mro_get(wdg_class_name_get(wdg));
318 const char *classname;
319 Elm_Object_Item *glit = NULL;
320
321 const char *filter = _filter_string_get();
322
323 EINA_LIST_FREE(classes, classname)
324 {
325 const Eolian_Class *class = eolian_class_get_by_name(classname);
326 Eina_Iterator *events = eolian_class_events_get(class);
327 if (events)
328 {
329 if (filter)
330 {
331 _callbacks_classname_table_expand(wdg, classname, NULL);
332 }
333 else
334 {
335 Classname_Data *cl = calloc(1, sizeof(Classname_Data));
336 cl->classname = strdup(classname);
337 cl->wdg = wdg;
338 glit = elm_genlist_item_append(cb_list, _itc_class, cl,
339 NULL, ELM_GENLIST_ITEM_TREE, NULL,
340 NULL);
341 if (eina_hash_find(expanded_classes, classname))
342 elm_genlist_item_expanded_set(glit, EINA_TRUE);
343 }
344 }
345 eina_iterator_free(events);
346 }
347 //if filter search found nothing, yield an appropriate message to callbacks list
348 if (filter && !elm_genlist_items_count(cb_list))
349 elm_genlist_item_append(cb_list, _itc_class, NULL, NULL,
350 ELM_GENLIST_ITEM_NONE, NULL, NULL);
351}
352
353static void
354_expand_request_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
355{
356 Elm_Object_Item *glit = event_info;
357 Classname_Data *cl = elm_object_item_data_get(glit);
358 eina_hash_set(expanded_classes, cl->classname, (void *)1);
359 elm_genlist_item_expanded_set(glit, EINA_TRUE);
360}
361
362static void
363_contract_request_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
364{
365 Elm_Object_Item *glit = event_info;
366 Classname_Data *cl = elm_object_item_data_get(glit);
367 eina_hash_del_by_key(expanded_classes, cl->classname);
368 elm_genlist_item_expanded_set(glit, EINA_FALSE);
369}
370
371static void
372_selected_callback_move(int dir)
373{
374 Elm_Object_Item *sel = elm_genlist_selected_item_get(cb_list);
375 if ((sel) && (elm_genlist_item_item_class_get(sel) == _itc_cb))
376 {
377 It_Data *it_data = elm_object_item_data_get(sel);
378 if (cb_sequence_id_get(it_data->cb))
379 {
380 Callback_Container *cc_new = NULL, *cc_old = NULL;
381 Gui_Widget_Callback *cb = it_data->cb;
382 const Gui_Widget *wdg = it_data->wdg;
383 cc_old = (Callback_Container *) wdg_cb_container_get(wdg);
384 cc_new = cb_container_copy(cc_old);
385 if (cb_container_cb_move(cc_new, cb, dir))
386 {
387 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK_ADD_DEL, cc_old, cc_new);
388 gui_context_memento_add((Gui_Context *) wdg_context_get(wdg), memento);
389
390 wdg_cb_container_unset((Gui_Widget *) wdg);
391 wdg_cb_container_set((Gui_Widget *) wdg, cc_new);
392
393 Egui_Layout_Widgets *g = egui_layout_gui_get();
394 elm_object_item_disabled_set(g->main_win->toolbar_redo_it, EINA_TRUE);
395 elm_object_item_disabled_set(g->main_win->toolbar_undo_it, EINA_FALSE);
396
397 cbview_build(wdg);
398 _select_callback_item(cb_dep_id_get(cb));
399 }
400 /* If nothing wasn't move, delete Callback_Container */
401 else
402 {
403 cb_container_ref(cc_new);
404 cb_container_unref(cc_new);
405 }
406 }
407 }
408}
409
410Eina_Bool
411_callbacksview_up_btn_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
412{
413 _selected_callback_move(-1);
414 return EO_CALLBACK_CONTINUE;
415}
416
417Eina_Bool
418_callbacksview_down_btn_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
419{
420 _selected_callback_move(1);
421 return EO_CALLBACK_CONTINUE;
422}
423
424Eina_Bool
425_callbacksview_del_btn_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
426{
427 Elm_Object_Item *sel = elm_genlist_selected_item_get(cb_list);
428 if ((sel) && (elm_genlist_item_item_class_get(sel) == _itc_cb))
429 {
430 It_Data *it_data = elm_object_item_data_get(sel);
431 if (cb_sequence_id_get(it_data->cb))
432 {
433 const Gui_Widget *wdg = it_data->wdg;
434 Callback_Container *cc_new = NULL, *cc_old = NULL;
435 cc_old = (Callback_Container *) wdg_cb_container_get(wdg);
436 cc_new = cb_container_copy(cc_old);
437
438 cb_container_cb_remove(cc_new, it_data->cb);
439 elm_object_item_del(sel);
440
441 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK_ADD_DEL, cc_old, cc_new);
442 gui_context_memento_add((Gui_Context *) wdg_context_get(wdg), memento);
443
444 wdg_cb_container_unset((Gui_Widget *) wdg);
445 wdg_cb_container_set((Gui_Widget *) wdg, cc_new);
446
447 Egui_Layout_Widgets *g = egui_layout_gui_get();
448 elm_object_item_disabled_set(g->main_win->toolbar_redo_it, EINA_TRUE);
449 elm_object_item_disabled_set(g->main_win->toolbar_undo_it, EINA_FALSE);
450 }
451 }
452 return EO_CALLBACK_CONTINUE;
453}
454
455static char *
456_class_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
457{
458 Classname_Data *cl = data;
459 if (cl) return strdup(cl->classname);
460 else return strdup("No search results");
461}
462
463static void
464_class_item_del(void *data, Evas_Object *obj EINA_UNUSED)
465{
466 Classname_Data *cl = data;
467 free(cl->classname);
468 free(cl);
469}
6 470
7void 471void
8cbview_init(Elm_Genlist_Item_Class *itc_class) 472cbview_init()
9{ 473{
10 _itc_class = itc_class; 474 Egui_Layout_Widgets *g = egui_layout_gui_get();
475 if (!_itc_class)
476 {
477 _itc_class = elm_genlist_item_class_new();
478 _itc_class->item_style = "default";
479 _itc_class->func.text_get = _class_item_label_get;
480 _itc_class->func.del = _class_item_del;
481 }
482 if (!_itc_cb)
483 {
484 _itc_cb = elm_genlist_item_class_new();
485 _itc_cb->item_style = "full";
486 _itc_cb->func.content_get = _callbacks_item_content_get;
487 _itc_cb->func.del = _callbacks_item_del;
488 }
489 cb_list = g->main_win->callbacksview_list;
490 propview_table = g->main_win->propsview_table;
491
492 evas_object_smart_callback_add(cb_list, "expand,request", _expand_request_cb, NULL);
493 evas_object_smart_callback_add(cb_list, "contract,request", _contract_request_cb, NULL);
494 evas_object_smart_callback_add(cb_list, "expanded", _callbacks_expanded_cb, NULL);
495 evas_object_smart_callback_add(cb_list, "contracted", _callbacks_contracted_cb, NULL);
496
497 expanded_classes = eina_hash_string_superfast_new(NULL);
11} 498}
499
500void
501cbview_shutdown()
502{
503 eo_do(cb_list, elm_obj_genlist_clear());
504 cb_list = NULL;
505
506 elm_genlist_item_class_free(_itc_cb);
507 _itc_cb = NULL;
508
509 elm_genlist_item_class_free(_itc_class);
510 _itc_class = NULL;
511
512 eina_hash_free(expanded_classes);
513}
514
diff --git a/src/bin/egui_gui/cbview.h b/src/bin/egui_gui/cbview.h
index 29ab41f..ce1594a 100644
--- a/src/bin/egui_gui/cbview.h
+++ b/src/bin/egui_gui/cbview.h
@@ -3,7 +3,12 @@
3#define _CBVIEW_H 3#define _CBVIEW_H
4 4
5void 5void
6cbview_init(Elm_Genlist_Item_Class *itc_class); 6cbview_init(void);
7 7
8void
9cbview_build(const Gui_Widget *wdg);
10
11void
12cbview_shutdown(void);
8 13
9#endif 14#endif
diff --git a/src/bin/egui_gui/props_helper.c b/src/bin/egui_gui/props_helper.c
index c0a3a92..2a7c029 100644
--- a/src/bin/egui_gui/props_helper.c
+++ b/src/bin/egui_gui/props_helper.c
@@ -5,10 +5,85 @@
5#include "props_helper.h" 5#include "props_helper.h"
6#include "egui_log.h" 6#include "egui_log.h"
7#include "database.h" 7#include "database.h"
8#include "egui_logic_private.h"
9
10static Eina_Hash *mempool_cache = NULL;
8 11
9extern Gui_Context * 12extern Gui_Context *
10_active_context_get(); 13_active_context_get();
11 14
15const char*
16_filter_string_get()
17{
18 Egui_Layout_Widgets *g = egui_layout_gui_get();
19 const char *str = elm_entry_entry_get(g->main_win->propsview_filter_entry);
20 //Trim from left
21 while (*str == ' ') str++;
22
23 return strlen(str) ? str : NULL;
24}
25
26// Case insensitive test for a prefix in a string
27Eina_Bool
28_str_nocase_prefix(const char *str, const char *prefix)
29{
30 if (!(str && prefix)) return EINA_FALSE;
31
32 while (*prefix)
33 {
34 if ((*str == '\0') ||
35 (tolower(*prefix) != tolower(*str)))
36 return EINA_FALSE;
37 prefix++;
38 str++;
39 }
40 return EINA_TRUE;
41}
42
43void
44_mempool_hash_del(void* data)
45{
46 Eo* obj = NULL;
47 Eina_List *list = data;
48 EINA_LIST_FREE(list, obj)
49 eo_unref(obj);
50}
51
52void
53_mempool_cache_init()
54{
55 mempool_cache = eina_hash_string_superfast_new(_mempool_hash_del);
56}
57
58void
59_mempool_cache_free()
60{
61 if (mempool_cache) eina_hash_free(mempool_cache);
62}
63
64void*
65_mempool_cache_data_get(const char *key)
66{
67 Eina_List *l = eina_hash_find(mempool_cache, key);
68
69 if (!l) return NULL;
70
71 void *ptr = eina_list_data_get(l);
72 l = eina_list_remove_list(l, l);
73 eina_hash_set(mempool_cache, key, l);
74
75 return ptr;
76}
77
78void
79_mempool_cache_data_put(const char *key, void *ptr)
80{
81 Eina_List *l = eina_hash_find(mempool_cache, key);
82
83 l = eina_list_append(l, ptr);
84 eina_hash_set(mempool_cache, key, l);
85}
86
12/* Wrapper to add entry to property item. 87/* Wrapper to add entry to property item.
13 * Receives initial string and data for propertie's edit field 88 * Receives initial string and data for propertie's edit field
14 * (wdg, op, par idx). */ 89 * (wdg, op, par idx). */
diff --git a/src/bin/egui_gui/props_helper.h b/src/bin/egui_gui/props_helper.h
index 635938f..a840993 100644
--- a/src/bin/egui_gui/props_helper.h
+++ b/src/bin/egui_gui/props_helper.h
@@ -35,4 +35,21 @@ props_hoversel_resource_files_add(Eo *box, Eo *hoversel, Eo *hover_parent, const
35 35
36Eo * 36Eo *
37props_value_add(Eo *box, const Gui_Context *ctx, const Gui_Widget *wdg, const Gui_Value *value, const Op_Desc *op, unsigned int par_idx); 37props_value_add(Eo *box, const Gui_Context *ctx, const Gui_Widget *wdg, const Gui_Value *value, const Op_Desc *op, unsigned int par_idx);
38
39const char*
40_filter_string_get();
41
42Eina_Bool
43_str_nocase_prefix(const char *str, const char *prefix);
44
45void
46_mempool_hash_del(void* data);
47void
48_mempool_cache_init();
49void
50_mempool_cache_free();
51void*
52_mempool_cache_data_get(const char *key);
53void
54_mempool_cache_data_put(const char *key, void *ptr);
38#endif 55#endif
diff --git a/src/bin/egui_gui/propview.c b/src/bin/egui_gui/propview.c
index 10392ab..bf16953 100644
--- a/src/bin/egui_gui/propview.c
+++ b/src/bin/egui_gui/propview.c
@@ -7,19 +7,18 @@
7#include "propview.h" 7#include "propview.h"
8#include "itemview.h" 8#include "itemview.h"
9#include "egui_logic_private.h" 9#include "egui_logic_private.h"
10#include "cbview.h"
10 11
11#include "elm_widget_container.h" 12#include "elm_widget_container.h"
12 13
13static Elm_Genlist_Item_Class *_itc_class = NULL; 14static Elm_Genlist_Item_Class *_itc_class = NULL;
14static Elm_Genlist_Item_Class *_itc_prop = NULL; 15static Elm_Genlist_Item_Class *_itc_prop = NULL;
15static Elm_Genlist_Item_Class *_itc_notfound = NULL; 16static Elm_Genlist_Item_Class *_itc_notfound = NULL;
16static Elm_Genlist_Item_Class *_itc_cb = NULL;
17static Elm_Genlist_Item_Class *_itc_desc = NULL; 17static Elm_Genlist_Item_Class *_itc_desc = NULL;
18static Elm_Genlist_Item_Class *_itc_ctn = NULL; 18static Elm_Genlist_Item_Class *_itc_ctn = NULL;
19 19
20static Eo *propview_table = NULL; 20static Eo *propview_table = NULL;
21static Eo *prop_list = NULL; 21static Eo *prop_list = NULL;
22static Eo *cb_list = NULL;
23static Eo *desc_list = NULL; 22static Eo *desc_list = NULL;
24static Eo *ctn_list = NULL; 23static Eo *ctn_list = NULL;
25 24
@@ -62,52 +61,6 @@ static Eina_Hash *op_item_table = NULL;
62/* Hash table to keep the list of expanded classes */ 61/* Hash table to keep the list of expanded classes */
63static Eina_Hash *expanded_classes = NULL; 62static Eina_Hash *expanded_classes = NULL;
64 63
65static Eina_Hash *mempool_cache = NULL;
66
67static void
68_mempool_hash_del(void* data)
69{
70 Eo* obj = NULL;
71 Eina_List *list = data;
72 EINA_LIST_FREE(list, obj)
73 eo_unref(obj);
74}
75
76static void
77_mempool_cache_init()
78{
79 mempool_cache = eina_hash_string_superfast_new(_mempool_hash_del);
80}
81
82static void
83_mempool_cache_free()
84{
85 if (mempool_cache) eina_hash_free(mempool_cache);
86}
87
88static void*
89_mempool_cache_data_get(const char *key)
90{
91 Eina_List *l = eina_hash_find(mempool_cache, key);
92
93 if (!l) return NULL;
94
95 void *ptr = eina_list_data_get(l);
96 l = eina_list_remove_list(l, l);
97 eina_hash_set(mempool_cache, key, l);
98
99 return ptr;
100}
101
102static void
103_mempool_cache_data_put(const char *key, void *ptr)
104{
105 Eina_List *l = eina_hash_find(mempool_cache, key);
106
107 l = eina_list_append(l, ptr);
108 eina_hash_set(mempool_cache, key, l);
109}
110
111static Evas_Object * 64static Evas_Object *
112_item_content_get(It_Data *it_data); 65_item_content_get(It_Data *it_data);
113 66
@@ -255,175 +208,6 @@ _property_item_content_get(It_Data *it_data)
255 return EINA_TRUE; 208 return EINA_TRUE;
256} 209}
257 210
258static void
259_callback_item_box_reassign(It_Data *it_data, Eo *box);
260
261static void
262_select_callback_item(Dep_Id *cb_dep_id)
263{
264 Elm_Object_Item *it = elm_genlist_first_item_get(cb_list);
265 for (; it; it = elm_genlist_item_next_get(it))
266 {
267 if (elm_genlist_item_item_class_get(it) != _itc_cb)
268 continue;
269
270 It_Data *it_data = elm_object_item_data_get(it);
271 if (cb_dep_id_get(it_data->cb) == cb_dep_id)
272 {
273 /* In case of Undo/Redo can happen, that Callback in Dep_data was changed,
274 * but It_Data still holds the old one. So need to change CB in It_Data and update the box. */
275 if (it_data->cb != cb_get(cb_dep_id))
276 {
277 it_data->cb = cb_get(cb_dep_id);
278 _callback_item_box_reassign(it_data, it_data->box);
279 }
280 elm_genlist_item_selected_set(it, EINA_TRUE);
281 elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
282 break;
283 }
284 }
285}
286
287void
288cbview_item_selected_set(Dep_Id *cb_dep_id)
289{
290 _select_callback_item(cb_dep_id);
291}
292
293static Eina_Bool
294_cb_sequence_modify(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
295{
296 It_Data *it_data = data;
297 Gui_Widget_Callback *cb_old = it_data->cb, *new_cb;
298 Gui_Widget *wdg = (Gui_Widget *) it_data->wdg;
299 Gui_Context *ctx = (Gui_Context *) wdg_context_get(wdg);
300 Dep_Id *prevseq = cb_sequence_id_get(cb_old);
301 const char *seq_name = elm_object_item_part_text_get(event_info, NULL);
302 Dep_Id *new_seq_id = gui_context_dep_id_by_name_get(_active_context_get(), seq_name);
303 if (prevseq == new_seq_id) return EO_CALLBACK_CONTINUE;
304 elm_object_text_set(obj, seq_name);
305
306 Gui_Memento *memento;
307 /* if !prevseq - cb is default field, so there is no real callback behind, so create new. */
308 if (!prevseq)
309 {
310 new_cb = cb_new_full(ctx, cb_type_get(cb_old), new_seq_id);
311 Callback_Container *cc_new = NULL, *cc_old = NULL;
312 cc_old = (Callback_Container *) wdg_cb_container_get(wdg);
313 if (!cc_old)
314 {
315 cc_new = cb_container_new();
316 }
317 else
318 {
319 cc_new = cb_container_copy(cc_old);
320 }
321 /* Add callback to container. */
322 cb_container_cb_add(cc_new, new_cb);
323 /* Save containers into memento*/
324 memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK_ADD_DEL, cc_old, cc_new);
325 /* Unset old container from widget */
326 wdg_cb_container_unset(wdg);
327 wdg_cb_container_set(wdg, cc_new);
328 }
329 else
330 {
331 /* When changing existing callback need to copy old one, in order to have the same old Dep_Id. */
332 new_cb = cb_copy(cb_old);
333 cb_modify(new_cb, cb_type_get(new_cb), new_seq_id);
334 memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK, cb_old, new_cb);
335 Dep_Data *dep_data = gui_context_dep_data_get(cb_dep_id_get(new_cb));
336 dep_data_cb_set(dep_data, new_cb);
337 }
338 gui_context_memento_add(ctx, memento);
339 Egui_Layout_Widgets *g = egui_layout_gui_get();
340 elm_object_item_disabled_set(g->main_win->toolbar_redo_it, EINA_TRUE);
341 elm_object_item_disabled_set(g->main_win->toolbar_undo_it, EINA_FALSE);
342
343 propview_build(it_data->wdg);
344 _select_callback_item(cb_dep_id_get(new_cb));
345
346 return EO_CALLBACK_CONTINUE;
347}
348
349static Eina_Bool
350_callback_item_content_get(It_Data *it_data)
351{
352 Eo *box = it_data->box;
353 Gui_Widget_Callback *cb = it_data->cb;
354
355 Eo *label = props_label_add(box, cb_type_get(cb));
356 eo_do(label, evas_obj_size_hint_align_set(0, 0.5));
357 eo_do(label, evas_obj_size_hint_weight_set(1, 0));
358
359 Dep_Id *dep_id = cb_sequence_id_get(cb);
360 const char *default_str = NULL;
361 if (dep_id)
362
363 default_str = dep_name_get(dep_id);
364 Eo *seqs_list = props_hoversel_seqs_add(box, elm_widget_top_get(propview_table), wdg_context_get(it_data->wdg), default_str, EINA_FALSE);
365
366 eo_do(seqs_list, evas_obj_size_hint_align_set(1, 0));
367 eo_do(seqs_list, evas_obj_size_hint_weight_set(1, 0));
368 eo_do(seqs_list, eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED,
369 _cb_sequence_modify, it_data));
370
371 /* Add callbacks from resources. */
372 Eina_List *res_lst = (Eina_List *) gui_context_resource_list_get(wdg_context_get(it_data->wdg), RESOURCE_EO_CALLBACK);
373 Eina_List *itr;
374 Dep_Id *res_id;
375 EINA_LIST_FOREACH(res_lst, itr, res_id)
376 {
377 const Gui_Resource *res = gui_context_resource_get(res_id);
378 if (res) elm_hoversel_item_add(seqs_list, resource_name_get(res), NULL, ELM_ICON_NONE, NULL, NULL);
379 }
380
381 return EINA_TRUE;
382}
383
384static void
385_callback_item_box_reassign(It_Data *it_data, Eo *box)
386{
387 Dep_Id *res_id, *seq_id;
388 const Eina_List *itr, *list;
389
390 it_data->box = box;
391 const Gui_Context *ctx = wdg_context_get(it_data->wdg);
392
393 Eina_List *contents = elm_box_children_get(box);
394
395 Eo *label = eina_list_nth(contents, 0);
396 Eo *seqs_list = eina_list_nth(contents, 1);
397
398 eo_do(label, elm_obj_widget_part_text_set(NULL, cb_type_get(it_data->cb)));
399
400 eo_do(seqs_list, eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED,
401 _cb_sequence_modify, it_data));
402
403 eo_do(seqs_list, elm_obj_hoversel_clear());
404
405 list = gui_context_seq_list_get(ctx);
406 EINA_LIST_FOREACH(list, itr, seq_id)
407 {
408 Gui_Sequence *seq = sequence_get(seq_id);
409 if (seq) eo_do(seqs_list, elm_obj_hoversel_item_add(sequence_name_get(seq), NULL, ELM_ICON_NONE, NULL, NULL));
410 }
411
412 list = gui_context_resource_list_get(ctx, RESOURCE_EO_CALLBACK);
413 EINA_LIST_FOREACH(list, itr, res_id)
414 {
415 const Gui_Resource *res = gui_context_resource_get(res_id);
416 if (res) eo_do(seqs_list, elm_obj_hoversel_item_add(resource_name_get(res), NULL, ELM_ICON_NONE, NULL, NULL));
417 }
418
419 Dep_Id *seqid = cb_sequence_id_get(it_data->cb);
420 const char *txt = (seqid) ? dep_name_get(seqid) : PROP_HOVERSEL_NONE_VALUE;
421
422 eo_do(seqs_list, elm_obj_widget_part_text_set(NULL, txt));
423
424 eina_list_free(contents);
425}
426
427static Eina_Bool 211static Eina_Bool
428_wdg_public_change_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 212_wdg_public_change_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
429{ 213{
@@ -603,9 +387,6 @@ _item_content_get(It_Data *it_data)
603 case PROPERTY_TYPE: 387 case PROPERTY_TYPE:
604 _property_item_content_get(it_data); 388 _property_item_content_get(it_data);
605 break; 389 break;
606 case CALLBACK_TYPE:
607 _callback_item_content_get(it_data);
608 break;
609 case DESCRIPTION_TYPE: 390 case DESCRIPTION_TYPE:
610 _description_item_content_get(it_data); 391 _description_item_content_get(it_data);
611 break; 392 break;
@@ -615,6 +396,8 @@ _item_content_get(It_Data *it_data)
615 case CONTENT_TYPE: 396 case CONTENT_TYPE:
616 _content_item_content_get(it_data); 397 _content_item_content_get(it_data);
617 break; 398 break;
399 default:
400 break;
618 } 401 }
619 402
620 return box; 403 return box;
@@ -626,34 +409,6 @@ PropViewCbs *propview_cbs_get()
626 return _view_cbs; 409 return _view_cbs;
627} 410}
628 411
629static const char*
630_filter_string_get()
631{
632 Egui_Layout_Widgets *g = egui_layout_gui_get();
633 const char *str = elm_entry_entry_get(g->main_win->propsview_filter_entry);
634 //Trim from left
635 while (*str == ' ') str++;
636
637 return strlen(str) ? str : NULL;
638}
639
640// Case insensitive test for a prefix in a string
641static Eina_Bool
642_str_nocase_prefix(const char *str, const char *prefix)
643{
644 if (!(str && prefix)) return EINA_FALSE;
645
646 while (*prefix)
647 {
648 if ((*str == '\0') ||
649 (tolower(*prefix) != tolower(*str)))
650 return EINA_FALSE;
651 prefix++;
652 str++;
653 }
654 return EINA_TRUE;
655}
656
657static char * 412static char *
658_class_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) 413_class_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
659{ 414{
@@ -1089,157 +844,6 @@ _description_build(const Gui_Widget *wdg)
1089 } 844 }
1090} 845}
1091 846
1092static void
1093_callbacks_classname_table_expand(const Gui_Widget *wdg, const char *classname, Elm_Object_Item *parent)
1094{
1095 const Eolian_Class *class = eolian_class_get_by_name(classname);
1096 Eina_Iterator *events = eolian_class_events_get(class);
1097 Eolian_Event *event;
1098
1099 const char *filter = _filter_string_get();
1100
1101 EINA_ITERATOR_FOREACH(events, event)
1102 {
1103 const char *event_name = eolian_event_name_get(event);
1104
1105 // If filter is on and no match, dont add to property list
1106 if (filter && !_str_nocase_prefix(event_name, filter))
1107 continue;
1108
1109 Eina_List *wgdcbs = wdg_cb_list_get(wdg);
1110 Eina_List *items = NULL;
1111 Eina_List *l = NULL;
1112 Gui_Widget_Callback *cb;
1113
1114 Dep_Id *dep_id;
1115 EINA_LIST_FOREACH(wgdcbs, l, dep_id)
1116 {
1117 cb = cb_get(dep_id);
1118 if (!strcmp(event_name, cb_type_get(cb)))
1119 items = eina_list_append(items, cb);
1120 }
1121
1122 cb = cb_new(event_name, 0);
1123 items = eina_list_append(items, cb);
1124
1125 EINA_LIST_FOREACH(items, l, cb)
1126 {
1127 It_Data *it_data = IT_DATA_BUILD(CALLBACK_TYPE, wdg);
1128 cb_ref(cb);
1129 it_data->cb = cb;
1130 elm_genlist_item_append(cb_list, _itc_cb, it_data, parent,
1131 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1132 }
1133 eina_list_free(items);
1134 }
1135 eina_iterator_free(events);
1136}
1137
1138static void
1139_callbacks_expanded_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
1140{
1141 Elm_Object_Item *glit = event_info;
1142 Classname_Data *cl = elm_object_item_data_get(glit);
1143 eina_hash_set(expanded_classes, cl->classname, (void *)1);
1144 _callbacks_classname_table_expand(cl->wdg, cl->classname, glit);
1145}
1146
1147static void
1148_callbacks_contracted_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
1149{
1150 Elm_Object_Item *glit = event_info;
1151 Classname_Data *cl = elm_object_item_data_get(glit);
1152 eina_hash_del_by_key(expanded_classes, cl->classname);
1153 elm_genlist_item_subitems_clear(glit);
1154}
1155
1156static void
1157_callbacks_item_del(void *data, Evas_Object *obj EINA_UNUSED)
1158{
1159 It_Data *it_data = data;
1160 cb_unref(it_data->cb);
1161
1162 // Make box cache ready. Remove the callback event.
1163 Eina_List *contents = elm_box_children_get(it_data->box);
1164 Eo *hoversel = eina_list_nth(contents, 1);
1165 eo_do(hoversel, eo_event_callback_del(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED,
1166 _cb_sequence_modify, it_data));
1167 eina_list_free(contents);
1168
1169 _mempool_cache_data_put(CACHE_CALLBACKS, it_data->box);
1170 _it_data_free(it_data);
1171}
1172
1173static Evas_Object *
1174_callbacks_item_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
1175{
1176 It_Data *it_data = data;
1177
1178 // Genlist can call content get without calling delete first
1179 // so in that case just return what it already has.
1180 if (it_data->box) return it_data->box;
1181
1182 Dep_Id *dep_id = cb_sequence_id_get(it_data->cb);
1183
1184 Eo *it_box = _mempool_cache_data_get(CACHE_CALLBACKS);
1185
1186 if (it_box)
1187 {
1188 _callback_item_box_reassign(it_data, it_box);
1189 }
1190 else
1191 {
1192 it_box = _item_content_get(it_data);
1193 eo_ref(it_box);
1194 }
1195
1196 if (dep_id)
1197 eo_do(it_box, evas_obj_color_set(255, 255, 255, 255));
1198 else
1199 eo_do(it_box, evas_obj_color_set(150, 150, 150, 255));
1200
1201 return it_box;
1202}
1203
1204static void
1205_callbacks_build(const Gui_Widget *wdg)
1206{
1207 Eina_List *classes = eo_class_mro_get(wdg_class_name_get(wdg));
1208 const char *classname;
1209 Elm_Object_Item *glit = NULL;
1210
1211 const char *filter = _filter_string_get();
1212
1213 EINA_LIST_FREE(classes, classname)
1214 {
1215 const Eolian_Class *class = eolian_class_get_by_name(classname);
1216 Eina_Iterator *events = eolian_class_events_get(class);
1217 if (events)
1218 {
1219 if (filter)
1220 {
1221 _callbacks_classname_table_expand(wdg, classname, NULL);
1222 }
1223 else
1224 {
1225 Classname_Data *cl = calloc(1, sizeof(Classname_Data));
1226 cl->classname = strdup(classname);
1227 cl->wdg = wdg;
1228 glit = elm_genlist_item_append(cb_list, _itc_class, cl,
1229 NULL, ELM_GENLIST_ITEM_TREE, NULL,
1230 NULL);
1231 if (eina_hash_find(expanded_classes, classname))
1232 elm_genlist_item_expanded_set(glit, EINA_TRUE);
1233 }
1234 }
1235 eina_iterator_free(events);
1236 }
1237 //if filter search found nothing, yield an appropriate message to callbacks list
1238 if (filter && !elm_genlist_items_count(cb_list))
1239 elm_genlist_item_append(cb_list, _itc_notfound, NULL, NULL,
1240 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1241}
1242
1243/* This callback is called in the end of propview_build() 847/* This callback is called in the end of propview_build()
1244 * in order to switch between scrollbox for properties 848 * in order to switch between scrollbox for properties
1245 * and genlist for items. */ 849 * and genlist for items. */
@@ -1337,7 +941,6 @@ propview_build(const Gui_Widget *wdg)
1337{ 941{
1338 It_Data_Type type = _new_type; 942 It_Data_Type type = _new_type;
1339 943
1340 eo_do(cb_list, elm_obj_genlist_clear());
1341 eo_do(desc_list, elm_obj_genlist_clear()); 944 eo_do(desc_list, elm_obj_genlist_clear());
1342 eo_do(prop_list, elm_obj_genlist_clear()); 945 eo_do(prop_list, elm_obj_genlist_clear());
1343 eo_do(ctn_list, elm_obj_genlist_clear()); 946 eo_do(ctn_list, elm_obj_genlist_clear());
@@ -1379,7 +982,7 @@ propview_build(const Gui_Widget *wdg)
1379 } 982 }
1380 case CALLBACK_TYPE: 983 case CALLBACK_TYPE:
1381 { 984 {
1382 _callbacks_build(wdg); 985 cbview_build(wdg);
1383 break; 986 break;
1384 } 987 }
1385 case CONTENT_TYPE: 988 case CONTENT_TYPE:
@@ -1518,90 +1121,6 @@ _propview_filter_entry_changed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_
1518 return EO_CALLBACK_CONTINUE; 1121 return EO_CALLBACK_CONTINUE;
1519} 1122}
1520 1123
1521static void
1522_selected_callback_move(int dir)
1523{
1524 Elm_Object_Item *sel = elm_genlist_selected_item_get(cb_list);
1525 if ((sel) && (elm_genlist_item_item_class_get(sel) == _itc_cb))
1526 {
1527 It_Data *it_data = elm_object_item_data_get(sel);
1528 if (cb_sequence_id_get(it_data->cb))
1529 {
1530 Callback_Container *cc_new = NULL, *cc_old = NULL;
1531 Gui_Widget_Callback *cb = it_data->cb;
1532 const Gui_Widget *wdg = it_data->wdg;
1533 cc_old = (Callback_Container *) wdg_cb_container_get(wdg);
1534 cc_new = cb_container_copy(cc_old);
1535 if (cb_container_cb_move(cc_new, cb, dir))
1536 {
1537 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK_ADD_DEL, cc_old, cc_new);
1538 gui_context_memento_add((Gui_Context *) wdg_context_get(wdg), memento);
1539
1540 wdg_cb_container_unset((Gui_Widget *) wdg);
1541 wdg_cb_container_set((Gui_Widget *) wdg, cc_new);
1542
1543 Egui_Layout_Widgets *g = egui_layout_gui_get();
1544 elm_object_item_disabled_set(g->main_win->toolbar_redo_it, EINA_TRUE);
1545 elm_object_item_disabled_set(g->main_win->toolbar_undo_it, EINA_FALSE);
1546
1547 propview_build(wdg);
1548 _select_callback_item(cb_dep_id_get(cb));
1549 }
1550 /* If nothing wasn't move, delete Callback_Container */
1551 else
1552 {
1553 cb_container_ref(cc_new);
1554 cb_container_unref(cc_new);
1555 }
1556 }
1557 }
1558}
1559
1560Eina_Bool
1561_callbacksview_up_btn_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
1562{
1563 _selected_callback_move(-1);
1564 return EO_CALLBACK_CONTINUE;
1565}
1566
1567Eina_Bool
1568_callbacksview_down_btn_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
1569{
1570 _selected_callback_move(1);
1571 return EO_CALLBACK_CONTINUE;
1572}
1573
1574Eina_Bool
1575_callbacksview_del_btn_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
1576{
1577 Elm_Object_Item *sel = elm_genlist_selected_item_get(cb_list);
1578 if ((sel) && (elm_genlist_item_item_class_get(sel) == _itc_cb))
1579 {
1580 It_Data *it_data = elm_object_item_data_get(sel);
1581 if (cb_sequence_id_get(it_data->cb))
1582 {
1583 const Gui_Widget *wdg = it_data->wdg;
1584 Callback_Container *cc_new = NULL, *cc_old = NULL;
1585 cc_old = (Callback_Container *) wdg_cb_container_get(wdg);
1586 cc_new = cb_container_copy(cc_old);
1587
1588 cb_container_cb_remove(cc_new, it_data->cb);
1589 elm_object_item_del(sel);
1590
1591 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_CALLBACK_ADD_DEL, cc_old, cc_new);
1592 gui_context_memento_add((Gui_Context *) wdg_context_get(wdg), memento);
1593
1594 wdg_cb_container_unset((Gui_Widget *) wdg);
1595 wdg_cb_container_set((Gui_Widget *) wdg, cc_new);
1596
1597 Egui_Layout_Widgets *g = egui_layout_gui_get();
1598 elm_object_item_disabled_set(g->main_win->toolbar_redo_it, EINA_TRUE);
1599 elm_object_item_disabled_set(g->main_win->toolbar_undo_it, EINA_FALSE);
1600 }
1601 }
1602 return EO_CALLBACK_CONTINUE;
1603}
1604
1605void 1124void
1606propview_init() 1125propview_init()
1607{ 1126{
@@ -1628,14 +1147,6 @@ propview_init()
1628 _itc_notfound->func.text_get = _notfound_item_text_get; 1147 _itc_notfound->func.text_get = _notfound_item_text_get;
1629 } 1148 }
1630 1149
1631 if (!_itc_cb)
1632 {
1633 _itc_cb = elm_genlist_item_class_new();
1634 _itc_cb->item_style = "full";
1635 _itc_cb->func.content_get = _callbacks_item_content_get;
1636 _itc_cb->func.del = _callbacks_item_del;
1637 }
1638
1639 if (!_itc_desc) 1150 if (!_itc_desc)
1640 { 1151 {
1641 _itc_desc = elm_genlist_item_class_new(); 1152 _itc_desc = elm_genlist_item_class_new();
@@ -1654,6 +1165,7 @@ propview_init()
1654 1165
1655 Egui_Layout_Widgets *g = egui_layout_gui_get(); 1166 Egui_Layout_Widgets *g = egui_layout_gui_get();
1656 1167
1168 cbview_init();
1657 propview_table = g->main_win->propsview_table; 1169 propview_table = g->main_win->propsview_table;
1658 1170
1659 prop_list = g->main_win->properties_list; 1171 prop_list = g->main_win->properties_list;
@@ -1674,13 +1186,6 @@ propview_init()
1674 _propview_filter_entry_changed_cb, 1186 _propview_filter_entry_changed_cb,
1675 NULL)); 1187 NULL));
1676 1188
1677 cb_list = g->main_win->callbacksview_list;
1678
1679 evas_object_smart_callback_add(cb_list, "expand,request", _expand_request_cb, NULL);
1680 evas_object_smart_callback_add(cb_list, "contract,request", _contract_request_cb, NULL);
1681 evas_object_smart_callback_add(cb_list, "expanded", _callbacks_expanded_cb, NULL);
1682 evas_object_smart_callback_add(cb_list, "contracted", _callbacks_contracted_cb, NULL);
1683
1684 desc_list = g->main_win->description_list; 1189 desc_list = g->main_win->description_list;
1685 1190
1686 ctn_list = g->main_win->contentview_list; 1191 ctn_list = g->main_win->contentview_list;
@@ -1698,19 +1203,18 @@ propview_shutdown()
1698 _itc_prop = NULL; 1203 _itc_prop = NULL;
1699 elm_genlist_item_class_free(_itc_notfound); 1204 elm_genlist_item_class_free(_itc_notfound);
1700 _itc_notfound = NULL; 1205 _itc_notfound = NULL;
1701 elm_genlist_item_class_free(_itc_cb);
1702 _itc_cb = NULL;
1703 elm_genlist_item_class_free(_itc_desc); 1206 elm_genlist_item_class_free(_itc_desc);
1704 _itc_desc = NULL; 1207 _itc_desc = NULL;
1705 elm_genlist_item_class_free(_itc_ctn); 1208 elm_genlist_item_class_free(_itc_ctn);
1706 _itc_ctn = NULL; 1209 _itc_ctn = NULL;
1707 1210
1211 cbview_shutdown();
1212
1708 eo_do(prop_list, elm_obj_genlist_clear()); 1213 eo_do(prop_list, elm_obj_genlist_clear());
1709 eo_do(cb_list, elm_obj_genlist_clear());
1710 eo_do(desc_list, elm_obj_genlist_clear()); 1214 eo_do(desc_list, elm_obj_genlist_clear());
1711 eo_do(ctn_list, elm_obj_genlist_clear()); 1215 eo_do(ctn_list, elm_obj_genlist_clear());
1712 1216
1713 prop_list = cb_list = desc_list = ctn_list = NULL; 1217 prop_list = desc_list = ctn_list = NULL;
1714 1218
1715 _mempool_cache_free(); 1219 _mempool_cache_free();
1716 1220