summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-01-22 10:44:03 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-01-22 12:10:14 -0800
commit0f6e1a46a402fd9cf848ffb1bd47c6b406eb7ffa (patch)
tree18e995d8ea69c1e743717d8504247b389e04a36c
parenta575db8c64eea4553c4e719b95de2eccb29d239c (diff)
combobox: move responsibility to define filter and content to the user of a combobox
Before this patch, the filter was set inside the combobox. This is confusing for the user of the object as it can't define a custom filter except on strings. It is also impossible to bind as binding require to know what was put in and they can't differentiate between a genlist filter being set from the binding to one being set internally by the combobox. @fix
-rw-r--r--src/bin/test_combobox.c10
-rw-r--r--src/lib/elc_combobox.c35
-rw-r--r--src/lib/elm_combobox.eo1
-rw-r--r--src/lib/elm_widget_combobox.h1
4 files changed, 40 insertions, 7 deletions
diff --git a/src/bin/test_combobox.c b/src/bin/test_combobox.c
index 43bd4efa6..b8ef5db15 100644
--- a/src/bin/test_combobox.c
+++ b/src/bin/test_combobox.c
@@ -86,6 +86,14 @@ gl_filter_get(void *data, Evas_Object *obj EINA_UNUSED, void *key)
86} 86}
87 87
88static void 88static void
89_gl_filter_restart_cb(void *data EINA_UNUSED,
90 Evas_Object *obj,
91 void *event_info EINA_UNUSED)
92{
93 elm_genlist_filter_set(obj, (void *)elm_object_text_get(obj));
94}
95
96static void
89_gl_filter_finished_cb(void *data EINA_UNUSED, 97_gl_filter_finished_cb(void *data EINA_UNUSED,
90 Evas_Object *obj EINA_UNUSED, 98 Evas_Object *obj EINA_UNUSED,
91 void *event_info EINA_UNUSED) 99 void *event_info EINA_UNUSED)
@@ -135,6 +143,8 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
135 _combobox_item_pressed_cb, NULL); 143 _combobox_item_pressed_cb, NULL);
136 evas_object_smart_callback_add(combobox, "filter,done", 144 evas_object_smart_callback_add(combobox, "filter,done",
137 _gl_filter_finished_cb, NULL); 145 _gl_filter_finished_cb, NULL);
146 evas_object_smart_callback_add(combobox, "changed",
147 _gl_filter_restart_cb, NULL);
138 elm_box_pack_end(bx, combobox); 148 elm_box_pack_end(bx, combobox);
139 evas_object_show(combobox); 149 evas_object_show(combobox);
140 150
diff --git a/src/lib/elc_combobox.c b/src/lib/elc_combobox.c
index 4076c416c..cb2a835f1 100644
--- a/src/lib/elc_combobox.c
+++ b/src/lib/elc_combobox.c
@@ -179,8 +179,18 @@ _gl_filter_finished_cb(void *data, Eo *obj EINA_UNUSED,
179 const Eo_Event_Description *desc EINA_UNUSED, void *event) 179 const Eo_Event_Description *desc EINA_UNUSED, void *event)
180{ 180{
181 ELM_COMBOBOX_DATA_GET(data, sd); 181 ELM_COMBOBOX_DATA_GET(data, sd);
182 eo_do(data, eo_event_callback_call(ELM_COMBOBOX_EVENT_FILTER_DONE, event)); 182
183 count_items_genlist(data); 183 count_items_genlist(data);
184
185 if (sd->first_filter)
186 {
187 sd->first_filter = EINA_FALSE;
188 elm_combobox_hover_end(data);
189 return EINA_TRUE;
190 }
191
192 eo_do(data, eo_event_callback_call(ELM_COMBOBOX_EVENT_FILTER_DONE, event));
193
184 if (sd->count > 0) 194 if (sd->count > 0)
185 { 195 {
186 if (sd->expanded == EINA_TRUE) 196 if (sd->expanded == EINA_TRUE)
@@ -204,16 +214,16 @@ static Eina_Bool
204_on_changed(void *data, Eo *obj EINA_UNUSED, 214_on_changed(void *data, Eo *obj EINA_UNUSED,
205 const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 215 const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
206{ 216{
207 elm_combobox_hover_begin(data); 217 eo_do(data, eo_event_callback_call(ELM_ENTRY_EVENT_CHANGED, NULL));
208 return EINA_TRUE; 218 return EINA_TRUE;
209} 219}
210 220
211static void 221static void
212_on_clicked(void *data, 222_on_clicked(void *data EINA_UNUSED,
213 Evas_Object *obj EINA_UNUSED, 223 Evas_Object *obj,
214 void *event_info EINA_UNUSED) 224 void *event_info EINA_UNUSED)
215{ 225{
216 elm_combobox_hover_begin(data); 226 elm_combobox_hover_begin(obj);
217} 227}
218 228
219EOLIAN static void 229EOLIAN static void
@@ -275,6 +285,8 @@ _elm_combobox_eo_base_constructor(Eo *obj, Elm_Combobox_Data *sd)
275 285
276 eo_do_super(obj, MY_CLASS, eo_constructor()); 286 eo_do_super(obj, MY_CLASS, eo_constructor());
277 287
288 sd->first_filter = EINA_TRUE;
289
278 eo_do(obj, 290 eo_do(obj,
279 evas_obj_type_set(MY_CLASS_NAME_LEGACY), 291 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
280 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks), 292 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
@@ -302,6 +314,7 @@ _elm_combobox_eo_base_constructor(Eo *obj, Elm_Combobox_Data *sd)
302 314
303 // This is the genlist object that will take over the genlist call 315 // This is the genlist object that will take over the genlist call
304 sd->genlist = gl = eo_add(ELM_GENLIST_CLASS, obj); 316 sd->genlist = gl = eo_add(ELM_GENLIST_CLASS, obj);
317 elm_genlist_filter_set(gl, NULL);
305 elm_widget_mirrored_automatic_set(gl, EINA_FALSE); 318 elm_widget_mirrored_automatic_set(gl, EINA_FALSE);
306 elm_widget_mirrored_set(gl, elm_widget_mirrored_get(obj)); 319 elm_widget_mirrored_set(gl, elm_widget_mirrored_get(obj));
307 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 320 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -340,11 +353,11 @@ _elm_combobox_eo_base_constructor(Eo *obj, Elm_Combobox_Data *sd)
340} 353}
341 354
342EOLIAN static void 355EOLIAN static void
343_elm_combobox_hover_begin(Eo *obj EINA_UNUSED, Elm_Combobox_Data *sd) 356_elm_combobox_hover_begin(Eo *obj, Elm_Combobox_Data *sd)
344{ 357{
345 if (!sd->hover) return; 358 if (!sd->hover) return;
346 elm_object_focus_set(sd->entry, EINA_TRUE); 359 elm_object_focus_set(sd->entry, EINA_TRUE);
347 elm_genlist_filter_set(sd->genlist, (void *)elm_object_text_get(sd->entry)); 360 _activate(obj);
348} 361}
349 362
350EOLIAN static void 363EOLIAN static void
@@ -437,6 +450,14 @@ _elm_combobox_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNU
437} 450}
438 451
439EOLIAN void 452EOLIAN void
453_elm_combobox_elm_genlist_filter_set(Eo *obj, Elm_Combobox_Data *pd, void *key)
454{
455 pd->first_filter = EINA_FALSE;
456
457 eo_do(pd->genlist, elm_obj_genlist_filter_set(key));
458}
459
460EOLIAN void
440_elm_combobox_elm_widget_part_text_set(Eo *obj EINA_UNUSED, Elm_Combobox_Data *pd, 461_elm_combobox_elm_widget_part_text_set(Eo *obj EINA_UNUSED, Elm_Combobox_Data *pd,
441 const char * part, const char *label) 462 const char * part, const char *label)
442{ 463{
diff --git a/src/lib/elm_combobox.eo b/src/lib/elm_combobox.eo
index f189fca13..4e131978f 100644
--- a/src/lib/elm_combobox.eo
+++ b/src/lib/elm_combobox.eo
@@ -45,6 +45,7 @@ class Elm_Combobox (Elm.Button, Evas.Selectable_Interface,
45 Elm.Widget.translate; 45 Elm.Widget.translate;
46 Elm.Widget.event; 46 Elm.Widget.event;
47 Elm.Button.admits_autorepeat.get; 47 Elm.Button.admits_autorepeat.get;
48 Elm.Genlist.filter.set;
48 Elm_Interface_Atspi_Widget_Action.elm_actions.get; 49 Elm_Interface_Atspi_Widget_Action.elm_actions.get;
49 } 50 }
50 events { 51 events {
diff --git a/src/lib/elm_widget_combobox.h b/src/lib/elm_widget_combobox.h
index 80ffe25c7..f3ec5bfe0 100644
--- a/src/lib/elm_widget_combobox.h
+++ b/src/lib/elm_widget_combobox.h
@@ -38,6 +38,7 @@ struct _Elm_Combobox_Data
38 int count; 38 int count;
39 int item_height; 39 int item_height;
40 Eina_Bool expanded:1; 40 Eina_Bool expanded:1;
41 Eina_Bool first_filter:1;
41}; 42};
42 43
43/** 44/**