fixed plugin image size problem
[framework/uifw/elementary.git] / src / bin / test.c
index 6653b57..57e5788 100644 (file)
@@ -1,8 +1,10 @@
-#include <Elementary.h>
-#include "test.h"
 #ifdef HAVE_CONFIG_H
 # include "elementary_config.h"
 #endif
+
+#include <string.h>
+#include <Elementary.h>
+#include "test.h"
 #ifndef ELM_LIB_QUICKLAUNCH
 
 /* all tests prototypes */
@@ -67,6 +69,7 @@ void test_list2(void *data, Evas_Object *obj, void *event_info);
 void test_list3(void *data, Evas_Object *obj, void *event_info);
 void test_list4(void *data, Evas_Object *obj, void *event_info);
 void test_list5(void *data, Evas_Object *obj, void *event_info);
+void test_list6(void *data, Evas_Object *obj, void *event_info);
 void test_inwin(void *data, Evas_Object *obj, void *event_info);
 void test_inwin2(void *data, Evas_Object *obj, void *event_info);
 void test_scaling(void *data, Evas_Object *obj, void *event_info);
@@ -125,6 +128,7 @@ void test_panel(void *data, Evas_Object *obj, void *event_info);
 void test_panes(void *data, Evas_Object *obj, void *event_info);
 void test_calendar(void *data, Evas_Object *obj, void *event_info);
 void test_calendar2(void *data, Evas_Object *obj, void *event_info);
+void test_calendar3(void *data, Evas_Object *obj, void *event_info);
 void test_map(void *data, Evas_Object *obj, void *event_info);
 void test_weather(void *data, Evas_Object *obj, void *event_info);
 void test_flip(void *data, Evas_Object *obj, void *event_info);
@@ -172,6 +176,7 @@ void test_naviframe_complex(void *data, Evas_Object *obj, void *event_info);
 void test_datetime(void *data, Evas_Object *obj, void *event_info);
 void test_popup(void *data, Evas_Object *obj, void *event_info);
 void test_dayselector(void *data, Evas_Object *obj, void *event_info);
+void test_config(void *data, Evas_Object *obj, void *event_info);
 #ifdef HAVE_EMOTION
 void test_video(void *data, Evas_Object *obj, void *event_info);
 #endif
@@ -183,6 +188,10 @@ void test_web_normal(void *data, Evas_Object *obj, void *event_info);
 void test_web_mobile(void *data, Evas_Object *obj, void *event_info);
 #endif
 
+Evas_Object *win, *tbx; // TODO: refactoring
+void *tt;
+Eina_List *tests;
+
 struct elm_test
 {
    const char *icon;
@@ -231,14 +240,81 @@ _frame_clicked(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSE
 }
 
 static void
+_menu_create(const char *option_str)
+{
+   struct elm_test *t = NULL;
+   const char *pcat = NULL;
+   Evas_Object *cfr = NULL, *tbx2 = NULL, *bt = NULL, *ic = NULL;
+   char buf[PATH_MAX];
+   Eina_List *l;
+
+   elm_box_clear(tbx);
+   EINA_LIST_FOREACH(tests, l, t)
+     {
+        if (option_str && !strcasestr(t->name, option_str)) continue;
+        if ((!pcat) || (strcmp(pcat, t->category)))
+          {
+             cfr = elm_frame_add(win);
+             // FIXME: add new style of frame for this
+             evas_object_smart_callback_add(cfr, "clicked", _frame_clicked, NULL);
+             elm_frame_autocollapse_set(cfr, EINA_TRUE);
+             elm_object_text_set(cfr, t->category);
+             evas_object_size_hint_weight_set(cfr, EVAS_HINT_EXPAND, 0.0);
+             evas_object_size_hint_fill_set(cfr, EVAS_HINT_FILL, 0.0);
+             elm_box_pack_end(tbx, cfr);
+             evas_object_show(cfr);
+
+             tbx2 = elm_box_add(win);
+             elm_box_layout_set(tbx2, evas_object_box_layout_flow_horizontal, NULL, NULL);
+             evas_object_size_hint_weight_set(tbx2, EVAS_HINT_EXPAND, 0.0);
+             evas_object_size_hint_align_set(tbx2, EVAS_HINT_FILL, 0.0);
+             elm_box_align_set(tbx2, 0.0, 0.5);
+             elm_object_content_set(cfr, tbx2);
+             evas_object_show(tbx2);
+          }
+        bt = elm_button_add(win);
+        // FIXME: add new style of button for this like efm in e17
+        elm_object_text_set(bt, t->name);
+        if (t->icon)
+          {
+             ic = elm_icon_add(win);
+             snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), t->icon);
+             elm_icon_file_set(ic, buf, NULL);
+             elm_object_part_content_set(bt, "icon", ic);
+             evas_object_show(ic);
+          }
+        elm_box_pack_end(tbx2, bt);
+        evas_object_show(bt);
+        evas_object_smart_callback_add(bt, "clicked", t->cb, NULL);
+        pcat = t->category;
+        if (t == tt) tt = cfr;
+     }
+}
+
+static void
+_entry_activated_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+   const char *str = elm_entry_entry_get(obj);
+   if (!str) return;
+   _menu_create(str);
+}
+
+static void
+_btn_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   const char *str = elm_entry_entry_get(data);
+   if (!str) return;
+   _menu_create(str);
+}
+
+static void
 my_win_main(char *autorun, Eina_Bool test_win_only)
 {
-   Evas_Object *win = NULL, *bg = NULL, *bx0 = NULL, *lb = NULL;
-   Evas_Object *fr = NULL, *tg = NULL, *sc = NULL, *ic = NULL;
-   Evas_Object *tbx = NULL, *cfr = NULL, *tbx2 = NULL, *bt = NULL;
-   Eina_List *tests, *l;
+   Evas_Object *bg = NULL, *bx0 = NULL, *bx1 = NULL, *lb = NULL;
+   Evas_Object *fr = NULL, *tg = NULL, *sc = NULL, *en = NULL;
+   Evas_Object *btn = NULL;
+   Eina_List *l;
    struct elm_test *t = NULL;
-   void *tt;
 
    if (test_win_only) goto add_tests;
    /* Create an elm window - It returns an evas object. This is a little
@@ -252,7 +328,11 @@ my_win_main(char *autorun, Eina_Bool test_win_only)
     * is no parent. "main" is the name of the window - used by the window
     * manager for identifying the window uniquely amongst all the windows
     * within this application (and all instances of the application). The
-    * type is a basic window (the final parameter) */
+    * type is a basic window (the final parameter).
+    * You can call elm_win_util_standard_add() instead. This is a convenient API
+    * for window and bg creation. You don't need to create bg object manually.
+    * You can also set the title of the window at the same time. 
+    *   ex) win = elm_win_util_standard_add("main", "Elementary Tests"); */
    win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
    /* Set the title of the window - This is in the titlebar. */
    elm_win_title_set(win, "Elementary Tests");
@@ -314,6 +394,36 @@ my_win_main(char *autorun, Eina_Bool test_win_only)
    elm_box_pack_end(bx0, tg);
    evas_object_show(tg);
 
+   bx1 = elm_box_add(win);
+   elm_box_horizontal_set(bx1, EINA_TRUE);
+   evas_object_size_hint_weight_set(bx1, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(bx1, EVAS_HINT_FILL, 0.0);
+   elm_box_pack_end(bx0, bx1);
+   evas_object_show(bx1);
+
+   lb = elm_label_add(win);
+   elm_object_text_set(lb, " Search Menu :");
+   evas_object_size_hint_weight_set(lb, 0.0, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(lb, 0.0, EVAS_HINT_FILL);
+   elm_box_pack_end(bx1, lb);
+   evas_object_show(lb);
+
+   en = elm_entry_add(win);
+   elm_entry_single_line_set(en, EINA_TRUE);
+   elm_entry_scrollable_set(en, EINA_TRUE);
+   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_smart_callback_add(en, "activated", _entry_activated_cb, NULL);
+   elm_box_pack_end(bx1, en);
+   evas_object_show(en);
+   elm_object_focus_set(en, EINA_TRUE);
+
+   btn = elm_button_add(win);
+   elm_object_text_set(btn, "Go");
+   evas_object_smart_callback_add(btn, "clicked", _btn_clicked_cb, en);
+   elm_box_pack_end(bx1, btn);
+   evas_object_show(btn);
+
    sc = elm_scroller_add(win);
    elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -424,6 +534,7 @@ add_tests:
    ADD_TEST(NULL, "Lists", "List 3", test_list3);
    ADD_TEST(NULL, "Lists", "List 4", test_list4);
    ADD_TEST(NULL, "Lists", "List 5", test_list5);
+   ADD_TEST(NULL, "Lists", "List 6", test_list6);
    ADD_TEST(NULL, "Lists", "Genlist", test_genlist);
    ADD_TEST(NULL, "Lists", "Genlist 2", test_genlist2);
    ADD_TEST(NULL, "Lists", "Genlist 3", test_genlist3);
@@ -433,7 +544,8 @@ add_tests:
    ADD_TEST(NULL, "Lists", "Genlist Tree", test_genlist6);
    ADD_TEST(NULL, "Lists", "Genlist Group", test_genlist8);
    ADD_TEST(NULL, "Lists", "Genlist Group Tree", test_genlist9);
-   ADD_TEST(NULL, "Lists", "Genlist Mode", test_genlist10);
+   ADD_TEST(NULL, "Lists", "Genlist Decorate Item Mode", test_genlist10);
+   ADD_TEST(NULL, "Lists", "Genlist Decorate All Mode", test_genlist15);
    ADD_TEST(NULL, "Lists", "Genlist Reorder Mode", test_genlist11);
 #ifdef HAVE_EIO
    ADD_TEST(NULL, "Lists", "Genlist Eio", test_eio);
@@ -441,7 +553,6 @@ add_tests:
    ADD_TEST(NULL, "Lists", "Genlist Textblock", test_genlist12);
    ADD_TEST(NULL, "Lists", "Genlist Tree, Insert Sorted", test_genlist13);
    ADD_TEST(NULL, "Lists", "Genlist Tree, Insert Relative", test_genlist14);
-   ADD_TEST(NULL, "Lists", "Genlist Edit Mode", test_genlist15);
    ADD_TEST(NULL, "Lists", "Genlist Flip Mode", test_genlist16);
    ADD_TEST(NULL, "Lists", "Genlist Tree Effect", test_genlist17);
    ADD_TEST(NULL, "Lists", "GenGrid", test_gengrid);
@@ -521,6 +632,7 @@ add_tests:
    //------------------------------//
    ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar);
    ADD_TEST(NULL, "Times & Dates", "Calendar 2", test_calendar2);
+   ADD_TEST(NULL, "Times & Dates", "Calendar 3", test_calendar3);
    ADD_TEST(NULL, "Times & Dates", "Clock", test_clock);
    ADD_TEST(NULL, "Times & Dates", "Clock 2", test_clock2);
    ADD_TEST(NULL, "Times & Dates", "Clock 3", test_clock3);
@@ -565,6 +677,7 @@ add_tests:
    ADD_TEST(NULL, "Micellaneous", "Weather", test_weather);
    ADD_TEST(NULL, "Micellaneous", "Icon Desktops", test_icon_desktops);
    ADD_TEST(NULL, "Micellaneous", "Floating Objects", test_floating);
+   ADD_TEST(NULL, "Micellaneous", "Configuration", test_config);
 
 #undef ADD_TEST
 
@@ -586,58 +699,13 @@ add_tests:
    if (test_win_only)
      {
         EINA_LIST_FREE(tests, t)
-           free (t);
+          free(t);
 
         return;
      }
 
    if (tests)
-     {
-        const char *pcat = NULL;
-
-        EINA_LIST_FREE(tests, t)
-          {
-             if ((!pcat) || (strcmp(pcat, t->category)))
-               {
-                  cfr = elm_frame_add(win);
-                  // FIXME: add new style of frame for this
-                  evas_object_smart_callback_add(cfr, "clicked", _frame_clicked, NULL);
-                  elm_frame_autocollapse_set(cfr, EINA_TRUE);
-                  elm_object_text_set(cfr, t->category);
-                  evas_object_size_hint_weight_set(cfr, EVAS_HINT_EXPAND, 0.0);
-                  evas_object_size_hint_fill_set(cfr, EVAS_HINT_FILL, 0.0);
-                  elm_box_pack_end(tbx, cfr);
-                  evas_object_show(cfr);
-
-                  tbx2 = elm_box_add(win);
-                  elm_box_layout_set(tbx2, evas_object_box_layout_flow_horizontal, NULL, NULL);
-                  evas_object_size_hint_weight_set(tbx2, EVAS_HINT_EXPAND, 0.0);
-                  evas_object_size_hint_align_set(tbx2, EVAS_HINT_FILL, 0.0);
-                  elm_box_align_set(tbx2, 0.0, 0.5);
-                  elm_object_content_set(cfr, tbx2);
-                  evas_object_show(tbx2);
-               }
-             bt = elm_button_add(win);
-             // FIXME: add new style of button for this like efm in e17
-             elm_object_text_set(bt, t->name);
-             if (t->icon)
-               {
-                  char buf[PATH_MAX];
-
-                  ic = elm_icon_add(win);
-                  snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), t->icon);
-                  elm_icon_file_set(ic, buf, NULL);
-                  elm_object_part_content_set(bt, "icon", ic);
-                  evas_object_show(ic);
-               }
-             elm_box_pack_end(tbx2, bt);
-             evas_object_show(bt);
-             evas_object_smart_callback_add(bt, "clicked", t->cb, NULL);
-             pcat = t->category;
-             if (t == tt) tt = cfr;
-             free(t);
-          }
-     }
+     _menu_create(NULL);
 
    /* set an initial window size */
    evas_object_resize(win, 480, 480);