davemds pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=bed32441a7b2a256162b2bdf69f9e198c199de3f

commit bed32441a7b2a256162b2bdf69f9e198c199de3f
Author: Dave Andreoli <d...@gurumeditation.it>
Date:   Sat Jan 3 14:13:35 2015 +0100

    Added the elm_win_util_dialog_add() API function
    
    This new @feature is just a convenient way to create dialogs, It
    mimic the elm_win_util_standard_add() function but crete a
    standard dialog, with background and the parent set.
    
    WinDialog test changed to use the new function.
---
 src/bin/test_win_dialog.c | 13 ++++---------
 src/lib/elm_win.c         | 25 +++++++++++++++++++++++--
 src/lib/elm_win_legacy.h  | 22 ++++++++++++++++++++++
 3 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/src/bin/test_win_dialog.c b/src/bin/test_win_dialog.c
index 1eb78e3..a82915a 100644
--- a/src/bin/test_win_dialog.c
+++ b/src/bin/test_win_dialog.c
@@ -6,19 +6,14 @@
 void
 test_win_dialog(void *data, Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
 {
-   Evas_Object *win, *bg, *bt;
+   Evas_Object *win, *bt;
+   Evas_Object *parent = data;
 
-   win = elm_win_add(data, "window-dialog", ELM_WIN_DIALOG_BASIC);
-   elm_win_title_set(win, "Window Dialog");
+   win = elm_win_util_dialog_add(parent, "window-dia", "Dialog Window");
    elm_win_autodel_set(win, EINA_TRUE);
 
-   bg = elm_bg_add(win);
-   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   elm_win_resize_object_add(win, bg);
-   evas_object_show(bg);
-
    bt = elm_button_add(win);
-   elm_object_text_set(bt, "OK");
+   elm_object_text_set(bt, "This is a dialog window");
    evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(win, bt);
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 2446d89..f2d8420 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -3594,8 +3594,7 @@ _elm_win_trap_data_get(Eo *obj EINA_UNUSED, Elm_Win_Data 
*pd)
 
 
 EAPI Evas_Object *
-elm_win_util_standard_add(const char *name,
-                          const char *title)
+elm_win_util_standard_add(const char *name, const char *title)
 {
    Evas_Object *win, *bg;
 
@@ -3616,6 +3615,28 @@ elm_win_util_standard_add(const char *name,
    return win;
 }
 
+EAPI Evas_Object *
+elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char 
*title)
+{
+   Evas_Object *win, *bg;
+
+   win = elm_win_add(parent, name, ELM_WIN_DIALOG_BASIC);
+   if (!win) return NULL;
+
+   elm_win_title_set(win, title);
+   bg = elm_bg_add(win);
+   if (!bg)
+     {
+        evas_object_del(win);
+        return NULL;
+     }
+   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bg);
+   evas_object_show(bg);
+
+   return win;
+}
+
 EOLIAN static void
 _elm_win_resize_object_add(Eo *obj, Elm_Win_Data *sd, Evas_Object *subobj)
 {
diff --git a/src/lib/elm_win_legacy.h b/src/lib/elm_win_legacy.h
index 2788037..a6f0c2b 100644
--- a/src/lib/elm_win_legacy.h
+++ b/src/lib/elm_win_legacy.h
@@ -36,6 +36,28 @@ EAPI Evas_Object          *elm_win_add(Evas_Object *parent, 
const char *name, El
 EAPI Evas_Object          *elm_win_util_standard_add(const char *name, const 
char *title);
 
 /**
+ * Adds a window object with dialog setup
+ *
+ * @param parent The parent window
+ * @param name The name of the window
+ * @param title The title for the window
+ *
+ * This creates a window like elm_win_add() but also puts in a standard
+ * background with elm_bg_add(), as well as setting the window title to
+ * @p title. The window type created is of type ELM_WIN_DIALOG_BASIC.
+ * This tipe of window will be handled in special mode by window managers
+ * with regards of it's @p parent window.
+ *
+ * @return The created object, or @c NULL on failure
+ *
+ * @see elm_win_add()
+ *
+ * @ingroup Win
+ * @since 1.13
+ */
+EAPI Evas_Object          *elm_win_util_dialog_add(Evas_Object *parent, const 
char *name, const char *title);
+
+/**
  * Set the floating mode of a window.
  *
  * @param obj The window object

-- 


Reply via email to