summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-01-07 15:17:46 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-01-07 17:23:29 +0900
commitb8e6d6a708aa1bde8c3be87556cc6714be4310c1 (patch)
tree5fcbf00aee58c0a79d45f647f3b8a9454e673dd0
parentcebc6835bc2c00915b7ff67f1575f1f83dd57fa4 (diff)
fileselector: added a search icon
Summary: fileselector: redirect keystrokes to the searchbar Keystrokes like a-z A-Z 0-9 are redirected to the searchbar, so you dont need to click arround to search files in the fileselector. The search icon is from ApB (Apostolos B.), thx for that! :) @feature Improved the searchbar Reviewers: raster, seoz Subscribers: ryuan.choi, cedric, seoz Differential Revision: https://phab.enlightenment.org/D1237 Conflicts: src/lib/elc_fileselector.c
-rw-r--r--data/themes/edc/elm/icon.edc1
-rw-r--r--data/themes/img/icon_search.pngbin0 -> 1782 bytes
-rw-r--r--src/lib/elc_fileselector.c42
3 files changed, 43 insertions, 0 deletions
diff --git a/data/themes/edc/elm/icon.edc b/data/themes/edc/elm/icon.edc
index f07495e80..23fc6be8c 100644
--- a/data/themes/edc/elm/icon.edc
+++ b/data/themes/edc/elm/icon.edc
@@ -86,6 +86,7 @@ IC("edit", "toolbar/edit", "icon_edit.png", 16, 0);
86IC("refresh", "toolbar/refresh", "icon_refresh.png", 16, 0); 86IC("refresh", "toolbar/refresh", "icon_refresh.png", 16, 0);
87IC("file", "toolbar/file", "icon_file.png", 16, 0); 87IC("file", "toolbar/file", "icon_file.png", 16, 0);
88IC("no_photo", "photo/no_photo", "icon_head.png", 16, 0); 88IC("no_photo", "photo/no_photo", "icon_head.png", 16, 0);
89IC("search", "toolbar/search", "icon_search.png", 16, 0);
89#undef IC 90#undef IC
90 91
91#define IC(Name, File, Min, Max) \ 92#define IC(Name, File, Min, Max) \
diff --git a/data/themes/img/icon_search.png b/data/themes/img/icon_search.png
new file mode 100644
index 000000000..b8cafcc1c
--- /dev/null
+++ b/data/themes/img/icon_search.png
Binary files differ
diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c
index d4b2a730e..9a70311a6 100644
--- a/src/lib/elc_fileselector.c
+++ b/src/lib/elc_fileselector.c
@@ -1180,6 +1180,40 @@ _anchor_clicked(void *data,
1180 } 1180 }
1181} 1181}
1182 1182
1183static void
1184_files_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1185{
1186 Evas_Event_Key_Down *ev = event_info;
1187 Evas_Object *par, *searchbar;
1188
1189 par = data;
1190 searchbar = evas_object_data_get(par, "search");
1191
1192 if (!searchbar) return;
1193
1194 if (((ev->string) && *(ev->string) &&
1195 (isalpha(*ev->string) ||
1196 isdigit(*ev->string))))
1197 {
1198
1199 elm_entry_entry_append(searchbar, ev->string);
1200 }
1201 else if (ev->string &&
1202 *(ev->string) &&
1203 !strcmp(ev->key, "BackSpace"))
1204 {
1205 char buf[PATH_MAX];
1206 const char *en;
1207 en = elm_entry_entry_get(searchbar);
1208 if (strlen(en) > 0)
1209 {
1210 memmove(buf, en, strlen(en) -1);
1211 buf[strlen(en) -1] = '\0';
1212 elm_entry_entry_set(searchbar, buf);
1213 }
1214 }
1215}
1216
1183static Evas_Object * 1217static Evas_Object *
1184_files_list_add(Evas_Object *obj) 1218_files_list_add(Evas_Object *obj)
1185{ 1219{
@@ -1201,6 +1235,7 @@ _files_list_add(Evas_Object *obj)
1201 (li, "contract,request", _on_list_contract_req, obj); 1235 (li, "contract,request", _on_list_contract_req, obj);
1202 evas_object_smart_callback_add(li, "expanded", _on_list_expanded, obj); 1236 evas_object_smart_callback_add(li, "expanded", _on_list_expanded, obj);
1203 evas_object_smart_callback_add(li, "contracted", _on_list_contracted, obj); 1237 evas_object_smart_callback_add(li, "contracted", _on_list_contracted, obj);
1238 evas_object_event_callback_add(li, EVAS_CALLBACK_KEY_DOWN, _files_key_down, obj);
1204 1239
1205 elm_widget_sub_object_add(obj, li); 1240 elm_widget_sub_object_add(obj, li);
1206 1241
@@ -1227,6 +1262,7 @@ _files_grid_add(Evas_Object *obj)
1227 evas_object_smart_callback_add(grid, "selected", _on_item_selected, obj); 1262 evas_object_smart_callback_add(grid, "selected", _on_item_selected, obj);
1228 evas_object_smart_callback_add(grid, "unselected", _on_item_unselected, obj); 1263 evas_object_smart_callback_add(grid, "unselected", _on_item_unselected, obj);
1229 evas_object_smart_callback_add(grid, "activated", _on_item_activated, obj); 1264 evas_object_smart_callback_add(grid, "activated", _on_item_activated, obj);
1265 evas_object_event_callback_add(grid, EVAS_CALLBACK_KEY_DOWN, _files_key_down, obj);
1230 1266
1231 elm_widget_sub_object_add(obj, grid); 1267 elm_widget_sub_object_add(obj, grid);
1232 1268
@@ -1468,6 +1504,9 @@ _elm_fileselector_evas_object_smart_add(Eo *obj, Elm_Fileselector_Data *priv)
1468 priv->name_entry = en; 1504 priv->name_entry = en;
1469 1505
1470 //search entry 1506 //search entry
1507 ic = elm_icon_add(obj);
1508 elm_icon_standard_set(ic, "search");
1509 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1471 en = elm_entry_add(obj); 1510 en = elm_entry_add(obj);
1472 elm_entry_scrollable_set(en, EINA_TRUE); 1511 elm_entry_scrollable_set(en, EINA_TRUE);
1473 elm_widget_mirrored_automatic_set(en, EINA_FALSE); 1512 elm_widget_mirrored_automatic_set(en, EINA_FALSE);
@@ -1476,9 +1515,12 @@ _elm_fileselector_evas_object_smart_add(Eo *obj, Elm_Fileselector_Data *priv)
1476 elm_entry_line_wrap_set(en, ELM_WRAP_CHAR); 1515 elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
1477 elm_object_domain_translatable_part_text_set(en, "guide", 1516 elm_object_domain_translatable_part_text_set(en, "guide",
1478 PACKAGE, N_("Search")); 1517 PACKAGE, N_("Search"));
1518 elm_object_part_content_set(en, "icon", ic);
1519 elm_entry_icon_visible_set(en, EINA_TRUE);
1479 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1520 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1480 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL); 1521 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
1481 evas_object_smart_callback_add(en, "changed", _preedit_cb, obj); 1522 evas_object_smart_callback_add(en, "changed", _preedit_cb, obj);
1523 evas_object_data_set(obj, "search", en);
1482 1524
1483 elm_widget_sub_object_add(obj, en); 1525 elm_widget_sub_object_add(obj, en);
1484 priv->search_entry = en; 1526 priv->search_entry = en;