summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-10-10 15:27:51 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-10-10 15:27:51 +0000
commitaa1529d411fe1e1172bbf122f1952d29d77bfa68 (patch)
tree680decba53716b62a338e0ec760008a922f502a2
parent9a6d41e4bdb171a844817ea051cda9599b2fc255 (diff)
and now i have a simple check and radio liust infrastructure to use to build
config dialogs... thats next phase... SVN revision: 17387
-rw-r--r--data/themes/default_check.edc3
-rw-r--r--data/themes/default_frame.edc1
-rw-r--r--data/themes/default_radio.edc32
-rw-r--r--src/bin/Makefile.am6
-rw-r--r--src/bin/e_includes.h2
-rw-r--r--src/bin/e_test.c24
-rw-r--r--src/bin/e_widget_check.c2
-rw-r--r--src/bin/e_widget_check.h2
-rw-r--r--src/bin/e_widget_framelist.c85
-rw-r--r--src/bin/e_widget_framelist.h14
-rw-r--r--src/bin/e_widget_radio.c116
-rw-r--r--src/bin/e_widget_radio.h15
12 files changed, 276 insertions, 26 deletions
diff --git a/data/themes/default_check.edc b/data/themes/default_check.edc
index 08aa369..424c121 100644
--- a/data/themes/default_check.edc
+++ b/data/themes/default_check.edc
@@ -60,10 +60,11 @@ group {
60 mouse_events: 0; 60 mouse_events: 0;
61 description { 61 description {
62 state: "default" 0.0; 62 state: "default" 0.0;
63 min: 16 16;
63 rel1 { 64 rel1 {
64 to_x: "outline"; 65 to_x: "outline";
65 relative: 1.0 0.0; 66 relative: 1.0 0.0;
66 offset: 2 4; 67 offset: 4 4;
67 } 68 }
68 rel2 { 69 rel2 {
69 relative: 1.0 1.0; 70 relative: 1.0 1.0;
diff --git a/data/themes/default_frame.edc b/data/themes/default_frame.edc
index f88ff6d..b0a3c81 100644
--- a/data/themes/default_frame.edc
+++ b/data/themes/default_frame.edc
@@ -81,6 +81,7 @@ group {
81 description { 81 description {
82 state: "default" 0.0; 82 state: "default" 0.0;
83 align: 0.0 0.0; 83 align: 0.0 0.0;
84 fixed: 1 1;
84 rel1 { 85 rel1 {
85 relative: 0.0 0.0; 86 relative: 0.0 0.0;
86 offset: 16 6; 87 offset: 16 6;
diff --git a/data/themes/default_radio.edc b/data/themes/default_radio.edc
index 3b224de..10959d1 100644
--- a/data/themes/default_radio.edc
+++ b/data/themes/default_radio.edc
@@ -16,11 +16,11 @@ group {
16 fixed: 1 1; 16 fixed: 1 1;
17 rel1 { 17 rel1 {
18 relative: 0.0 0.0; 18 relative: 0.0 0.0;
19 offset: 1 1; 19 offset: 4 4;
20 } 20 }
21 rel2 { 21 rel2 {
22 relative: 1.0 1.0; 22 relative: 0.0 1.0;
23 offset: -2 -2; 23 offset: 4 -5;
24 } 24 }
25 image { 25 image {
26 normal: "e17_menu_radio1.png"; 26 normal: "e17_menu_radio1.png";
@@ -60,14 +60,15 @@ group {
60 mouse_events: 0; 60 mouse_events: 0;
61 description { 61 description {
62 state: "default" 0.0; 62 state: "default" 0.0;
63 min: 16 16;
63 rel1 { 64 rel1 {
64 to_x: "outline"; 65 to_x: "outline";
65 relative: 1.0 0.0; 66 relative: 1.0 0.0;
66 offset: 1 1; 67 offset: 4 4;
67 } 68 }
68 rel2 { 69 rel2 {
69 relative: 1.0 1.0; 70 relative: 1.0 1.0;
70 offset: -1 -2; 71 offset: -5 -5;
71 } 72 }
72 color: 0 0 0 255; 73 color: 0 0 0 255;
73 color3: 255 255 255 128; 74 color3: 255 255 255 128;
@@ -108,20 +109,13 @@ group {
108 name: "click"; 109 name: "click";
109 signal: "mouse,down,1"; 110 signal: "mouse,down,1";
110 source: "event"; 111 source: "event";
111 script { 112 action: STATE_SET "active" 0.0;
112 new buf[100]; 113 target: "item1";
113 new Float:val; 114 after: "click2";
114 115 }
115 get_state(PART:"item1", buf, sizeof(buf), val); 116 program {
116 if (!strcmp(buf, "default")) { 117 name: "click2";
117 set_state(PART:"item1", "active", 0.0); 118 action: SIGNAL_EMIT "toggled" "on";
118 emit("toggled", "on");
119 }
120 else {
121 set_state(PART:"item1", "default", 0.0);
122 emit("toggled", "off");
123 }
124 }
125 } 119 }
126 } 120 }
127} 121}
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index c4880a5..774a940 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -84,7 +84,9 @@ e_fileman.h \
84e_scrollbar.h \ 84e_scrollbar.h \
85e_fileman_smart.h \ 85e_fileman_smart.h \
86e_widget.h \ 86e_widget.h \
87e_widget_check.h 87e_widget_check.h \
88e_widget_radio.h \
89e_widget_framelist.h
88 90
89enlightenment_src = \ 91enlightenment_src = \
90e_user.c \ 92e_user.c \
@@ -151,6 +153,8 @@ e_scrollbar.c \
151e_fileman_smart.c \ 153e_fileman_smart.c \
152e_widget.c \ 154e_widget.c \
153e_widget_check.c \ 155e_widget_check.c \
156e_widget_radio.c \
157e_widget_framelist.c \
154$(ENLIGHTENMENTHEADERS) 158$(ENLIGHTENMENTHEADERS)
155 159
156enlightenment_SOURCES = \ 160enlightenment_SOURCES = \
diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h
index 4e0ffb6..61cdb8b 100644
--- a/src/bin/e_includes.h
+++ b/src/bin/e_includes.h
@@ -66,3 +66,5 @@
66#include "e_fileman_smart.h" 66#include "e_fileman_smart.h"
67#include "e_widget.h" 67#include "e_widget.h"
68#include "e_widget_check.h" 68#include "e_widget_check.h"
69#include "e_widget_radio.h"
70#include "e_widget_framelist.h"
diff --git a/src/bin/e_test.c b/src/bin/e_test.c
index 1dfbfe4..ccf4546 100644
--- a/src/bin/e_test.c
+++ b/src/bin/e_test.c
@@ -309,6 +309,7 @@ _e_test_internal(E_Container *con)
309} 309}
310#elif 0 310#elif 0
311static int my_val = 0; 311static int my_val = 0;
312static int my_rval = 1;
312 313
313static void 314static void
314_e_test_internal(E_Container *con) 315_e_test_internal(E_Container *con)
@@ -320,12 +321,29 @@ _e_test_internal(E_Container *con)
320 { 321 {
321 Evas_Object *o; 322 Evas_Object *o;
322 Evas_Coord mw, mh; 323 Evas_Coord mw, mh;
324 E_Radio_Group *rg;
325 Evas *e;
326
327 e = e_win_evas_get(dia->win);
328 o = e_widget_framelist_add(e, "My Checklist", 0);
329
330 e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 1", &my_val));
331 e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 2", &my_val));
332 e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 3", &my_val));
333 e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox and some long text", &my_val));
334 e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 7", &my_val));
335 e_widget_framelist_object_append(o, e_widget_check_add(e, "Koneko", &my_val));
336
337 rg = e_widget_radio_group_new(&my_rval);
338 e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 0", 0, rg));
339 e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 1", 1, rg));
340 e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 2", 2, rg));
341 e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 3", 3, rg));
342 e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 4", 4, rg));
323 343
324 o = e_widget_checkbox_add(e_win_evas_get(dia->win),
325 "My checkbox widget which on toggles is modifying my_val",
326 &my_val);
327 e_widget_min_size_get(o, &mw, &mh); 344 e_widget_min_size_get(o, &mw, &mh);
328 e_dialog_content_set(dia, o, mw, mh); 345 e_dialog_content_set(dia, o, mw, mh);
346 evas_object_show(o);
329// e_theme_edje_object_set(o, "base/theme/dialog", 347// e_theme_edje_object_set(o, "base/theme/dialog",
330// "widgets/frame"); 348// "widgets/frame");
331 } 349 }
diff --git a/src/bin/e_widget_check.c b/src/bin/e_widget_check.c
index 6a4fad2..75d6113 100644
--- a/src/bin/e_widget_check.c
+++ b/src/bin/e_widget_check.c
@@ -15,7 +15,7 @@ static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission
15 15
16/* externally accessible functions */ 16/* externally accessible functions */
17Evas_Object * 17Evas_Object *
18e_widget_checkbox_add(Evas *evas, char *label, int *val) 18e_widget_check_add(Evas *evas, char *label, int *val)
19{ 19{
20 Evas_Object *obj, *o; 20 Evas_Object *obj, *o;
21 E_Widget_Data *wd; 21 E_Widget_Data *wd;
diff --git a/src/bin/e_widget_check.h b/src/bin/e_widget_check.h
index 908cac3..8958896 100644
--- a/src/bin/e_widget_check.h
+++ b/src/bin/e_widget_check.h
@@ -6,7 +6,7 @@
6#ifndef E_WIDGET_CHECK_H 6#ifndef E_WIDGET_CHECK_H
7#define E_WIDGET_CHECK_H 7#define E_WIDGET_CHECK_H
8 8
9EAPI Evas_Object *e_widget_checkbox_add(Evas *evas, char *label, int *val); 9EAPI Evas_Object *e_widget_check_add(Evas *evas, char *label, int *val);
10 10
11#endif 11#endif
12#endif 12#endif
diff --git a/src/bin/e_widget_framelist.c b/src/bin/e_widget_framelist.c
new file mode 100644
index 0000000..552829b
--- /dev/null
+++ b/src/bin/e_widget_framelist.c
@@ -0,0 +1,85 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#include "e.h"
5
6typedef struct _E_Widget_Data E_Widget_Data;
7struct _E_Widget_Data
8{
9 Evas_Object *o_frame, *o_box;
10};
11
12static void _e_wid_del_hook(Evas_Object *obj);
13static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source);
14/* local subsystem functions */
15
16/* externally accessible functions */
17Evas_Object *
18e_widget_framelist_add(Evas *evas, char *label, int horiz)
19{
20 Evas_Object *obj, *o;
21 E_Widget_Data *wd;
22 Evas_Coord mw, mh;
23
24 obj = e_widget_add(evas);
25
26 e_widget_del_hook_set(obj, _e_wid_del_hook);
27 wd = calloc(1, sizeof(E_Widget_Data));
28 e_widget_data_set(obj, wd);
29
30 o = edje_object_add(evas);
31 wd->o_frame = o;
32 e_theme_edje_object_set(o, "base/theme/widgets",
33 "widgets/frame");
34 edje_object_part_text_set(o, "label", label);
35 e_widget_sub_object_add(obj, o);
36 e_widget_resize_object_set(obj, o);
37
38 o = e_box_add(evas);
39 wd->o_box = o;
40 e_box_orientation_set(o, horiz);
41 e_box_homogenous_set(o, 0);
42 edje_object_part_swallow(o, "items", wd->o_box);
43 e_widget_sub_object_add(obj, o);
44 evas_object_show(o);
45
46 edje_object_size_min_calc(wd->o_frame, &mw, &mh);
47 e_widget_min_size_set(obj, mw, mh);
48
49 return obj;
50}
51
52void
53e_widget_framelist_object_append(Evas_Object *obj, Evas_Object *sobj)
54{
55 E_Widget_Data *wd;
56 Evas_Coord mw, mh;
57
58 wd = e_widget_data_get(obj);
59
60 e_box_pack_end(wd->o_box, sobj);
61 e_widget_min_size_get(sobj, &mw, &mh);
62 e_box_pack_options_set(sobj,
63 1, 1, /* fill */
64 1, 0, /* expand */
65 0.5, 0.5, /* align */
66 mw, mh, /* min */
67 99999, 99999 /* max */
68 );
69 e_box_min_size_get(wd->o_box, &mw, &mh);
70 edje_extern_object_min_size_set(wd->o_box, mw, mh);
71 edje_object_part_swallow(wd->o_frame, "items", wd->o_box);
72 edje_object_size_min_calc(wd->o_frame, &mw, &mh);
73 e_widget_min_size_set(obj, mw, mh);
74 e_widget_sub_object_add(obj, sobj);
75 evas_object_show(sobj);
76}
77
78static void
79_e_wid_del_hook(Evas_Object *obj)
80{
81 E_Widget_Data *wd;
82
83 wd = e_widget_data_get(obj);
84 free(wd);
85}
diff --git a/src/bin/e_widget_framelist.h b/src/bin/e_widget_framelist.h
new file mode 100644
index 0000000..0905aba
--- /dev/null
+++ b/src/bin/e_widget_framelist.h
@@ -0,0 +1,14 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#ifdef E_TYPEDEFS
5#else
6#ifndef E_WIDGET_FRAMELIST_H
7#define E_WIDGET_FRAMELIST_H
8
9EAPI Evas_Object *e_widget_framelist_add(Evas *evas, char *label, int horiz);
10EAPI void e_widget_framelist_object_append(Evas_Object *obj, Evas_Object *sobj);
11
12
13#endif
14#endif
diff --git a/src/bin/e_widget_radio.c b/src/bin/e_widget_radio.c
new file mode 100644
index 0000000..4a58ae1
--- /dev/null
+++ b/src/bin/e_widget_radio.c
@@ -0,0 +1,116 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#include "e.h"
5
6struct _E_Radio_Group
7{
8 int *valptr;
9 Evas_List *radios;
10};
11
12typedef struct _E_Widget_Data E_Widget_Data;
13struct _E_Widget_Data
14{
15 E_Radio_Group *group;
16 Evas_Object *o_radio;
17 int valnum;
18};
19
20static void _e_wid_del_hook(Evas_Object *obj);
21static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source);
22/* local subsystem functions */
23
24/* externally accessible functions */
25E_Radio_Group *
26e_widget_radio_group_new(int *val)
27{
28 E_Radio_Group *group;
29
30 group = calloc(1, sizeof(E_Radio_Group));
31 group->valptr = val;
32 return group;
33}
34
35Evas_Object *
36e_widget_radio_add(Evas *evas, char *label, int valnum, E_Radio_Group *group)
37{
38 Evas_Object *obj, *o;
39 E_Widget_Data *wd;
40 Evas_Coord mw, mh;
41
42 obj = e_widget_add(evas);
43
44 e_widget_del_hook_set(obj, _e_wid_del_hook);
45 wd = calloc(1, sizeof(E_Widget_Data));
46 wd->group = group;
47 wd->valnum = valnum;
48 e_widget_data_set(obj, wd);
49
50 o = edje_object_add(evas);
51 wd->o_radio = o;
52 e_theme_edje_object_set(o, "base/theme/widgets",
53 "widgets/radio");
54 edje_object_signal_callback_add(o, "toggled", "*", _e_wid_signal_cb1, obj);
55 edje_object_part_text_set(o, "label", label);
56 edje_object_size_min_calc(o, &mw, &mh);
57 e_widget_min_size_set(obj, mw, mh);
58 if ((wd->group) && (wd->group->valptr))
59 {
60 if (*(wd->group->valptr) == valnum) edje_object_signal_emit(o, "toggle_on", "");
61 }
62 if (wd->group)
63 {
64 wd->group->radios = evas_list_append(wd->group->radios, obj);
65 }
66
67 e_widget_sub_object_add(obj, o);
68 e_widget_resize_object_set(obj, o);
69
70 return obj;
71}
72
73static void
74_e_wid_del_hook(Evas_Object *obj)
75{
76 E_Widget_Data *wd;
77
78 wd = e_widget_data_get(obj);
79 if (wd->group)
80 {
81 wd->group->radios = evas_list_remove(wd->group->radios, obj);
82 if (!wd->group->radios) free(wd->group);
83 }
84 free(wd);
85}
86
87static void
88_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source)
89{
90 E_Widget_Data *wd;
91
92 wd = e_widget_data_get(data);
93 if ((wd->group) && (wd->group->valptr))
94 {
95 Evas_List *l;
96 int toggled = 0;
97
98 for (l = wd->group->radios; l; l = l->next)
99 {
100 wd = e_widget_data_get(l->data);
101 if (l->data != data)
102 {
103 wd = e_widget_data_get(l->data);
104 if (wd->valnum == *(wd->group->valptr))
105 {
106 edje_object_signal_emit(wd->o_radio, "toggle_off", "");
107 toggled = 1;
108 break;
109 }
110 }
111 }
112 if (!toggled) return;
113 wd = e_widget_data_get(data);
114 if (!strcmp(source, "on")) *(wd->group->valptr) = wd->valnum;
115 }
116}
diff --git a/src/bin/e_widget_radio.h b/src/bin/e_widget_radio.h
new file mode 100644
index 0000000..f289807
--- /dev/null
+++ b/src/bin/e_widget_radio.h
@@ -0,0 +1,15 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#ifdef E_TYPEDEFS
5#else
6#ifndef E_WIDGET_RADIO_H
7#define E_WIDGET_RADIO_H
8
9typedef struct _E_Radio_Group E_Radio_Group;
10
11EAPI E_Radio_Group *e_widget_radio_group_new(int *val);
12EAPI Evas_Object *e_widget_radio_add(Evas *evas, char *label, int valnum, E_Radio_Group *group);
13
14#endif
15#endif