diff options
author | Vitor Sousa <vitorsousasilva@gmail.com> | 2015-04-17 19:10:11 -0300 |
---|---|---|
committer | Vitor Sousa <vitorsousasilva@gmail.com> | 2015-05-07 13:55:27 -0300 |
commit | cd8da71dc14d1de5d3771cf69be998eddf96ef88 (patch) | |
tree | 36c50fd4c5b25cd71518aef30677a2a4e1c26043 | |
parent | c99c116b922ced9e88ae73444bb44db1c7f5392a (diff) | |
download | elementary-cd8da71dc14d1de5d3771cf69be998eddf96ef88.tar.gz |
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.c | 49 | ||||
-rw-r--r-- | src/lib/elm_win.eo | 75 |
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 const char *title; const char *icon_name; const char *role; + Eina_Stringshare *name; Evas_Object *main_menu; @@ -1806,6 +1807,7 @@ _elm_win_evas_object_smart_del(Eo *obj, Elm_Win_Data *sd) eina_stringshare_del(sd->title); eina_stringshare_del(sd->icon_name); eina_stringshare_del(sd->role); + eina_stringshare_del(sd->name); evas_object_del(sd->icon); evas_object_del(sd->main_menu); @@ -2958,7 +2960,9 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) { - Evas_Object *obj = eo_add(MY_CLASS, parent, elm_obj_win_constructor(name, type)); + Evas_Object *obj = eo_add(MY_CLASS, parent, + elm_obj_win_name_set(name), + elm_obj_win_type_set(type)); return obj; } @@ -2967,7 +2971,8 @@ elm_win_fake_add(Ecore_Evas *ee) { return eo_add(MY_CLASS, NULL, elm_obj_win_fake_canvas_set(ee), - elm_obj_win_constructor(NULL, ELM_WIN_FAKE)); + elm_obj_win_name_set(NULL), + elm_obj_win_type_set(ELM_WIN_FAKE)); } static void @@ -3118,8 +3123,8 @@ _cb_deled(void *_data, return EO_CALLBACK_CONTINUE; } -EOLIAN static void -_elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type) +static void +_elm_win_finalize_internal(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type) { sd->obj = obj; // in ctor @@ -3586,6 +3591,7 @@ _elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type t } TRAP(sd, name_class_set, name, _elm_appname); + TRAP(sd, title_set, sd->title); ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request); ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change); 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) /* Do nothing. */ } +EOLIAN static Eo * +_elm_win_eo_base_finalize(Eo *obj, Elm_Win_Data *_pd) +{ + _elm_win_finalize_internal(obj, _pd, _pd->name, _pd->type); + eo_do_super(obj, MY_CLASS, obj = eo_finalize()); + return obj; +} + EOLIAN static void _elm_win_fake_canvas_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Ecore_Evas *oee) { pd->ee = oee; } +EOLIAN static void +_elm_win_type_set(Eo *obj, Elm_Win_Data *sd, Elm_Win_Type type) +{ + Eina_Bool finalized; + if (eo_do_ret(obj, finalized, eo_finalized_get())) + { + ERR("This function is only allowed during construction."); + return; + } + sd->type = type; +} + EOLIAN static Elm_Win_Type _elm_win_type_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd) { @@ -3718,6 +3744,18 @@ _elm_win_type_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd) } EOLIAN static void +_elm_win_name_set(Eo *obj, Elm_Win_Data *sd, const char *name) +{ + Eina_Bool finalized; + if (eo_do_ret(obj, finalized, eo_finalized_get())) + { + ERR("This function is only allowed during construction."); + return; + } + sd->name = eina_stringshare_add(name); +} + +EOLIAN static void _elm_win_noblank_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Eina_Bool noblank) { noblank = !!noblank; @@ -3806,7 +3844,8 @@ _elm_win_title_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *title) { if (!title) return; eina_stringshare_replace(&(sd->title), title); - TRAP(sd, title_set, sd->title); + if (sd->ee) + TRAP(sd, title_set, sd->title); if (sd->frame_obj) edje_object_part_text_escaped_set (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, return: Evas_Object *; } } + @property name { + /*@ + The window name. + + The meaning of name depends on the underlying windowing system. + + The window name is a constructing property that need to be set at + creation within @ref eo_add. + + Example: + @code + win = eo_add(ELM_WIN_CLASS, NULL, elm_obj_win_name_set(ELM_WIN_BASIC)); + @endcode + + @note Once set, it can NOT be modified afterward. + + @ingroup Win */ + + set { + /*@ + Can only be used at creation time, within @ref eo_add. + + @ingroup Win */ + } + values { + const(char)* name @nullable; + } + } @property type { - get { + /*@ + The type of the window. + + It is a hint of how the Window Manager should handle it. + + The window type is a constructing property that need to be set at + creation within @ref eo_add. + + Example: + @code + win = eo_add(ELM_WIN_CLASS, NULL, elm_obj_win_type_set(ELM_WIN_BASIC)); + @endcode + + @note Once set, it can NOT be modified afterward. + + @see Elm_Win_Type + + @ingroup Win */ + + set { /*@ - Get the type of a window. + Can only be used at creation time, within @ref eo_add. + + @see Elm_Win_Type - @return The type of a window object. If the object is not window object, return #ELM_WIN_UNKNOWN. + @ingroup Win */ + } + get { + /*@ + If the object is not window object, return #ELM_WIN_UNKNOWN. @ingroup Win */ - return: Elm_Win_Type(-1); + } + values { + Elm_Win_Type type(-1); } } @property noblank { @@ -1193,14 +1248,6 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window, Ecore_Evas *oee; } } - constructor { - /*@ No description supplied by the EAPI. */ - legacy: null; - params { - @in const(char)* name; - @in Elm_Win_Type type; - } - } wm_manual_rotation_done_manual { /*@ To notify the rotation done to WM manually. @@ -1352,6 +1399,7 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window, implements { class.constructor; Eo.Base.constructor; + Eo.Base.finalize; Evas.Object_Smart.hide; Evas.Object_Smart.show; Evas.Object_Smart.move; @@ -1369,7 +1417,8 @@ class Elm.Win (Elm.Widget, Elm_Interface_Atspi_Window, Elm_Interface_Atspi_Widget_Action.elm_actions.get; } constructors { - .constructor; + .name; + .type; } events { delete,request; |