summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-07-02 17:56:35 +0300
committerYossi Kantor <yossi.kantor@samsung.com>2014-08-03 14:50:41 +0300
commitb165ad46cd4b1ac1afbc9f71aaf1fe3aac8aa94a (patch)
tree30c47878d645e7a0fe5e31d0995113921f5f5402
parentf399fee1cd37ad0faf91d7f64aa2f769da42c350 (diff)
Integration of Ctxpopup item
-rw-r--r--src/lib/Makefile.am7
-rw-r--r--src/lib/elc_ctxpopup.c122
-rw-r--r--src/lib/elm_ctxpopup_item.eo15
-rw-r--r--src/lib/elm_widget_ctxpopup.h11
4 files changed, 84 insertions, 71 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index c95782055..1b795a5c3 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -790,7 +790,9 @@ BUILT_SOURCES = \
790 elm_flipselector_item.eo.c \ 790 elm_flipselector_item.eo.c \
791 elm_flipselector_item.eo.h \ 791 elm_flipselector_item.eo.h \
792 elm_menu_item.eo.c \ 792 elm_menu_item.eo.c \
793 elm_menu_item.eo.h 793 elm_menu_item.eo.h \
794 elm_ctxpopup_item.eo.c \
795 elm_ctxpopup_item.eo.h
794 796
795elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@ 797elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
796elementaryeolianfiles_DATA = \ 798elementaryeolianfiles_DATA = \
@@ -890,7 +892,8 @@ elementaryeolianfiles_DATA = \
890 elm_segment_control_item.eo \ 892 elm_segment_control_item.eo \
891 elm_slideshow_item.eo \ 893 elm_slideshow_item.eo \
892 elm_flipselector_item.eo \ 894 elm_flipselector_item.eo \
893 elm_menu_item.eo 895 elm_menu_item.eo \
896 elm_ctxpopup_item.eo
894 897
895EXTRA_DIST += \ 898EXTRA_DIST += \
896 ${elementaryeolianfiles_DATA} 899 ${elementaryeolianfiles_DATA}
diff --git a/src/lib/elc_ctxpopup.c b/src/lib/elc_ctxpopup.c
index aadfee7c6..e58a00524 100644
--- a/src/lib/elc_ctxpopup.c
+++ b/src/lib/elc_ctxpopup.c
@@ -42,12 +42,12 @@ EOLIAN static Eina_Bool
42_elm_ctxpopup_elm_widget_translate(Eo *obj, Elm_Ctxpopup_Data *sd) 42_elm_ctxpopup_elm_widget_translate(Eo *obj, Elm_Ctxpopup_Data *sd)
43{ 43{
44 Eina_List *l; 44 Eina_List *l;
45 Elm_Ctxpopup_Item *it; 45 Elm_Widobj_Item *it;
46 46
47 if (sd->auto_hide) evas_object_hide(obj); 47 if (sd->auto_hide) evas_object_hide(obj);
48 48
49 EINA_LIST_FOREACH(sd->items, l, it) 49 EINA_LIST_FOREACH(sd->items, l, it)
50 elm_widget_item_translate(it); 50 eo_do(it, elm_wdg_item_translate());
51 51
52 eo_do_super(obj, MY_CLASS, elm_obj_widget_translate()); 52 eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
53 53
@@ -831,17 +831,14 @@ _elm_ctxpopup_elm_container_content_unset(Eo *obj, Elm_Ctxpopup_Data *sd, const
831 return content; 831 return content;
832} 832}
833 833
834static void 834EOLIAN static void
835_item_text_set_hook(Elm_Object_Item *it, 835_elm_ctxpopup_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
836 const char *part, 836 Elm_Ctxpopup_Item_Data *ctxpopup_it,
837 const char *label) 837 const char *part,
838 const char *label)
838{ 839{
839 Elm_Ctxpopup_Item *ctxpopup_it;
840
841 if ((part) && (strcmp(part, "default"))) return; 840 if ((part) && (strcmp(part, "default"))) return;
842 841
843 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
844
845 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd); 842 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
846 843
847 elm_object_item_part_text_set(ctxpopup_it->list_item, "default", label); 844 elm_object_item_part_text_set(ctxpopup_it->list_item, "default", label);
@@ -850,31 +847,26 @@ _item_text_set_hook(Elm_Object_Item *it,
850 if (sd->visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it)); 847 if (sd->visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
851} 848}
852 849
853static const char * 850EOLIAN static const char *
854_item_text_get_hook(const Elm_Object_Item *it, 851_elm_ctxpopup_item_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
855 const char *part) 852 Elm_Ctxpopup_Item_Data *ctxpopup_it,
853 const char *part)
856{ 854{
857 Elm_Ctxpopup_Item *ctxpopup_it;
858
859 if (part && strcmp(part, "default")) return NULL; 855 if (part && strcmp(part, "default")) return NULL;
860 856
861 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
862 return elm_object_item_part_text_get(ctxpopup_it->list_item, "default"); 857 return elm_object_item_part_text_get(ctxpopup_it->list_item, "default");
863} 858}
864 859
865static void 860EOLIAN static void
866_item_content_set_hook(Elm_Object_Item *it, 861_elm_ctxpopup_item_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
867 const char *part, 862 Elm_Ctxpopup_Item_Data *ctxpopup_it,
868 Evas_Object *content) 863 const char *part,
864 Evas_Object *content)
869{ 865{
870 Elm_Ctxpopup_Item *ctxpopup_it;
871
872 if ((part) && (strcmp(part, "icon")) 866 if ((part) && (strcmp(part, "icon"))
873 && (strcmp(part, "start")) 867 && (strcmp(part, "start"))
874 && (strcmp(part, "end"))) return; 868 && (strcmp(part, "end"))) return;
875 869
876 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
877
878 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd); 870 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
879 871
880 if ((part) && (!strcmp(part, "end"))) 872 if ((part) && (!strcmp(part, "end")))
@@ -888,39 +880,35 @@ _item_content_set_hook(Elm_Object_Item *it,
888 if (sd->visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it)); 880 if (sd->visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
889} 881}
890 882
891static Evas_Object * 883EOLIAN static Evas_Object *
892_item_content_get_hook(const Elm_Object_Item *it, 884_elm_ctxpopup_item_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
893 const char *part) 885 Elm_Ctxpopup_Item_Data *ctxpopup_it,
886 const char *part)
894{ 887{
895 Elm_Ctxpopup_Item *ctxpopup_it;
896
897 if (part && strcmp(part, "icon") && strcmp(part, "start") 888 if (part && strcmp(part, "icon") && strcmp(part, "start")
898 && strcmp(part, "end")) return NULL; 889 && strcmp(part, "end")) return NULL;
899 890
900 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
901
902 if (part && !strcmp(part, "end")) 891 if (part && !strcmp(part, "end"))
903 return elm_object_item_part_content_get(ctxpopup_it->list_item, "end"); 892 return elm_object_item_part_content_get(ctxpopup_it->list_item, "end");
904 else 893 else
905 return elm_object_item_part_content_get(ctxpopup_it->list_item, "start"); 894 return elm_object_item_part_content_get(ctxpopup_it->list_item, "start");
906} 895}
907 896
908static void 897EOLIAN static void
909_item_disable_hook(Elm_Object_Item *it) 898_elm_ctxpopup_item_elm_widget_item_disable(Eo *eo_item,
899 Elm_Ctxpopup_Item_Data *ctxpopup_it)
910{ 900{
911 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
912 901
913 elm_object_item_disabled_set 902 elm_object_item_disabled_set
914 (ctxpopup_it->list_item, elm_widget_item_disabled_get(ctxpopup_it)); 903 (ctxpopup_it->list_item, elm_object_item_disabled_get((Elm_Object_Item*)eo_item));
915} 904}
916 905
917static void 906EOLIAN static void
918_item_signal_emit_hook(Elm_Object_Item *it, 907_elm_ctxpopup_item_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
919 const char *emission, 908 Elm_Ctxpopup_Item_Data *ctxpopup_it,
920 const char *source) 909 const char *emission,
910 const char *source)
921{ 911{
922 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
923
924 elm_object_item_signal_emit(ctxpopup_it->list_item, emission, source); 912 elm_object_item_signal_emit(ctxpopup_it->list_item, emission, source);
925} 913}
926 914
@@ -1027,11 +1015,11 @@ _list_del(Elm_Ctxpopup_Data *sd)
1027 ELM_SAFE_FREE(sd->list, evas_object_del); 1015 ELM_SAFE_FREE(sd->list, evas_object_del);
1028} 1016}
1029 1017
1030static Eina_Bool 1018EOLIAN static Eina_Bool
1031_item_del_pre_hook(Elm_Object_Item *it) 1019_elm_ctxpopup_item_elm_widget_item_del_pre(Eo *eo_item,
1020 Elm_Ctxpopup_Item_Data *ctxpopup_it)
1032{ 1021{
1033 Evas_Object *list; 1022 Evas_Object *list;
1034 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1035 1023
1036 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd); 1024 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
1037 1025
@@ -1042,16 +1030,16 @@ _item_del_pre_hook(Elm_Object_Item *it)
1042 if (eina_list_count(elm_list_items_get(list)) < 2) 1030 if (eina_list_count(elm_list_items_get(list)) < 2)
1043 { 1031 {
1044 if (ctxpopup_it->list_item) 1032 if (ctxpopup_it->list_item)
1045 elm_widget_item_del(ctxpopup_it->list_item); 1033 elm_object_item_del(ctxpopup_it->list_item);
1046 sd->items = eina_list_remove(sd->items, ctxpopup_it); 1034 sd->items = eina_list_remove(sd->items, eo_item);
1047 evas_object_hide(WIDGET(ctxpopup_it)); 1035 evas_object_hide(WIDGET(ctxpopup_it));
1048 1036
1049 return EINA_TRUE; 1037 return EINA_TRUE;
1050 } 1038 }
1051 1039
1052 if (ctxpopup_it->list_item) 1040 if (ctxpopup_it->list_item)
1053 elm_widget_item_del(ctxpopup_it->list_item); 1041 elm_object_item_del(ctxpopup_it->list_item);
1054 sd->items = eina_list_remove(sd->items, ctxpopup_it); 1042 sd->items = eina_list_remove(sd->items, eo_item);
1055 if (sd->list_visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it)); 1043 if (sd->list_visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
1056 1044
1057 return EINA_TRUE; 1045 return EINA_TRUE;
@@ -1128,7 +1116,7 @@ _elm_ctxpopup_evas_object_smart_add(Eo *obj, Elm_Ctxpopup_Data *priv)
1128EOLIAN static void 1116EOLIAN static void
1129_elm_ctxpopup_evas_object_smart_del(Eo *obj, Elm_Ctxpopup_Data *sd) 1117_elm_ctxpopup_evas_object_smart_del(Eo *obj, Elm_Ctxpopup_Data *sd)
1130{ 1118{
1131 Elm_Ctxpopup_Item *it; 1119 Elm_Widobj_Item *it;
1132 1120
1133 evas_object_event_callback_del_full 1121 evas_object_event_callback_del_full
1134 (sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj); 1122 (sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
@@ -1139,7 +1127,7 @@ _elm_ctxpopup_evas_object_smart_del(Eo *obj, Elm_Ctxpopup_Data *sd)
1139 ELM_SAFE_FREE(sd->bg, evas_object_del); 1127 ELM_SAFE_FREE(sd->bg, evas_object_del);
1140 1128
1141 EINA_LIST_FREE(sd->items, it) 1129 EINA_LIST_FREE(sd->items, it)
1142 elm_widget_item_free(it); 1130 eo_del(it);
1143 1131
1144 eo_do_super(obj, MY_CLASS, evas_obj_smart_del()); 1132 eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
1145} 1133}
@@ -1239,27 +1227,28 @@ _elm_ctxpopup_horizontal_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
1239static void 1227static void
1240_item_wrap_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1228_item_wrap_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1241{ 1229{
1242 Elm_Ctxpopup_Item *item = data; 1230 Elm_Widobj_Item *eo_item = data;
1231 ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
1243 if (!item->wcb.org_func_cb) return; 1232 if (!item->wcb.org_func_cb) return;
1244 item->wcb.org_func_cb((void *)item->wcb.org_data, item->wcb.cobj, item); 1233 item->wcb.org_func_cb((void *)item->wcb.org_data, item->wcb.cobj, eo_item);
1234}
1235
1236EOLIAN static void
1237_elm_ctxpopup_item_eo_base_constructor(Eo *obj, Elm_Ctxpopup_Item_Data *it)
1238{
1239 eo_do_super(obj, ELM_CTXPOPUP_ITEM_CLASS, eo_constructor());
1240 it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
1245} 1241}
1246 1242
1247EOLIAN static Elm_Object_Item* 1243EOLIAN static Elm_Object_Item*
1248_elm_ctxpopup_item_append(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) 1244_elm_ctxpopup_item_append(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1249{ 1245{
1250 Elm_Ctxpopup_Item *item; 1246 Elm_Widobj_Item *eo_item;
1251
1252 1247
1253 item = elm_widget_item_new(obj, Elm_Ctxpopup_Item); 1248 eo_item = eo_add(ELM_CTXPOPUP_ITEM_CLASS, obj);
1254 if (!item) return NULL; 1249 if (!eo_item) return NULL;
1255 1250
1256 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook); 1251 ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
1257 elm_widget_item_disable_hook_set(item, _item_disable_hook);
1258 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
1259 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
1260 elm_widget_item_content_set_hook_set(item, _item_content_set_hook);
1261 elm_widget_item_content_get_hook_set(item, _item_content_get_hook);
1262 elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
1263 1252
1264 if (!sd->list) 1253 if (!sd->list)
1265 { 1254 {
@@ -1279,14 +1268,14 @@ _elm_ctxpopup_item_append(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Eva
1279 item->wcb.org_data = data; 1268 item->wcb.org_data = data;
1280 item->wcb.cobj = obj; 1269 item->wcb.cobj = obj;
1281 item->list_item = 1270 item->list_item =
1282 elm_list_item_append(sd->list, label, icon, NULL, _item_wrap_cb, item); 1271 elm_list_item_append(sd->list, label, icon, NULL, _item_wrap_cb, eo_item);
1283 sd->items = eina_list_append(sd->items, item); 1272 sd->items = eina_list_append(sd->items, eo_item);
1284 1273
1285 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN; 1274 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1286 1275
1287 if (sd->visible) elm_layout_sizing_eval(obj); 1276 if (sd->visible) elm_layout_sizing_eval(obj);
1288 1277
1289 return (Elm_Object_Item *)item; 1278 return (Elm_Object_Item *)eo_item;
1290} 1279}
1291 1280
1292EOLIAN static void 1281EOLIAN static void
@@ -1341,4 +1330,5 @@ _elm_ctxpopup_class_constructor(Eo_Class *klass)
1341 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 1330 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
1342} 1331}
1343 1332
1333#include "elm_ctxpopup_item.eo.c"
1344#include "elc_ctxpopup.eo.c" 1334#include "elc_ctxpopup.eo.c"
diff --git a/src/lib/elm_ctxpopup_item.eo b/src/lib/elm_ctxpopup_item.eo
new file mode 100644
index 000000000..926a07d45
--- /dev/null
+++ b/src/lib/elm_ctxpopup_item.eo
@@ -0,0 +1,15 @@
1class Elm_Ctxpopup_Item(Elm_Widget_Item)
2{
3 legacy_prefix: null;
4 eo_prefix: elm_ctxpopup_item;
5 implements {
6 Eo_Base::constructor;
7 Elm_Widget_Item::del_pre;
8 Elm_Widget_Item::disable;
9 Elm_Widget_Item::signal_emit;
10 Elm_Widget_Item::part_text::get;
11 Elm_Widget_Item::part_text::set;
12 Elm_Widget_Item::part_content::get;
13 Elm_Widget_Item::part_content::set;
14 }
15} \ No newline at end of file
diff --git a/src/lib/elm_widget_ctxpopup.h b/src/lib/elm_widget_ctxpopup.h
index 3f4eabc89..32045e489 100644
--- a/src/lib/elm_widget_ctxpopup.h
+++ b/src/lib/elm_widget_ctxpopup.h
@@ -2,7 +2,9 @@
2#define ELM_WIDGET_CTXPOPUP_H 2#define ELM_WIDGET_CTXPOPUP_H
3 3
4#include "elm_widget_layout.h" 4#include "elm_widget_layout.h"
5#include "elm_ctxpopup_item.eo.h"
5 6
7#include "elm_object_item_migration_temp.h"
6/** 8/**
7 * @addtogroup Widget 9 * @addtogroup Widget
8 * @{ 10 * @{
@@ -14,15 +16,15 @@
14 * widgets which are a ctxpopup with some more logic on top. 16 * widgets which are a ctxpopup with some more logic on top.
15 */ 17 */
16 18
17typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item; 19typedef struct _Elm_Ctxpopup_Item_Data Elm_Ctxpopup_Item_Data;
18 20
19/** 21/**
20 * Base widget smart data extended with ctxpopup instance data. 22 * Base widget smart data extended with ctxpopup instance data.
21 */ 23 */
22typedef struct _Elm_Ctxpopup_Data Elm_Ctxpopup_Data; 24typedef struct _Elm_Ctxpopup_Data Elm_Ctxpopup_Data;
23struct _Elm_Ctxpopup_Item 25struct _Elm_Ctxpopup_Item_Data
24{ 26{
25 ELM_WIDGET_ITEM; 27 Elm_Widget_Item_Data *base;
26 28
27 Elm_Object_Item *list_item; 29 Elm_Object_Item *list_item;
28 30
@@ -85,4 +87,7 @@ struct _Elm_Ctxpopup_Data
85 if (EINA_UNLIKELY(!eo_isa((obj), ELM_CTXPOPUP_CLASS))) \ 87 if (EINA_UNLIKELY(!eo_isa((obj), ELM_CTXPOPUP_CLASS))) \
86 return 88 return
87 89
90#define ELM_CTXPOPUP_ITEM_DATA_GET(o, sd) \
91 Elm_Ctxpopup_Item_Data * sd = eo_data_scope_get(o, ELM_CTXPOPUP_ITEM_CLASS)
92
88#endif 93#endif