summaryrefslogtreecommitdiff
path: root/src/bin/egui_gui/propview.c
blob: bf169537ad185e2c1d3e814292cf7e74e95c4b66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223

#include <Elementary.h>
#include <Eolian.h>
#include "ffi_glue.h"
#include "egui_log.h"
#include "props_helper.h"
#include "propview.h"
#include "itemview.h"
#include "egui_logic_private.h"
#include "cbview.h"

#include "elm_widget_container.h"

static Elm_Genlist_Item_Class *_itc_class = NULL;
static Elm_Genlist_Item_Class *_itc_prop = NULL;
static Elm_Genlist_Item_Class *_itc_notfound = NULL;
static Elm_Genlist_Item_Class *_itc_desc = NULL;
static Elm_Genlist_Item_Class *_itc_ctn = NULL;

static Eo *propview_table = NULL;
static Eo *prop_list = NULL;
static Eo *desc_list = NULL;
static Eo *ctn_list = NULL;

extern Gui_Context *
_active_context_get();

static PropViewCbs *_view_cbs = NULL;
static It_Data_Type _propsview_toolbar_selected_item_type = DESCRIPTION_TYPE;
static It_Data_Type _new_type = DESCRIPTION_TYPE;

void
_it_data_free(void *data)
{
   It_Data *it_data = data;

   if (!it_data) return;

   /* If property wasn't assigned to any widget, this is property with default values.
    * Delete it. */
   if ((it_data->type == PROPERTY_TYPE) && (it_data->prop) && !prop_wdg_get(it_data->prop))
     {
        prop_ref((Gui_Widget_Property *) it_data->prop);
        prop_unref((Gui_Widget_Property *) it_data->prop);
        it_data->prop = NULL;
     }

   free(it_data);
   it_data = NULL;
}

#define _PATH_ICON_UP_ARROW PACKAGE_DATA_DIR"/images/icon_up_arrow.png"
#define _PATH_ICON_DOWN_ARROW PACKAGE_DATA_DIR"/images/icon_down_arrow.png"

/*
 * Hash table to map op to proplist's item.
 * In order to quickly find item in list, when prop name is known.
 * [Op_Desc]->[Item] */
static Eina_Hash *op_item_table = NULL;

/* Hash table to keep the list of expanded classes */
static Eina_Hash *expanded_classes = NULL;

static Evas_Object *
_item_content_get(It_Data *it_data);

static Eina_Bool
_content_item_content_get(It_Data *it_data)
{
   Eo *box = it_data->box;
   const Gui_Widget *wdg = it_data->wdg;
   const Gui_Context *ctx = wdg_context_get(wdg);

   unsigned int count, i;
   count = db_op_desc_param_number_get(it_data->op_desc);

   for (i = 0; i < count; i++)
     {
        /* Get value, for which we want to build field.
         * If it is NULL, field will be build, for nth value in Op_Desc */
        Gui_Value *val = ((it_data->prop) ? prop_value_nth_get(it_data->prop, i) : NULL);
        Eo *obj = props_value_add(box, ctx, wdg, val, it_data->op_desc, i);
        if (obj)
          {
             Par_Field_Data *pfd = calloc (1, sizeof(Par_Field_Data));
             pfd->it_data = it_data;
             pfd->par_idx = i;

             eo_do(obj, eo_key_data_set(_STR_EDITOR, pfd, free));

             if (eo_isa(obj, ELM_HOVERSEL_CLASS))
               {
                  eo_do(obj, eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED,
                                                   _view_cbs->content_change_cb_func, NULL));
                  eo_do(obj, evas_obj_size_hint_weight_set(0, EVAS_HINT_EXPAND),
                             evas_obj_size_hint_align_set(0, EVAS_HINT_FILL));
               }
             else
               {
                  eo_do(obj, eo_event_callback_add(ELM_ENTRY_EVENT_ACTIVATED, _view_cbs->content_change_cb_func, NULL));
               }
          }
        else
          {
             ERR("Can't create field for %dnth parameter in \"%s\", \
                 probably this parameter is NULL pointer", i + 1, db_op_desc_op_name_get(it_data->op_desc));
          }
     }
   return EINA_TRUE;
}

static Eina_Bool
_default_hover_selected_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
{
   const char *choosen_value = elm_object_item_part_text_get(event_info, NULL);
   Eo *entry = data;
   Par_Field_Data *pfd = NULL;
   eo_do(entry, pfd = eo_key_data_get(_STR_EDITOR));
   const Op_Desc *op = pfd->it_data->op_desc;
   Eina_List *def_vals = (Eina_List *) op_params_desc_default_values_list_get(db_op_desc_nth_param_desc_get(op, pfd->par_idx));
   if (def_vals)
     {
        Param_Default_Value *def_val;
        Eina_List *itr;
        EINA_LIST_FOREACH(def_vals, itr, def_val)
          {
             if (!strcmp(choosen_value, param_default_value_name_get(def_val)))
               {
                  eo_do(entry, elm_obj_widget_part_text_set(NULL, param_default_value_get(def_val)));
                  break;
               }
          }
     }
   _view_cbs->property_update_cb_func(NULL, entry, NULL, NULL);
   return EO_CALLBACK_CONTINUE;
}

static Eina_Bool
_property_item_content_get(It_Data *it_data)
{
   Eo *box = it_data->box;
   const Op_Desc *op = it_data->op_desc;
   const Gui_Widget_Property *prop = it_data->prop;
   /* Add label with op name. */

   const char *label = db_op_desc_prop_display_name_get(op);
   if (!label) label = db_op_desc_op_name_get(op);
   props_label_add(box, label);

   unsigned int count, i;
   count = db_op_desc_param_number_get(op);

   for (i = 0; i < count; i++)
     {
        /* Get value, for which we want to build field.
         * If it is NULL, field will be build, for nth value in Op_Desc*/
        Gui_Value *value = ((prop && prop_value_get(prop)) ? prop_value_nth_get(prop, i) : NULL);
        Eo *obj = props_value_add(box, wdg_context_get(it_data->wdg), it_data->wdg, value, op, i);
        if (obj)
          {
             Par_Field_Data *pfd = calloc (1, sizeof(Par_Field_Data));
             pfd->it_data = it_data;
             pfd->par_idx = i;

             eo_do(obj, eo_key_data_set(_STR_EDITOR, pfd, free));

             if (eo_isa(obj, ELM_HOVERSEL_CLASS))
               {
                  /* pass box as a data, in order to change its color then value changed from default. */
                  eo_do(obj, eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, _view_cbs->property_update_cb_func, NULL));
               }
             else if (eo_isa(obj, ELM_CHECK_CLASS))
               {
                  /* pass box as a data, in order to change its color then value changed from default. */
                  eo_do(obj, eo_event_callback_add(ELM_CHECK_EVENT_CHANGED, _view_cbs->property_update_cb_func, NULL));
               }
             else if (eo_isa(obj, ELM_ENTRY_CLASS))
               {
                  /*FIXME: decide how to handle CHANGE ON ACTIVATE*/
                  /* pass box as a data, in order to change its color then value changed from default. */
                  eo_do(obj, eo_event_callback_add(ELM_ENTRY_EVENT_CHANGED_USER, _view_cbs->property_update_cb_func, NULL));

                  /* If there are default values, add Hoversel. */
                  Eina_List *def_vals = (Eina_List *) op_params_desc_default_values_list_get(db_op_desc_nth_param_desc_get(op, i));
                  if (def_vals)
                    {
                       Eo *hover = props_hoversel_enums_add(box, elm_widget_top_get(box), "...", NULL);
                       eo_do(hover, eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, _default_hover_selected_cb, obj));
                       Param_Default_Value *def_val;
                       Eina_List *itr;
                       EINA_LIST_FOREACH(def_vals, itr, def_val)
                         {
                            const char *def_val_name = param_default_value_name_get(def_val);
                            eo_do(hover, elm_obj_hoversel_item_add(def_val_name, NULL, ELM_ICON_NONE, NULL, NULL));
                         }
                    }
               }
          }
        else
          {
             /*
             ERR("Can't create field for %dnth parameter in \"%s\", \
                 probably this parameter is NULL pointer", i + 1, db_op_desc_op_name_get(op));
                 */
          }
     }

   return EINA_TRUE;
}

static Eina_Bool
_wdg_public_change_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Eina_Bool state;
   eo_do(obj, state = elm_obj_check_state_get());
   wdg_public_set(data, state);

   return EO_CALLBACK_CONTINUE;
}

static Eina_Bool
_wdg_name_change_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Gui_Widget *wdg = data;
   const char *str = NULL;
   eo_do(obj, str = elm_obj_widget_part_text_get(NULL));
   widget_name_change(wdg, str);

   return EO_CALLBACK_CONTINUE;
}

// Updates property visual box according to the specified propertiy.
// if it_data is given, also reassigns it to all of the fields
static void
_prop_field_update(const Gui_Widget_Property *prop, Eo *item_box, It_Data *it_data)
{
   Eina_List *box_list, *box_list_itr, *par_list, *l;
   Gui_Value *val;
   int i = 0;

   /* Need to free box_list in the end*/
   eo_do(item_box, box_list = elm_obj_box_children_get());
   box_list_itr = box_list;
   par_list = prop_value_get(prop);

   EINA_LIST_FOREACH(par_list, l, val)
     {
        Eo *o = NULL;
        Par_Field_Data *pfd = NULL;

        // Only fields that have a Par_Field_Data attached to them interest us.
        // Iterate over the next elements of the box until such element is found
        // and reassign it_data to it if needed.
        while (box_list_itr)
          {
             o = eina_list_data_get(box_list_itr);
             eo_do(o, pfd = (Par_Field_Data *) eo_key_data_get(_STR_EDITOR));
             box_list_itr = eina_list_next(box_list_itr);
             if (pfd)
               {
                  if (it_data) pfd->it_data = it_data;
                  break;
               }
          }

        if (!(box_list_itr || pfd)) break;

        Gui_Type t = gui_value_type_get(val);

        /* Create edit field for each parameter. */
        switch (t)
          {
           case GUI_TYPE_SINT:
                {
                   char str[15];
                   int int_v = INT_GET(prop_value_nth_get(prop, i));
                   sprintf(str, "%d", int_v);
                   /* Add this callback in order to avoid _prop_update_from_propview cb to be called. */
                   elm_entry_entry_set(o, str);
                   break;
                }
           case GUI_TYPE_STRING:
                {
                   char *str = STRING_GET(prop_value_nth_get(prop, i));
                   elm_entry_entry_set(o, str);
                   break;
                }
           case GUI_TYPE_FILE:
                {
                   eo_do(o, elm_obj_hoversel_clear());
                   props_hoversel_resource_files_add(NULL, o, NULL, NULL, wdg_context_get(it_data->wdg));

                   Dep_Id *dep_id = DEP_ID_GET(prop_value_nth_get(prop, i));
                   const char *default_str = PROP_HOVERSEL_NONE_VALUE;
                   if (dep_id)
                     default_str = dep_name_get(dep_id);
                   eo_do(o, elm_obj_widget_part_text_set(NULL, default_str));
                   break;
                }
           case GUI_TYPE_OBJECT:
                {
                   eo_do(o, elm_obj_hoversel_clear());
                   props_hoversel_objects_add(NULL, o, NULL, NULL, gui_context_wdg_list_get(wdg_context_get(it_data->wdg)), it_data->wdg);
                   Dep_Id *dep_id = DEP_ID_GET(prop_value_nth_get(prop, i));
                   const char *default_str = PROP_HOVERSEL_NONE_VALUE;
                   if (dep_id)
                     default_str = dep_name_get(dep_id);
                   eo_do(o, elm_obj_widget_part_text_set(NULL, default_str));
                   break;
                }
           case GUI_TYPE_DOUBLE:
                {
                   char str[30];
                   double d = DOUBLE_GET(prop_value_nth_get(prop, i));
                   sprintf(str, "%f", d);
                   elm_entry_entry_set(o, str);
                   break;
                }
           case GUI_TYPE_BOOL:
                {
                   Eina_Bool state = BOOL_GET(prop_value_nth_get(prop, i));
                   elm_check_state_set(o, state);
                   break;
                }
           case GUI_TYPE_ENUM:
                {
                   char *default_str = STRING_GET(prop_value_nth_get(prop, i));
                   elm_object_text_set(o, default_str);
                   break;
                }
           default:
              ERR("switch default for type: %s of property %s", db_gui_type_name_get(t), prop_name_get(prop));
          }
        i++; /*Because first item in box list is label*/
     }
   eina_list_free(box_list);
}

static Eina_Bool
_description_item_content_get(It_Data *it_data)
{
   Eo *box = it_data->box;
   Eo *label = eo_add(ELM_LABEL_CLASS, box);
   eo_do(label, evas_obj_visibility_set(EINA_TRUE),
                elm_obj_widget_part_text_set(NULL, it_data->desc));
   eo_do(box, elm_obj_box_pack_end(label));

   if (!strcmp(it_data->desc, DB_DEF_PUBLIC))
     {
        Eo *ck = props_check_add(box, wdg_public_get(it_data->wdg));
        eo_do (ck, eo_event_callback_add(ELM_ENTRY_EVENT_CHANGED, _wdg_public_change_cb, it_data->wdg));
     }
   else if (!strcmp(it_data->desc, DB_DEF_NAME))
     {
        Eo *entry = props_entry_add(box, wdg_name_get(it_data->wdg), GUI_TYPE_STRING);
        eo_do (entry, eo_event_callback_add(ELM_ENTRY_EVENT_ACTIVATED, _wdg_name_change_cb, it_data->wdg));
     }
   else if (!strcmp(it_data->desc, DB_DEF_CLASS))
     {
        Eo *entry = props_entry_add(box, wdg_class_name_get(it_data->wdg), GUI_TYPE_STRING);
        elm_object_disabled_set(entry, EINA_TRUE);
     }
   return EINA_TRUE;
}

/* Content set for property view.
 * Used to show properties and actions
 */
static Evas_Object *
_item_content_get(It_Data *it_data)
{
   Eo *box = NULL;

   box = eo_add(ELM_BOX_CLASS, propview_table);
   eo_do(box, evas_obj_visibility_set(EINA_TRUE),
         elm_obj_box_horizontal_set(EINA_TRUE),
         elm_obj_box_padding_set(5, 0),
         evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0),
         evas_obj_size_hint_align_set(EVAS_HINT_FILL, 0)
//         evas_obj_size_hint_min_set(32 * elm_config_scale_get(),
//                                    18 * elm_config_scale_get())
        );

   it_data->box = box;
   switch (it_data->type)
     {
      case PROPERTY_TYPE:
         _property_item_content_get(it_data);
         break;
      case DESCRIPTION_TYPE:
         _description_item_content_get(it_data);
         break;
         /* Currently ITEM_TYPE cannot appear here.
          * This case is only to shut compiler up. */
      case ITEM_TYPE:
      case CONTENT_TYPE:
         _content_item_content_get(it_data);
         break;
      default:
         break;
     }

   return box;
}

PropViewCbs *propview_cbs_get()
{
   if (!_view_cbs) _view_cbs = calloc(1, sizeof(*_view_cbs));
   return _view_cbs;
}

static char *
_class_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   Classname_Data *cl = data;
   return strdup(cl->classname);
}

static char *
_notfound_item_text_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   return strdup("No search results");
}

static Evas_Object *
_prop_item_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   It_Data *it_data = data;

   if (it_data->box) return it_data->box;

   const char *fullname = db_op_desc_op_name_full_get(it_data->op_desc);

   if (!it_data->prop)
     {
        it_data->prop = prop_create_for_op(it_data->op_desc);
        const Gui_Context *ctx = _active_context_get();
        Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(ctx);
        manager_widget_property_get(session, it_data->wdg, it_data->prop);
     }

   Evas_Object * it_box = _mempool_cache_data_get(fullname);

   if (!it_box)
     {
        it_box = _item_content_get(it_data);

        Eo *prop_menu_button = props_button_add(it_box, NULL);
        eo_do(prop_menu_button, evas_obj_size_hint_align_set(1, 0));
        eo_do(prop_menu_button, evas_obj_size_hint_weight_set(0.01, 0));
        eo_do(prop_menu_button, eo_key_data_set(_STR_EDITOR, it_data, NULL));
        eo_do(prop_menu_button, eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _view_cbs->property_ctx_menu_cb_func, NULL));

        Eo *ic = eo_add(ELM_ICON_CLASS, it_box);
        eo_do(ic, efl_file_set(PACKAGE_DATA_DIR"/images/icon_prop_menu2.png", NULL));
        eo_do(prop_menu_button, elm_obj_container_content_set("icon", ic));

        eo_ref(it_box);
     }
   else
     {
        Eina_List *last = eina_list_last(eo_do(it_box, elm_obj_box_children_get()));
        Eo *prop_menu_button  = eina_list_data_get(last);
        eo_do(prop_menu_button, eo_key_data_set(_STR_EDITOR, it_data, NULL));

        it_data->box = it_box;
        _prop_field_update(it_data->prop, it_box, it_data);
     }

   if (!prop_wdg_get(it_data->prop))
     eo_do(it_box, evas_obj_color_set(150, 150, 150, 255));
   else
     eo_do(it_box, evas_obj_color_set(255, 255, 255, 255));

   return it_box;
}

static void
_class_item_del(void *data, Evas_Object *obj EINA_UNUSED)
{
   Classname_Data *cl = data;
   free(cl->classname);
   free(cl);
}

static void
_prop_item_del(void *data, Evas_Object *obj EINA_UNUSED)
{
   It_Data *it_data = data;
   const char *fullname = db_op_desc_op_name_full_get(it_data->op_desc);

   eina_hash_del(op_item_table, NULL, it_data);
   _mempool_cache_data_put(fullname, it_data->box);
   _it_data_free(it_data);
}

static void
_expand_request_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
{
   Elm_Object_Item *glit = event_info;
   Classname_Data *cl = elm_object_item_data_get(glit);
   eina_hash_set(expanded_classes, cl->classname, (void *)1);
   elm_genlist_item_expanded_set(glit, EINA_TRUE);
}

static void
_contract_request_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
{
   Elm_Object_Item *glit = event_info;
   Classname_Data *cl = elm_object_item_data_get(glit);
   eina_hash_del_by_key(expanded_classes, cl->classname);
   elm_genlist_item_expanded_set(glit, EINA_FALSE);
}

// Expand a specific class name for its properties children.
static void
_props_classname_table_expand(const Gui_Widget *wdg, const char *classname, Elm_Object_Item *parent)
{
   Eina_List *l1 = NULL;
   Eina_List *l2 = NULL;
   Op_Desc *op;

   const char *filter = _filter_string_get();

   /* iterate over each operation of class. */
   Eina_List *llst = db_class_op_desc_list_get(classname);

   EINA_LIST_FOREACH(llst, l1, op)
     {
        Gui_Widget_Property *prop;
        It_Data *it_data;

        if (db_op_desc_is_container(op)) continue;

        const char *op_display_name = db_op_desc_prop_display_name_get(op);

        // If filter is on and no match, dont add to property list
        if (filter && !_str_nocase_prefix(op_display_name, filter))
          continue;

        Eina_List *pitems = NULL;
        Eina_List *wdg_prop_lst = wdg_prop_list_get(wdg);

        // Find which class properties are in widget. Can be more than one.
        EINA_LIST_FOREACH(wdg_prop_lst, l2, prop)
          if (prop_op_desc_get(prop) == op) pitems = eina_list_append(pitems, prop);

        // If none found, its a default one
        if (!eina_list_count(pitems)) pitems = eina_list_append(pitems, NULL);

        EINA_LIST_FREE(pitems, prop)
          {
             it_data = IT_DATA_BUILD(PROPERTY_TYPE, wdg);
             it_data->op_desc = op;
             it_data->prop = prop;
             elm_genlist_item_append(prop_list, _itc_prop, it_data, parent,
                                      ELM_GENLIST_ITEM_NONE, NULL, NULL);
             /* map current item with its prop name. */
             eina_hash_add(op_item_table, db_op_desc_op_name_full_get(op), it_data);
          }
     }
}

static void
_props_expanded_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
{
   Elm_Object_Item *glit = event_info;
   Classname_Data *cl = elm_object_item_data_get(glit);
   _props_classname_table_expand(cl->wdg, cl->classname, glit);
}

static void
_props_contracted_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
{
   Elm_Object_Item *glit = event_info;
   elm_genlist_item_subitems_clear(glit);
}

static void
_properties_build(const Gui_Widget *wdg)
{
   op_item_table = eina_hash_string_superfast_new(NULL);
   Eina_List *kl_list = NULL;

   if (wdg)
     {
        /* FIXME: this will be fixed, when Eolian will be used for MRO.
         * Eo will not be needed for MRO. */
        const Gui_Session *session = gui_context_editor_session_get(_active_context_get());
        kl_list = eo_class_mro_get(eo_class_name_get(session_eo_get(session, wdg)));
     }
   const char *kl;

   const char *filter = _filter_string_get();

   EINA_LIST_FREE(kl_list, kl)
     {
        Op_Desc *op;
        Eina_List *llst = db_class_op_desc_list_get(kl);
        Eina_List *l = NULL;

        EINA_LIST_FOREACH(llst, l, op)
          {
             // We dont show container properties. So class with at least one non-container
             // property is good to show.
             if (!db_op_desc_is_container(op))
               {
                  if (filter)
                    {
                       _props_classname_table_expand(wdg, kl, NULL);
                    }
                  else
                    {
                       Classname_Data *cldata = calloc(1, sizeof(Classname_Data));
                       cldata->classname = strdup(kl);
                       cldata->wdg = wdg;

                       Elm_Object_Item *glit = elm_genlist_item_append(prop_list, _itc_class,
                                                                       cldata, NULL,
                                                                       ELM_GENLIST_ITEM_TREE,
                                                                       NULL, NULL);
                       if (eina_hash_find(expanded_classes, kl))
                          elm_genlist_item_expanded_set(glit, EINA_TRUE);
                    }
                  break;
               }
          }
     }

     //if filter search found nothing, yield an appropriate message to properties list
     if (filter)
       {
          if (!elm_genlist_items_count(prop_list))
              elm_genlist_item_append(prop_list, _itc_notfound, NULL, NULL,
                                      ELM_GENLIST_ITEM_NONE, NULL, NULL);
       }
     // Automatically expand the class
     else
       {
          Elm_Object_Item *glit = elm_genlist_first_item_get(prop_list);
          if (glit) elm_genlist_item_expanded_set(glit, EINA_TRUE);
       }
}

static void
_content_build(const Gui_Widget *wdg)
{
   Eina_List *ctn_items = NULL;
   Eina_List *l;
   int i = 0;
   Object_Container_Item *ci;
   It_Data *it_data;

   const char *wdg_name = wdg_obj_container_class_name_get(wdg);
   Eina_Bool isbox = (wdg_name &&
                      (!strcmp(wdg_name, DB_DEF_BOX_CLASS) ||
                       !strcmp(wdg_name, DB_DEF_WIN_CLASS)));

   Egui_Layout_Widgets *g = egui_layout_gui_get();
   elm_object_disabled_set(g->main_win->contentview_down_btn, !isbox);
   elm_object_disabled_set(g->main_win->contentview_up_btn, !isbox);

   Eina_List *items_lst = wdg_obj_container_contents_list_get(wdg);

   EINA_LIST_FOREACH(items_lst, l, ci)
     {
        Dep_Id *item_id = obj_container_item_dep_id_get(ci);
        if (item_id && !wdg_get(item_id)) continue;

        Gui_Widget_Property *prop = obj_container_item_prop_get(ci);
        it_data = IT_DATA_BUILD(CONTENT_TYPE, wdg);
        it_data->idx = i;
        it_data->prop = prop;
        it_data->op_desc = (Op_Desc *) prop_op_desc_get(prop);
        i++;

        ctn_items = eina_list_append(ctn_items, it_data);
     }

   /*  Add empty fields. */
   const char *wdg_class_name = wdg_class_name_get(wdg);
   const char *name;
   /* Add empty field for each type of container. */
   EINA_LIST_FOREACH(db_class_inherit_containers_list_get(wdg_class_name), l, name)
     {
        const Op_Desc *op_desc = db_container_desc_op_desc_get(db_container_desc_get(name), CONTAINER_PACK);
        it_data = IT_DATA_BUILD(CONTENT_TYPE, wdg);
        it_data->idx = i;
        it_data->op_desc = op_desc;
        it_data->prop = NULL;

        ctn_items = eina_list_append(ctn_items, it_data);
     }

   EINA_LIST_FREE(ctn_items, it_data)
     elm_genlist_item_append(ctn_list, _itc_ctn, it_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
}

static void
_content_select_item(const Gui_Widget_Property *prop)
{
    Elm_Object_Item *it = elm_genlist_first_item_get(ctn_list);
    for (; it; it = elm_genlist_item_next_get(it))
      {
         It_Data *it_data = elm_object_item_data_get(it);
         if (it_data->prop == prop)
           {
              elm_genlist_item_selected_set(it, EINA_TRUE);
              break;
           }
      }
}

Eina_Bool
_contentview_del_btn_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc, void *event_info)
{
   const Gui_Widget_Property *prev_prop = NULL;

   Elm_Object_Item *glit = elm_genlist_selected_item_get(ctn_list);
   if (!glit) return EO_CALLBACK_CONTINUE;

   It_Data *it_data = elm_object_item_data_get(glit);
   intptr_t idx = (intptr_t) it_data->idx;

   it_data = elm_object_item_data_get(elm_genlist_item_next_get(glit));
   if (it_data) prev_prop = it_data->prop;
   if (!prev_prop)
     {
        it_data = elm_object_item_data_get(elm_genlist_item_prev_get(glit));
        if (it_data) prev_prop = it_data->prop;
     }

   Eina_Bool ret = _view_cbs->content_delete_cb_func((void *)idx, obj, desc, event_info);
   if (prev_prop) _content_select_item(prev_prop);

   return ret;
}

Eina_Bool
_contentview_up_btn_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc, void *event_info EINA_UNUSED)
{
   Elm_Object_Item *glit = elm_genlist_selected_item_get(ctn_list);
   if (!glit) return EO_CALLBACK_CONTINUE;

   It_Data *it_data = elm_object_item_data_get(glit);
   const Gui_Widget_Property *prev_prop = it_data->prop;
   intptr_t idx = it_data->idx;

   Eina_Bool ret = _view_cbs->content_reorder_cb_func((void *)idx, obj, desc, (void *)(intptr_t)UP);
   _content_select_item(prev_prop);

   return ret;
}

Eina_Bool
_contentview_down_btn_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc, void *event_info EINA_UNUSED)
{
    Elm_Object_Item *glit = elm_genlist_selected_item_get(ctn_list);
   if (!glit) return EO_CALLBACK_CONTINUE;

   It_Data *it_data = elm_object_item_data_get(glit);
   const Gui_Widget_Property *prev_prop = it_data->prop;
   intptr_t idx = it_data->idx;

   Eina_Bool ret = _view_cbs->content_reorder_cb_func((void *)idx, obj, desc, (void *)(intptr_t)DOWN);
   _content_select_item(prev_prop);

   return ret;
}

/* This function now is called for meny only */
static void
_item_build(const Gui_Widget *wdg)
{
   itemview_build(wdg);
}

static void
_desc_item_del(void *data, Evas_Object *obj EINA_UNUSED)
{
   It_Data *it_data = data;
   _it_data_free(it_data);
}

static Evas_Object *
_desc_item_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   return _item_content_get(data);
}

static void
_contents_item_del(void *data, Evas_Object *obj EINA_UNUSED)
{
   It_Data *it_data = data;

   if (it_data->prop)
     {
        const char *fullname = db_op_desc_op_name_full_get(it_data->op_desc);
        _mempool_cache_data_put(fullname, it_data->box);
     }

   _it_data_free(it_data);
}

static Evas_Object *
_contents_item_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   It_Data *it_data = data;

   if (!it_data->prop) return _item_content_get(it_data);

   if (it_data->box) return it_data->box;

   const char *fullname = db_op_desc_op_name_full_get(it_data->op_desc);

   Evas_Object * it_box = _mempool_cache_data_get(fullname);

   if (!it_box)
     {
        it_box = _item_content_get(it_data);
        eo_ref(it_box);
     }
   else
     {
        it_data->box = it_box;
        _prop_field_update(it_data->prop, it_box, it_data);
     }

   return it_box;
}

// Used to loop in _description_build function
static char *descs[] = { DB_DEF_NAME, DB_DEF_CLASS, DB_DEF_PUBLIC, NULL };

static void
_description_build(const Gui_Widget *wdg)
{
   int i;
   for (i = 0; descs[i]; i++)
     {
        It_Data *it_data = IT_DATA_BUILD(DESCRIPTION_TYPE, wdg);
        it_data->desc = descs[i];
        elm_genlist_item_append(desc_list, _itc_desc, it_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
     }
}

/* This callback is called in the end of propview_build()
 * in order to switch between scrollbox for properties
 * and genlist for items. */
static void
_propview_build_post_cb(const Gui_Widget *wdg, It_Data_Type new_type)
{
   Egui_Layout_Widgets *g = egui_layout_gui_get();
   /* Unsetting view according to old selected toolbar's item. */
   switch (_propsview_toolbar_selected_item_type)
     {
      case DESCRIPTION_TYPE:
           {
              break;
           }
      case PROPERTY_TYPE:
           {
              break;
           }
      case CALLBACK_TYPE:
           {
              break;
           }
      case CONTENT_TYPE:
           {
              break;
           }
      case ITEM_TYPE:
           {
              eo_do(g->main_win->contentview_box, evas_obj_visibility_set(EINA_TRUE));
              eo_do(g->main_win->itemview_box, evas_obj_visibility_set(EINA_FALSE));
              break;
           }
     }

   _propsview_toolbar_selected_item_type = new_type;

   /* Setting view according to new selected toolbar's item. */
   eo_do(g->main_win->contentview_box, evas_obj_visibility_set(EINA_FALSE));
   eo_do(g->main_win->properties_list, evas_obj_visibility_set(EINA_FALSE));
   eo_do(g->main_win->itemview_box, evas_obj_visibility_set(EINA_FALSE));
   eo_do(g->main_win->callbacksview_box, evas_obj_visibility_set(EINA_FALSE));
   eo_do(g->main_win->description_list, evas_obj_visibility_set(EINA_FALSE));

   switch (new_type)
     {
      case DESCRIPTION_TYPE:
           {
              eo_do(g->main_win->description_list, evas_obj_visibility_set(EINA_TRUE));
              break;
           }
      case PROPERTY_TYPE:
           {
              eo_do(g->main_win->properties_list, evas_obj_visibility_set(EINA_TRUE));
              break;
           }
      case CALLBACK_TYPE:
           {
              eo_do(g->main_win->callbacksview_box, evas_obj_visibility_set(EINA_TRUE));
              break;
           }
      case CONTENT_TYPE:
           {
              eo_do(g->main_win->contentview_box, evas_obj_visibility_set(EINA_TRUE));
              break;
           }
      case ITEM_TYPE:
           {
              eo_do(g->main_win->contentview_box, evas_obj_visibility_set(EINA_FALSE));
              eo_do(g->main_win->itemview_box, evas_obj_visibility_set(EINA_TRUE));

              if (wdg_is_container(wdg, DB_DEF_MENU_CLASS))
                {
                   eo_do(g->main_win->itemview_add_item_nested_but, elm_obj_widget_disabled_set(EINA_FALSE));
                   eo_do(g->main_win->itemview_add_separator_but, elm_obj_widget_disabled_set(EINA_FALSE));
                }
              else if (wdg_is_container(wdg, DB_DEF_DISKSELECTOR_CLASS) ||
                       wdg_is_container(wdg, DB_DEF_CTXPOPUP_CLASS) ||
                       wdg_is_container(wdg, DB_DEF_TOOLBAR_CLASS))
                {
                   eo_do(g->main_win->itemview_add_item_nested_but, elm_obj_widget_disabled_set(EINA_TRUE));
                   eo_do(g->main_win->itemview_add_separator_but, elm_obj_widget_disabled_set(EINA_TRUE));
                }
              break;
           }
     }
}

/* Build property view for current widget.
 * Show propeties, which defined in class hyerarchy
 * for current widget's class. And fill fields, if property
 * is defined for current widget.(or put default values into fields.)
 * Called, when item in objtree is selected. */
void
propview_build(const Gui_Widget *wdg)
{
   It_Data_Type type = _new_type;

   eo_do(desc_list, elm_obj_genlist_clear());
   eo_do(prop_list, elm_obj_genlist_clear());
   eo_do(ctn_list, elm_obj_genlist_clear());

   if (op_item_table)
     {
        eina_hash_free(op_item_table);
        op_item_table = NULL;
     }

   if (!wdg) return;

   /* type ITEM_TYPE not assigned to any toolbar's item.
    * It's assigned when toolbar's item is CONTENT and widget is menu.
    * So if current type is ITEM_TYPEm we need to assign it to CONTENT_TYPE,
    * and it will be resolved according to widget's type. */
   if (type == ITEM_TYPE) type = CONTENT_TYPE;

   if ((type == CONTENT_TYPE) &&
      (wdg_is_container(wdg, DB_DEF_MENU_CLASS) ||
       wdg_is_container(wdg, DB_DEF_DISKSELECTOR_CLASS) ||
       wdg_is_container(wdg, DB_DEF_CTXPOPUP_CLASS) ||
       wdg_is_container(wdg, DB_DEF_TOOLBAR_CLASS)))
     {
        type = ITEM_TYPE;
     }

   switch(type)
     {
      case DESCRIPTION_TYPE:
           {
              _description_build(wdg);
              break;
           }
      case PROPERTY_TYPE:
           {
              _properties_build(wdg);
              break;
           }
      case CALLBACK_TYPE:
           {
              cbview_build(wdg);
              break;
           }
      case CONTENT_TYPE:
           {
              _content_build(wdg);
              break;
           }
      case ITEM_TYPE:
           {
              itemview_clear();
              _item_build(wdg);
              break;
           }
      default:
         ERR("switch default");
     }
   _propview_build_post_cb(wdg, type);
}

/* API to select property in genlist.
 * Op_Desc is used to be able to select empty property. */
void
propview_item_selected_set(const Op_Desc *op_desc)
{
   if (!op_desc) return;
   Elm_Object_Item *it = elm_genlist_first_item_get(prop_list);
   for (; it; it = elm_genlist_item_next_get(it))
     {
        if (elm_genlist_item_item_class_get(it) != _itc_prop)
          continue;

        It_Data *it_data = elm_object_item_data_get(it);
        if (prop_op_desc_get(it_data->prop) == op_desc)
          {
             elm_genlist_item_selected_set(it, EINA_TRUE);
             elm_genlist_item_bring_in(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
             break;
          }
     }
}

void
propview_item_update(const Gui_Widget_Property *prop)
{
   const char *prop_name;
   Eo *item_box;
   It_Data *it_data = NULL;

   if (!prop) return;
   prop_name = prop_full_name_get(prop);
   /* get item_data from hash. */
   it_data = eina_hash_find(op_item_table, prop_name);
   /* if item of genlist is not visible, box will be NULL, so don't need to update prop.*/
   if (!it_data) return;
   /* Get the item box from item data */
   item_box = it_data->box;
   /* if item box is not realized or any other reason please return.*/
   if (!item_box) return;
   /* If property assigned to widget, make this box white. */
   if (prop_wdg_get(prop))
     eo_do(item_box, evas_obj_color_set(255, 255, 255, 255));

   /* When Undo/Redo only one item is updated.
    * So if this item is doing to be changed from default, this prop must be deleted*/
   if ((it_data->prop) && (!prop_wdg_get(it_data->prop)))
     {
        prop_ref((Gui_Widget_Property *) it_data->prop);
        prop_unref((Gui_Widget_Property *) it_data->prop);
     }

   it_data->prop = prop;

   // Update the fields of the box with properties
   _prop_field_update(prop, item_box, it_data);
}

/* FIXME: need to change signature to Eo_Callback, when it will be supported.
 * This callback is used in Egui Layout JSON. */
void
_propsview_toolbar_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
//(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
{
   Elm_Object_Item *it = event_info;
   elm_toolbar_item_selected_set(it, EINA_TRUE);
   const Gui_Context *ctx = _active_context_get();
   if (!ctx) return;
   const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
   _new_type = (int) (intptr_t) elm_object_item_data_get(it);
   propview_build(wdg);
}

/* API to switch propsview Description->Properties->Callbacks->Contents */
void
propsview_view_switch(It_Data_Type type)
{
   Elm_Object_Item *it;
   Egui_Layout_Widgets *g = egui_layout_gui_get();
   switch (type)
     {
      case PROPERTY_TYPE:
           {
              it = g->main_win->propsview_toolbar_prop_it;
              break;
           }
      case CALLBACK_TYPE:
           {
              it = g->main_win->propsview_toolbar_cb_it;
              break;
           }
      case DESCRIPTION_TYPE:
           {
              it = g->main_win->propsview_toolbar_desc_it;
              break;
           }
         /* Currently ITEM_TYPE cannot appear here.
          * This case is only to shut compiler up. */
      case ITEM_TYPE:
      case CONTENT_TYPE:
           {
              it = g->main_win->propsview_toolbar_cont_it;
              break;
           }
     }
   _propsview_toolbar_clicked(NULL, NULL, it);
}

static Eina_Bool
_propview_filter_entry_changed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
                                  const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{
   const Gui_Context *ctx = _active_context_get();
   if (!ctx) return EO_CALLBACK_CONTINUE;
   const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
   propview_build(wdg);

   return EO_CALLBACK_CONTINUE;
}

void
propview_init()
{
   if (!_itc_class)
     {
        _itc_class = elm_genlist_item_class_new();
        _itc_class->item_style = "default";
        _itc_class->func.text_get = _class_item_label_get;
        _itc_class->func.del = _class_item_del;
     }

   if (!_itc_prop)
     {
        _itc_prop = elm_genlist_item_class_new();
        _itc_prop->item_style = "full";
        _itc_prop->func.content_get = _prop_item_content_get;
        _itc_prop->func.del = _prop_item_del;
     }

   if (!_itc_notfound)
     {
        _itc_notfound = elm_genlist_item_class_new();
        _itc_notfound->item_style = "default";
        _itc_notfound->func.text_get = _notfound_item_text_get;
     }

   if (!_itc_desc)
     {
        _itc_desc = elm_genlist_item_class_new();
        _itc_desc->item_style = "full";
        _itc_desc->func.content_get = _desc_item_content_get;
        _itc_desc->func.del = _desc_item_del;
     }

   if (!_itc_ctn)
     {
        _itc_ctn = elm_genlist_item_class_new();
        _itc_ctn->item_style = "full";
        _itc_ctn->func.content_get = _contents_item_content_get;
        _itc_ctn->func.del = _contents_item_del;
     }

   Egui_Layout_Widgets *g = egui_layout_gui_get();

   cbview_init();
   propview_table = g->main_win->propsview_table;

   prop_list = g->main_win->properties_list;

   /* Put it here, because it Enums defined in propsview.h */
   elm_object_item_data_set(g->main_win->propsview_toolbar_desc_it, (void *) (intptr_t) DESCRIPTION_TYPE);
   elm_object_item_data_set(g->main_win->propsview_toolbar_prop_it, (void *) (intptr_t) PROPERTY_TYPE);
   elm_object_item_data_set(g->main_win->propsview_toolbar_cb_it, (void *) (intptr_t) CALLBACK_TYPE);
   elm_object_item_data_set(g->main_win->propsview_toolbar_cont_it, (void *) (intptr_t) CONTENT_TYPE);

   evas_object_smart_callback_add(prop_list, "expand,request", _expand_request_cb, NULL);
   evas_object_smart_callback_add(prop_list, "contract,request", _contract_request_cb, NULL);
   evas_object_smart_callback_add(prop_list, "expanded", _props_expanded_cb, NULL);
   evas_object_smart_callback_add(prop_list, "contracted", _props_contracted_cb, NULL);

   eo_do(g->main_win->propsview_filter_entry,
         eo_event_callback_add(ELM_ENTRY_EVENT_CHANGED_USER,
                               _propview_filter_entry_changed_cb,
                               NULL));

   desc_list = g->main_win->description_list;

   ctn_list = g->main_win->contentview_list;

   _mempool_cache_init();
   expanded_classes = eina_hash_string_superfast_new(NULL);
}

void
propview_shutdown()
{
   elm_genlist_item_class_free(_itc_class);
   _itc_class = NULL;
   elm_genlist_item_class_free(_itc_prop);
   _itc_prop = NULL;
   elm_genlist_item_class_free(_itc_notfound);
   _itc_notfound = NULL;
   elm_genlist_item_class_free(_itc_desc);
   _itc_desc = NULL;
   elm_genlist_item_class_free(_itc_ctn);
   _itc_ctn = NULL;

   cbview_shutdown();

   eo_do(prop_list, elm_obj_genlist_clear());
   eo_do(desc_list, elm_obj_genlist_clear());
   eo_do(ctn_list, elm_obj_genlist_clear());

   prop_list = desc_list = ctn_list = NULL;

   _mempool_cache_free();

   if (op_item_table) eina_hash_free(op_item_table);
   eina_hash_free(expanded_classes);
}