This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository xdg-desktop-portal-efl.

View the commit online.

commit 3ec0f22805dbf207a8936690e2528a70ed6ee6bb
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Thu Nov 26 10:43:14 2026 +0000

    make enter and escape do the right thing in the file selector
---
 src/bin/dialog_filechooser.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/bin/dialog_filechooser.c b/src/bin/dialog_filechooser.c
index 4032186..e83d355 100644
--- a/src/bin/dialog_filechooser.c
+++ b/src/bin/dialog_filechooser.c
@@ -215,10 +215,30 @@ _selected(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
   else _selected_path(d, elm_fileselector_selected_get(d->content));
 }
 
+static void
+_done(void *data, Evas_Object *obj, void *event)
+{
+  if (event) _selected(data, obj, NULL);
+  else dialog_cancel(data, obj, NULL);
+}
+
+static Eina_Bool
+_key_down(void *data, Evas_Object *obj, Evas_Object *source EINA_UNUSED,
+          Evas_Callback_Type type, void *event)
+{
+  Evas_Event_Key_Down *ev = event;
+
+  if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
+  if (strcmp(ev->key, "Escape")) return EINA_FALSE;
+  ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+  dialog_cancel(data, obj, NULL);
+  return EINA_TRUE;
+}
+
 void
 dialog_file_show(Dialog *d)
 {
-  Evas_Object *o, *win, *options_row, *buttons;
+  Evas_Object *o, *win, *options_row, *buttons, *entry;
   const char *folder;
   const char *home;
   const char *file;
@@ -229,6 +249,7 @@ dialog_file_show(Dialog *d)
       return;
     }
   win = d->win;
+  elm_object_event_callback_add(win, _key_down, d);
 
   d->content = o = elm_fileselector_add(win);
   evas_object_name_set(o, "portal-filechooser");
@@ -236,6 +257,16 @@ dialog_file_show(Dialog *d)
   elm_fileselector_folder_only_set(o, d->directory);
   elm_fileselector_multi_select_set(o, d->multiple);
   elm_fileselector_buttons_ok_cancel_set(o, EINA_FALSE);
+  evas_object_smart_callback_add(o, "done", _done, d);
+  evas_object_smart_callback_add(o, "activated", _selected, d);
+  /* Entries consume Return/Escape before the fileselector can handle them. */
+  entry = elm_object_part_content_get(o, "elm.swallow.filename");
+  evas_object_smart_callback_add(entry, "activated", _selected, d);
+  evas_object_smart_callback_add(entry, "aborted", dialog_cancel, d);
+  entry = elm_object_part_content_get(o, "elm.swallow.path");
+  evas_object_smart_callback_add(entry, "aborted", dialog_cancel, d);
+  entry = elm_object_part_content_get(o, "elm.swallow.search");
+  evas_object_smart_callback_add(entry, "aborted", dialog_cancel, d);
   if (d->filters)
     {
       Eina_List *l;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to