summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-07-23 16:51:01 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-07-23 16:51:01 -0300
commit1857e0df0b29a19a6aea330c85ffed0482b58041 (patch)
tree69d84595f7318c8bf41f9534d852091c2b656cf7
parentb425ec957a2dc92b872c26b80559bfaca625b121 (diff)
Fix C++ box_cxx_example_02.cc and removed text_part_{set/get} from elm_button
As discussed in IRC, the commit that added text_part_set, text_part_get functions to elm_button are wrong. The correct functions to be used are from elm_layout: text_set and text_get. Fixed the example to use these functions that are inherited on elm_button from elm_layout and fixed the cleanup of childrens in the parent window by using the del event callback.
-rw-r--r--src/examples/box_cxx_example_02.cc44
-rw-r--r--src/lib/elm_button.c20
-rw-r--r--src/lib/elm_button.eo66
3 files changed, 30 insertions, 100 deletions
diff --git a/src/examples/box_cxx_example_02.cc b/src/examples/box_cxx_example_02.cc
index 1f57247e8..d51e4a8e7 100644
--- a/src/examples/box_cxx_example_02.cc
+++ b/src/examples/box_cxx_example_02.cc
@@ -66,6 +66,22 @@ _test_box_transition_change(void *data)
66 } 66 }
67} 67}
68 68
69struct clean_ref
70{
71 clean_ref(efl::eo::base base)
72 : _ref(base._eo_ptr())
73 {}
74
75 template <typename T>
76 void operator()(T const&, Eo_Event_Description const&, void*) const
77 {
78 if(_ref)
79 eo_unref(_ref);
80 }
81
82 Eo* _ref;
83};
84
69EAPI_MAIN int 85EAPI_MAIN int
70elm_main(int argc, char *argv[]) 86elm_main(int argc, char *argv[])
71{ 87{
@@ -79,20 +95,19 @@ elm_main(int argc, char *argv[])
79 win.autodel_set(true); 95 win.autodel_set(true);
80 96
81 elm_box bigbox ( efl::eo::parent = win ); 97 elm_box bigbox ( efl::eo::parent = win );
82 ::eo_unref(bigbox._eo_ptr());
83 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 98 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
84 win.resize_object_add(bigbox); 99 win.resize_object_add(bigbox);
85 bigbox.visibility_set(true); 100 bigbox.visibility_set(true);
101 win.event_del_callback_add(clean_ref(bigbox));
86 102
87 elm_box buttons ( efl::eo::parent = win ); 103 elm_box buttons ( efl::eo::parent = win );
88 ::eo_unref(buttons._eo_ptr());
89 buttons.horizontal_set(EINA_TRUE); 104 buttons.horizontal_set(EINA_TRUE);
90 bigbox.pack_end(buttons); 105 bigbox.pack_end(buttons);
91 buttons.visibility_set(true); 106 buttons.visibility_set(true);
107 win.event_del_callback_add(clean_ref(buttons));
92 108
93 elm_button add ( efl::eo::parent = win ); 109 elm_button add ( efl::eo::parent = win );
94 ::eo_unref(add._eo_ptr()); 110 add.text_set("elm.text", "Add");
95 add.text_set("Add");
96 buttons.pack_end(add); 111 buttons.pack_end(add);
97 add.visibility_set(true); 112 add.visibility_set(true);
98 add.event_clicked_callback_add 113 add.event_clicked_callback_add
@@ -101,7 +116,7 @@ elm_main(int argc, char *argv[])
101 if(efl::eina::optional<elm_box> box = tdata.box.lock()) 116 if(efl::eina::optional<elm_box> box = tdata.box.lock())
102 { 117 {
103 elm_button btn ( efl::eo::parent = *box ); 118 elm_button btn ( efl::eo::parent = *box );
104 btn.text_set("I do nothing"); 119 btn.text_set("elm.text", "I do nothing");
105 efl::eina::list<evas::object> childrens = box->children_get(); 120 efl::eina::list<evas::object> childrens = box->children_get();
106 if (!childrens.empty()) 121 if (!childrens.empty())
107 { 122 {
@@ -112,20 +127,21 @@ elm_main(int argc, char *argv[])
112 btn.visibility_set(true); 127 btn.visibility_set(true);
113 } 128 }
114 })); 129 }));
130 win.event_del_callback_add(clean_ref(add));
115 131
116 elm_button clear ( efl::eo::parent = win ); 132 elm_button clear ( efl::eo::parent = win );
117 ::eo_unref(clear._eo_ptr()); 133 clear.text_set("elm.text", "Clear");
118 clear.text_set("Clear");
119 buttons.pack_end(clear); 134 buttons.pack_end(clear);
120 clear.visibility_set(true); 135 clear.visibility_set(true);
121 clear.event_clicked_callback_add(std::bind([&tdata] { tdata.box.lock()->clear(); })); 136 clear.event_clicked_callback_add(std::bind([&tdata] { tdata.box.lock()->clear(); }));
137 win.event_del_callback_add(clean_ref(clear));
122 138
123 elm_box dynamic ( efl::eo::parent = win ); 139 elm_box dynamic ( efl::eo::parent = win );
124 ::eo_unref(dynamic._eo_ptr());
125 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 140 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
126 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 141 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
127 bigbox.pack_end(dynamic); 142 bigbox.pack_end(dynamic);
128 dynamic.visibility_set(true); 143 dynamic.visibility_set(true);
144 win.event_del_callback_add(clean_ref(dynamic));
129 145
130 auto unpack = std::bind([&tdata] (evas::clickable_interface obj) 146 auto unpack = std::bind([&tdata] (evas::clickable_interface obj)
131 { 147 {
@@ -137,29 +153,29 @@ elm_main(int argc, char *argv[])
137 ; 153 ;
138 154
139 elm_button bt1 ( efl::eo::parent = win ); 155 elm_button bt1 ( efl::eo::parent = win );
140 ::eo_unref(bt1._eo_ptr()); 156 bt1.text_set("elm.text", "Button 1");
141 bt1.text_set("Button 1");
142 bt1.event_clicked_callback_add(unpack); 157 bt1.event_clicked_callback_add(unpack);
143 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 158 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
144 bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 159 bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
145 dynamic.pack_end(bt1); 160 dynamic.pack_end(bt1);
146 bt1.visibility_set(true); 161 bt1.visibility_set(true);
162 win.event_del_callback_add(clean_ref(bt1));
147 163
148 elm_button bt2 ( efl::eo::parent = win ); 164 elm_button bt2 ( efl::eo::parent = win );
149 ::eo_unref(bt2._eo_ptr()); 165 bt2.text_set("elm.text", "Button 2");
150 bt2.text_set("Button 2");
151 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0); 166 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
152 bt2.size_hint_align_set(1.0, 0.5); 167 bt2.size_hint_align_set(1.0, 0.5);
153 bt2.event_clicked_callback_add(unpack); 168 bt2.event_clicked_callback_add(unpack);
154 dynamic.pack_end(bt2); 169 dynamic.pack_end(bt2);
155 bt2.visibility_set(true); 170 bt2.visibility_set(true);
171 win.event_del_callback_add(clean_ref(bt2));
156 172
157 elm_button bt3 ( efl::eo::parent = win ); 173 elm_button bt3 ( efl::eo::parent = win );
158 ::eo_unref(bt3._eo_ptr()); 174 bt3.text_set("elm.text", "Button 3");
159 bt3.text_set("Button 3");
160 bt3.event_clicked_callback_add(unpack); 175 bt3.event_clicked_callback_add(unpack);
161 dynamic.pack_end(bt3); 176 dynamic.pack_end(bt3);
162 bt3.visibility_set(true); 177 bt3.visibility_set(true);
178 win.event_del_callback_add(clean_ref(bt3));
163 179
164 tdata.box = dynamic; 180 tdata.box = dynamic;
165 tdata.last_layout = evas_object_box_layout_horizontal; 181 tdata.last_layout = evas_object_box_layout_horizontal;
diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c
index 6db3487d1..d9376c08f 100644
--- a/src/lib/elm_button.c
+++ b/src/lib/elm_button.c
@@ -433,26 +433,6 @@ _elm_button_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSE
433 return &key_actions[0]; 433 return &key_actions[0];
434} 434}
435 435
436EOLIAN const char* _elm_button_part_text_get(Eo* obj, Elm_Button_Data* pd EINA_UNUSED, const char* part)
437{
438 return elm_object_part_text_get(obj, part);
439}
440
441EOLIAN void _elm_button_part_text_set(Eo* obj, Elm_Button_Data* pd EINA_UNUSED, const char* part, const char* text)
442{
443 return elm_object_part_text_set(obj, part, text);
444}
445
446EOLIAN const char* _elm_button_text_get(Eo* obj, Elm_Button_Data* pd EINA_UNUSED)
447{
448 return _elm_button_part_text_get(obj, pd, NULL);
449}
450
451EOLIAN void _elm_button_text_set(Eo* obj, Elm_Button_Data* pd EINA_UNUSED, const char* text)
452{
453 return _elm_button_part_text_set(obj, pd, NULL, text);
454}
455
456static void 436static void
457_elm_button_class_constructor(Eo_Class *klass) 437_elm_button_class_constructor(Eo_Class *klass)
458{ 438{
diff --git a/src/lib/elm_button.eo b/src/lib/elm_button.eo
index 1b40c2d1e..4e0d567fa 100644
--- a/src/lib/elm_button.eo
+++ b/src/lib/elm_button.eo
@@ -96,72 +96,6 @@ class Elm_Button (Elm_Layout, Evas.Clickable_Interface,
96 } 96 }
97 } 97 }
98 } 98 }
99 methods {
100 part_text_set {
101 /**
102 * Set a text of an object
103 *
104 * @param obj The Elementary object
105 * @param part The text part name to set (NULL for the default part)
106 * @param text The new text of the part
107 *
108 * @note Elementary objects may have many text parts (e.g. Action Slider)
109 *
110 * @ingroup General
111 */
112 params {
113 @in const(char)* part;
114 @in const(char)* text;
115 }
116 }
117 part_text_get {
118 /**
119 * Get a text of an object
120 *
121 * @param obj The Elementary object
122 * @param part The text part name to get (NULL for the default part)
123 * @return text of the part or NULL for any error
124 *
125 * @note Elementary objects may have many text parts (e.g. Action Slider)
126 *
127 * @ingroup General
128 */
129 params {
130 @in const(char)* part;
131 }
132 return const(char)*;
133 }
134 text_set {
135 /**
136 * Set a text of an object
137 *
138 * @param obj The Elementary object
139 * @param part The text part name to set (NULL for the default part)
140 * @param text The new text of the part
141 *
142 * @note Elementary objects may have many text parts (e.g. Action Slider)
143 *
144 * @ingroup General
145 */
146 params {
147 @in const(char)* text;
148 }
149 }
150 text_get {
151 /**
152 * Get a text of an object
153 *
154 * @param obj The Elementary object
155 * @param part The text part name to get (NULL for the default part)
156 * @return text of the part or NULL for any error
157 *
158 * @note Elementary objects may have many text parts (e.g. Action Slider)
159 *
160 * @ingroup General
161 */
162 return const(char)*;
163 }
164 }
165 implements { 99 implements {
166 class.constructor; 100 class.constructor;
167 Eo.Base.constructor; 101 Eo.Base.constructor;