This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository edi.
View the commit online.
commit 75aca4f2f52126123760437bd59ae638cb588ca2
Author: Alastair Poole <[email protected]>
AuthorDate: Wed Apr 15 23:37:46 2026 +0100
mainview: Allow drag and drop into the panel.
---
NEWS | 1 +
src/bin/mainview/edi_mainview_panel.c | 88 +++++++++++++++++++++++++++++++++++
src/bin/mainview/edi_mainview_panel.h | 1 +
3 files changed, 90 insertions(+)
diff --git a/NEWS b/NEWS
index 69263ce..10f9710 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Edi 0.9
* Fix rare crash.
* Improve panel behaviour.
* Fix bottom panel resize bogosity.
+ * Add drag and drop support to our panels.
* ...
=======
diff --git a/src/bin/mainview/edi_mainview_panel.c b/src/bin/mainview/edi_mainview_panel.c
index 11049c7..f01bf8d 100644
--- a/src/bin/mainview/edi_mainview_panel.c
+++ b/src/bin/mainview/edi_mainview_panel.c
@@ -7,6 +7,7 @@
#include <Eina.h>
#include <Eio.h>
#include <Elementary.h>
+#include <efreet_uri.h>
#include "mainview/edi_mainview_item.h"
#include "mainview/edi_mainview_panel.h"
@@ -1453,9 +1454,91 @@ _edi_mainview_panel_welcome_focused_cb(void *data,
edi_mainview_panel_focus((Edi_Mainview_Panel *) data);
}
+static Eina_Bool
+_edi_mainview_panel_drop_path_open(Edi_Mainview_Panel *panel, const char *path)
+{
+ Edi_Path_Options *options;
+
+ if (!path || !path[0] || !ecore_file_exists(path) || ecore_file_is_dir(path))
+ return EINA_FALSE;
+
+ options = edi_path_options_create(path);
+ edi_mainview_panel_open(panel, options);
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_edi_mainview_panel_drop_open_list(Edi_Mainview_Panel *panel, const char *text)
+{
+ Eina_Bool opened = EINA_FALSE;
+ char *line, *list, *saveptr = NULL;
+
+ if (!text || !text[0])
+ return EINA_FALSE;
+
+ list = strdup(text);
+ if (!list)
+ return EINA_FALSE;
+
+ line = strtok_r(list, "\r\n", &saveptr);
+ while (line)
+ {
+ Efreet_Uri *uri;
+
+ if (line[0] == '#')
+ goto next;
+
+ uri = efreet_uri_decode(line);
+ if (uri)
+ {
+ if ((!uri->protocol || !strcmp(uri->protocol, "file")) &&
+ _edi_mainview_panel_drop_path_open(panel, uri->path))
+ opened = EINA_TRUE;
+
+ efreet_uri_free(uri);
+ goto next;
+ }
+
+ if (_edi_mainview_panel_drop_path_open(panel, line))
+ opened = EINA_TRUE;
+next:
+ line = strtok_r(NULL, "\r\n", &saveptr);
+ }
+
+ free(list);
+ return opened;
+}
+
+static Eina_Bool
+_edi_mainview_panel_external_drop_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ Elm_Selection_Data *ev)
+{
+ Edi_Mainview_Panel *panel = data;
+ Eina_Bool opened;
+ char *text;
+
+ if (!panel || !ev || !ev->data || !ev->len)
+ return EINA_FALSE;
+
+ text = strndup(ev->data, ev->len);
+ if (!text)
+ return EINA_FALSE;
+
+ opened = _edi_mainview_panel_drop_open_list(panel, text);
+ free(text);
+
+ return opened;
+}
+
void
edi_mainview_panel_free(Edi_Mainview_Panel *panel)
{
+ if (panel->drop_target_enabled)
+ elm_drop_target_del(panel->content, ELM_SEL_FORMAT_URILIST | ELM_SEL_FORMAT_TEXT,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ _edi_mainview_panel_external_drop_cb, panel);
+
evas_object_del(panel->welcome);
evas_object_del(panel->content);
evas_object_del(panel->tabs);
@@ -1595,5 +1678,10 @@ edi_mainview_panel_add(Evas_Object *parent)
panel->welcome = scroll;
_edi_mainview_panel_show(panel, scroll);
+
+ panel->drop_target_enabled = elm_drop_target_add(panel->content,
+ ELM_SEL_FORMAT_URILIST | ELM_SEL_FORMAT_TEXT,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ _edi_mainview_panel_external_drop_cb, panel);
return panel;
}
diff --git a/src/bin/mainview/edi_mainview_panel.h b/src/bin/mainview/edi_mainview_panel.h
index 49f774f..0bfe6f6 100644
--- a/src/bin/mainview/edi_mainview_panel.h
+++ b/src/bin/mainview/edi_mainview_panel.h
@@ -29,6 +29,7 @@ typedef struct _Edi_Mainview_Panel
Edi_Mainview_Item *current;
Evas_Object *box, *scroll, *tabs, *content, *welcome, *tb, *sep;
+ Eina_Bool drop_target_enabled;
} Edi_Mainview_Panel;
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.