1 #include <Elementary.h>
4 # include "elementary_config.h"
6 #ifndef ELM_LIB_QUICKLAUNCH
9 _print_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
11 printf("bubble clicked\n");
16 unsigned int state; /* What state we are testing */
17 Evas_Object *win; /* Parent Window of widgets */
18 void *box; /* Use this to get box content */
20 typedef struct _api_data api_data;
26 BUBBLE_SET_ICON_CONTENT,
29 typedef enum _api_state api_state;
32 set_api_state(api_data *api)
34 const Eina_List *items = elm_box_children_get(api->box);
35 if(!eina_list_count(items))
39 { /* Put all api-changes under switch */
40 case BUBBLE_SET_CORNER_1:
41 elm_bubble_pos_set(eina_list_nth(items, 0), ELM_BUBBLE_POS_BOTTOM_LEFT);
42 elm_object_text_set(elm_object_content_get(eina_list_nth(items, 0)),
43 "Corner: base (bottom-left) - with icon");
44 elm_bubble_pos_set(eina_list_nth(items, 1), ELM_BUBBLE_POS_TOP_RIGHT);
45 elm_object_text_set(elm_object_content_get(eina_list_nth(items, 1)),
46 "Corner: base (top-right) - no icon");
49 case BUBBLE_SET_CORNER_2:
50 elm_bubble_pos_set(eina_list_nth(items, 0), ELM_BUBBLE_POS_TOP_RIGHT);
51 elm_object_text_set(elm_object_content_get(eina_list_nth(items, 0)),
52 "Corner: base (top-right) - with icon");
53 elm_bubble_pos_set(eina_list_nth(items, 1), ELM_BUBBLE_POS_BOTTOM_LEFT);
54 elm_object_text_set(elm_object_content_get(eina_list_nth(items, 1)),
55 "Corner: base (bottom-left) - no icon");
58 case BUBBLE_SET_ICON_CONTENT:
61 Evas_Object *ct, *ic = elm_icon_add(api->win);
63 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
64 elm_icon_file_set(ic, buf, NULL);
65 elm_icon_scale_set(ic, 0, 0);
66 elm_object_content_set(eina_list_nth(items, 0), ic);
67 ct = elm_label_add(api->win);
68 elm_object_text_set(ct, "Using icon as top-bubble content");
69 elm_object_content_set(eina_list_nth(items, 1), ct);
70 evas_object_size_hint_align_set(ic, 0.5, 0.5);
84 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
85 { /* Will add here a SWITCH command containing code to modify test-object */
86 /* in accordance a->state value. */
90 printf("clicked event on API Button: api_state=<%d>\n", a->state);
93 sprintf(str, "Next API function (%u)", a->state);
94 elm_object_text_set(obj, str);
95 elm_object_disabled_set(obj, a->state == API_STATE_LAST);
99 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
106 test_bubble(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
108 Evas_Object *win, *bg, *bx, *ic, *bb, *ct, *bxx, *bt;
110 api_data *api = calloc(1, sizeof(api_data));
112 win = elm_win_add(NULL, "box-vert", ELM_WIN_BASIC);
114 elm_win_title_set(win, "Bubble");
115 elm_win_autodel_set(win, EINA_TRUE);
116 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
118 bg = elm_bg_add(win);
119 elm_win_resize_object_add(win, bg);
120 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121 evas_object_show(bg);
123 bxx = elm_box_add(win);
124 elm_win_resize_object_add(win, bxx);
125 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
126 evas_object_show(bxx);
128 bx = elm_box_add(win);
129 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
131 evas_object_show(bx);
133 bt = elm_button_add(win);
134 elm_object_text_set(bt, "Next API function");
135 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
136 elm_box_pack_end(bxx, bt);
137 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
138 evas_object_show(bt);
140 elm_box_pack_end(bxx, bx);
142 ic = elm_icon_add(win);
143 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
144 elm_icon_file_set(ic, buf, NULL);
145 elm_icon_scale_set(ic, 0, 0);
146 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
148 bb = elm_bubble_add(win);
149 elm_object_text_set(bb, "Message 1");
150 elm_object_part_text_set(bb, "info", "Corner: bottom_right");
151 elm_object_part_content_set(bb, "icon", ic);
152 elm_bubble_pos_set(bb, ELM_BUBBLE_POS_BOTTOM_RIGHT);
153 evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
154 evas_object_show(ic);
155 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
156 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
158 ct = elm_label_add(win);
159 elm_object_text_set(ct,
160 "\"The future of the art: R or G or B?\", by Rusty");
161 elm_object_content_set(bb, ct);
163 elm_box_pack_end(bx, bb);
164 evas_object_show(bb);
166 bb = elm_bubble_add(win);
167 elm_object_text_set(bb, "Message 2");
168 elm_object_part_text_set(bb, "info", "10:32 4/11/2008");
169 evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
170 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
171 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
173 ct = elm_label_add(win);
174 elm_object_text_set(ct, "Corner: base (top-left) - no icon");
175 elm_object_content_set(bb, ct);
177 elm_box_pack_end(bx, bb);
178 evas_object_show(bb);
180 evas_object_show(win);