move gui_simple_popup to its own file, remove gui_ prefix.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Fri, 7 Sep 2012 19:22:41 +0000 (16:22 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Fri, 7 Sep 2012 19:22:41 +0000 (16:22 -0300)
This commit is in preparation to create a new libofono-efl-utils to be
used by dialer and other applications.

The gui_simple_popup() helper is left to aid creation of popups in the
current window.

Makefile.am
dialer/callscreen.c
dialer/gui.c
dialer/gui.h
dialer/history.c
dialer/keypad.c
dialer/simple-popup.c [new file with mode: 0644]
dialer/simple-popup.h [new file with mode: 0644]
dialer/ussd.c

index d756718..07fda77 100644 (file)
@@ -45,6 +45,8 @@ dialer_dialer_SOURCES = \
        dialer/callscreen.h \
        dialer/ussd.c \
        dialer/ussd.h \
+       dialer/simple-popup.c \
+       dialer/simple-popup.h \
        dialer/util.c \
        dialer/util.h
 
index 76759e4..cc2d838 100644 (file)
@@ -7,6 +7,7 @@
 #include "gui.h"
 #include "ofono.h"
 #include "util.h"
+#include "simple-popup.h"
 
 typedef struct _Callscreen
 {
@@ -751,7 +752,7 @@ static void _call_disconnected_show(Callscreen *ctx, OFono_Call *c,
        eina_stringshare_replace(&ctx->disconnected.number, number);
 
        ctx->disconnected.popup = p = gui_simple_popup(title, msg);
-       gui_simple_popup_buttons_set(p,
+       simple_popup_buttons_set(p,
                                        "Dismiss",
                                        "dialer",
                                        _popup_close,
index a3003ff..0ea697b 100644 (file)
@@ -10,6 +10,7 @@
 #include "callscreen.h"
 #include "ussd.h"
 #include "util.h"
+#include "simple-popup.h"
 
 #ifdef HAVE_TIZEN
 #include <appcore-efl.h>
@@ -70,298 +71,9 @@ static void _gui_show(Evas_Object *o)
        elm_object_focus_set(o, EINA_TRUE);
 }
 
-typedef struct _Simple_Popup
-{
-       Evas_Object *popup;
-       Evas_Object *box;
-       Evas_Object *message;
-       Evas_Object *entry;
-       Ecore_Timer *recalc_timer; /* HACK */
-} Simple_Popup;
-
-static void _popup_close(void *data, Evas_Object *bt __UNUSED__, void *event __UNUSED__)
-{
-       Evas_Object *popup = data;
-       evas_object_del(popup);
-}
-
-void gui_simple_popup_title_set(Evas_Object *p, const char *title)
-{
-       if (title) {
-               elm_object_part_text_set(p, "elm.text.title", title);
-               elm_object_signal_emit(p, "show,title", "gui");
-       } else {
-               elm_object_part_text_set(p, "elm.text.title", "");
-               elm_object_signal_emit(p, "hide,title", "gui");
-       }
-}
-
-/* HACK: force recalc from an idler to fix elm_entry problem */
-static Eina_Bool _gui_simple_popup_entries_reeval(void *data)
-{
-       Simple_Popup *ctx = data;
-       if (ctx->message)
-               elm_entry_calc_force(ctx->message);
-       if (ctx->entry)
-               elm_entry_calc_force(ctx->entry);
-       ctx->recalc_timer = NULL;
-       return EINA_FALSE;
-}
-
-static void _gui_simple_popup_timer_cancel_if_needed(Simple_Popup *ctx)
-{
-       if (!ctx->recalc_timer)
-               return;
-       if (ctx->message || ctx->entry)
-               return;
-       ecore_timer_del(ctx->recalc_timer);
-       ctx->recalc_timer = NULL;
-}
-
-static void _gui_simple_popup_message_del(void *data, Evas *e __UNUSED__,
-                                               Evas_Object *en __UNUSED__,
-                                               void *einfo __UNUSED__)
-{
-       Simple_Popup *ctx = data;
-       ctx->message = NULL;
-       _gui_simple_popup_timer_cancel_if_needed(ctx);
-}
-
-static void _gui_simple_popup_entry_del(void *data, Evas *e __UNUSED__,
-                                       Evas_Object *en __UNUSED__,
-                                       void *einfo __UNUSED__)
-{
-       Simple_Popup *ctx = data;
-       ctx->entry = NULL;
-       _gui_simple_popup_timer_cancel_if_needed(ctx);
-}
-
-static void _gui_simple_popup_reeval_content(Simple_Popup *ctx)
-{
-       if ((!ctx->message) && (!ctx->entry)) {
-               elm_object_part_content_unset(ctx->popup,
-                                               "elm.swallow.content");
-               elm_object_signal_emit(ctx->popup, "hide,content", "gui");
-               evas_object_hide(ctx->box);
-               return;
-       }
-
-       elm_box_unpack_all(ctx->box);
-       if (ctx->message) {
-               elm_box_pack_end(ctx->box, ctx->message);
-               evas_object_show(ctx->message);
-       }
-       if (ctx->entry) {
-               elm_box_pack_end(ctx->box, ctx->entry);
-               evas_object_show(ctx->entry);
-       }
-
-       elm_object_part_content_set(ctx->popup, "elm.swallow.content",
-                                       ctx->box);
-       elm_object_signal_emit(ctx->popup, "show,content", "gui");
-
-       /* HACK: elm_entry is not evaluating properly and the text is
-        * not centered as it should be. Then we must force a
-        * calculation from an timer.
-        */
-       if (ctx->recalc_timer)
-               ecore_timer_del(ctx->recalc_timer);
-       ctx->recalc_timer = ecore_timer_add(
-               0.02, _gui_simple_popup_entries_reeval, ctx);
-}
-
-void gui_simple_popup_message_set(Evas_Object *p, const char *msg)
-{
-       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
-       Evas_Object *en;
-
-       EINA_SAFETY_ON_NULL_RETURN(ctx);
-
-       if (!msg) {
-               if (ctx->message)
-                       evas_object_del(ctx->message);
-               _gui_simple_popup_reeval_content(ctx);
-               return;
-       }
-
-       if (ctx->message)
-               en = ctx->message;
-       else {
-               en = ctx->message = elm_entry_add(p);
-               elm_object_style_set(en, "dialer-popup");
-               elm_entry_editable_set(en, EINA_FALSE);
-               elm_entry_scrollable_set(en, EINA_TRUE);
-#if ELM_VERSION_MAJOR == 1 && ELM_VERSION_MINOR < 7
-               /* old, deprecated api */
-               elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF,
-                                               ELM_SCROLLER_POLICY_AUTO);
-#else
-               elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF,
-                                       ELM_SCROLLER_POLICY_AUTO);
-#endif
-
-               evas_object_event_callback_add(en, EVAS_CALLBACK_DEL,
-                                       _gui_simple_popup_message_del,
-                                       ctx);
-               evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND,
-                                                       EVAS_HINT_EXPAND);
-               evas_object_size_hint_align_set(en, EVAS_HINT_FILL,
-                                               EVAS_HINT_FILL);
-       }
-
-       elm_object_text_set(en, msg);
-       _gui_simple_popup_reeval_content(ctx);
-}
-
-void gui_simple_popup_entry_enable(Evas_Object *p)
-{
-       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
-       Evas_Object *en;
-
-       EINA_SAFETY_ON_NULL_RETURN(ctx);
-
-       if (ctx->entry)
-               return;
-       en = ctx->entry = elm_entry_add(p);
-       elm_object_style_set(en, "dialer-popup-editable");
-       elm_entry_editable_set(en, EINA_TRUE);
-       elm_entry_scrollable_set(en, EINA_TRUE);
-#if ELM_VERSION_MAJOR == 1 && ELM_VERSION_MINOR < 7
-       /* old, deprecated api */
-       elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF,
-                                       ELM_SCROLLER_POLICY_AUTO);
-#else
-       elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF,
-                               ELM_SCROLLER_POLICY_AUTO);
-#endif
-
-       evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND,
-                                               EVAS_HINT_EXPAND);
-       evas_object_size_hint_align_set(en, EVAS_HINT_FILL,
-                                       EVAS_HINT_FILL);
-
-       evas_object_event_callback_add(en, EVAS_CALLBACK_DEL,
-                                       _gui_simple_popup_entry_del,
-                                       ctx);
-       _gui_simple_popup_reeval_content(ctx);
-}
-
-void gui_simple_popup_entry_disable(Evas_Object *p)
-{
-       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
-       EINA_SAFETY_ON_NULL_RETURN(ctx);
-       if (!ctx->entry)
-               return;
-       evas_object_del(ctx->entry);
-       _gui_simple_popup_reeval_content(ctx);
-}
-
-const char *gui_simple_popup_entry_get(const Evas_Object *p)
-{
-       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
-       EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL);
-       EINA_SAFETY_ON_NULL_RETURN_VAL(ctx->entry, NULL);
-       return elm_object_text_get(ctx->entry);
-}
-
-void gui_simple_popup_button_dismiss_set(Evas_Object *p)
-{
-       gui_simple_popup_buttons_set(p,
-                                       "Dismiss",
-                                       "dialer",
-                                       _popup_close,
-                                       NULL, NULL, NULL,
-                                       p);
-}
-
-void gui_simple_popup_buttons_set(Evas_Object *p,
-                                       const char *b1_label,
-                                       const char *b1_class,
-                                       Evas_Smart_Cb b1_cb,
-                                       const char *b2_label,
-                                       const char *b2_class,
-                                       Evas_Smart_Cb b2_cb,
-                                       const void *data)
-{
-       Evas_Object *bt;
-       unsigned int count = 0;
-
-       if (b1_label) {
-               bt = elm_button_add(p);
-               elm_object_style_set(bt, b1_class ? b1_class : "dialer");
-               elm_object_text_set(bt, b1_label);
-               elm_object_part_content_set(p, "elm.swallow.button1", bt);
-               evas_object_smart_callback_add(bt, "clicked", b1_cb, data);
-               count++;
-       }
-
-       if (b2_label) {
-               const char *part;
-               bt = elm_button_add(p);
-               elm_object_style_set(bt, b2_class ? b2_class : "dialer");
-               elm_object_text_set(bt, b2_label);
-
-               if (count == 1)
-                       part = "elm.swallow.button2";
-               else
-                       part = "elm.swallow.button1";
-
-               elm_object_part_content_set(p, part, bt);
-               evas_object_smart_callback_add(bt, "clicked", b2_cb, data);
-               count++;
-       }
-
-       if (count == 2)
-               elm_object_signal_emit(p, "buttons,2", "gui");
-       else if (count == 1) {
-               elm_object_signal_emit(p, "buttons,1", "gui");
-               elm_object_part_content_set(p, "elm.swallow.button2", NULL);
-       } else {
-               elm_object_signal_emit(p, "buttons,0", "gui");
-               elm_object_part_content_set(p, "elm.swallow.button1", NULL);
-               elm_object_part_content_set(p, "elm.swallow.button2", NULL);
-       }
-}
-
-static void _gui_simple_popup_del(void *data, Evas *e __UNUSED__,
-                                       Evas_Object *o __UNUSED__,
-                                       void *event_info __UNUSED__)
-{
-       Simple_Popup *ctx = data;
-       free(ctx);
-}
-
 Evas_Object *gui_simple_popup(const char *title, const char *message)
 {
-       Evas_Object *p = layout_add(win, "popup");
-       Simple_Popup *ctx;
-
-       EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
-
-       ctx = calloc(1, sizeof(Simple_Popup));
-       EINA_SAFETY_ON_NULL_GOTO(ctx, failed_calloc);
-
-       evas_object_data_set(p, "simple_popup", ctx);
-       ctx->popup = p;
-       evas_object_event_callback_add(p, EVAS_CALLBACK_DEL,
-                                       _gui_simple_popup_del, ctx);
-
-       evas_object_size_hint_weight_set(p, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_win_resize_object_add(win, p);
-
-       ctx->box = elm_box_add(p);
-
-       gui_simple_popup_title_set(p, title);
-       gui_simple_popup_message_set(p, message);
-       gui_simple_popup_button_dismiss_set(p);
-
-       evas_object_show(p);
-
-       return p;
-
-failed_calloc:
-       evas_object_del(p);
-       return NULL;
+       return simple_popup_add(win, title, message);
 }
 
 void gui_activate(void)
index 3ac8db8..8939bcf 100644 (file)
@@ -6,24 +6,6 @@
 
 Evas_Object *gui_simple_popup(const char *title, const char *message);
 
-void gui_simple_popup_title_set(Evas_Object *p, const char *title);
-void gui_simple_popup_message_set(Evas_Object *p, const char *msg);
-
-void gui_simple_popup_button_dismiss_set(Evas_Object *p);
-void gui_simple_popup_buttons_set(Evas_Object *p,
-                                       const char *b1_label,
-                                       const char *b1_class,
-                                       Evas_Smart_Cb b1_cb,
-                                       const char *b2_label,
-                                       const char *b2_class,
-                                       Evas_Smart_Cb b2_cb,
-                                       const void *data);
-
-void gui_simple_popup_entry_enable(Evas_Object *p);
-void gui_simple_popup_entry_disable(Evas_Object *p);
-const char *gui_simple_popup_entry_get(const Evas_Object *p);
-
-
 void gui_activate(void);
 void gui_number_set(const char *number, Eina_Bool auto_dial);
 
index 498bc34..472064e 100644 (file)
@@ -12,6 +12,7 @@
 #include "log.h"
 #include "util.h"
 #include "gui.h"
+#include "simple-popup.h"
 
 #ifndef EET_COMPRESSION_DEFAULT
 #define EET_COMPRESSION_DEFAULT 1
@@ -635,7 +636,7 @@ static void _history_clear(History *ctx)
        ctx->clear_popup = p = gui_simple_popup("Clear History",
                                "Do you want to clear all history entries?");
 
-       gui_simple_popup_buttons_set(p,
+       simple_popup_buttons_set(p,
                                        "Dismiss",
                                        "dialer",
                                        _history_clear_cancel,
index 47566cc..dd0e2eb 100644 (file)
@@ -8,6 +8,7 @@
 #include "ofono.h"
 #include "ussd.h"
 #include "util.h"
+#include "simple-popup.h"
 
 /* timeout before a popup is show for supplementary services.  It is
  * not shown immediately as the call may fail as "not supported" in
@@ -262,10 +263,10 @@ static void _ss_initiate_reply(void *data, OFono_Error err, const char *str)
                _dial(ctx);
                evas_object_del(ctx->ss_popup);
        } else if (err == OFONO_ERROR_OFFLINE) {
-               gui_simple_popup_title_set(ctx->ss_popup, "Offline");
-               gui_simple_popup_message_set(ctx->ss_popup,
+               simple_popup_title_set(ctx->ss_popup, "Offline");
+               simple_popup_message_set(ctx->ss_popup,
                                                "System is Offline");
-               gui_simple_popup_button_dismiss_set(ctx->ss_popup);
+               simple_popup_button_dismiss_set(ctx->ss_popup);
                evas_object_show(ctx->ss_popup);
        } else if (err != OFONO_ERROR_NONE) {
                char buf[256];
@@ -276,9 +277,9 @@ static void _ss_initiate_reply(void *data, OFono_Error err, const char *str)
 
                snprintf(buf, sizeof(buf), "Could not complete.<br>Error: %s",
                                ofono_error_message_get(err));
-               gui_simple_popup_title_set(ctx->ss_popup, "Error");
-               gui_simple_popup_message_set(ctx->ss_popup, buf);
-               gui_simple_popup_button_dismiss_set(ctx->ss_popup);
+               simple_popup_title_set(ctx->ss_popup, "Error");
+               simple_popup_message_set(ctx->ss_popup, buf);
+               simple_popup_button_dismiss_set(ctx->ss_popup);
                evas_object_show(ctx->ss_popup);
        } else {
                evas_object_del(ctx->ss_popup);
diff --git a/dialer/simple-popup.c b/dialer/simple-popup.c
new file mode 100644 (file)
index 0000000..ccfc132
--- /dev/null
@@ -0,0 +1,303 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <Elementary.h>
+
+#include "simple-popup.h"
+#include "util.h"
+
+typedef struct _Simple_Popup
+{
+       Evas_Object *popup;
+       Evas_Object *box;
+       Evas_Object *message;
+       Evas_Object *entry;
+       Ecore_Timer *recalc_timer; /* HACK */
+} Simple_Popup;
+
+static void _popup_close(void *data, Evas_Object *bt __UNUSED__,
+                               void *event __UNUSED__)
+{
+       Evas_Object *popup = data;
+       evas_object_del(popup);
+}
+
+void simple_popup_title_set(Evas_Object *p, const char *title)
+{
+       if (title) {
+               elm_object_part_text_set(p, "elm.text.title", title);
+               elm_object_signal_emit(p, "show,title", "gui");
+       } else {
+               elm_object_part_text_set(p, "elm.text.title", "");
+               elm_object_signal_emit(p, "hide,title", "gui");
+       }
+}
+
+/* HACK: force recalc from an idler to fix elm_entry problem */
+static Eina_Bool _simple_popup_entries_reeval(void *data)
+{
+       Simple_Popup *ctx = data;
+       if (ctx->message)
+               elm_entry_calc_force(ctx->message);
+       if (ctx->entry)
+               elm_entry_calc_force(ctx->entry);
+       ctx->recalc_timer = NULL;
+       return EINA_FALSE;
+}
+
+static void _simple_popup_timer_cancel_if_needed(Simple_Popup *ctx)
+{
+       if (!ctx->recalc_timer)
+               return;
+       if (ctx->message || ctx->entry)
+               return;
+       ecore_timer_del(ctx->recalc_timer);
+       ctx->recalc_timer = NULL;
+}
+
+static void _simple_popup_message_del(void *data, Evas *e __UNUSED__,
+                                               Evas_Object *en __UNUSED__,
+                                               void *einfo __UNUSED__)
+{
+       Simple_Popup *ctx = data;
+       ctx->message = NULL;
+       _simple_popup_timer_cancel_if_needed(ctx);
+}
+
+static void _simple_popup_entry_del(void *data, Evas *e __UNUSED__,
+                                       Evas_Object *en __UNUSED__,
+                                       void *einfo __UNUSED__)
+{
+       Simple_Popup *ctx = data;
+       ctx->entry = NULL;
+       _simple_popup_timer_cancel_if_needed(ctx);
+}
+
+static void _simple_popup_reeval_content(Simple_Popup *ctx)
+{
+       if ((!ctx->message) && (!ctx->entry)) {
+               elm_object_part_content_unset(ctx->popup,
+                                               "elm.swallow.content");
+               elm_object_signal_emit(ctx->popup, "hide,content", "gui");
+               evas_object_hide(ctx->box);
+               return;
+       }
+
+       elm_box_unpack_all(ctx->box);
+       if (ctx->message) {
+               elm_box_pack_end(ctx->box, ctx->message);
+               evas_object_show(ctx->message);
+       }
+       if (ctx->entry) {
+               elm_box_pack_end(ctx->box, ctx->entry);
+               evas_object_show(ctx->entry);
+       }
+
+       elm_object_part_content_set(ctx->popup, "elm.swallow.content",
+                                       ctx->box);
+       elm_object_signal_emit(ctx->popup, "show,content", "gui");
+
+       /* HACK: elm_entry is not evaluating properly and the text is
+        * not centered as it should be. Then we must force a
+        * calculation from an timer.
+        */
+       if (ctx->recalc_timer)
+               ecore_timer_del(ctx->recalc_timer);
+       ctx->recalc_timer = ecore_timer_add(
+               0.02, _simple_popup_entries_reeval, ctx);
+}
+
+void simple_popup_message_set(Evas_Object *p, const char *msg)
+{
+       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
+       Evas_Object *en;
+
+       EINA_SAFETY_ON_NULL_RETURN(ctx);
+
+       if (!msg) {
+               if (ctx->message)
+                       evas_object_del(ctx->message);
+               _simple_popup_reeval_content(ctx);
+               return;
+       }
+
+       if (ctx->message)
+               en = ctx->message;
+       else {
+               en = ctx->message = elm_entry_add(p);
+               elm_object_style_set(en, "dialer-popup");
+               elm_entry_editable_set(en, EINA_FALSE);
+               elm_entry_scrollable_set(en, EINA_TRUE);
+#ifdef HAVE_TIZEN
+               /* old, deprecated API */
+               elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF,
+                                               ELM_SCROLLER_POLICY_AUTO);
+#else
+               elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF,
+                                       ELM_SCROLLER_POLICY_AUTO);
+#endif
+
+               evas_object_event_callback_add(en, EVAS_CALLBACK_DEL,
+                                       _simple_popup_message_del,
+                                       ctx);
+               evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND,
+                                                       EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(en, EVAS_HINT_FILL,
+                                               EVAS_HINT_FILL);
+       }
+
+       elm_object_text_set(en, msg);
+       _simple_popup_reeval_content(ctx);
+}
+
+void simple_popup_entry_enable(Evas_Object *p)
+{
+       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
+       Evas_Object *en;
+
+       EINA_SAFETY_ON_NULL_RETURN(ctx);
+
+       if (ctx->entry)
+               return;
+       en = ctx->entry = elm_entry_add(p);
+       elm_object_style_set(en, "dialer-popup-editable");
+       elm_entry_editable_set(en, EINA_TRUE);
+       elm_entry_scrollable_set(en, EINA_TRUE);
+#ifdef HAVE_TIZEN
+       /* old, deprecated API */
+       elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF,
+                                       ELM_SCROLLER_POLICY_AUTO);
+#else
+       elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF,
+                               ELM_SCROLLER_POLICY_AUTO);
+#endif
+
+       evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND,
+                                               EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(en, EVAS_HINT_FILL,
+                                       EVAS_HINT_FILL);
+
+       evas_object_event_callback_add(en, EVAS_CALLBACK_DEL,
+                                       _simple_popup_entry_del,
+                                       ctx);
+       _simple_popup_reeval_content(ctx);
+}
+
+void simple_popup_entry_disable(Evas_Object *p)
+{
+       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
+       EINA_SAFETY_ON_NULL_RETURN(ctx);
+       if (!ctx->entry)
+               return;
+       evas_object_del(ctx->entry);
+       _simple_popup_reeval_content(ctx);
+}
+
+const char *simple_popup_entry_get(const Evas_Object *p)
+{
+       Simple_Popup *ctx = evas_object_data_get(p, "simple_popup");
+       EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL);
+       EINA_SAFETY_ON_NULL_RETURN_VAL(ctx->entry, NULL);
+       return elm_object_text_get(ctx->entry);
+}
+
+void simple_popup_button_dismiss_set(Evas_Object *p)
+{
+       simple_popup_buttons_set(p,
+                                       "Dismiss",
+                                       "dialer",
+                                       _popup_close,
+                                       NULL, NULL, NULL,
+                                       p);
+}
+
+void simple_popup_buttons_set(Evas_Object *p,
+                                       const char *b1_label,
+                                       const char *b1_class,
+                                       Evas_Smart_Cb b1_cb,
+                                       const char *b2_label,
+                                       const char *b2_class,
+                                       Evas_Smart_Cb b2_cb,
+                                       const void *data)
+{
+       Evas_Object *bt;
+       unsigned int count = 0;
+
+       if (b1_label) {
+               bt = elm_button_add(p);
+               elm_object_style_set(bt, b1_class ? b1_class : "dialer");
+               elm_object_text_set(bt, b1_label);
+               elm_object_part_content_set(p, "elm.swallow.button1", bt);
+               evas_object_smart_callback_add(bt, "clicked", b1_cb, data);
+               count++;
+       }
+
+       if (b2_label) {
+               const char *part;
+               bt = elm_button_add(p);
+               elm_object_style_set(bt, b2_class ? b2_class : "dialer");
+               elm_object_text_set(bt, b2_label);
+
+               if (count == 1)
+                       part = "elm.swallow.button2";
+               else
+                       part = "elm.swallow.button1";
+
+               elm_object_part_content_set(p, part, bt);
+               evas_object_smart_callback_add(bt, "clicked", b2_cb, data);
+               count++;
+       }
+
+       if (count == 2)
+               elm_object_signal_emit(p, "buttons,2", "gui");
+       else if (count == 1) {
+               elm_object_signal_emit(p, "buttons,1", "gui");
+               elm_object_part_content_set(p, "elm.swallow.button2", NULL);
+       } else {
+               elm_object_signal_emit(p, "buttons,0", "gui");
+               elm_object_part_content_set(p, "elm.swallow.button1", NULL);
+               elm_object_part_content_set(p, "elm.swallow.button2", NULL);
+       }
+}
+
+static void _simple_popup_del(void *data, Evas *e __UNUSED__,
+                                       Evas_Object *o __UNUSED__,
+                                       void *event_info __UNUSED__)
+{
+       Simple_Popup *ctx = data;
+       free(ctx);
+}
+
+Evas_Object *simple_popup_add(Evas_Object *win,
+                               const char *title, const char *message)
+{
+       Evas_Object *p = layout_add(win, "popup");
+       Simple_Popup *ctx;
+
+       EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
+
+       ctx = calloc(1, sizeof(Simple_Popup));
+       EINA_SAFETY_ON_NULL_GOTO(ctx, failed_calloc);
+
+       evas_object_data_set(p, "simple_popup", ctx);
+       ctx->popup = p;
+       evas_object_event_callback_add(p, EVAS_CALLBACK_DEL,
+                                       _simple_popup_del, ctx);
+
+       evas_object_size_hint_weight_set(p, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(win, p);
+
+       ctx->box = elm_box_add(p);
+
+       simple_popup_title_set(p, title);
+       simple_popup_message_set(p, message);
+       simple_popup_button_dismiss_set(p);
+
+       evas_object_show(p);
+
+       return p;
+
+failed_calloc:
+       evas_object_del(p);
+       return NULL;
+}
diff --git a/dialer/simple-popup.h b/dialer/simple-popup.h
new file mode 100644 (file)
index 0000000..f456bf3
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef _EFL_OFONO_SIMPLE_POPUP_H__
+#define _EFL_OFONO_SIMPLE_POPUP_H__ 1
+
+Evas_Object *simple_popup_add(Evas_Object *win,
+                               const char *title, const char *message);
+
+void simple_popup_title_set(Evas_Object *p, const char *title);
+void simple_popup_message_set(Evas_Object *p, const char *msg);
+
+void simple_popup_button_dismiss_set(Evas_Object *p);
+void simple_popup_buttons_set(Evas_Object *p,
+                               const char *b1_label,
+                               const char *b1_class,
+                               Evas_Smart_Cb b1_cb,
+                               const char *b2_label,
+                               const char *b2_class,
+                               Evas_Smart_Cb b2_cb,
+                               const void *data);
+
+void simple_popup_entry_enable(Evas_Object *p);
+void simple_popup_entry_disable(Evas_Object *p);
+const char *simple_popup_entry_get(const Evas_Object *p);
+
+#endif
index 9e79bfe..3952a01 100644 (file)
@@ -6,6 +6,7 @@
 #include "log.h"
 #include "gui.h"
 #include "ofono.h"
+#include "simple-popup.h"
 
 typedef struct _USSD
 {
@@ -30,11 +31,11 @@ static void _ussd_respond_reply(void *data, OFono_Error err, const char *str)
 
        if (err == OFONO_ERROR_NONE) {
                eina_stringshare_replace(&(ctx->message), str);
-               gui_simple_popup_message_set(ctx->popup, ctx->message);
+               simple_popup_message_set(ctx->popup, ctx->message);
        } else if (err == OFONO_ERROR_OFFLINE) {
-               gui_simple_popup_title_set(ctx->popup, "Offline");
-               gui_simple_popup_message_set(ctx->popup, "System is Offline");
-               gui_simple_popup_button_dismiss_set(ctx->popup);
+               simple_popup_title_set(ctx->popup, "Offline");
+               simple_popup_message_set(ctx->popup, "System is Offline");
+               simple_popup_button_dismiss_set(ctx->popup);
        } else {
                char buf[256];
 
@@ -49,8 +50,8 @@ static void _ussd_respond_reply(void *data, OFono_Error err, const char *str)
                                        "Could not complete.<br>Error: %s.",
                                        ofono_error_message_get(err));
 
-               gui_simple_popup_title_set(ctx->popup, "Error");
-               gui_simple_popup_message_set(ctx->popup, buf);
+               simple_popup_title_set(ctx->popup, "Error");
+               simple_popup_message_set(ctx->popup, buf);
        }
 }
 
@@ -58,7 +59,7 @@ static void _ussd_respond(void *data, Evas_Object *o __UNUSED__,
                                void *event_info __UNUSED__)
 {
        USSD *ctx = data;
-       const char *markup = gui_simple_popup_entry_get(ctx->popup);
+       const char *markup = simple_popup_entry_get(ctx->popup);
        char *utf8;
 
        DBG("ctx=%p, markup=%s, pending=%p, popup=%p",
@@ -76,8 +77,8 @@ static void _ussd_respond(void *data, Evas_Object *o __UNUSED__,
        ctx->pending = ofono_ussd_respond(utf8, _ussd_respond_reply, ctx);
        free(utf8);
 
-       gui_simple_popup_message_set(ctx->popup, NULL);
-       gui_simple_popup_entry_disable(ctx->popup);
+       simple_popup_message_set(ctx->popup, NULL);
+       simple_popup_entry_disable(ctx->popup);
 }
 
 static void _ussd_cancel_reply(void *data, OFono_Error e)
@@ -110,11 +111,11 @@ static void _ofono_changed(void *data)
                return;
 
        if (state != OFONO_USSD_STATE_USER_RESPONSE) {
-               gui_simple_popup_entry_disable(ctx->popup);
-               gui_simple_popup_button_dismiss_set(ctx->popup);
+               simple_popup_entry_disable(ctx->popup);
+               simple_popup_button_dismiss_set(ctx->popup);
        } else {
-               gui_simple_popup_entry_enable(ctx->popup);
-               gui_simple_popup_buttons_set(ctx->popup,
+               simple_popup_entry_enable(ctx->popup);
+               simple_popup_buttons_set(ctx->popup,
                                                "Respond",
                                                "dialer",
                                                _ussd_respond,