move gui_layout_add() from gui.h to layout_add() in utils.h
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Fri, 7 Sep 2012 19:12:47 +0000 (16:12 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Fri, 7 Sep 2012 19:12:47 +0000 (16:12 -0300)
Additionally add utils_init() that will setup the theme to be used by
default.

This commit is in preparation to create a new libofono-efl-utils to be
used by dialer and other applications.

dialer/callscreen.c
dialer/contacts-tizen.c
dialer/contacts.c
dialer/gui.c
dialer/gui.h
dialer/history.c
dialer/keypad.c
dialer/main.c
dialer/util.c
dialer/util.h

index 0296bd8..76759e4 100644 (file)
@@ -182,7 +182,7 @@ repopulate:
                type = _call_type_get(c);
                number = phone_format(ofono_call_line_id_get(c));
 
-               it = gui_layout_add(ctx->multiparty.bx, "multiparty-details");
+               it = layout_add(ctx->multiparty.bx, "multiparty-details");
                evas_object_size_hint_align_set(it,
                                                EVAS_HINT_FILL, EVAS_HINT_FILL);
                evas_object_show(it);
@@ -530,7 +530,7 @@ static void _call_current_set(Callscreen *ctx, OFono_Call *c)
                }
        } else {
                if (!ctx->gui_activecall) {
-                       ctx->gui_activecall = gui_layout_add(o, "activecall");
+                       ctx->gui_activecall = layout_add(o, "activecall");
                        elm_object_signal_callback_add(
                                ctx->gui_activecall, "clicked", "call",
                                _on_active_call_clicked, ctx);
@@ -1261,7 +1261,7 @@ static void _on_del(void *data, Evas *e __UNUSED__,
 Evas_Object *callscreen_add(Evas_Object *parent)
 {
        Callscreen *ctx;
-       Evas_Object *obj = gui_layout_add(parent, "call");
+       Evas_Object *obj = layout_add(parent, "call");
        EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
 
        ctx = calloc(1, sizeof(Callscreen));
index 619e80e..2dd196b 100644 (file)
@@ -830,7 +830,7 @@ Evas_Object *contacts_add(Evas_Object *parent)
 
        contacts = calloc(1, sizeof(Contacts));
        EINA_SAFETY_ON_NULL_RETURN_VAL(contacts, NULL);
-       contacts->self = gui_layout_add(parent, "contacts_bg");
+       contacts->self = layout_add(parent, "contacts_bg");
        EINA_SAFETY_ON_NULL_GOTO(contacts->self, err_layout);
        evas_object_event_callback_add(contacts->self, EVAS_CALLBACK_DEL,
                                        _on_del, contacts);
index 8d8446b..4e50a3e 100644 (file)
@@ -737,10 +737,10 @@ Evas_Object *contacts_add(Evas_Object *parent)
        EINA_SAFETY_ON_NULL_RETURN_VAL(contacts, NULL);
 
 
-       details = gui_layout_add(parent, "contacts_details");
+       details = layout_add(parent, "contacts_details");
        EINA_SAFETY_ON_NULL_GOTO(details, err_layout);
 
-       obj = gui_layout_add(parent, "contacts_bg");
+       obj = layout_add(parent, "contacts_bg");
        EINA_SAFETY_ON_NULL_GOTO(obj, err_obj);
 
        genlist = elm_genlist_add(obj);
index 289fede..a3003ff 100644 (file)
@@ -24,7 +24,6 @@ static Evas_Object *contacts = NULL;
 static Evas_Object *history = NULL;
 static Evas_Object *cs = NULL;
 static Evas_Object *flip = NULL;
-static char def_theme[PATH_MAX] = "";
 
 static OFono_Callback_List_Modem_Node *callback_node_modem_changed = NULL;
 static OFono_Callback_List_USSD_Notify_Node *callback_node_ussd_notify = NULL;
@@ -60,18 +59,6 @@ OFono_Pending *gui_dial(const char *number)
        return ofono_dial(copy, NULL, _dial_reply, copy);
 }
 
-Evas_Object *gui_layout_add(Evas_Object *parent, const char *style)
-{
-       Evas_Object *layout = elm_layout_add(parent);
-       if (!elm_layout_theme_set(layout, "layout", "dialer", style)) {
-               CRITICAL("No theme for 'elm/layout/dialer/%s' at %s",
-                               style, def_theme);
-               evas_object_del(layout);
-               return NULL;
-       }
-       return layout;
-}
-
 static void _gui_show(Evas_Object *o)
 {
        if (o == keypad)
@@ -346,7 +333,7 @@ static void _gui_simple_popup_del(void *data, Evas *e __UNUSED__,
 
 Evas_Object *gui_simple_popup(const char *title, const char *message)
 {
-       Evas_Object *p = gui_layout_add(win, "popup");
+       Evas_Object *p = layout_add(win, "popup");
        Simple_Popup *ctx;
 
        EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
@@ -525,7 +512,7 @@ static void _ofono_ussd_notify(void *data __UNUSED__, Eina_Bool needs_reply,
        ussd_start(message);
 }
 
-Eina_Bool gui_init(const char *theme)
+Eina_Bool gui_init(void)
 {
        Evas_Object *lay, *obj;
        Evas_Coord w, h;
@@ -533,31 +520,6 @@ Eina_Bool gui_init(const char *theme)
        /* dialer should never, ever quit */
        elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE);
 
-       elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
-       elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
-       elm_app_info_set(gui_init, "ofono-efl", "themes/default.edj");
-
-       snprintf(def_theme, sizeof(def_theme), "%s/themes/default.edj",
-                       elm_app_data_dir_get());
-
-       elm_theme_extension_add(NULL, def_theme);
-       if (!theme)
-               elm_theme_overlay_add(NULL, def_theme);
-       else {
-               char tmp[PATH_MAX];
-               if (theme[0] != '/') {
-                       if (eina_str_has_suffix(theme, ".edj")) {
-                               snprintf(tmp, sizeof(tmp), "%s/themes/%s",
-                                               elm_app_data_dir_get(), theme);
-                       } else {
-                               snprintf(tmp, sizeof(tmp), "%s/themes/%s.edj",
-                                               elm_app_data_dir_get(), theme);
-                       }
-                       theme = tmp;
-               }
-               elm_theme_overlay_add(NULL, theme);
-       }
-
        win = elm_win_util_standard_add("ofono-dialer", "oFono Dialer");
        EINA_SAFETY_ON_NULL_RETURN_VAL(win, EINA_FALSE);
        elm_win_autodel_set(win, EINA_FALSE);
@@ -576,7 +538,7 @@ Eina_Bool gui_init(const char *theme)
                                        _gui_call_sync, NULL);
        evas_object_show(flip);
 
-       main_layout = lay = gui_layout_add(win, "main");
+       main_layout = lay = layout_add(win, "main");
        EINA_SAFETY_ON_NULL_RETURN_VAL(lay, EINA_FALSE);
        evas_object_size_hint_weight_set(lay,
                                EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
index 85d45d7..3ac8db8 100644 (file)
@@ -4,8 +4,6 @@
 #include "contacts.h"
 #include "ofono.h"
 
-Evas_Object *gui_layout_add(Evas_Object *parent, const char *style);
-
 Evas_Object *gui_simple_popup(const char *title, const char *message);
 
 void gui_simple_popup_title_set(Evas_Object *p, const char *title);
@@ -36,7 +34,7 @@ void gui_contacts_show(void);
 void gui_call_enter(void);
 void gui_call_exit(void);
 
-Eina_Bool gui_init(const char *theme);
+Eina_Bool gui_init(void);
 void gui_shutdown(void);
 
 Contact_Info *gui_contact_search(const char *number, const char **type);
index 488f28d..498bc34 100644 (file)
@@ -764,7 +764,7 @@ static Evas_Object *_item_content_get(void *data, Evas_Object *obj,
        Evas_Object *btn = NULL;
 
        if (strcmp(part, "call.swallow.more") == 0) {
-               btn = gui_layout_add(obj, "history/img");
+               btn = layout_add(obj, "history/img");
                EINA_SAFETY_ON_NULL_RETURN_VAL(btn, NULL);
                elm_object_signal_callback_add(btn, "clicked,more", "gui",
                                                _on_more_clicked, NULL);
@@ -823,7 +823,7 @@ Evas_Object *history_add(Evas_Object *parent)
        history = calloc(1, sizeof(History));
        EINA_SAFETY_ON_NULL_RETURN_VAL(history, NULL);
 
-       history->self = obj = gui_layout_add(parent, "history_bg");
+       history->self = obj = layout_add(parent, "history_bg");
        EINA_SAFETY_ON_NULL_GOTO(obj, err_layout);
 
        genlist_all = elm_genlist_add(obj);
index a19b9c3..47566cc 100644 (file)
@@ -504,7 +504,7 @@ static void _on_del(void *data, Evas *e __UNUSED__,
 Evas_Object *keypad_add(Evas_Object *parent)
 {
        Keypad *ctx;
-       Evas_Object *obj = gui_layout_add(parent, "keypad");
+       Evas_Object *obj = layout_add(parent, "keypad");
        EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
 
        ctx = calloc(1, sizeof(Keypad));
index 12449a7..1422ead 100644 (file)
@@ -8,6 +8,7 @@
 #include "ofono.h"
 #include "gui.h"
 #include "rc.h"
+#include "util.h"
 
 #include <Ecore_Getopt.h>
 
@@ -166,18 +167,26 @@ EAPI int elm_main(int argc, char **argv)
                ofono_modem_type_require(def_modem_type);
        }
 
-       if (!gui_init(theme)) {
+       if (!util_init(theme)) {
                CRITICAL("Could not setup graphical user interface");
                _app_exit_code = EXIT_FAILURE;
                goto end_ofono;
        }
 
+       if (!gui_init()) {
+               CRITICAL("Could not setup graphical user interface");
+               _app_exit_code = EXIT_FAILURE;
+               goto end_util;
+       }
+
        INF("Entering main loop");
        elm_run();
        INF("Quit main loop");
 
        gui_shutdown();
 
+end_util:
+       util_shutdown();
 end_ofono:
        ofono_shutdown();
 end_rc:
index e906d37..5231e5d 100644 (file)
@@ -9,6 +9,9 @@
 
 #include "gui.h"
 #include "util.h"
+#include "log.h"
+
+static char def_theme[PATH_MAX] = "";
 
 /* TODO: find a configurable way to format the number.
  * Right now it's: 1-234-567-8901 as per
@@ -120,3 +123,49 @@ Evas_Object *picture_icon_get(Evas_Object *parent, const char *picture)
        }
        return icon;
 }
+
+Evas_Object *layout_add(Evas_Object *parent, const char *style)
+{
+       Evas_Object *layout = elm_layout_add(parent);
+       if (!elm_layout_theme_set(layout, "layout", "dialer", style)) {
+               CRITICAL("No theme for 'elm/layout/dialer/%s' at %s",
+                               style, def_theme);
+               evas_object_del(layout);
+               return NULL;
+       }
+       return layout;
+}
+
+Eina_Bool util_init(const char *theme)
+{
+       elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
+       elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
+       elm_app_info_set(util_init, "ofono-efl", "themes/default.edj");
+
+       snprintf(def_theme, sizeof(def_theme), "%s/themes/default.edj",
+                       elm_app_data_dir_get());
+
+       elm_theme_extension_add(NULL, def_theme);
+       if (!theme)
+               elm_theme_overlay_add(NULL, def_theme);
+       else {
+               char tmp[PATH_MAX];
+               if (theme[0] != '/') {
+                       if (eina_str_has_suffix(theme, ".edj")) {
+                               snprintf(tmp, sizeof(tmp), "%s/themes/%s",
+                                               elm_app_data_dir_get(), theme);
+                       } else {
+                               snprintf(tmp, sizeof(tmp), "%s/themes/%s.edj",
+                                               elm_app_data_dir_get(), theme);
+                       }
+                       theme = tmp;
+               }
+               elm_theme_overlay_add(NULL, theme);
+       }
+
+       return EINA_TRUE;
+}
+
+void util_shutdown(void)
+{
+}
index ee23986..e5d60fe 100644 (file)
@@ -14,4 +14,9 @@ char *date_format(time_t date);
 
 Evas_Object *picture_icon_get(Evas_Object *parent, const char *picture);
 
+Evas_Object *layout_add(Evas_Object *parent, const char *style);
+
+Eina_Bool util_init(const char *theme);
+void util_shutdown(void);
+
 #endif