summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-04-02 21:12:13 -0300
committerVitor Sousa <vitorsousasilva@gmail.com>2015-04-10 18:54:52 -0300
commit920ceb57145ce4d48d9ec419773aaf6ca83ac5b3 (patch)
treec2d94dcd17fe4d52050c36af51ebe20239c6bbf2
parentcb7d786ea05e0c93decf59201355f63c43fa7378 (diff)
downloadelementary-devs/vitorsousa/efaces.tar.gz
elm_win: Add Eo replacements for elm_win_util functionsdevs/vitorsousa/efaces
This commit adds the Eolian class elm_win_standard. It is basically a derivation from elm_win that creates a default background. The intent is to replace the legacy functions elm_win_util_standard_add and elm_win_util_dialog_add by functions accessible via Eo API functions such as eo_add and eo_do. It also replaces elm_obj_win_constructor with "constructing properties". 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. So, to fully replace an elm_win_util_standard_add call, use: eo_add(ELM_WIN_STANDARD_CLASS, NULL, elm_obj_win_name_set("example"), elm_obj_win_type_set(ELM_WIN_BASIC), elm_obj_win_title_set("Example"));
-rw-r--r--src/lib/Elementary.h.in1
-rw-r--r--src/lib/Makefile.am5
-rw-r--r--src/lib/elm_win.c51
-rw-r--r--src/lib/elm_win.eo58
-rw-r--r--src/lib/elm_win_standard.c34
-rw-r--r--src/lib/elm_win_standard.eo7
-rw-r--r--src/lib/elm_win_standard.h3
7 files changed, 144 insertions, 15 deletions
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index 3ec825996..cd17bbfd3 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -261,6 +261,7 @@ EAPI extern Elm_Version *elm_version;
#include <elm_video.h>
#include <elm_web.h>
#include <elm_win.h>
+#include <elm_win_standard.h>
/* include deprecated calls last of all */
#include <elm_deprecated.h>
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 8c137e8c3..859b0ef4e 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -385,6 +385,8 @@ elm_win.h \
elm_win_common.h \
elm_win_eo.h \
elm_win_legacy.h \
+elm_win_standard.h \
+elm_win_standard.eo.h \
elm_helper.h
includesubdir = $(includedir)/elementary-@VMAJ@/
@@ -502,6 +504,7 @@ elm_video.c \
elm_web2.c \
elm_widget.c \
elm_win.c \
+elm_win_standard.c \
elm_helper.c \
els_box.c \
els_cursor.c \
@@ -619,6 +622,7 @@ elm_video.eo \
elm_web.eo \
elm_widget.eo \
elm_win.eo \
+elm_win_standard.eo \
elm_widget_item.eo \
elm_color_item.eo \
elm_dayselector_item.eo \
@@ -747,6 +751,7 @@ elementaryeolianfiles_DATA = \
elm_video.eo \
elm_web.eo \
elm_win.eo \
+ elm_win_standard.eo \
elm_widget_item.eo \
elm_color_item.eo \
elm_dayselector_item.eo \
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 8674105ea..ddc3134e7 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -174,6 +174,7 @@ struct _Elm_Win_Data
const char *title;
const char *icon_name;
const char *role;
+ Eina_Stringshare *name;
Evas_Object *main_menu;
@@ -1796,6 +1797,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);
@@ -2946,7 +2948,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;
}
@@ -2955,7 +2959,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
@@ -3053,8 +3058,8 @@ _accel_is_gl(void)
return EINA_FALSE;
}
-EOLIAN static void
-_elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type)
+static void
+_elm_win_construct(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type)
{
sd->obj = obj; // in ctor
@@ -3521,6 +3526,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);
@@ -3637,12 +3643,34 @@ _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_construct(obj, _pd, _pd->name, _pd->type);
+
+ eo_do_super(obj, MY_CLASS, 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)
{
@@ -3650,6 +3678,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;
@@ -3738,7 +3778,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 8f348699a..ccba7017f 100644
--- a/src/lib/elm_win.eo
+++ b/src/lib/elm_win.eo
@@ -1131,7 +1131,49 @@ class Elm_Win (Elm_Widget, Elm_Interface_Atspi_Window,
return: Evas_Object *;
}
}
+
+ name {
+ set {
+ /*@
+ Set the window name.
+
+ The window name is a constructing property that need to be
+ set at creation within 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 */
+ }
+ values {
+ const(char)* name @nullable;
+ }
+ }
type {
+ set {
+ /*@
+ Set the window type.
+
+ The window type is a constructing property that need to be
+ set at creation within 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 */
+ }
get {
/*@
Get the type of a window.
@@ -1139,7 +1181,9 @@ class Elm_Win (Elm_Widget, Elm_Interface_Atspi_Window,
@return The type of a window object. If the object is not window object, return #ELM_WIN_UNKNOWN.
@ingroup Win */
- return: Elm_Win_Type(-1);
+ }
+ values {
+ Elm_Win_Type type;
}
}
noblank {
@@ -1195,14 +1239,6 @@ class Elm_Win (Elm_Widget, Elm_Interface_Atspi_Window,
}
}
methods {
- 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.
@@ -1354,6 +1390,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;
@@ -1371,7 +1408,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;
diff --git a/src/lib/elm_win_standard.c b/src/lib/elm_win_standard.c
new file mode 100644
index 000000000..e449cc3f4
--- /dev/null
+++ b/src/lib/elm_win_standard.c
@@ -0,0 +1,34 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
+#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
+#define ELM_WIN_PROTECTED
+
+#include <Elementary.h>
+
+#include "elm_priv.h"
+
+#define MY_CLASS ELM_WIN_STANDARD_CLASS
+
+EOLIAN static Eo *
+_elm_win_standard_eo_base_finalize(Eo *obj, void *pd EINA_UNUSED)
+{
+ eo_do_super(obj, MY_CLASS, eo_finalize());
+
+ Evas_Object *bg = eo_add(ELM_BG_CLASS, obj);
+ if (!bg)
+ {
+ ERR("Cannot create background.");
+ evas_object_del(obj);
+ return NULL;
+ }
+ eo_do(bg, evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND));
+ eo_do(obj, elm_obj_win_resize_object_add(bg));
+ eo_do(bg, efl_gfx_visible_set(EINA_TRUE));
+
+ return obj;
+}
+
+#include "elm_win_standard.eo.c"
diff --git a/src/lib/elm_win_standard.eo b/src/lib/elm_win_standard.eo
new file mode 100644
index 000000000..845866044
--- /dev/null
+++ b/src/lib/elm_win_standard.eo
@@ -0,0 +1,7 @@
+class Elm_Win_Standard (Elm_Win)
+{
+ data: null;
+ implements {
+ Eo.Base.finalize;
+ }
+}
diff --git a/src/lib/elm_win_standard.h b/src/lib/elm_win_standard.h
new file mode 100644
index 000000000..2222bbb68
--- /dev/null
+++ b/src/lib/elm_win_standard.h
@@ -0,0 +1,3 @@
+#ifdef EFL_EO_API_SUPPORT
+#include <elm_win_standard.eo.h>
+#endif