summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-04-17 19:10:11 -0300
committerVitor Sousa <vitorsousasilva@gmail.com>2015-05-07 13:55:27 -0300
commitcd8da71dc14d1de5d3771cf69be998eddf96ef88 (patch)
tree36c50fd4c5b25cd71518aef30677a2a4e1c26043
parentc99c116b922ced9e88ae73444bb44db1c7f5392a (diff)
elm_win: Replace elm_win_constructor by constructing properties
Removed the constructing method elm_obj_win_constructor. Now "name" and "type" are properties that must be set at creation, like this: eo_add(ELM_WIN_CLASS, NULL, elm_obj_win_name_set("example"), elm_obj_win_type_set(ELM_WIN_BASIC)); Also, the "title" property can be set at creation now.
-rw-r--r--src/lib/elm_win.c49
-rw-r--r--src/lib/elm_win.eo75
2 files changed, 106 insertions, 18 deletions
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 32bbd09c2..8198a31af 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -176,6 +176,7 @@ struct _Elm_Win_Data
176 const char *title; 176 const char *title;
177 const char *icon_name; 177 const char *icon_name;
178 const char *role; 178 const char *role;
179 Eina_Stringshare *name;
179 180
180 Evas_Object *main_menu; 181 Evas_Object *main_menu;
181 182
@@ -1806,6 +1807,7 @@ _elm_win_evas_object_smart_del(Eo *obj, Elm_Win_Data *sd)
1806 eina_stringshare_del(sd->title); 1807 eina_stringshare_del(sd->title);
1807 eina_stringshare_del(sd->icon_name); 1808 eina_stringshare_del(sd->icon_name);
1808 eina_stringshare_del(sd->role); 1809 eina_stringshare_del(sd->role);
1810 eina_stringshare_del(sd->name);
1809 evas_object_del(sd->icon); 1811 evas_object_del(sd->icon);
1810 evas_object_del(sd->main_menu); 1812 evas_object_del(sd->main_menu);
1811 1813
@@ -2958,7 +2960,9 @@ elm_win_add(Evas_Object *parent,
2958 const char *name, 2960 const char *name,
2959 Elm_Win_Type type) 2961 Elm_Win_Type type)
2960{ 2962{
2961 Evas_Object *obj = eo_add(MY_CLASS, parent, elm_obj_win_constructor(name, type)); 2963 Evas_Object *obj = eo_add(MY_CLASS, parent,
2964 elm_obj_win_name_set(name),
2965 elm_obj_win_type_set(type));
2962 return obj; 2966 return obj;
2963} 2967}
2964 2968
@@ -2967,7 +2971,8 @@ elm_win_fake_add(Ecore_Evas *ee)
2967{ 2971{
2968 return eo_add(MY_CLASS, NULL, 2972 return eo_add(MY_CLASS, NULL,
2969 elm_obj_win_fake_canvas_set(ee), 2973 elm_obj_win_fake_canvas_set(ee),
2970 elm_obj_win_constructor(NULL, ELM_WIN_FAKE)); 2974 elm_obj_win_name_set(NULL),
2975 elm_obj_win_type_set(ELM_WIN_FAKE));
2971} 2976}
2972 2977
2973static void 2978static void
@@ -3118,8 +3123,8 @@ _cb_deled(void *_data,
3118 return EO_CALLBACK_CONTINUE; 3123 return EO_CALLBACK_CONTINUE;
3119} 3124}
3120 3125
3121EOLIAN static void 3126static void
3122_elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type) 3127_elm_win_finalize_internal(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type)
3123{ 3128{
3124 sd->obj = obj; // in ctor 3129 sd->obj = obj; // in ctor
3125 3130
@@ -3586,6 +3591,7 @@ _elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type t
3586 } 3591 }
3587 3592
3588 TRAP(sd, name_class_set, name, _elm_appname); 3593 TRAP(sd, name_class_set, name, _elm_appname);
3594 TRAP(sd, title_set, sd->title);
3589 ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request); 3595 ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request);
3590 ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change); 3596 ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change);
3591 ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in); 3597 ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in);
@@ -3705,12 +3711,32 @@ _elm_win_eo_base_constructor(Eo *obj EINA_UNUSED, Elm_Win_Data *_pd EINA_UNUSED)
3705 /* Do nothing. */ 3711 /* Do nothing. */
3706} 3712}
3707 3713
3714EOLIAN static Eo *
3715_elm_win_eo_base_finalize(Eo *obj, Elm_Win_Data *_pd)
3716{
3717 _elm_win_finalize_internal(obj, _pd, _pd->name, _pd->type);
3718 eo_do_super(obj, MY_CLASS, obj = eo_finalize());
3719 return obj;
3720}
3721
3708EOLIAN static void 3722EOLIAN static void
3709_elm_win_fake_canvas_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Ecore_Evas *oee) 3723_elm_win_fake_canvas_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Ecore_Evas *oee)
3710{ 3724{
3711 pd->ee = oee; 3725 pd->ee = oee;
3712} 3726}
3713 3727
3728EOLIAN static void
3729_elm_win_type_set(Eo *obj, Elm_Win_Data *sd, Elm_Win_Type type)
3730{
3731 Eina_Bool finalized;
3732 if (eo_do_ret(obj, finalized, eo_finalized_get()))
3733 {
3734 ERR("This function is only allowed during construction.");
3735 return;
3736 }
3737 sd->type = type;
3738}
3739
3714EOLIAN static Elm_Win_Type 3740EOLIAN static Elm_Win_Type
3715_elm_win_type_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd) 3741_elm_win_type_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3716{ 3742{
@@ -3718,6 +3744,18 @@ _elm_win_type_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3718} 3744}
3719 3745
3720EOLIAN static void 3746EOLIAN static void
3747_elm_win_name_set(Eo *obj, Elm_Win_Data *sd, const char *name)
3748{
3749 Eina_Bool finalized;
3750 if (eo_do_ret(obj, finalized, eo_finalized_get()))
3751 {
3752 ERR("This function is only allowed during construction.");
3753 return;
3754 }
3755 sd->name = eina_stringshare_add(name);
3756}
3757
3758EOLIAN static void
3721_elm_win_noblank_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Eina_Bool noblank) 3759_elm_win_noblank_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Eina_Bool noblank)
3722{ 3760{
3723 noblank = !!noblank; 3761 noblank = !!noblank;
@@ -3806,7 +3844,8 @@ _elm_win_title_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *title)
3806{ 3844{
3807 if (!title) return; 3845 if (!title) return;
3808 eina_stringshare_replace(&(sd->title), title); 3846 eina_stringshare_replace(&(sd->title), title);
3809 TRAP(sd, title_set, sd->title); 3847 if (sd->ee)
3848 TRAP(sd, title_set, sd->title);
3810 if (sd->frame_obj) 3849 if (sd->frame_obj)
3811 edje_object_part_text_escaped_set 3850 edje_object_part_text_escaped_set
3812 (sd->frame_obj, "elm.text.title", sd->title); 3851 (sd->frame_obj, "elm.text.title", sd->title);
diff --git a/src/lib/elm_win.eo b/src/lib/elm_win.eo
index 9b91788f3..d0863aee9 100644
--- a/src/lib/elm_win.eo
+++ b/src/lib/elm_win.eo
@@ -1131,15 +1131,70 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window,
1131 return: Evas_Object *; 1131 return: Evas_Object *;
1132 } 1132 }
1133 } 1133 }
1134 @property name {
1135 /*@
1136 The window name.
1137
1138 The meaning of name depends on the underlying windowing system.
1139
1140 The window name is a constructing property that need to be set at
1141 creation within @ref eo_add.
1142
1143 Example:
1144 @code
1145 win = eo_add(ELM_WIN_CLASS, NULL, elm_obj_win_name_set(ELM_WIN_BASIC));
1146 @endcode
1147
1148 @note Once set, it can NOT be modified afterward.
1149
1150 @ingroup Win */
1151
1152 set {
1153 /*@
1154 Can only be used at creation time, within @ref eo_add.
1155
1156 @ingroup Win */
1157 }
1158 values {
1159 const(char)* name @nullable;
1160 }
1161 }
1134 @property type { 1162 @property type {
1135 get { 1163 /*@
1164 The type of the window.
1165
1166 It is a hint of how the Window Manager should handle it.
1167
1168 The window type is a constructing property that need to be set at
1169 creation within @ref eo_add.
1170
1171 Example:
1172 @code
1173 win = eo_add(ELM_WIN_CLASS, NULL, elm_obj_win_type_set(ELM_WIN_BASIC));
1174 @endcode
1175
1176 @note Once set, it can NOT be modified afterward.
1177
1178 @see Elm_Win_Type
1179
1180 @ingroup Win */
1181
1182 set {
1136 /*@ 1183 /*@
1137 Get the type of a window. 1184 Can only be used at creation time, within @ref eo_add.
1185
1186 @see Elm_Win_Type
1138 1187
1139 @return The type of a window object. If the object is not window object, return #ELM_WIN_UNKNOWN. 1188 @ingroup Win */
1189 }
1190 get {
1191 /*@
1192 If the object is not window object, return #ELM_WIN_UNKNOWN.
1140 1193
1141 @ingroup Win */ 1194 @ingroup Win */
1142 return: Elm_Win_Type(-1); 1195 }
1196 values {
1197 Elm_Win_Type type(-1);
1143 } 1198 }
1144 } 1199 }
1145 @property noblank { 1200 @property noblank {
@@ -1193,14 +1248,6 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window,
1193 Ecore_Evas *oee; 1248 Ecore_Evas *oee;
1194 } 1249 }
1195 } 1250 }
1196 constructor {
1197 /*@ No description supplied by the EAPI. */
1198 legacy: null;
1199 params {
1200 @in const(char)* name;
1201 @in Elm_Win_Type type;
1202 }
1203 }
1204 wm_manual_rotation_done_manual { 1251 wm_manual_rotation_done_manual {
1205 /*@ 1252 /*@
1206 To notify the rotation done to WM manually. 1253 To notify the rotation done to WM manually.
@@ -1352,6 +1399,7 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window,
1352 implements { 1399 implements {
1353 class.constructor; 1400 class.constructor;
1354 Eo.Base.constructor; 1401 Eo.Base.constructor;
1402 Eo.Base.finalize;
1355 Evas.Object_Smart.hide; 1403 Evas.Object_Smart.hide;
1356 Evas.Object_Smart.show; 1404 Evas.Object_Smart.show;
1357 Evas.Object_Smart.move; 1405 Evas.Object_Smart.move;
@@ -1369,7 +1417,8 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window,
1369 Elm_Interface_Atspi_Widget_Action.elm_actions.get; 1417 Elm_Interface_Atspi_Widget_Action.elm_actions.get;
1370 } 1418 }
1371 constructors { 1419 constructors {
1372 .constructor; 1420 .name;
1421 .type;
1373 } 1422 }
1374 events { 1423 events {
1375 delete,request; 1424 delete,request;