2 # include "elementary_config.h"
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
7 typedef struct _App_Data App_Data;
11 Eina_Bool wm_rot_supported;
13 int available_rots[4];
20 _bt_available_rots_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
22 Evas_Object *win = (Evas_Object *)(data);
23 App_Data *ad = evas_object_data_get(win, "ad");
29 if (!ad->wm_rot_supported) return;
31 EINA_LIST_FOREACH(ad->chs, l, o)
33 if (!elm_check_state_get(o)) continue;
34 str = elm_object_text_get(o);
36 ad->available_rots[i] = atoi(str);
42 elm_win_wm_rotation_available_rotations_set
43 (win, ad->available_rots, ad->count);
47 _bt_preferred_rot_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
49 Evas_Object *win = (Evas_Object *)(data);
50 App_Data *ad = evas_object_data_get(win, "ad");
52 if (!ad->wm_rot_supported) return;
54 Evas_Object *rd = elm_radio_selected_object_get(ad->rdg);
57 const char *str = elm_object_text_get(rd);
60 if (!strcmp(str, "Unset"))
65 elm_win_wm_rotation_preferred_rotation_set(win, rot);
70 _win_wm_rotation_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
72 Evas_Object *win = (Evas_Object *)(data);
73 App_Data *ad = evas_object_data_get(win, "ad");
74 int rot = elm_win_rotation_get(win);
77 if (!ad->wm_rot_supported) return;
79 eina_convert_itoa(rot, buf);
80 elm_object_text_set(ad->lb, eina_stringshare_add(buf));
84 _win_del_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
86 App_Data *ad = evas_object_data_get(obj, "ad");
89 if (ad->wm_rot_supported)
91 EINA_LIST_FREE(ad->chs, o)
92 evas_object_data_del(o, "rotation");
99 test_win_wm_rotation(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
102 Evas_Object *win, *bx, *bx2, *lb, *ch, *bt, *en, *rd, *rdg = NULL;
106 if (!(ad = calloc(1, sizeof(App_Data)))) return;
108 win = elm_win_util_standard_add("wmrotation", "WMRotation");
109 elm_win_autodel_set(win, EINA_TRUE);
110 evas_object_data_set(win, "ad", ad);
112 bx = elm_box_add(win);
113 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114 elm_win_resize_object_add(win, bx);
116 lb = elm_label_add(win);
117 elm_object_text_set(lb, "<b>Window manager rotation test</b>");
118 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
119 elm_box_pack_end(bx, lb);
120 evas_object_show(lb);
122 ad->wm_rot_supported = elm_win_wm_rotation_supported_get(win);
123 if (ad->wm_rot_supported)
125 int rots[] = { 0, 90, 270 };
126 elm_win_wm_rotation_available_rotations_set(win, rots, (sizeof(rots) / sizeof(int)));
127 elm_win_wm_rotation_preferred_rotation_set(win, 90);
129 bx2 = elm_box_add(win);
130 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
131 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, 0.0);
132 elm_box_align_set(bx2, 0.0, 0.5);
133 elm_box_horizontal_set(bx2, EINA_TRUE);
134 elm_box_pack_end(bx, bx2);
135 evas_object_show(bx2);
137 for (i = 0; i < 4; i++)
139 ch = elm_check_add(win);
140 eina_convert_itoa((i * 90), buf);
141 elm_object_text_set(ch, eina_stringshare_add(buf));
142 evas_object_size_hint_weight_set(ch, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
143 elm_box_pack_end(bx2, ch);
144 evas_object_show(ch);
146 if (i != 2) elm_check_state_set(ch, 1);
148 ad->chs = eina_list_append(ad->chs, ch);
151 bt = elm_button_add(win);
152 elm_object_text_set(bt, "Available rotations");
153 evas_object_smart_callback_add(bt, "clicked", _bt_available_rots_set, win);
154 elm_box_pack_end(bx, bt);
155 evas_object_show(bt);
157 bx2 = elm_box_add(win);
158 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
159 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, 0.0);
160 elm_box_align_set(bx2, 0.0, 0.5);
161 elm_box_horizontal_set(bx2, EINA_TRUE);
162 elm_box_pack_end(bx, bx2);
163 evas_object_show(bx2);
165 for (i = 0; i < 5; i++)
167 rd = elm_radio_add(win);
169 elm_radio_state_value_set(rd, i);
170 elm_radio_group_add(rd, rdg);
173 elm_object_text_set(rd, "Unset");
176 eina_convert_itoa(((i - 1) * 90), buf);
177 elm_object_text_set(rd, eina_stringshare_add(buf));
180 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
181 elm_box_pack_end(bx2, rd);
182 evas_object_show(rd);
185 elm_radio_value_set(rdg, 2);
188 bt = elm_button_add(win);
189 elm_object_text_set(bt, "Preferred rotation");
190 evas_object_smart_callback_add(bt, "clicked", _bt_preferred_rot_set, win);
191 elm_box_pack_end(bx, bt);
192 evas_object_show(bt);
194 evas_object_smart_callback_add(win, "wm,rotation,changed", _win_wm_rotation_changed_cb, win);
197 en = elm_entry_add(win);
198 elm_entry_single_line_set(en, EINA_TRUE);
199 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
200 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
201 elm_box_pack_end(bx, en);
202 evas_object_show(en);
204 lb = elm_label_add(win);
205 elm_object_text_set(lb, "N/A");
206 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
207 elm_box_pack_end(bx, lb);
208 evas_object_show(lb);
211 evas_object_smart_callback_add(win, "delete,request", _win_del_cb, NULL);
213 evas_object_resize(win, 480, 400);
214 evas_object_show(bx);
215 evas_object_show(win);