summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-01-23 14:30:02 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-10-05 12:54:39 +0200
commite39c8091071c6b36f93a5c62f466c111ac01c470 (patch)
tree8cbe4b1f4782e10c9d91422106b836b6cfbd9678
parent9eff1557923fa1679b41545139933c0764f9ad43 (diff)
New widget, Settingspane
Added a new widget called Settingspane, it can display settingscategorys and panels. For more information: https://phab.enlightenment.org/w/elementary_settingspane/
-rw-r--r--data/themes/Makefile.am1
-rw-r--r--data/themes/default.edc2
-rw-r--r--data/themes/edc/elm/settingspane.edc411
-rw-r--r--data/themes/img/back.pngbin0 -> 437 bytes
-rw-r--r--data/themes/img/vshadow.pngbin0 -> 900 bytes
-rw-r--r--src/bin/Makefile.am1
-rw-r--r--src/bin/test.c2
-rw-r--r--src/bin/test_settingspane.c289
-rw-r--r--src/lib/Elementary.h.in1
-rw-r--r--src/lib/Makefile.am132
-rw-r--r--src/lib/elc_settingspane.c1560
-rw-r--r--src/lib/elc_settingspane.h8
-rw-r--r--src/lib/elc_settingspane_eo.h2
-rw-r--r--src/lib/elc_settingspane_legacy.h4
-rw-r--r--src/lib/elm_settingspane.eo107
-rw-r--r--src/lib/elm_settingspane_item.eo167
16 files changed, 2683 insertions, 4 deletions
diff --git a/data/themes/Makefile.am b/data/themes/Makefile.am
index 58d649cae..fb9b48817 100644
--- a/data/themes/Makefile.am
+++ b/data/themes/Makefile.am
@@ -147,6 +147,7 @@ edc/elm/toolbar.edc \
147edc/elm/tooltip.edc \ 147edc/elm/tooltip.edc \
148edc/elm/video.edc \ 148edc/elm/video.edc \
149edc/elm/win.edc \ 149edc/elm/win.edc \
150edc/elm/settingspane.edc \
150\ 151\
151edc/O/efm_icons.edc \ 152edc/O/efm_icons.edc \
152edc/O/icons.edc \ 153edc/O/icons.edc \
diff --git a/data/themes/default.edc b/data/themes/default.edc
index b7903e495..cdca16843 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -70,7 +70,7 @@ collections {
70#include "edc/elm/gengrid.edc" 70#include "edc/elm/gengrid.edc"
71#include "edc/elm/hover.edc" 71#include "edc/elm/hover.edc"
72#include "edc/elm/cursor.edc" 72#include "edc/elm/cursor.edc"
73 73#include "edc/elm/settingspane.edc"
74// desktop in general 74// desktop in general
75#include "edc/wallpaper.edc" 75#include "edc/wallpaper.edc"
76#include "edc/comp.edc" 76#include "edc/comp.edc"
diff --git a/data/themes/edc/elm/settingspane.edc b/data/themes/edc/elm/settingspane.edc
new file mode 100644
index 000000000..f11be28cd
--- /dev/null
+++ b/data/themes/edc/elm/settingspane.edc
@@ -0,0 +1,411 @@
1group { name: "elm/settingspane/base/default";
2 images.image: "shadow_vert.png" COMP;
3 images.image: "bevel_out.png" COMP;
4 images.image: "vgrad_med.png" COMP;
5 images.image: "back.png" COMP;
6 images.image: "horiz_bar_inset.png" COMP;
7 parts {
8 part { name: "elm.swallow.panel"; type: SWALLOW;
9 description { state: "default" 0.0;
10 align: 0 0;
11 rel1.to_y: "title_base";
12 rel1.to_x: "elm.swallow.menu";
13 rel1.relative: 1.0 1.0;
14 }
15 }
16 part { name: "elm.swallow.menu"; type: SWALLOW;
17 description { state: "default" 0.0;
18 align: 0 0;
19 rel1.to_y: "title_base";
20 rel1.relative: 0.0 1.0;
21 rel2.relative: 0.0 1.0;
22 rel2.offset: 150 0;
23 }
24 description { state: "searchmode" 0.0;
25 inherit: "default" 0.0;
26 rel2.offset: 0 0;
27 }
28 }
29 part { name: "shadow"; mouse_events: 0;
30 description { state: "default" 0.0;
31 image.normal: "shadow_vert.png";
32 rel1.to: "title_base";
33 rel1.relative: 0.0 1.0;
34 rel2.to: "title_base";
35 rel2.offset: -1 40;
36 align: 0.5 0.0;
37 }
38 description { state: "visible" 0.0;
39 inherit: "default" 0.0;
40 rel2.offset: 40 -1;
41 }
42 }
43 part { name: "title_base";
44 description { state: "default" 0.0;
45 image.normal: "vgrad_med.png";
46 fill.smooth: 0;
47 TILED_HORIZ(120)
48 rel2.relative: 1.0 1.0;
49 rel2.to_y: "elm.swallow.search";
50 rel2.offset: -1 4;
51 }
52 }
53 part { name: "bevel"; mouse_events: 0;
54 description { state: "default" 0.0;
55 rel1.to: "title_base";
56 rel2.to: "title_base";
57 image.normal: "bevel_out.png";
58 image.border: 1 1 1 1;
59 image.middle: 0;
60 fill.smooth: 0;
61 min: 5 5;
62 }
63 }
64 part { name: "elm.swallow.search"; type: SWALLOW;
65 description { state: "default" 0.0;
66 rel1.relative: 1.0 0.0;
67 rel1.offset: -5 4;
68 rel2.to_x: "unsaved_changes";
69 rel2.relative: 0.0 0.0;
70 rel2.offset: -5 4;
71 align: 1.0 0.0;
72 min: 120 4;
73 fixed: 1 1;
74 }
75 }
76 part { name: "unsaved_changes"; scale: 1; type: IMAGE;
77 description { state: "default" 0.0;
78 aspect: 1.0 1.0; aspect_preference: VERTICAL;
79 rel1.to_y: "elm.swallow.search";
80 rel2.to_y: "elm.swallow.search";
81 rel1.relative: 1.0 0.0;
82 rel2.relative: 1.0 1.0;
83 rel2.offset: -5 0;
84 color: 50 50 50 50;
85 align: 1.0 0.5;
86 image.normal: "icon_warning.png";
87 }
88 description { state: "enabled" 0.0;
89 inherit: "default" 0.0;
90 color: 255 255 255 255;
91 }
92 }
93 part { name: "elm.swallow.title"; type: SWALLOW;
94 description { state: "default" 0.0;
95 align: 1.0 0.5;
96 rel1.to_x: "back";
97 rel1.to_y: "title_base";
98 rel1.relative: 1.0 0.0;
99 rel2.to_x: "elm.swallow.search";
100 rel2.to_y: "title_base";
101 rel2.relative: 0.0 1.0;
102 fixed: 0 1;
103 }
104 }
105 part { name: "back"; type: RECT; scale: 1;
106 description { state: "default" 0.0;
107 aspect: 1.0 1.0; aspect_preference: VERTICAL;
108 rel1.to: "title_base";
109 rel2.to: "title_base";
110 rel2.relative: 0.0 1.0;
111 rel2.offset: 0 -1;
112 align: 0.0 0.5;
113 color: 0 0 0 0;
114 min: 17 17;
115 }
116 description { state: "disabled" 0.0;
117 inherit: "default" 0.0;
118 visible: 0;
119 }
120 }
121 part { name: "backarrow"; mouse_events: 0;
122 description { state: "default" 0.0;
123 rel1.to: "back";
124 rel2.to: "back";
125 image.normal: "back.png";
126 min: 14 17;
127 max: 14 17;
128 }
129 description { state: "disabled" 0.0;
130 inherit: "default" 0.0;
131 color: 255 255 255 64;
132 }
133 }
134 }
135 programs {
136 program {
137 signal: "mouse,clicked,1"; source: "back";
138 action: SIGNAL_EMIT "elm,action,back" "elm";
139 }
140 program {
141 signal: "mouse,clicked,3"; source: "back";
142 action: SIGNAL_EMIT "elm,action,back_menu" "elm";
143 }
144 program {
145 signal: "mouse,clicked,*"; source: "unsaved_changes";
146 action: SIGNAL_EMIT "elm,unsaved,clicked" "elm";
147 }
148 program {
149 signal: "elm,state,unsaved,enabled"; source: "elm";
150 action: "STATE_SET" "enabled";
151 target: "unsaved_changes";
152 }
153 program {
154 signal: "elm,state,unsaved,disabled"; source: "elm";
155 action: "STATE_SET" "default";
156 target: "unsaved_changes";
157 }
158 program {
159 signal: "elm,state,back,disabled"; source: "elm";
160 action: STATE_SET "disabled" 0.0;
161 target: "back";
162 target: "backarrow";
163 }
164 program {
165 signal: "elm,state,back,enabled"; source: "elm";
166 action: STATE_SET "default" 0.0;
167 target: "back";
168 target: "backarrow";
169 }
170 program {
171 signal: "elm,searchmode,enable"; source: "elm";
172 action: STATE_SET "searchmode" 0.0;
173 target: "elm.swallow.menu";
174 }
175 program {
176 signal: "elm,searchmode,disable"; source: "elm";
177 action: STATE_SET "default" 0.0;
178 target: "elm.swallow.menu";
179 }
180 }
181 }
182 group { name: "elm/settingspane/panel/default";
183 images.image: "bevel_out.png" COMP;
184 images.image: "error_hover.png" COMP;
185 parts {
186 part { name: "base"; type: RECT;
187 description { state: "default" 0.0;
188 color: 64 64 64 255;
189 rel1.relative: -1.0 0.0;
190 rel2.relative: 0.0 1.0;
191 }
192 description { state: "visible" 0.0;
193 inherit: "default" 0.0;
194 rel1.relative: 0.0 0.0;
195 rel2.relative: 1.0 1.0;
196 }
197 }
198 part { name: "base_clipper"; type:RECT;
199 description { state: "default" 0.0;
200 rel1.to: "base";
201 rel2.to: "base";
202 }
203 }
204 part { name: "error"; type: RECT;
205 description { state: "default" 0.0;
206 color: 255 255 255 0;
207 visible: 0;
208 }
209 description { state: "visible" 0.0;
210 inherit: "default" 0.0;
211 color: 255 255 255 75;
212 visible: 1;
213 }
214 }
215 part { name: "error_hover"; type: IMAGE;
216 clip_to: "error";
217 description {
218 image.normal: "error_hover.png";
219 image.scale_hint: STATIC;
220 }
221 }
222 part { name: "bevel"; mouse_events: 0;
223 description { state: "default" 0.0;
224 rel1.to: "base";
225 rel1.offset: 0 -1;
226 rel2.to: "base";
227 image.normal: "bevel_out.png";
228 image.border: 1 1 1 1;
229 image.middle: 0;
230 fill.smooth: 0;
231 min: 5 5;
232 }
233 }
234 part { name: "elm.rect.pad"; type: SWALLOW;
235 description { state: "default" 0.0;
236 align: 0.0 0.5;
237 rel1.to: "base";
238 rel2.to: "base";
239 rel2.relative: 0.0 1.0;
240 fixed: 1 0;
241 }
242 }
243 part { name: "elm.swallow.content"; type: SWALLOW;
244 description { state: "default" 0.0;
245 rel1.to: "elm.rect.pad";
246 rel1.relative: 1.0 0.0;
247 rel2.to_x: "base";
248 rel2.to_y: "elm.swallow.controls";
249 rel2.relative: 1.0 0.0;
250 }
251 }
252 part { name: "elm.swallow.controls"; type: SWALLOW;
253 clip_to: "base_clipper";
254 description { state: "default" 0.0;
255 rel1.to: "base";
256 rel1.relative: 0.0 1.0;
257 rel2.to: "base";
258 rel2.offset: 0 40;
259 }
260 description { state: "visible" 0.0;
261 inherit: "default" 0.0;
262 rel1.offset: 0 -40;
263 rel2.offset: 0 0;
264 }
265 }
266 }
267 programs {
268 program {
269 signal: "elm,state,controls,enable"; source: "elm";
270 action: STATE_SET "visible" 0.0;
271 transition: LINEAR 0.3;
272 target: "elm.swallow.controls";
273 }
274 program {
275 signal: "elm,state,controls,disable"; source: "elm";
276 action: STATE_SET "default" 0.0;
277 transition: LINEAR 0.3;
278 target: "elm.swallow.controls";
279 }
280 program {
281 signal: "elm,state,visible"; source: "elm";
282 action: STATE_SET "visible" 0.0;
283 transition: DECELERATE 0.6;
284 target: "base";
285 }
286 program {
287 name: "error";
288 signal: "elm,state,highlight"; source: "elm";
289 action: STATE_SET "visible" 0.0;
290 target: "error";
291 after: "error_cleanup";
292 transition: BOUNCE 1.5 0.0 2.0;
293 }
294 program {
295 name: "error_cleanup";
296 action: STATE_SET "default" 0.0;
297 target: "error";
298 transition: LINEAR 0.75;
299 }
300 program {
301 signal: "elm,state,default"; source: "elm";
302 action: STATE_SET "default" 0.0;
303 transition: DECELERATE 0.8;
304 target: "base";
305 }
306 }
307 }
308 group { name: "elm/settingspane/menu/default";
309 images.image: "bevel_out.png" COMP;
310 parts {
311 part { name: "base"; type: RECT;
312 description { state: "default" 0.0;
313 rel1.to: "elm.swallow.content";
314 rel2.to: "elm.swallow.content";
315 rel2.offset: -1 -1;
316 color: 64 64 64 255;
317 }
318 }
319 part { name: "elm.swallow.content"; type: SWALLOW;
320 description { state: "default" 0.0;
321 rel1.relative: 0.0 0.0;
322 rel2.relative: 0.0 1.0;
323 align: 1.0 0.0;
324 fixed: 1 1;
325 }
326 /* Only visible without display hidden */
327 description { state: "visible" 0.0;
328 inherit: "default" 0.0;
329 rel1.offset: 0 0;
330 rel2.offset: -1 -1;
331 rel2.relative: 1.0 1.0;
332 align: 0.0 0.0;
333 }
334 /* part gets this state when there is hidden */
335 /* otherwise it will overlap the hidden part */
336 description { state: "visible_hidden" 0.0;
337 inherit: "visible" 0.0;
338 rel1.offset: 15 0;
339 rel2.offset: 0 -1;
340 align: 0.0 0.0;
341 }
342 /* just a tiny bit on the left side from the old list */
343 description { state: "hidden" 0.0;
344 inherit: "visible" 0.0;
345 rel1.offset: 0 0;
346 rel2.offset: 15 -1;
347 rel2.relative: 0.0 1.0;
348 align: 1.0 0.0;
349 }
350 }
351 part { name: "bevel"; mouse_events: 0;
352 description { state: "default" 0.0;
353 fixed: 1 1;
354 rel1.to: "base";
355 rel1.offset: 0 -1;
356 rel2.to: "base";
357 image.normal: "bevel_out.png";
358 image.border: 1 1 1 1;
359 image.middle: 0;
360 fill.smooth: 0;
361 min: 5 5;
362 }
363 }
364 part { name: "back_cover"; type: RECT;
365 description { state: "default" 0.0;
366 color: 0 0 0 0;
367 rel1.to: "base";
368 rel2.to: "base";
369 visible: 0;
370 }
371 description { state: "hidden" 0.0;
372 inherit: "default" 0.0;
373 visible: 1;
374 }
375 }
376 }
377 programs {
378 program {
379 signal: "elm,state,visible"; source: "elm";
380 action: STATE_SET "visible" 0.0;
381 transition: DECELERATE 0.4;
382 target: "elm.swallow.content";
383 target: "back_cover";
384 }
385 program {
386 signal: "elm,state,visible,hidden"; source: "elm";
387 action: STATE_SET "visible_hidden" 0.0;
388 transition: DECELERATE 0.4;
389 target: "elm.swallow.content";
390 target: "back_cover";
391 }
392 program {
393 signal: "elm,state,hidden"; source: "elm";
394 action: STATE_SET "hidden" 0.0;
395 transition: DECELERATE 0.5;
396 target: "elm.swallow.content";
397 target: "back_cover";
398 }
399 program {
400 signal: "elm,state,default"; source: "elm";
401 action: STATE_SET "default" 0.0;
402 transition: DECELERATE 0.2;
403 target: "elm.swallow.content";
404 target: "back_cover";
405 }
406 program {
407 signal: "mouse,clicked,1"; source: "back_cover";
408 action: SIGNAL_EMIT "action,back" "conf";
409 }
410 }
411 }
diff --git a/data/themes/img/back.png b/data/themes/img/back.png
new file mode 100644
index 000000000..3277ecd25
--- /dev/null
+++ b/data/themes/img/back.png
Binary files differ
diff --git a/data/themes/img/vshadow.png b/data/themes/img/vshadow.png
new file mode 100644
index 000000000..a24ef46a9
--- /dev/null
+++ b/data/themes/img/vshadow.png
Binary files differ
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index b93374a11..05d4e9b50 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -133,6 +133,7 @@ test_win_plug.c \
133test_win_state.c \ 133test_win_state.c \
134test_win_wm_rotation.c \ 134test_win_wm_rotation.c \
135test_win_dialog.c \ 135test_win_dialog.c \
136test_settingspane.c \
136test.h 137test.h
137 138
138elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \ 139elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \
diff --git a/src/bin/test.c b/src/bin/test.c
index 14296a313..9e4bc45bd 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -267,6 +267,7 @@ void test_application_server_phone(void *data, Evas_Object *obj, void *event_inf
267void test_win_dialog(void *data, Evas_Object *obj, void *event_info); 267void test_win_dialog(void *data, Evas_Object *obj, void *event_info);
268void test_box_disable(void *data, Evas_Object *obj, void *event_info); 268void test_box_disable(void *data, Evas_Object *obj, void *event_info);
269void test_layout_disable(void *data, Evas_Object *obj, void *event_info); 269void test_layout_disable(void *data, Evas_Object *obj, void *event_info);
270void test_settingspane(void *data, Evas_Object *obj, void *event_info);
270 271
271void test_colorclass(); 272void test_colorclass();
272 273
@@ -865,6 +866,7 @@ add_tests:
865 ADD_TEST(NULL, "Miscellaneous", "Accessibility", test_access); 866 ADD_TEST(NULL, "Miscellaneous", "Accessibility", test_access);
866 ADD_TEST(NULL, "Miscellaneous", "Accessibility2", test_access2); 867 ADD_TEST(NULL, "Miscellaneous", "Accessibility2", test_access2);
867 ADD_TEST(NULL, "Miscellaneous", "Accessibility3", test_access3); 868 ADD_TEST(NULL, "Miscellaneous", "Accessibility3", test_access3);
869 ADD_TEST(NULL, "Miscellaneous", "Settingspane", test_settingspane);
868 870
869 //------------------------------// 871 //------------------------------//
870 ADD_TEST(NULL, "Application client/server", "Task switcher", test_task_switcher); 872 ADD_TEST(NULL, "Application client/server", "Task switcher", test_task_switcher);
diff --git a/src/bin/test_settingspane.c b/src/bin/test_settingspane.c
new file mode 100644
index 000000000..60e680b98
--- /dev/null
+++ b/src/bin/test_settingspane.c
@@ -0,0 +1,289 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6static const char* simple_menu[3][3] =
7 {
8 { "Fonts",
9 "Here you can set the Settings of the Fonts, this should be a very very very long text as a description, so someone can also enter something really really long!",
10 "./logo_small.png"},
11 { "Color",
12 "Here you can find the settings for settings up colors bla bla bla text text text",
13 "./icon_00.png"},
14 { "Themes",
15 "Here you can set up themes installed to ~/.yourappsawesomethemefolder/",
16 "./icon_07.png",
17 }
18};
19
20static void
21entry_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
22{
23 Elm_Settingspane_Item *it = data;
24 elm_settingspane_item_changed_set(it, EINA_TRUE);
25}
26
27static void
28anchor_clicked(void *data, Evas_Object *obj, void *event_info)
29{
30 Elm_Entry_Anchor_Hover_Info *ei = event_info;
31 Elm_Settingspane_Item *it = NULL;
32 const char *name = ei->anchor_info->name;
33
34 if (!strcmp(name, "color"))
35 {
36 it = elm_settingspane_item_get(data, "Color");
37 }
38 else if (!strcmp(name, "font"))
39 {
40 it = elm_settingspane_item_get(data, "Fonts");
41 }
42 else if (!strcmp(name, "theme"))
43 {
44 it = elm_settingspane_item_get(data, "Themes");
45 }
46 elm_entry_anchor_hover_end(obj);
47 elm_settingspane_item_focus(it);
48}
49
50static Evas_Object*
51content_font_get(Evas_Object *par, Elm_Settingspane_Item *item, void *data EINA_UNUSED)
52{
53 Evas_Object *box, *o;
54
55 box = elm_box_add(par);
56 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
57 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
58
59 o = elm_entry_add(par);
60 evas_object_size_hint_weight_set(o, 0.0, 0.0);
61 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
62 elm_object_text_set(o, "This are the font settings, here you can set up everything regarding font etc. etc. etc. if you want to change fonts color you have to search <a href=color> here </a> Normal options are now following wuu wuu:");
63 elm_entry_editable_set(o, EINA_FALSE);
64 evas_object_smart_callback_add(o, "anchor,hover,opened", anchor_clicked, par);
65 elm_box_pack_end(box, o);
66 evas_object_show(o);
67
68 o = elm_entry_add(par);
69 elm_object_text_set(o, "A entry");
70 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
71 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
72 elm_entry_single_line_set(o, EINA_TRUE);
73 evas_object_smart_callback_add(o, "changed", entry_changed, item);
74 elm_box_pack_end(box, o);
75 evas_object_show(o);
76
77 return box;
78}
79
80static Evas_Object*
81content_color_get(Evas_Object *par, Elm_Settingspane_Item *item EINA_UNUSED, void *data EINA_UNUSED)
82{
83 Evas_Object *box, *o;
84
85 box = elm_box_add(par);
86 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
87 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
88
89 o = elm_entry_add(par);
90 evas_object_size_hint_weight_set(o, 0.0, 0.0);
91 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
92 elm_object_text_set(o, "This are the color settings, here you can setup everything regarding colors, maybe you have been here because you clicked a link in <a href=font> font </a> If you want to change the applications complete look and feel the <a href=theme> theme </a> settings could be more usefull than the colors.");
93 elm_entry_editable_set(o, EINA_FALSE);
94 evas_object_smart_callback_add(o, "anchor,hover,opened", anchor_clicked, par);
95 elm_box_pack_end(box, o);
96 evas_object_show(o);
97
98 return box;
99}
100
101
102static Evas_Object*
103content_theme_get(Evas_Object *par, Elm_Settingspane_Item *item, void *data EINA_UNUSED)
104{
105 Evas_Object *box, *o;
106
107 box = elm_box_add(par);
108 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
109 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
110
111 o = elm_entry_add(par);
112 evas_object_size_hint_weight_set(o, 0.0, 0.0);
113 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
114 elm_object_text_set(o, "Theme settings - change the entry to see what happens if you change something.");
115 elm_entry_editable_set(o, EINA_FALSE);
116 evas_object_smart_callback_add(o, "anchor,hover,opened", anchor_clicked, par);
117 elm_box_pack_end(box, o);
118 evas_object_show(o);
119
120 o = elm_entry_add(par);
121 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
122 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
123 elm_entry_single_line_set(o, EINA_TRUE);
124 elm_object_text_set(o, "Lets think you can set here a theme (:");
125 elm_box_pack_end(box, o);
126 evas_object_smart_callback_add(o, "changed", entry_changed, item);
127 evas_object_show(o);
128
129 return box;
130}
131
132static Evas_Object*
133content_complex_child_get(Evas_Object *par, Elm_Settingspane_Item *item, void *data EINA_UNUSED)
134{
135 Evas_Object *box, *o;
136
137 box = elm_box_add(par);
138 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
139 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
140
141 o = elm_entry_add(par);
142 evas_object_size_hint_weight_set(o, 0.0, 0.0);
143 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
144 elm_object_text_set(o, "Complex settings - This is just a sample of how a menu structur can be, those can be n examples.");
145 elm_entry_editable_set(o, EINA_FALSE);
146 evas_object_smart_callback_add(o, "anchor,hover,opened", anchor_clicked, par);
147 elm_box_pack_end(box, o);
148 evas_object_show(o);
149
150 o = elm_entry_add(par);
151 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
152 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
153 elm_entry_single_line_set(o, EINA_TRUE);
154 elm_object_text_set(o, "EFL EFL EFL EFL EFL :) >>>change me<<<");
155 elm_box_pack_end(box, o);
156 evas_object_smart_callback_add(o, "changed", entry_changed, item);
157 evas_object_show(o);
158
159 return box;
160}
161
162static Content_Get_Cb content_cb[4] =
163{
164 content_font_get,content_color_get, content_theme_get, content_complex_child_get
165};
166
167
168static void
169reset_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
170{
171 Elm_Settingspane_Item *item = event_info;
172 elm_settingspane_item_changed_set(item, EINA_FALSE);
173}
174
175static void
176apply_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
177{
178 Elm_Settingspane_Item *item = event_info;
179 elm_settingspane_item_changed_set(item, EINA_FALSE);
180}
181
182static void
183highlight_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
184{
185 elm_settingspane_raise_unsaved(data);
186}
187
188static void
189save_q_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
190{
191 if (!elm_settingspane_save_quit(data))
192 printf("No.\n");
193 else
194 printf("Yes :)\n");
195
196}
197
198void
199test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
200{
201 Evas_Object *win, *o, *box, *sw, *btnbox, *ic;
202 Elm_Settingspane_Item *it, *it2;
203 char buf[PATH_MAX];
204
205 win = elm_win_util_standard_add("settingspane", "Settingspane");
206 elm_win_autodel_set(win, EINA_TRUE);
207 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
208
209 box = elm_box_add(win);
210 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
212 elm_win_resize_object_add(win, box);
213 evas_object_show(box);
214
215 sw = elm_settingspane_add(win);
216 evas_object_size_hint_weight_set(sw, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
217 evas_object_size_hint_align_set(sw, EVAS_HINT_FILL, EVAS_HINT_FILL);
218 elm_box_pack_end(box, sw);
219
220 int i = 0;
221 for(i = 0; i < 3; i++)
222 {
223 snprintf(buf, sizeof(buf), "%s/images/%s",
224 elm_app_data_dir_get(), simple_menu[i][2]);
225 ic = elm_icon_add(win);
226 elm_image_file_set(ic, buf, NULL);
227 evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
228 evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL);
229
230 it = elm_settingspane_item_append(sw, ic, simple_menu[i][0],
231 simple_menu[i][1], ic, NULL);
232 elm_settingspane_item_attach_panel(it, content_cb[i], reset_cb, apply_cb);
233 }
234
235 /* A complex item! */
236 ic = elm_icon_add(win);
237 snprintf(buf, sizeof(buf), "%s/images/%s",
238 elm_app_data_dir_get(), "icon_09.png");
239 elm_image_file_set(ic, buf, NULL);
240 evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
241 evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL);
242
243 it = elm_settingspane_item_append(sw, ic, "Complex",
244 "No we are not going to jump here into complex numbers, this is just a complex menu item, this means it has childrens!",
245 ic, NULL);
246 elm_settingspane_item_keyword_add(it, eina_stringshare_add("Hardone"));
247 elm_settingspane_item_keyword_add(it, eina_stringshare_add("second"));
248 ic = elm_icon_add(win);
249 snprintf(buf, sizeof(buf), "%s/images/%s",
250 elm_app_data_dir_get(), "bubble.png");
251 elm_image_file_set(ic, buf, NULL);
252 evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
253 evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL);
254 it2 = elm_settingspane_item_append(sw, ic, "Child",
255 "This is a children entry",
256 ic, it);
257 elm_settingspane_item_keyword_add(it2, eina_stringshare_add("Heavyone"));
258 elm_settingspane_item_attach_panel(it2, content_cb[3], reset_cb, apply_cb);
259
260 evas_object_show(sw);
261
262 btnbox = elm_box_add(win);
263 elm_box_horizontal_set(btnbox, EINA_TRUE);
264 evas_object_size_hint_weight_set(btnbox, EVAS_HINT_EXPAND, 0.0);
265 evas_object_size_hint_align_set(btnbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
266 elm_box_pack_end(box, btnbox);
267 evas_object_show(btnbox);
268
269 o = elm_button_add(win);
270 elm_object_text_set(o, "Highlight Unsaved Changes");
271 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
272 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
273 evas_object_smart_callback_add(o, "clicked", highlight_cb, sw);
274 elm_box_pack_end(btnbox, o);
275 evas_object_show(o);
276
277 o = elm_button_add(win);
278 elm_object_text_set(o, "Everything Saved ?");
279 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
280 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
281 evas_object_smart_callback_add(o, "clicked", save_q_cb, sw);
282 elm_box_pack_end(btnbox, o);
283 evas_object_show(o);
284
285 evas_object_show(win);
286 evas_object_resize(win, 500, 500);
287}
288
289
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index 1cd7c7616..4c3e342ba 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -266,6 +266,7 @@ EAPI extern Elm_Version *elm_version;
266#include <elm_web.h> 266#include <elm_web.h>
267#include <elm_win.h> 267#include <elm_win.h>
268#include <elm_win_standard.h> 268#include <elm_win_standard.h>
269#include <elc_settingspane.h>
269 270
270/* include deprecated calls last of all */ 271/* include deprecated calls last of all */
271#include <elm_deprecated.h> 272#include <elm_deprecated.h>
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 3b6153272..2fcdc9755 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -376,7 +376,11 @@ elm_win_eo.h \
376elm_win_legacy.h \ 376elm_win_legacy.h \
377elm_win_standard.h \ 377elm_win_standard.h \
378elm_win_standard.eo.h \ 378elm_win_standard.eo.h \
379elm_helper.h 379elm_helper.h \
380elc_settingspane.h \
381elc_settingspane_eo.h \
382elc_settingspane_legacy.h
383
380includesubdir = $(includedir)/elementary-@VMAJ@/ 384includesubdir = $(includedir)/elementary-@VMAJ@/
381 385
382libelementary_la_SOURCES = \ 386libelementary_la_SOURCES = \
@@ -495,7 +499,9 @@ elm_helper.c \
495els_box.c \ 499els_box.c \
496els_cursor.c \ 500els_cursor.c \
497els_tooltip.c \ 501els_tooltip.c \
498elu_ews_wm.c 502elu_ews_wm.c \
503elc_settingspane.c \
504$(COLORCLASS_GEN)
499 505
500libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@ 506libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@
501libelementary_la_LIBADD = \ 507libelementary_la_LIBADD = \
@@ -621,7 +627,9 @@ elm_gengrid_item.eo \
621elm_list_item.eo \ 627elm_list_item.eo \
622elm_toolbar_item.eo \ 628elm_toolbar_item.eo \
623elm_diskselector_item.eo \ 629elm_diskselector_item.eo \
624elm_popup_item.eo 630elm_popup_item.eo \
631elm_settingspane.eo \
632elm_settingspane_item.eo
625 633
626elm_eolian_type_files = \ 634elm_eolian_type_files = \
627elm_general.eot 635elm_general.eot
@@ -647,6 +655,124 @@ EXTRA_DIST += ${elementaryeolianfiles_DATA}
647nodist_includesunstable_HEADERS = $(elm_eolian_h) $(elm_eolian_legacy_h) $(elm_eolian_eot_h) 655nodist_includesunstable_HEADERS = $(elm_eolian_h) $(elm_eolian_legacy_h) $(elm_eolian_eot_h)
648CLEANFILES += $(nodist_includesunstable_HEADERS) 656CLEANFILES += $(nodist_includesunstable_HEADERS)
649 657
658elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
659elementaryeolianfiles_DATA = \
660 elm_widget.eo \
661 elm_container.eo \
662 elm_layout.eo \
663 elm_interface_scrollable.eo \
664 elm_pan.eo \
665 elm_frame.eo \
666 elm_hover.eo \
667 elm_access.eo \
668 elm_actionslider.eo \
669 elm_app_client.eo \
670 elm_app_client_view.eo \
671 elm_app_server.eo \
672 elm_app_server_view.eo \
673 elm_atspi_app_object.eo \
674 elm_atspi_bridge.eo \
675 elm_interface_atspi_accessible.eo \
676 elm_interface_atspi_action.eo \
677 elm_interface_atspi_component.eo \
678 elm_interface_atspi_editable_text.eo \
679 elm_interface_atspi_image.eo \
680 elm_interface_atspi_selection.eo \
681 elm_interface_atspi_text.eo \
682 elm_interface_atspi_value.eo \
683 elm_interface_atspi_widget_action.eo \
684 elm_interface_atspi_window.eo \
685 elm_bg.eo \
686 elm_box.eo \
687 elm_bubble.eo \
688 elm_button.eo \
689 elm_calendar.eo \
690 elm_check.eo \
691 elm_clock.eo \
692 elm_colorselector.eo \
693 elm_conformant.eo \
694 elm_ctxpopup.eo \
695 elm_datetime.eo \
696 elm_dayselector.eo \
697 elm_diskselector.eo \
698 elm_entry.eo \
699 elm_fileselector.eo \
700 elm_fileselector_button.eo \
701 elm_fileselector_entry.eo \
702 elm_flipselector.eo \
703 elm_flip.eo \
704 elm_general.eot \
705 elm_gengrid.eo \
706 elm_gengrid_pan.eo \
707 elm_genlist.eo \
708 elm_genlist_pan.eo \
709 elm_gesture_layer.eo \
710 elm_glview.eo \
711 elm_grid.eo \
712 elm_hoversel.eo \
713 elm_image.eo \
714 elm_icon.eo \
715 elm_index.eo \
716 elm_interface_fileselector.eo \
717 elm_inwin.eo \
718 elm_label.eo \
719 elm_list.eo \
720 elm_map_pan.eo \
721 elm_map.eo \
722 elm_menu.eo \
723 elm_multibuttonentry.eo \
724 elm_naviframe.eo \
725 elm_panel.eo \
726 elm_mapbuf.eo \
727 elm_notify.eo \
728 elm_panes.eo \
729 elm_photocam.eo \
730 elm_photocam_pan.eo \
731 elm_photo.eo \
732 elm_player.eo \
733 elm_plug.eo \
734 elm_popup.eo \
735 elm_prefs.eo \
736 elm_progressbar.eo \
737 elm_radio.eo \
738 elm_route.eo \
739 elm_scroller.eo \
740 elm_segment_control.eo \
741 elm_separator.eo \
742 elm_slider.eo \
743 elm_slideshow.eo \
744 elm_spinner.eo \
745 elm_systray.eo \
746 elm_table.eo \
747 elm_thumb.eo \
748 elm_toolbar.eo \
749 elm_video.eo \
750 elm_view_list.eo \
751 elm_view_form.eo \
752 elm_web.eo \
753 elm_win.eo \
754 elm_win_standard.eo \
755 elm_widget_item.eo \
756 elm_color_item.eo \
757 elm_dayselector_item.eo \
758 elm_hoversel_item.eo \
759 elm_segment_control_item.eo \
760 elm_slideshow_item.eo \
761 elm_flipselector_item.eo \
762 elm_menu_item.eo \
763 elm_ctxpopup_item.eo \
764 elm_index_item.eo \
765 elm_multibuttonentry_item.eo \
766 elm_naviframe_item.eo \
767 elm_genlist_item.eo \
768 elm_gengrid_item.eo \
769 elm_list_item.eo \
770 elm_toolbar_item.eo \
771 elm_diskselector_item.eo \
772 elm_popup_item.eo \
773 elm_settingspane.eo \
774 elm_settingspane_item.eo
775
650EXTRA_DIST += ${elementaryeolianfiles_DATA} 776EXTRA_DIST += ${elementaryeolianfiles_DATA}
651 777
652includecxxbindingsdir = $(includedir)/elementary-cxx-@VMAJ@ 778includecxxbindingsdir = $(includedir)/elementary-cxx-@VMAJ@
diff --git a/src/lib/elc_settingspane.c b/src/lib/elc_settingspane.c
new file mode 100644
index 000000000..8d73b7cf4
--- /dev/null
+++ b/src/lib/elc_settingspane.c
@@ -0,0 +1,1560 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7#include <elm_priv.h>
8
9/**
10 * This widget has a internal stack for displaying panels.
11 *
12 * - Each item is a Stack_Item
13 *
14 * - A new item on the stack will result from a call to item_focus
15 *
16 * - If just a entry in a menu is selected the current field of this item
17 * will be adjusted.
18 *
19 * - If the "back" arrived at the end of a item, the item under this
20 * will be displayed again
21 *
22 * - If there is no lower item on the stack the "back" buton should be disabled
23 *
24 */
25
26typedef struct
27{
28 Elm_Settingspane_Item *zero;
29
30 // list of all Elm_Item_Object
31 Eina_List *history_stack;
32 Eina_List *unsaved_changes;
33
34 Elm_Genlist_Item_Class *itcc; // , *itci;
35
36 struct
37 {
38 Eina_Bool on;
39 Evas_Object *display;
40 Ecore_Thread *run;
41 const char* keyword;
42 } search;
43} Elm_Settingspane_Data;
44
45typedef struct
46{
47 Elm_Settingspane_Item *par;
48
49 Eina_List *childs; //list of Elm_Settingspane_Item*
50
51 Eina_List *key_words; //< list of strdupĀ“ed strings to match searching
52
53 const char *name;
54 const char *description;
55 void *data;
56
57 Evas_Object *sw;
58 Eina_Bool changed;
59
60 Elm_Widget_Item *it;
61 Evas_Object *icon;
62
63 struct
64 {
65 Evas_Object *tmp_content; //obejct of a hiden content will be held here.
66
67 Evas_Smart_Cb apply;
68 Evas_Smart_Cb reset;
69 Content_Get_Cb content_get;
70 } panel;
71} Elm_Settingspane_Item_Data;
72
73typedef struct _Search_Run
74{
75 Eina_List *results;
76 Elm_Settingspane_Data *data;
77 const char *keyword;
78} Search_Run;
79
80static void _unsaved_changes_add(Evas_Object *w, Elm_Object_Item *item);
81static void _unsaved_changes_remove(Evas_Object *w, Elm_Object_Item *item);
82
83static void _history_stack_push(Evas_Object *w, Elm_Object_Item *it);
84static Elm_Object_Item* _history_stack_pop(Evas_Object *w);
85static Elm_Object_Item* _history_stack_current(Evas_Object *w);
86static Eina_Bool _history_stack_end(Evas_Object *w);
87static void _history_stack_remove(Evas_Object *w, Elm_Object_Item *it);
88
89static void _item_sel_cb(void *data, Evas_Object *obj, void *event_info);
90static void _search_panel_stop(Evas_Object *w);
91
92#define HAS_PANEL(id) (id->panel.content_get)
93/* Data Keys in the layouts, DK = Data Key */
94
95#define DK_MAIN_MENU_TABLE "__menu_table"
96#define DK_MAIN_MENU_SHOWED "__menu_layout_show"
97#define DK_MAIN_MENU_HIDDEN "__menu_layout_hidden"
98#define DK_MAIN_MENU_BEHIND "__menu_layout_behind"
99
100#define DK_MAIN_PANEL_TABLE "__panel_table"
101#define DK_MAIN_PANEL_SHOWED "__panel_layout_show"
102#define DK_MAIN_PANEL_HIDDEN "__panel_layout_hidden"
103
104#define DK_MAIN_TITLE_BOX "__panel_title"
105
106#define DK_MAIN_SEARCH_OBJECTS "__panel_search"
107#define DK_PANEL_APPLY_BUTTON "__apply_btn"
108#define DK_PANEL_RESET_BUTTON "__reset_btn"
109#define DK_PANEL_ITEM_SHOWN "__showed_item"
110
111#define DK_MENU_GENLIST "__menu_genlist"
112#define DK_MENU_ITEM_SHOWN "__showed_item"
113
114#define DK_SEARCH_LABEL "__search_label"
115#define DK_SEARCH_GRID "__search_results"
116#define DK_UNSAVED_OPENED "__unsaved_opened"
117
118/* Layout positions */
119
120#define POS_PANEL_PAD "elm.rect.pad"
121#define POS_PANEL_CONTROLS "elm.swallow.controls"
122#define POS_PANEL_CONTENT "elm.swallow.content"
123
124#define POS_MENU_CONTENT "elm.swallow.content"
125
126#define POS_MAIN_TITLE "elm.swallow.title"
127#define POS_MAIN_PANEL "elm.swallow.panel"
128#define POS_MAIN_MENU "elm.swallow.menu"
129#define POS_MAIN_SEARCH "elm.swallow.search"
130
131/* Signals */
132
133#define EMITTER "elm"
134
135#define EMIT_BACK_ENABLE "elm,state,back,enabled", EMITTER
136#define EMIT_BACK_DISABLE "elm,state,back,disabled", EMITTER
137#define EMIT_UNSAVED_ENABLE "elm,state,unsaved,enabled", EMITTER
138#define EMIT_UNSAVED_DISABLE "elm,state,unsaved,disabled", EMITTER
139
140#define EMIT_MENU_DEFAULT "elm,state,default", EMITTER
141#define EMIT_MENU_VISIBLE "elm,state,visible", EMITTER
142#define EMIT_MENU_VISIBLE_HIDDEN "elm,state,visible,hidden", EMITTER
143#define EMIT_MENU_HIDDEN "elm,state,hidden", EMITTER
144#define EMIT_MENU_SEARCHMODE_ENABLE "elm,searchmode,enable", EMITTER
145#define EMIT_MENU_SEARCHMODE_DISABLE "elm,searchmode,disable", EMITTER
146
147#define EMIT_CONTENT_DEFAULT "elm,state,default", EMITTER
148#define EMIT_CONTENT_VISIBLE "elm,state,visible", EMITTER
149#define EMIT_CONTENT_HIGHLIGHT "elm,state,highlight", EMITTER
150#define EMIT_CONTENT_CONTROLS_SHOW "elm,state,controls,enable", EMITTER
151#define EMIT_CONTENT_CONTROLS_HIDE "elm,state,controls,disable", EMITTER
152
153
154#define IC_DATA(v) Elm_Settingspane_Item_Data *id = eo_data_scope_get(v, ELM_SETTINGSPANE_ITEM_CLASS)
155#define IC_DATA_L(v) eo_data_scope_get(v, ELM_SETTINGSPANE_ITEM_CLASS)
156#define C_DATA(v) Elm_Settingspane_Data *wd = eo_data_scope_get(v, ELM_SETTINGSPANE_CLASS)
157
158static void
159conf_menu_back_cb(void *data EINA_UNUSED, Evas_Object *obj, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
160{
161 /*
162 *
163 * FIXME: For menu cb, we need a new stack method here which pop to the next menu entry!!!
164 *
165 */
166 C_DATA(obj);
167 if (wd->search.on)
168 _search_panel_stop(obj);
169 else
170 _history_stack_pop(obj);
171}
172
173/*
174 * Titlebar stuff
175 */
176static void
177_title_bar_refresh(Evas_Object *w)
178{
179 Elm_Object_Item *it, *walker;
180 Elm_Settingspane_Item_Data *id = NULL;
181 Evas_Object *bt, *bx;
182 it = _history_stack_current(w);
183 bx = evas_object_data_get(w, DK_MAIN_TITLE_BOX);
184
185 elm_box_clear(bx);
186
187 do {
188 walker = id ? id->par : it;
189 id = IC_DATA_L(walker);
190
191 bt = elm_button_add(bx);
192 elm_object_style_set(bt, "navlink");
193 elm_object_text_set(bt, id->name);
194 evas_object_show(bt);
195
196 elm_box_pack_start(bx, bt);
197 } while(id->par);
198}
199
200/*
201 * Elm_Settingspane_Item event funktions
202 */
203static void
204_item_content_reset(Elm_Settingspane_Item *it)
205{
206 IC_DATA(it);
207
208 if (id->panel.reset)
209 id->panel.reset(id->data, id->sw, it);
210}
211
212static void
213_item_content_apply(Elm_Settingspane_Item *it)
214{
215 IC_DATA(it);
216
217 if (id->panel.apply)
218 id->panel.apply(id->data, id->sw, it);
219}
220
221static void
222_item_content_del(Elm_Settingspane_Item *it EINA_UNUSED)
223{
224/* Elm_Settingspane_Item_Data *id = eo_data_scope_get(it,
225 ELM_SETTINGSPANE_ITEM_CLASS);
226 if (id->class->content_del)
227 id->class->content_del(id->data);*/
228}
229
230static Evas_Object*
231_item_content_get(Elm_Settingspane_Item *it, Evas_Object *obj)
232{
233 IC_DATA(it);
234
235 if (id->panel.content_get)
236 return id->panel.content_get(obj, it, id->data);
237 else
238 return NULL;
239}
240
241
242/*
243 * content_layout section
244 */
245
246static void
247_content_layout_apply_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
248{
249 Evas_Object *l = data;
250 Elm_Settingspane_Item *displayed = evas_object_data_get(l, DK_PANEL_ITEM_SHOWN);
251
252 if (!displayed) return;
253
254 _item_content_apply(displayed);
255}
256
257static void
258_content_layout_reset_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
259{
260 Evas_Object *l = data;
261 Elm_Settingspane_Item *displayed = evas_object_data_get(l, DK_PANEL_ITEM_SHOWN);
262
263 if (!displayed) return;
264
265 _item_content_reset(displayed);
266}
267
268
269
270static void
271_content_layout_content_init(Evas_Object *w)
272{
273 Evas_Object *o, *pad, *table, *bx, *apply, *reset;
274 int i = 0;
275
276 table = evas_object_data_get(w, DK_MAIN_PANEL_TABLE);
277
278 for (i = 0; i < 2; i++)
279 {
280 o = elm_layout_add(w);
281 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
282 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
283 elm_layout_theme_set(o, "settingspane", "panel", "default");
284 evas_object_show(o);
285
286 pad = evas_object_rectangle_add(evas_object_evas_get(w));
287 evas_object_size_hint_weight_set(pad, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
288 evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
289 elm_object_part_content_set(o, POS_PANEL_PAD, pad);
290 evas_object_show(pad);
291
292 elm_table_pack(table, o, 0, 0, 1, 1);
293
294 bx = elm_box_add(w);
295 evas_object_size_hint_weight_set(bx, 0, 0);
296 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
297 elm_box_horizontal_set(bx, EINA_TRUE);
298 elm_object_part_content_set(o, POS_PANEL_CONTROLS, bx);
299
300 apply = elm_button_add(w);
301 evas_object_size_hint_weight_set(apply, 0.0, 0.0);
302 evas_object_size_hint_align_set(apply, 0.0, 0.0);
303 evas_object_smart_callback_add(apply, "clicked", _content_layout_apply_cb, o);
304 elm_object_text_set(apply, "Apply");
305 evas_object_data_set(o, DK_PANEL_APPLY_BUTTON, apply);
306 elm_box_pack_end(bx, apply);
307
308 reset = elm_button_add(w);
309 evas_object_size_hint_weight_set(reset, 0, 0);
310 evas_object_size_hint_align_set(reset, 0.0, 0.0);
311 elm_object_text_set(reset, "Reset");
312 evas_object_smart_callback_add(reset, "clicked", _content_layout_reset_cb, o);
313 evas_object_data_set(o, DK_PANEL_RESET_BUTTON, reset);
314 elm_box_pack_end(bx, reset);
315
316 evas_object_show(bx);
317 evas_object_show(reset);
318 evas_object_show(apply);
319
320 if (i < 1)
321 evas_object_data_set(w, DK_MAIN_PANEL_SHOWED, o);
322 else
323 evas_object_data_set(w, DK_MAIN_PANEL_HIDDEN, o);
324 }
325}
326
327static void
328_content_del(Elm_Settingspane_Item *it)
329{
330 Evas_Object *shown_content;
331 IC_DATA(it);
332
333 shown_content = id->panel.tmp_content;
334 id->panel.tmp_content = NULL;
335 eo_unref(shown_content);
336 evas_object_del(shown_content);
337 if (it)
338 _item_content_del(it);
339
340}
341
342static void
343_content_layout_content_hide(Evas_Object *w, Eina_Bool keep)
344{
345 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED);
346 Elm_Object_Item *item = evas_object_data_get(shown, DK_PANEL_ITEM_SHOWN);
347
348 evas_object_data_del(shown, DK_PANEL_ITEM_SHOWN);
349 elm_layout_signal_emit(shown, EMIT_CONTENT_DEFAULT);
350
351 if (!keep && item)
352 _content_del(item);
353 else
354 {
355 Evas_Object *cnt;
356
357 cnt = elm_object_part_content_unset(shown, POS_PANEL_CONTENT);
358 evas_object_hide(cnt);
359 }
360}
361
362static void
363_content_layout_content_controls_refresh(Evas_Object *w, Elm_Settingspane_Item *it)
364{
365 IC_DATA(it);
366
367 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED);
368 Evas_Object *apply_btn = evas_object_data_get(shown, DK_PANEL_APPLY_BUTTON);
369 Evas_Object *reset_btn = evas_object_data_get(shown, DK_PANEL_RESET_BUTTON);
370
371 if (!id->changed)
372 elm_layout_signal_emit(shown, EMIT_CONTENT_CONTROLS_HIDE);
373 else
374 elm_layout_signal_emit(shown, EMIT_CONTENT_CONTROLS_SHOW);
375
376 elm_object_disabled_set(apply_btn, !id->changed);
377 elm_object_disabled_set(reset_btn, !id->changed);
378}
379
380static void
381_content_layout_display(Evas_Object *w, Evas_Object *content)
382{
383 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED);
384 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_PANEL_HIDDEN);
385
386 elm_layout_content_unset(hidden, POS_PANEL_CONTENT);
387 elm_object_part_content_set(hidden, POS_PANEL_CONTENT, content);
388
389 elm_layout_signal_emit(hidden, EMIT_CONTENT_VISIBLE);
390
391 evas_object_data_set(w, DK_MAIN_PANEL_SHOWED, hidden);
392 evas_object_raise(hidden);
393 evas_object_data_set(w, DK_MAIN_PANEL_HIDDEN, shown);
394}
395
396static void
397_content_layout_content_set(Evas_Object *w, Elm_Settingspane_Item *it)
398{
399 IC_DATA(it);
400
401 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_PANEL_HIDDEN);
402
403 if (!id->panel.tmp_content)
404 {
405 id->panel.tmp_content = elm_scroller_add(w);
406 eo_ref(id->panel.tmp_content);
407 evas_object_size_hint_weight_set(id->panel.tmp_content,
408 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
409 evas_object_show(id->panel.tmp_content);
410 elm_object_content_set(id->panel.tmp_content, _item_content_get(it, w));
411
412 }
413
414 _content_layout_display(w, id->panel.tmp_content);
415 evas_object_data_set(hidden, DK_PANEL_ITEM_SHOWN, it);
416
417 _content_layout_content_controls_refresh(w, it);
418}
419
420/*
421 * menu_layout section
422 */
423static void
424_menu_layout_init(Evas_Object *w)
425{
426 Evas_Object *o, *table, *list;
427 int i = 0;
428
429 table = evas_object_data_get(w, DK_MAIN_MENU_TABLE);
430
431 for (i = 0; i < 3; i++)
432 {
433 o = elm_layout_add(w);
434 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
435 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
436 elm_layout_theme_set(o, "settingspane", "menu", "default");
437// elm_layout_signal_callback_add(w, "action,back", "conf", conf_menu_back_cb, w);
438 evas_object_show(o);
439
440 list = elm_genlist_add(w);
441 elm_scroller_bounce_set(list, EINA_FALSE, EINA_FALSE);
442 elm_object_style_set(list, "flatedge");
443 evas_object_size_hint_weight_set(list, 0.0, EVAS_HINT_EXPAND);
444 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
445 elm_genlist_mode_set(list, ELM_LIST_LIMIT);
446 evas_object_data_set(o, DK_MENU_GENLIST, list);
447 elm_object_part_content_set(o, POS_MENU_CONTENT, list);
448 evas_object_show(list);
449 elm_table_pack(table, o, 0, 0, 1, 1);
450
451 if (i == 0)
452 evas_object_data_set(w, DK_MAIN_MENU_HIDDEN, o);
453 else if (i == 1)
454 evas_object_data_set(w, DK_MAIN_MENU_SHOWED, o);
455 else if (i == 2)
456 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, o);
457 }
458}
459
460static void
461_list_fill(Evas_Object *list, Elm_Settingspane_Item *item)
462{
463 IC_DATA(item);
464 C_DATA(id->sw);
465
466 Eina_List *node;
467 Elm_Settingspane_Item *child;
468
469 elm_genlist_clear(list);
470
471 EINA_LIST_FOREACH(id->childs, node, child)
472 {
473 Elm_Settingspane_Item_Data *cid = IC_DATA_L(child);
474 Elm_Object_Item *it;
475
476 it = elm_genlist_item_append(list, wd->itcc, child,
477 NULL, ELM_GENLIST_ITEM_NONE,
478 _item_sel_cb, child);
479 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_ALWAYS);
480 elm_genlist_item_tooltip_text_set(it, cid->description);
481 }
482}
483
484static void
485_menu_layout_show(Evas_Object *w, Elm_Settingspane_Item *item, Elm_Settingspane_Item *item_h)
486{
487 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
488 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
489 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
490 Evas_Object *shownlist = evas_object_data_get(shown, DK_MENU_GENLIST);
491 Evas_Object *behindlist = evas_object_data_get(behind, DK_MENU_GENLIST);
492 Elm_Settingspane_Item *shown_h, *shown_l;
493
494 shown_h = evas_object_data_get(hidden, DK_MENU_ITEM_SHOWN);
495 shown_l = evas_object_data_get(shown, DK_MENU_ITEM_SHOWN);
496
497 if (shown_l == item && shown_h == item_h)
498 return;
499
500 _list_fill(behindlist, item);
501 evas_object_data_set(behind, DK_MENU_ITEM_SHOWN, item);
502
503 //showed item has not changed
504 if (!item_h)
505 {
506 elm_layout_signal_emit(shown, EMIT_MENU_DEFAULT);
507 elm_layout_signal_emit(behind, EMIT_MENU_VISIBLE);
508 evas_object_data_del(shown, DK_MENU_ITEM_SHOWN);
509 }
510 else
511 {
512 _list_fill(shownlist, item_h);
513 elm_layout_signal_emit(shown, EMIT_MENU_HIDDEN);
514 elm_layout_signal_emit(behind, EMIT_MENU_VISIBLE_HIDDEN);
515 evas_object_data_set(shown, DK_MENU_ITEM_SHOWN, item_h);
516 }
517 evas_object_raise(shown);
518
519 evas_object_stack_below(hidden, behind);
520 elm_layout_signal_emit(hidden, EMIT_MENU_DEFAULT);
521 evas_object_data_del(hidden, DK_MENU_ITEM_SHOWN);
522
523 //reorder the use
524 evas_object_data_set(w, DK_MAIN_MENU_SHOWED, behind);
525 evas_object_data_set(w, DK_MAIN_MENU_HIDDEN, shown);
526 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, hidden);
527}
528static void
529_menu_layout_refresh(Evas_Object *w)
530{
531 Evas_Object *layouts[3];
532 int i = 0;
533
534 layouts[0] = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
535 layouts[1] = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
536 layouts[2] = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
537
538 for (i = 0; i< 3; i++)
539 {
540 Elm_Settingspane_Item *it;
541 Evas_Object *list;
542
543 it = evas_object_data_get(layouts[i], DK_MENU_ITEM_SHOWN);
544 if (!it)
545 continue;
546
547 list = evas_object_data_get(layouts[i], DK_MENU_GENLIST);
548
549 _list_fill(list, it);
550 }
551}
552
553static void
554_menu_layout_fill(Elm_Settingspane_Item *it)
555{
556 IC_DATA(it);
557 if (id->par)
558 _menu_layout_show(id->sw, it, id->par);
559 else
560 _menu_layout_show(id->sw, it, NULL);
561}
562
563static void
564_menu_layout_hide(Evas_Object *w)
565{
566 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
567 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
568 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
569
570 elm_layout_signal_emit(hidden, EMIT_MENU_DEFAULT);
571 evas_object_data_del(hidden, DK_MENU_ITEM_SHOWN);
572 elm_layout_signal_emit(shown, EMIT_MENU_DEFAULT);
573 evas_object_data_del(shown, DK_MENU_ITEM_SHOWN);
574 elm_layout_signal_emit(behind, EMIT_MENU_DEFAULT);
575 evas_object_data_del(behind, DK_MENU_ITEM_SHOWN);
576
577 elm_layout_signal_emit(w, EMIT_MENU_SEARCHMODE_ENABLE);
578}
579static void
580_menu_layout_restore(Evas_Object *w)
581{
582 elm_layout_signal_emit(w, EMIT_MENU_SEARCHMODE_DISABLE);
583}
584
585static void
586_menu_layout_hidden_to_show(Evas_Object *w, Elm_Settingspane_Item *new, Elm_Settingspane_Item *lower_new)
587{
588 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
589 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
590 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
591 Evas_Object *behindlist = evas_object_data_get(behind, DK_MENU_GENLIST);
592 Evas_Object *hiddenlist = evas_object_data_get(hidden, DK_MENU_GENLIST);
593
594 Elm_Settingspane_Item *item_shown = evas_object_data_get(shown, DK_MENU_ITEM_SHOWN);
595 Elm_Settingspane_Item *item_hidden = evas_object_data_get(hidden, DK_MENU_ITEM_SHOWN);
596
597 if ((item_hidden == lower_new) && (item_shown == new))
598 return;
599
600
601 if (lower_new)
602 {
603 elm_layout_signal_emit(behind, EMIT_MENU_DEFAULT);
604 _list_fill(behindlist, lower_new);
605 evas_object_raise(behind);
606 elm_layout_signal_emit(behind, EMIT_MENU_HIDDEN);
607 }
608
609 //I guess in the hidden one the items should be the correct one
610 _list_fill(hiddenlist, new);
611 elm_layout_signal_emit(hidden, EMIT_MENU_VISIBLE);
612 evas_object_stack_below(shown, hidden);
613
614 elm_layout_signal_emit(shown, EMIT_MENU_DEFAULT);
615
616 evas_object_data_set(w, DK_MAIN_MENU_SHOWED, hidden);
617 evas_object_data_set(w, DK_MAIN_MENU_HIDDEN, behind);
618 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, shown);
619}
620
621/*
622 * Callbacks for the items in the gengrid
623 */
624
625static char*
626_elm_settingspane_ii_text_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
627{
628 Elm_Settingspane_Item *it = data;
629 IC_DATA(it);
630
631 if (!strcmp(part, "elm.text"))
632 return strdup(id->name);
633 else if (!strcmp(part, "elm.text.sub"))
634 return strdup(id->description);
635 return NULL;
636}
637
638static Evas_Object*
639_elm_settingspane_ii_content_cb(void *data, Evas_Object *obj, const char *part)
640{
641 Elm_Settingspane_Item *it = data;
642 IC_DATA(it);
643 Evas_Object *res = NULL;
644
645 if (!strcmp(part, "elm.swallow.icon"))
646 {
647 res = id->icon;
648 }
649 else
650 {
651 res = elm_icon_add(obj);
652 elm_icon_standard_set(res, "arrow_right");
653 elm_image_no_scale_set(res, EINA_TRUE);
654 }
655 return res;
656}
657
658static Elm_Settingspane_Item*
659_item_new(Evas_Object *obj, Elm_Settingspane_Item *par, void *usr_data, const char *name, const char *description, Evas_Object *icon)
660{
661 Elm_Settingspane_Item *item = eo_add(ELM_SETTINGSPANE_ITEM_CLASS, obj);
662 Elm_Settingspane_Item_Data *data = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS);
663
664 data->data = usr_data;
665 data->sw = obj;
666 data->par = par;
667 data->name = name;
668 data->description = description;
669 data->icon = icon;
670 data->key_words = NULL;
671 data->key_words = eina_list_append(data->key_words, eina_stringshare_add(name));
672 //we need to ref this item, so elm_genlist_clear will not delete it!
673 eo_ref(icon);
674 return item;
675}
676
677static Eina_Bool
678_item_has_panel(Elm_Settingspane_Item *item)
679{
680 IC_DATA(item);
681 return HAS_PANEL(id) ? EINA_TRUE : EINA_FALSE;
682}
683
684/*static void
685_item_stack_dump(Elm_Settingspane_Data *wd)
686{
687 Eina_List *node;
688 Elm_Settingspane_Item *it;
689
690 EINA_LIST_FOREACH(wd->stack, node, it)
691 {
692 Elm_Settingspane_Item_Data *id = eo_data_scope_get(it, ELM_SETTINGSPANE_ITEM_CLASS);
693 ERR("item %p:%s", id, id->class->style);
694 }
695}*/
696
697static void
698_back_check(Evas_Object *w)
699{
700 if (_history_stack_end(w))
701 elm_layout_signal_emit(w, EMIT_BACK_DISABLE);
702 else
703 elm_layout_signal_emit(w, EMIT_BACK_ENABLE);
704}
705
706static void
707_unsaved_check(Evas_Object *w)
708{
709 C_DATA(w);
710 if (eina_list_count(wd->unsaved_changes) == 0)
711 elm_layout_signal_emit(w, EMIT_UNSAVED_DISABLE);
712 else
713 elm_layout_signal_emit(w, EMIT_UNSAVED_ENABLE);
714}
715
716static void
717_unsaved_changes_add(Evas_Object *w, Elm_Object_Item *item)
718{
719 Eina_List *node;
720 Elm_Object_Item *it;
721 C_DATA(w);
722 EINA_LIST_FOREACH(wd->unsaved_changes, node, it)
723 {
724 if (it == item)
725 return;
726 }
727 wd->unsaved_changes = eina_list_append(wd->unsaved_changes, item);
728 _unsaved_check(w);
729}
730
731static void
732_unsaved_changes_remove(Evas_Object *w, Elm_Object_Item *item)
733{
734 C_DATA(w);
735 wd->unsaved_changes = eina_list_remove(wd->unsaved_changes, item);
736 _unsaved_check(w);
737}
738
739static void
740_history_stack_push(Evas_Object *w, Elm_Object_Item *it)
741{
742 C_DATA(w);
743 IC_DATA(it);
744 Elm_Object_Item *old;
745 Elm_Settingspane_Item_Data *ido;
746
747 /* we just want one item to be on the stack */
748 _history_stack_remove(w, it);
749
750 old = _history_stack_current(w);
751 ido = IC_DATA_L(old);
752 wd->history_stack = eina_list_append(wd->history_stack, it);
753
754 if (old && HAS_PANEL(ido))
755 {
756 _content_layout_content_hide(w, ido->changed);
757 }
758
759 if (HAS_PANEL(id))
760 {
761 _content_layout_content_set(id->sw, it);
762 }
763 else
764 _menu_layout_show(id->sw, it, old);
765
766 /* check if back is still valid */
767 _back_check(w);
768 /* refresh tiltlebar */
769 _title_bar_refresh(w);
770}
771
772static Elm_Object_Item*
773_history_stack_pop(Evas_Object *w)
774{
775 C_DATA(w);
776 Elm_Object_Item *current, *poped;
777 Elm_Settingspane_Item_Data *poped_id;
778 Eina_Bool keep = EINA_FALSE;
779
780 if (_history_stack_end(w))
781 return NULL;
782
783 poped = _history_stack_current(w);
784 poped_id = IC_DATA_L(poped);
785
786 /* check for unsaved changes */
787 if (poped_id->changed)
788 keep = EINA_TRUE;
789 /* pop the item */
790 wd->history_stack = eina_list_remove(wd->history_stack, poped);
791 /* new top item */
792 current = _history_stack_current(w);
793
794 /* make animations and display the new panels */
795 if (_item_has_panel(current) && _item_has_panel(poped))
796 {
797 IC_DATA(current);
798 _menu_layout_fill(id->par);
799 _content_layout_content_hide(w, keep);
800 _content_layout_content_set(w, current);
801 }
802 else if (_item_has_panel(current) && !_item_has_panel(poped))
803 {
804 IC_DATA(current);
805 _menu_layout_fill(id->par);
806 _content_layout_content_hide(w, keep);
807 _content_layout_content_set(w, current);
808 }
809 else if (!_item_has_panel(current) && _item_has_panel(poped))
810 {
811 _content_layout_content_hide(w, keep);
812 _menu_layout_fill(current);
813 }
814 else
815 {
816 IC_DATA(current);
817 _menu_layout_hidden_to_show(w, current, id->par);
818 }
819
820 /* check if back is still valid */
821 _back_check(w);
822 /* refresh tiltlebar */
823 _title_bar_refresh(w);
824 return poped;
825}
826
827static Elm_Object_Item*
828_history_stack_current(Evas_Object *w)
829{
830 C_DATA(w);
831 return eina_list_data_get(eina_list_last(wd->history_stack));
832}
833
834static Eina_Bool
835_history_stack_end(Evas_Object *w)
836{
837 C_DATA(w);
838 return eina_list_count(wd->history_stack) == 1;
839}
840
841static void
842_history_stack_remove(Evas_Object *w, Elm_Object_Item *rm_it)
843{
844 C_DATA(w);
845 Eina_List *node, *node2;
846 Elm_Object_Item *it;
847 /* we need to iterate throuw it, eina_list_remove removes it just once */
848 EINA_LIST_FOREACH_SAFE(wd->history_stack, node, node2, it)
849 {
850 if (it == rm_it)
851 wd->history_stack = eina_list_remove(wd->history_stack, it);
852 }
853}
854
855static void
856_item_append(Elm_Settingspane_Item *root, Elm_Settingspane_Item *toadd, Elm_Settingspane_Item *rel)
857{
858 IC_DATA(root);
859 id->childs = eina_list_append_relative(id->childs, toadd, rel);
860
861 if (_history_stack_current(id->sw) == root)
862 _menu_layout_refresh(id->sw);
863}
864
865static void
866_item_del(Elm_Settingspane_Item *del, Eina_Bool full)
867{
868 IC_DATA(del);
869 Elm_Settingspane_Item_Data *id_par = NULL;
870 Eina_List *node, *nnode;
871 Elm_Settingspane_Item *ci;
872
873 if (id->changed)
874 {
875 ERR("This page has unsaved changes, you have lost all the data!");
876 }
877 if (!full)
878 {
879 Elm_Settingspane_Item *top = _history_stack_current(id->sw);
880 if (top == del)
881 {
882 _history_stack_pop(id->sw);
883 }
884 }
885 EINA_LIST_FOREACH_SAFE(id->childs, node, nnode, ci)
886 {
887 _item_del(ci, full);
888 }
889
890 if (id->par)
891 {
892 id_par = IC_DATA_L(id->par);
893 id_par->childs = eina_list_remove(id_par->childs, del);
894 }
895 if (!full)
896 _menu_layout_refresh(id->sw);
897 //if we have the item somewhere in the stack, remove it!
898 _history_stack_remove(id->sw, del);
899 //unref the content, if there is one
900 eo_del(del);
901}
902
903static void
904_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
905{
906 Elm_Settingspane_Item *curr, *selected = data;
907 IC_DATA(selected);
908
909 curr = _history_stack_current(id->sw);
910
911 if (curr == selected)
912 return;
913
914 eo_do(data, elm_obj_settingspane_item_focus());
915}
916/*
917 * Seachbar stuff
918 */
919
920static void
921_search_panel_display(Evas_Object *w)
922{
923 Evas_Object *o, *l, *g;
924 C_DATA(w);
925
926 o = elm_box_add(w);
927 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
928 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
929 wd->search.display = o;
930 evas_object_show(o);
931
932 l = elm_label_add(w);
933 evas_object_size_hint_weight_set(l, EVAS_HINT_EXPAND, 0.0);
934 evas_object_size_hint_align_set(l, EVAS_HINT_FILL, EVAS_HINT_FILL);
935 evas_object_data_set(o, DK_SEARCH_LABEL, l);
936 elm_box_pack_end(o, l);
937 evas_object_show(l);
938
939 g = elm_gengrid_add(w);
940 elm_gengrid_item_size_set(g, 150, 150);
941 evas_object_size_hint_weight_set(g, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
942 evas_object_size_hint_align_set(g, EVAS_HINT_FILL, EVAS_HINT_FILL);
943 evas_object_data_set(o, DK_SEARCH_GRID, g);
944 elm_box_pack_end(o, g);
945 evas_object_show(g);
946
947 evas_object_data_set(w, DK_MAIN_SEARCH_OBJECTS, o);
948 _content_layout_content_hide(w, EINA_TRUE);
949 _content_layout_display(w, o);
950 _menu_layout_hide(w);
951}
952
953static void
954_search_panel_hide(Evas_Object *w)
955{
956 Elm_Settingspane_Item *item;
957 Elm_Settingspane_Item_Data *id;
958 Evas_Object *o;
959
960 item = _history_stack_current(w);
961 id = IC_DATA_L(item);
962
963 o = evas_object_data_get(w, DK_MAIN_SEARCH_OBJECTS);
964 if (!o)
965 return;
966
967 if (_item_has_panel(item))
968 {
969 _content_layout_content_hide(w, EINA_TRUE);
970 _content_layout_content_set(w, item);
971 if (id->par)
972 {
973 _menu_layout_restore(w);
974 _menu_layout_fill(id->par);
975 }
976 }
977 else
978 {
979 _content_layout_content_hide(w, EINA_TRUE);
980 _menu_layout_restore(w);
981 _menu_layout_fill(item);
982 }
983
984 evas_object_del(o);
985 evas_object_data_del(w, DK_MAIN_SEARCH_OBJECTS);
986}
987
988static void
989_search_panel_stop(Evas_Object *w)
990{
991 C_DATA(w);
992 Evas_Object *search;
993
994 search = elm_object_part_content_get(w, POS_MAIN_SEARCH);
995 _search_panel_hide(w);
996 elm_object_text_set(search, "");
997 wd->search.on = EINA_FALSE;
998 ecore_thread_cancel(wd->search.run);
999}
1000
1001static char*
1002_search_grid_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
1003{
1004 IC_DATA(data);
1005
1006 return strdup(id->name);
1007}
1008
1009
1010static Evas_Object*
1011_search_grid_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
1012{
1013 IC_DATA(data);
1014
1015 if (!strcmp(part, "elm.swallow.icon"))
1016 return id->icon;
1017 else
1018 return NULL;
1019}
1020
1021static void
1022_search_grid_item_sel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1023{
1024 IC_DATA(data);
1025
1026 _search_panel_stop(id->sw);
1027 eo_do(data, elm_obj_settingspane_item_focus());
1028}
1029
1030static void
1031_search_grid_del(void *data, Evas_Object *obj EINA_UNUSED)
1032{
1033 IC_DATA(data);
1034
1035 /* Also called when the widget is deleted, but then the item is allready freed.
1036 * This would result in a crash.
1037 */
1038 if (!id) return;
1039 evas_object_hide(id->icon);
1040}
1041
1042static void *
1043_search_display_items(void *data)
1044{
1045 Search_Run *sr = data;
1046 Eina_List *node;
1047 Elm_Settingspane_Item *it;
1048 Elm_Gengrid_Item_Class *gic = NULL;
1049 Evas_Object *grid = evas_object_data_get(sr->data->search.display,
1050 DK_SEARCH_GRID);
1051
1052 elm_gengrid_clear(grid);
1053
1054 gic = elm_gengrid_item_class_new();
1055 gic->item_style = "thumb";
1056 gic->func.text_get = _search_grid_label_get;
1057 gic->func.content_get = _search_grid_content_get;
1058 gic->func.del = _search_grid_del;
1059
1060 EINA_LIST_FOREACH(sr->results, node, it)
1061 {
1062 elm_gengrid_item_append(grid, gic, it, _search_grid_item_sel, it);
1063 }
1064
1065 return NULL;
1066}
1067
1068/*
1069 * !!!This code runs in a seperated thread!!!
1070 */
1071
1072
1073static Eina_Bool
1074_item_found(Elm_Settingspane_Item_Data *id, const char* keyword)
1075{
1076 Eina_List *node;
1077 Eina_Stringshare *val;
1078 int l = strlen(keyword);
1079
1080 EINA_LIST_FOREACH(id->key_words, node, val)
1081 {
1082 if (!strncasecmp(val, keyword, l))
1083 {
1084 return EINA_TRUE;
1085 }
1086 }
1087 return EINA_FALSE;
1088}
1089
1090static void
1091_search_tree(Elm_Settingspane_Item *it, Eina_List **results, const char *keyword)
1092{
1093 IC_DATA(it);
1094 Eina_List *node;
1095 Elm_Settingspane_Item *item;
1096
1097 if (_item_found(id, keyword))
1098 {
1099 *results = eina_list_append(*results, it);
1100 }
1101
1102 EINA_LIST_FOREACH(id->childs, node ,item)
1103 _search_tree(item, results, keyword);
1104}
1105
1106static void
1107_search_cb(void *data, Ecore_Thread *th)
1108{
1109 Search_Run *sr = data;
1110
1111 _search_tree(sr->data->zero, &(sr->results), sr->keyword);
1112
1113 if (ecore_thread_check(th))
1114 return;
1115
1116 ecore_main_loop_thread_safe_call_sync(_search_display_items, sr);
1117}
1118/*
1119 * END OF !!!This code runs in a seperated thread!!!
1120 */
1121
1122static void
1123_search_cb_ended(void *data, Ecore_Thread *th EINA_UNUSED)
1124{
1125 Search_Run *sr = data;
1126
1127 sr->data->search.run = NULL;
1128 free(sr);
1129}
1130
1131
1132static void
1133_search_panel_search_string_update(Evas_Object *w, const char *word)
1134{
1135 char buf[PATH_MAX];
1136 Search_Run *sr;
1137 C_DATA(w);
1138 Evas_Object *l = evas_object_data_get(wd->search.display, DK_SEARCH_LABEL);
1139
1140 sr = calloc(1, sizeof(Search_Run));
1141 sr->keyword = word;
1142 sr->data = wd;
1143
1144 snprintf(buf, sizeof(buf), "Search results for \"%s\": ", word);
1145 elm_object_text_set(l, buf);
1146
1147 if (wd->search.run)
1148 ecore_thread_cancel(wd->search.run);
1149 wd->search.run = ecore_thread_run(_search_cb, _search_cb_ended, NULL, sr);
1150}
1151
1152static void
1153_search_entry_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
1154{
1155 Evas_Object *w = data;
1156 C_DATA(data);
1157 const char *edit;
1158
1159 edit = elm_object_text_get(obj);
1160
1161 if (!strcmp(edit, ""))
1162 {
1163 if (!wd->search.on)
1164 return;
1165 _search_panel_stop(w);
1166 return;
1167 }
1168
1169 if (!wd->search.on)
1170 {
1171 wd->search.on = EINA_TRUE;
1172 _search_panel_display(w);
1173 }
1174 _search_panel_search_string_update(w, edit);
1175}
1176
1177static void
1178_conf_unsaved_item_click_cb(void *data, Evas_Object *obj, void *event EINA_UNUSED)
1179{
1180 Elm_Object_Item *it = data;
1181 IC_DATA(it);
1182
1183 evas_object_data_del(id->sw, DK_UNSAVED_OPENED);
1184
1185 eo_do(it, elm_obj_settingspane_item_focus());
1186 evas_object_hide(obj);
1187}
1188
1189static void
1190_conf_unsaved_menu_ctx_item_add(Evas_Object *ctx, Elm_Object_Item *it)
1191{
1192 IC_DATA(it);
1193 char buf[PATH_MAX];
1194 const char *group, *file;
1195 Evas_Object *ic;
1196
1197 snprintf(buf, sizeof(buf), "*%s", id->name);
1198
1199 ic = elm_icon_add(ctx);
1200 elm_image_file_get(id->icon, &file, &group);
1201 elm_image_file_set(ic, file, group);
1202 evas_object_show(ic);
1203
1204 elm_ctxpopup_item_append(ctx, buf, ic, _conf_unsaved_item_click_cb, it);
1205}
1206
1207static void
1208_conf_unsaved_dismissed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
1209{
1210 Evas_Object *par = data;
1211 evas_object_data_del(par, DK_UNSAVED_OPENED);
1212}
1213
1214static void
1215_conf_unsaved_menu_show(Evas_Object *par, int x, int y, char *style )
1216{
1217 Elm_Object_Item *it;
1218 Eina_List *node;
1219 Evas_Object *ctx;
1220 C_DATA(par);
1221
1222 if (eina_list_count(wd->unsaved_changes) == 0 || evas_object_data_get(par, DK_UNSAVED_OPENED))
1223 return;
1224
1225 evas_object_data_set(par, DK_UNSAVED_OPENED, (void*)1);
1226
1227 ctx = elm_ctxpopup_add(par);
1228 elm_object_style_set(ctx, style);
1229 evas_object_smart_callback_add(ctx, "dismissed", _conf_unsaved_dismissed_cb, par);
1230
1231 elm_ctxpopup_direction_priority_set(ctx, ELM_CTXPOPUP_DIRECTION_DOWN,
1232 ELM_CTXPOPUP_DIRECTION_LEFT,
1233 ELM_CTXPOPUP_DIRECTION_RIGHT,
1234 ELM_CTXPOPUP_DIRECTION_UP);
1235 EINA_LIST_FOREACH(wd->unsaved_changes, node, it)
1236 {
1237 _conf_unsaved_menu_ctx_item_add(ctx, it);
1238 }
1239 evas_object_move(ctx, x, y);
1240 evas_object_show(ctx);
1241}
1242
1243static void
1244_conf_unsaved_menu_cb(void *data EINA_UNUSED, Evas_Object *obj, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
1245{
1246 int x, y;
1247
1248 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
1249 _conf_unsaved_menu_show(obj, x, y, "default");
1250}
1251
1252static void
1253_history_menu_item_sel_cb(void *data, Evas_Object *obj, void *event EINA_UNUSED)
1254{
1255 Elm_Object_Item *it = data;
1256 eo_do(it, elm_obj_settingspane_item_focus());
1257 evas_object_hide(obj);
1258}
1259
1260static void
1261_history_menu_show(Evas_Object *par, int x, int y)
1262{
1263 Evas_Object *ctx;
1264 C_DATA(par);
1265 Eina_List *node;
1266 Elm_Widget_Item *it;
1267
1268 ctx = elm_ctxpopup_add(par);
1269 elm_ctxpopup_direction_priority_set(ctx, ELM_CTXPOPUP_DIRECTION_DOWN,
1270 ELM_CTXPOPUP_DIRECTION_LEFT,
1271 ELM_CTXPOPUP_DIRECTION_RIGHT,
1272 ELM_CTXPOPUP_DIRECTION_UP);
1273
1274 EINA_LIST_REVERSE_FOREACH(wd->history_stack, node, it)
1275 {
1276 if (it == wd->zero) continue;
1277 IC_DATA(it);
1278 elm_ctxpopup_item_append(ctx, id->name, NULL, _history_menu_item_sel_cb, it); //< FIXME
1279 }
1280
1281 evas_object_move(ctx, x, y);
1282 evas_object_show(ctx);
1283}
1284
1285static void
1286_history_menu_show_cb(void *data EINA_UNUSED, Evas_Object *obj, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
1287{
1288 int x, y;
1289
1290 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
1291 _history_menu_show(obj, x, y);
1292}
1293
1294EOLIAN static void
1295_elm_settingspane_evas_object_smart_add(Eo *obj, Elm_Settingspane_Data *pd)
1296{
1297 Evas_Object *bx, *en, *tb1, *tb2;
1298
1299 eo_do_super(obj, ELM_SETTINGSPANE_CLASS, evas_obj_smart_add());
1300 elm_widget_sub_object_parent_add(obj);
1301 elm_widget_can_focus_set(obj, EINA_TRUE);
1302
1303 if (!elm_layout_theme_set(obj, "settingspane", "base", "default"))
1304 {
1305 CRI("Failed to set theme file");
1306 }
1307 elm_layout_signal_callback_add(obj, "elm,action,back", EMITTER, conf_menu_back_cb, obj);
1308 elm_layout_signal_callback_add(obj, "elm,unsaved,clicked", EMITTER, _conf_unsaved_menu_cb, obj);
1309 elm_layout_signal_callback_add(obj, "elm,action,back_menu", EMITTER, _history_menu_show_cb, obj);
1310 elm_layout_signal_emit(obj, EMIT_BACK_DISABLE);
1311
1312 bx = elm_box_add(obj);
1313 elm_box_align_set(bx, 0.0, 0.5);
1314 elm_box_horizontal_set(bx, EINA_TRUE);
1315 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1316 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1317 elm_object_part_content_set(obj, POS_MAIN_TITLE, bx);
1318 evas_object_data_set(obj, DK_MAIN_TITLE_BOX, bx);
1319 evas_object_show(bx);
1320
1321 en = elm_entry_add(obj);
1322 elm_entry_single_line_set(en, EINA_TRUE);
1323 elm_entry_scrollable_set(en, EINA_TRUE);
1324 evas_object_smart_callback_add(en, "changed", _search_entry_changed, obj);
1325 elm_object_part_text_set(en, "guide", "Search");
1326 elm_object_part_content_set(obj, POS_MAIN_SEARCH, en);
1327 evas_object_show(en);
1328
1329 tb1 = elm_table_add(obj);
1330 evas_object_size_hint_weight_set(tb1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1331 evas_object_size_hint_align_set(tb1, EVAS_HINT_FILL, EVAS_HINT_FILL);
1332 elm_object_part_content_set(obj, POS_MAIN_PANEL, tb1);
1333 evas_object_show(tb1);
1334 evas_object_data_set(obj, DK_MAIN_PANEL_TABLE, tb1);
1335
1336 tb2 = elm_table_add(obj);
1337 evas_object_size_hint_weight_set(tb2, 0.0, EVAS_HINT_EXPAND);
1338 evas_object_size_hint_align_set(tb2, 0.0, EVAS_HINT_FILL);
1339 elm_object_part_content_set(obj, POS_MAIN_MENU, tb2);
1340 evas_object_show(tb2);
1341 evas_object_data_set(obj, DK_MAIN_MENU_TABLE, tb2);
1342
1343
1344 _content_layout_content_init(obj);
1345 _menu_layout_init(obj);
1346
1347 pd->zero = _item_new(obj, NULL, NULL, eina_stringshare_add("root"), eina_stringshare_add(""), NULL);
1348 _history_stack_push(obj, pd->zero);
1349 _title_bar_refresh(obj);
1350 }
1351
1352EOLIAN static void
1353_elm_settingspane_eo_base_constructor(Eo *obj, Elm_Settingspane_Data *pd)
1354{
1355 eo_do_super(obj, ELM_SETTINGSPANE_CLASS, eo_constructor());
1356
1357 pd->itcc = elm_genlist_item_class_new();
1358 pd->itcc->item_style = "double_label_unblock";
1359 pd->itcc->func.text_get = _elm_settingspane_ii_text_cb;
1360 pd->itcc->func.content_get = _elm_settingspane_ii_content_cb;
1361}
1362
1363static Elm_Settingspane_Item *
1364_elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *data,
1365 const char *name, const char *description,
1366 Evas_Object *icon, Elm_Settingspane_Item *par,
1367 Elm_Settingspane_Item *rel)
1368{
1369 Elm_Settingspane_Item *new_child = NULL;
1370 Elm_Settingspane_Item_Data *data_par;
1371
1372 /*
1373 * Append to the zero level
1374 */
1375 if (!par)
1376 {
1377 new_child = _item_new(obj, pd->zero, data, name, description, icon);
1378 _item_append(pd->zero, new_child, rel);
1379 return new_child;
1380 }
1381
1382 data_par = IC_DATA_L(par);
1383 if (!data_par)
1384 return NULL;
1385 if (HAS_PANEL(data_par))
1386 {
1387 ERR("You cannot add a menu item to a item with a panel!");
1388 return NULL;
1389 }
1390 else
1391 {
1392 new_child = _item_new(obj, par, data, name, description, icon);
1393 _item_append(par, new_child, rel);
1394 }
1395 return new_child;
1396}
1397
1398EOLIAN static Elm_Settingspane_Item *
1399_elm_settingspane_item_append(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, const char *description, Evas_Object *icon, Elm_Settingspane_Item *par)
1400{
1401 return _elm_settingspane_item_append_full(obj, pd, data, name, description, icon, par, NULL);
1402}
1403
1404EOLIAN static Elm_Settingspane_Item *
1405_elm_settingspane_item_append_relative(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, const char *description, Evas_Object *icon, Elm_Settingspane_Item *rel)
1406{
1407 EINA_SAFETY_ON_NULL_RETURN_VAL(rel, NULL);
1408 Elm_Settingspane_Item_Data *id = eo_data_scope_get(rel, ELM_SETTINGSPANE_ITEM_CLASS);
1409 return _elm_settingspane_item_append_full(obj, pd, data, name, description, icon, id->par, rel);
1410}
1411
1412/* Item implement */
1413EOLIAN static void
1414_elm_settingspane_item_focus(Eo *obj, Elm_Settingspane_Item_Data *pd)
1415{
1416 _history_stack_push(pd->sw, obj);
1417}
1418
1419EOLIAN static void
1420_elm_settingspane_item_delete(Eo *obj, Elm_Settingspane_Item_Data *pd EINA_UNUSED)
1421{
1422 _item_del(obj, EINA_FALSE);
1423}
1424
1425EOLIAN static const Elm_Settingspane_Item *
1426_elm_settingspane_item_parent_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd)
1427{
1428 return pd->par;
1429}
1430
1431EOLIAN static void
1432_elm_settingspane_item_changed_set(Eo *obj, Elm_Settingspane_Item_Data *pd, Eina_Bool changed)
1433{
1434 pd->changed = changed;
1435 if (changed)
1436 _unsaved_changes_add(pd->sw, obj);
1437 else
1438 _unsaved_changes_remove(pd->sw, obj);
1439 _content_layout_content_controls_refresh(pd->sw, obj);
1440}
1441
1442EOLIAN static Eina_Bool
1443_elm_settingspane_item_changed_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd)
1444{
1445 return pd->changed;
1446}
1447
1448EOLIAN static const char *
1449_elm_settingspane_item_name_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd)
1450{
1451 return pd->name;
1452}
1453
1454EOLIAN static const char *
1455_elm_settingspane_item_description_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd)
1456{
1457 return pd->description;
1458}
1459
1460EOLIAN static void
1461_elm_settingspane_item_attach_panel(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, Content_Get_Cb content_get, Evas_Smart_Cb reset, Evas_Smart_Cb apply)
1462{
1463 if (pd->childs)
1464 {
1465 ERR("You cannot add a panel to a item with childs!");
1466 return;
1467 }
1468 pd->panel.content_get = content_get;
1469 pd->panel.reset = reset;
1470 pd->panel.apply = apply;
1471}
1472
1473EOLIAN static void
1474_elm_settingspane_item_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd)
1475{
1476 if (pd->panel.tmp_content)
1477 eo_unref(pd->panel.tmp_content);
1478 //unref the icon,
1479 eo_unref(pd->icon);
1480 eo_do_super(obj, ELM_SETTINGSPANE_ITEM_CLASS, eo_destructor());
1481}
1482
1483
1484EOLIAN static void
1485_elm_settingspane_item_keyword_add(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, Eina_Stringshare *str)
1486{
1487 eina_stringshare_ref(str);
1488 pd->key_words = eina_list_append(pd->key_words, str);
1489}
1490
1491EOLIAN static void
1492_elm_settingspane_item_keyword_delete(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, Eina_Stringshare *str)
1493{
1494 eina_stringshare_del(str);
1495 pd->key_words = eina_list_remove(pd->key_words, str);
1496}
1497
1498/* widget api calls */
1499EOLIAN static Eina_Bool
1500_elm_settingspane_save_quit(Eo *obj EINA_UNUSED, Elm_Settingspane_Data *pd)
1501{
1502 return (pd->unsaved_changes) ? EINA_FALSE : EINA_TRUE;
1503}
1504
1505EOLIAN static void
1506_elm_settingspane_raise_unsaved(Eo *obj, Elm_Settingspane_Data *pd EINA_UNUSED)
1507{
1508 int x, y, w, h;
1509 evas_object_geometry_get(obj, &x, &y, &w, &h);
1510 _conf_unsaved_menu_show(obj, w/2, h/2, "clean");
1511}
1512
1513EOLIAN static void
1514_elm_settingspane_eo_base_destructor(Eo *obj, Elm_Settingspane_Data *pd)
1515{
1516 _item_del(pd->zero, EINA_TRUE);
1517 eo_do_super(obj, ELM_SETTINGSPANE_CLASS, eo_destructor());
1518}
1519
1520
1521static Elm_Settingspane_Item*
1522_item_search(Elm_Settingspane_Item *it, char **string, int lvl)
1523{
1524 IC_DATA(it);
1525 Elm_Settingspane_Item *item;
1526 Eina_List *node;
1527
1528 EINA_LIST_FOREACH(id->childs, node, item)
1529 {
1530 Elm_Settingspane_Item_Data *iid = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS);
1531
1532 if (strcmp(iid->name, string[lvl]))
1533 continue;
1534
1535 if (string[lvl +1])
1536 return _item_search(item, string, lvl +1);
1537 else
1538 return item;
1539 }
1540 return NULL;
1541}
1542
1543EOLIAN static Elm_Settingspane_Item *
1544_elm_settingspane_item_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Data *pd, const char *paths)
1545{
1546 char **string = eina_str_split(paths, "/", 0);
1547 return _item_search(pd->zero, string, 0);
1548}
1549
1550/* Implement of a legacy function */
1551
1552EAPI Evas_Object *
1553elm_settingspane_add(Evas_Object *parent)
1554{
1555 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
1556 Evas_Object *obj = eo_add(ELM_SETTINGSPANE_CLASS, parent);
1557 return obj;
1558}
1559#include "elm_settingspane_item.eo.c"
1560#include "elm_settingspane.eo.c" \ No newline at end of file
diff --git a/src/lib/elc_settingspane.h b/src/lib/elc_settingspane.h
new file mode 100644
index 000000000..420465e45
--- /dev/null
+++ b/src/lib/elc_settingspane.h
@@ -0,0 +1,8 @@
1typedef Evas_Object* (*Content_Get_Cb)(Evas_Object *par, Eo *item, void *data);
2
3#ifdef EFL_EO_API_SUPPORT
4#include "elc_settingspane_eo.h"
5#endif
6#ifndef EFL_NO_LEGACY_API_SUPPORT
7#include "elc_settingspane_legacy.h"
8#endif
diff --git a/src/lib/elc_settingspane_eo.h b/src/lib/elc_settingspane_eo.h
new file mode 100644
index 000000000..b6bfb235d
--- /dev/null
+++ b/src/lib/elc_settingspane_eo.h
@@ -0,0 +1,2 @@
1#include "elm_settingspane_item.eo.h"
2#include "elm_settingspane.eo.h"
diff --git a/src/lib/elc_settingspane_legacy.h b/src/lib/elc_settingspane_legacy.h
new file mode 100644
index 000000000..7a78f334f
--- /dev/null
+++ b/src/lib/elc_settingspane_legacy.h
@@ -0,0 +1,4 @@
1EAPI Evas_Object* elm_settingspane_add(Evas_Object *parent);
2
3#include "elm_settingspane_item.eo.legacy.h"
4#include "elm_settingspane.eo.legacy.h"
diff --git a/src/lib/elm_settingspane.eo b/src/lib/elm_settingspane.eo
new file mode 100644
index 000000000..ce8761dee
--- /dev/null
+++ b/src/lib/elm_settingspane.eo
@@ -0,0 +1,107 @@
1class Elm_Settingspane(Elm_Layout)
2{
3 eo_prefix: elm_obj_settingspane;
4 properties {
5 }
6 methods {
7 item_get {
8 /*@
9 Return the Item from this path
10
11 This will search the item of the given paths.
12 If the path is "settings/monitor/resolution"
13 The Item resolution in the parent "monitor" in the parent "settings" will be searched.
14 If the item is found, it will be retured, if it isnt, NULL is returned
15
16 @see elm_settingspane_item_focus
17
18 @ingroup Elm_Settingspane*/
19 return: Elm_Settingspane_Item* ;
20 params {
21 @in const(char) *paths;
22 }
23 }
24 item_append {
25 /*@
26 Append a item.
27
28 This will append a item with the given name, description and icon to the widget,
29 if par is not NULL it will be placed as a child of par. If par is NULL it will be placed in the 0 level.
30
31 @note *data will be passed as data to the specific callbacks.
32
33 @see elm_settingspane_item_append_relative
34
35 @ingroup Elm_Settingspane*/
36 return: Elm_Settingspane_Item *;
37 params {
38 @in void *data;
39 @in const(char) *name;
40 @in const(char) *description;
41 @in Evas_Object *icon;
42 @in Elm_Settingspane_Item *par;
43 }
44 }
45 item_append_relative {
46 /*@
47 Append a item relative
48
49 This will append a item like item_append, with the only difference that it will be appended to rel,
50 The parent of rel will be took as parent.
51
52 @note This will fail if rel is NULL
53
54 @see item_append
55
56 @ingroup Elm_Settingspane
57
58 */
59 return: Elm_Settingspane_Item *;
60 params {
61 @in void *data;
62 @in const(char) *name;
63 @in const(char) *description;
64 @in Evas_Object *icon;
65 @in Elm_Settingspane_Item *rel;
66 }
67 }
68 save_quit {
69 /*@
70 Check if everything is saved
71
72 With the internal stack of the widget it is possible that multiple panels are opened above each other.
73 If the changed flag is set to one of this panels the apply/reset buttons are enabled,
74 and you cannot close this page before you clicked reset or apply.
75 If there are panels with the change flag set this function will return EINA_FALSE,
76 if no change flag is set on the opened panel it will return EINA_TRUE
77
78 @see raise_unsaved
79
80 @return EINA_TRUE if no change flag is set on the opened panels.
81 @ingroup Elm_Settingspane
82
83 */
84 return: Eina_Bool;
85 }
86 raise_unsaved {
87 /*@
88 Raise unsaved panels in the internal stack
89
90 This will raise internal panels which have the changed flag set.
91 The panels are raised with a error highlighting.
92
93 The lowest unsaved panel will later be the lowest unsaved panel. The highest at the top.
94 All panels with unsaved changes will be infront of those without unsaved changes.
95
96 @see save_quit
97
98 @ingroup Elm_Settingspane
99 */
100 }
101 }
102 implements {
103 Eo.Base.constructor;
104 Eo.Base.destructor;
105 Evas.Object_Smart.add;
106 }
107}
diff --git a/src/lib/elm_settingspane_item.eo b/src/lib/elm_settingspane_item.eo
new file mode 100644
index 000000000..7711c14c0
--- /dev/null
+++ b/src/lib/elm_settingspane_item.eo
@@ -0,0 +1,167 @@
1class Elm_Settingspane_Item(Eo.Base){
2 eo_prefix: elm_obj_settingspane_item;
3 data: Elm_Settingspane_Item_Data;
4 properties {
5 name {
6 get {
7 /*@
8 Returns the name of the item
9
10 This will return the name which was passed at the creation via append_item or item_append_relative
11 This is the string displayed in the item.
12
13 @return The name of the item
14 */
15 }
16 values {
17 const (char) *name;
18 }
19 }
20 description{
21 get {
22 /*@
23 Return the description of the item
24
25 This will return the description which was passed at the creation via
26 append_item or item_append_relative.
27 This is the string displayed lower of the name.
28
29 @return The description of the item
30 */
31 }
32 values {
33 const (char) *description;
34 }
35 }
36 parent {
37 get {
38 /*@
39 Returns the parent of this item
40
41 This will return the parent item of this item. If there is none it will return NULL.
42
43 @return The Elm_Settingspane_Item of the parent.
44 */
45 }
46 values {
47 const (Elm_Settingspane_Item) *par;
48 }
49 }
50 changed {
51 /*
52 * This will mark this item internally as changed,
53 * the apply button will be enabled, and the item cannot be poped from stack anymore.
54 * This can be undo if the user clicks the apply or reset button.
55 */
56 get {
57 /*@
58 Returns the changed flag
59
60 This returns the changed flag of this Item.
61
62 The changed flag controls the enable/disable of the apply and reset buttons,
63 and controls if the panel can be closed.
64
65 If this flag is set the apply and reset buttons are enabled, a click on them will
66 result in the callbacks to the panel.
67 If someone tryes to close this panel while there are unsaved changes,
68 the panel will be highlighted with an error.
69
70 @return EINA_TRUE if the flag is set, EINA_FALSE if not
71 */
72 }
73 set {
74 /*@
75 Set the chagned flag
76
77 This will set the changed flag for this item.
78
79 The changed flag controls the enable/disable of the apply and reset buttons,
80 and controls if the panel can be closed.
81
82 If this flag is set the apply and reset buttons are enabled, a click on them will
83 result in the callbacks to the panel.
84 If someone tryes to close this panel while there are unsaved changes,
85 the panel will be highlighted with an error.
86
87 @note if this item doesnt have a attached panel settings this is useless
88 */
89 }
90 values {
91 Eina_Bool changed;
92 }
93 }
94 }
95 methods {
96 keyword_add {
97 /*@
98 Append a string to the internal search list.
99 If items are searched the keyword is checked against the elements of this stringlist.
100 */
101 params {
102 @in Eina_Stringshare* str; /*@ The String to append to the list*/
103 }
104 }
105 keyword_delete {
106 /*@
107 Delete a string from the internal search list.
108 */
109 params {
110 @in Eina_Stringshare* str; /*@ The String to remove from the internal list*/
111 }
112 }
113 attach_panel {
114 /*@
115 Attach a panel to the item
116
117 This will attach a panel to this item.
118
119 Attaching a panel means if this items gets focused this panel will be shown.
120
121 The callback content_get is just called if this item gets displayed.
122 If it was closed once and opened another time the callback will be called a second time.
123
124 reset and apply are called when the apply or reset button is clicked.
125
126 @note The panel can just be attached if this node doenst have childs.
127 @note Once the panel has a panel it cannot be used as a parent node anymore.
128
129 @ingroup Elm_Settingspane
130 */
131 params {
132 @in Content_Get_Cb content_get; /*@ Callback to call when the content is requested
133 Each time the panel is selected content is requested with the content_cb,
134 If the content is changed the old Evas_Object will be saved and displayed next time the item is selected. */
135 @in Evas_Smart_Cb reset; /*@ Callback to call when the reset button is clicked */
136 @in Evas_Smart_Cb apply; /*@ Callback to call when the apply button is clicked */
137 }
138 }
139 focus {
140 /*@
141 Focus this item
142
143 This will focus the item in the widget, this means its children will be displayed in the menu,
144 or the attached panel will be shown, this item will be the highest on the stack.
145
146 @ingroup Elm_Settingspane
147 */
148 }
149 delete {
150 /*@
151 Delete this item
152
153 This will delete this item from the widget.
154
155 If there are children they will also be deleted.
156 If the parent of this item is just diplayed it will be refreshed and show
157 the state after this item is deleted.
158 If this item is the current focused item the stack will go back to a not deleted item.
159
160 @ingroup Elm_Settingspane
161 */
162 }
163 }
164 implements {
165 Eo.Base.destructor;
166 }
167}