summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2012-04-03 14:26:09 +0000
committerDaniel Juyung Seo <seojuyung2@gmail.com>2012-04-03 14:26:09 +0000
commita3767d5c9d4d0f92369c13d210eb16454d55b635 (patch)
treef8ea6ae30fd6d552009f63c3190495250c9360f3 /src/bin
parenta45a5bd2008cdd24c2b0a97d772c903fd852fb40 (diff)
elm test: Separated test menu creation function.
SVN revision: 69901
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test.c100
1 files changed, 52 insertions, 48 deletions
diff --git a/src/bin/test.c b/src/bin/test.c
index cd27f8235..ab63d3899 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -231,11 +231,60 @@ _frame_clicked(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSE
231} 231}
232 232
233static void 233static void
234_menu_create(Evas_Object *win, Evas_Object *tbx, void **tt, Eina_List *tests, const char *option_str __UNUSED__)
235{
236 struct elm_test *t = NULL;
237 const char *pcat = NULL;
238 Evas_Object *cfr = NULL, *tbx2 = NULL, *bt = NULL, *ic = NULL;
239 char buf[PATH_MAX];
240
241 EINA_LIST_FREE(tests, t)
242 {
243 if ((!pcat) || (strcmp(pcat, t->category)))
244 {
245 cfr = elm_frame_add(win);
246 // FIXME: add new style of frame for this
247 evas_object_smart_callback_add(cfr, "clicked", _frame_clicked, NULL);
248 elm_frame_autocollapse_set(cfr, EINA_TRUE);
249 elm_object_text_set(cfr, t->category);
250 evas_object_size_hint_weight_set(cfr, EVAS_HINT_EXPAND, 0.0);
251 evas_object_size_hint_fill_set(cfr, EVAS_HINT_FILL, 0.0);
252 elm_box_pack_end(tbx, cfr);
253 evas_object_show(cfr);
254
255 tbx2 = elm_box_add(win);
256 elm_box_layout_set(tbx2, evas_object_box_layout_flow_horizontal, NULL, NULL);
257 evas_object_size_hint_weight_set(tbx2, EVAS_HINT_EXPAND, 0.0);
258 evas_object_size_hint_align_set(tbx2, EVAS_HINT_FILL, 0.0);
259 elm_box_align_set(tbx2, 0.0, 0.5);
260 elm_object_content_set(cfr, tbx2);
261 evas_object_show(tbx2);
262 }
263 bt = elm_button_add(win);
264 // FIXME: add new style of button for this like efm in e17
265 elm_object_text_set(bt, t->name);
266 if (t->icon)
267 {
268 ic = elm_icon_add(win);
269 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), t->icon);
270 elm_icon_file_set(ic, buf, NULL);
271 elm_object_part_content_set(bt, "icon", ic);
272 evas_object_show(ic);
273 }
274 elm_box_pack_end(tbx2, bt);
275 evas_object_show(bt);
276 evas_object_smart_callback_add(bt, "clicked", t->cb, NULL);
277 pcat = t->category;
278 if (t == *tt) *tt = cfr;
279 free(t);
280 }
281}
282
283static void
234my_win_main(char *autorun, Eina_Bool test_win_only) 284my_win_main(char *autorun, Eina_Bool test_win_only)
235{ 285{
236 Evas_Object *win = NULL, *bg = NULL, *bx0 = NULL, *lb = NULL; 286 Evas_Object *win = NULL, *bg = NULL, *bx0 = NULL, *lb = NULL;
237 Evas_Object *fr = NULL, *tg = NULL, *sc = NULL, *ic = NULL; 287 Evas_Object *fr = NULL, *tg = NULL, *sc = NULL, *tbx = NULL;
238 Evas_Object *tbx = NULL, *cfr = NULL, *tbx2 = NULL, *bt = NULL;
239 Eina_List *tests, *l; 288 Eina_List *tests, *l;
240 struct elm_test *t = NULL; 289 struct elm_test *t = NULL;
241 void *tt; 290 void *tt;
@@ -596,52 +645,7 @@ add_tests:
596 } 645 }
597 646
598 if (tests) 647 if (tests)
599 { 648 _menu_create(win, tbx, &tt, tests, NULL);
600 const char *pcat = NULL;
601
602 EINA_LIST_FREE(tests, t)
603 {
604 if ((!pcat) || (strcmp(pcat, t->category)))
605 {
606 cfr = elm_frame_add(win);
607 // FIXME: add new style of frame for this
608 evas_object_smart_callback_add(cfr, "clicked", _frame_clicked, NULL);
609 elm_frame_autocollapse_set(cfr, EINA_TRUE);
610 elm_object_text_set(cfr, t->category);
611 evas_object_size_hint_weight_set(cfr, EVAS_HINT_EXPAND, 0.0);
612 evas_object_size_hint_fill_set(cfr, EVAS_HINT_FILL, 0.0);
613 elm_box_pack_end(tbx, cfr);
614 evas_object_show(cfr);
615
616 tbx2 = elm_box_add(win);
617 elm_box_layout_set(tbx2, evas_object_box_layout_flow_horizontal, NULL, NULL);
618 evas_object_size_hint_weight_set(tbx2, EVAS_HINT_EXPAND, 0.0);
619 evas_object_size_hint_align_set(tbx2, EVAS_HINT_FILL, 0.0);
620 elm_box_align_set(tbx2, 0.0, 0.5);
621 elm_object_content_set(cfr, tbx2);
622 evas_object_show(tbx2);
623 }
624 bt = elm_button_add(win);
625 // FIXME: add new style of button for this like efm in e17
626 elm_object_text_set(bt, t->name);
627 if (t->icon)
628 {
629 char buf[PATH_MAX];
630
631 ic = elm_icon_add(win);
632 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), t->icon);
633 elm_icon_file_set(ic, buf, NULL);
634 elm_object_part_content_set(bt, "icon", ic);
635 evas_object_show(ic);
636 }
637 elm_box_pack_end(tbx2, bt);
638 evas_object_show(bt);
639 evas_object_smart_callback_add(bt, "clicked", t->cb, NULL);
640 pcat = t->category;
641 if (t == tt) tt = cfr;
642 free(t);
643 }
644 }
645 649
646 /* set an initial window size */ 650 /* set an initial window size */
647 evas_object_resize(win, 480, 480); 651 evas_object_resize(win, 480, 480);