summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--NEWS1
-rw-r--r--src/bin/e_dnd.c46
-rw-r--r--src/bin/e_dnd.h7
-rw-r--r--src/bin/e_fm.c77
5 files changed, 92 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 463b1b9413..bdc3516be9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-05-29 Mike Blumenkrantz
+
+ * added dnd support for text/x-moz-url
+
2013-05-24 Christopher Michael
* added support for hotplugging monitors in randr code
diff --git a/NEWS b/NEWS
index 9c57530193..304c69983f 100644
--- a/NEWS
+++ b/NEWS
@@ -141,6 +141,7 @@ Improvements:
* improve efm mouse movement detection for icons
* add check for vmware window in another spot to disable key remapping
* border menu now has top-level item to set borderless state
+ * added dnd support for text/x-moz-url
Fixes:
* IBar menu didn't allow to configure different icon sources, show contents menu even on empty IBar.
diff --git a/src/bin/e_dnd.c b/src/bin/e_dnd.c
index ca23b6b3cb..f52b38227b 100644
--- a/src/bin/e_dnd.c
+++ b/src/bin/e_dnd.c
@@ -61,7 +61,7 @@ static Eina_Stringshare **_e_dnd_types[] =
{
&_type_text_uri_list,
&_type_xds,
- //&_type_text_x_moz_url,
+ &_type_text_x_moz_url,
//&_type_enlightenment_x_file,
NULL
};
@@ -1430,42 +1430,16 @@ _e_dnd_cb_event_dnd_selection(void *data __UNUSED__, int type __UNUSED__, void *
}
else if (_type_text_x_moz_url == _xdnd->type)
{
- /* FIXME: Create a ecore x parser for this type */
- Ecore_X_Selection_Data *sdata;
- Eina_List *l = NULL;
- char file[PATH_MAX];
- char *text;
- int size;
-
- sdata = ev->data;
- text = (char *)sdata->data;
- size = MIN(sdata->length, PATH_MAX - 1);
- /* A moz url _shall_ contain a space */
- /* FIXME: The data is two-byte unicode. Somewhere it
- * is written that the url and the text is separated by
- * a space, but it seems like they are separated by
- * newline
- */
- for (i = 0; i < size; i++)
- {
- file[i] = text[i];
-// printf("'%d-%c' ", text[i], text[i]);
- /*
- if (text[i] == ' ')
- {
- file[i] = '\0';
- break;
- }
- */
- }
-// printf("\n");
- file[i] = '\0';
-// printf("file: %d \"%s\"\n", i, file);
- l = eina_list_append(l, file);
-
- _xdnd->data = l;
+#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
+ Ecore_X_Selection_Data_X_Moz_Url *sel;
+ E_Dnd_X_Moz_Url moz;
+
+ sel = ev->data;
+ moz.links = sel->links;
+ moz.link_names = sel->link_names;
+ _xdnd->data = &moz;
_e_drag_xdnd_end(ev->win, _xdnd->x, _xdnd->y);
- eina_list_free(l);
+#endif
}
else
_e_drag_xdnd_end(ev->win, _xdnd->x, _xdnd->y);
diff --git a/src/bin/e_dnd.h b/src/bin/e_dnd.h
index 57fd568c8f..f868f5d491 100644
--- a/src/bin/e_dnd.h
+++ b/src/bin/e_dnd.h
@@ -13,6 +13,7 @@ typedef struct _E_Event_Dnd_Enter E_Event_Dnd_Enter;
typedef struct _E_Event_Dnd_Move E_Event_Dnd_Move;
typedef struct _E_Event_Dnd_Leave E_Event_Dnd_Leave;
typedef struct _E_Event_Dnd_Drop E_Event_Dnd_Drop;
+typedef struct E_Dnd_X_Moz_Url E_Dnd_X_Moz_Url;
#else
#ifndef E_DND_H
@@ -99,6 +100,12 @@ struct _E_Event_Dnd_Drop
int x, y;
};
+struct E_Dnd_X_Moz_Url
+{
+ Eina_Inarray *links;
+ Eina_Inarray *link_names;
+};
+
EINTERN int e_dnd_init(void);
EINTERN int e_dnd_shutdown(void);
diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c
index aa55ce91ba..4a9b9a7172 100644
--- a/src/bin/e_fm.c
+++ b/src/bin/e_fm.c
@@ -488,6 +488,7 @@ static const char *_e_fm2_mime_inode_directory = NULL;
static const char *_e_fm2_mime_app_desktop = NULL;
static const char *_e_fm2_mime_app_edje = NULL;
static const char *_e_fm2_mime_text_uri_list = NULL;
+static const char *_e_fm2_mime_xmozurl = NULL;
static const char *_e_fm2_xds = NULL;
static Eina_List *_e_fm_handlers = NULL;
@@ -496,6 +497,7 @@ static const char **_e_fm2_dnd_types[] =
{
&_e_fm2_mime_text_uri_list,
&_e_fm2_xds,
+ &_e_fm2_mime_xmozurl,
NULL
};
@@ -843,6 +845,7 @@ e_fm2_init(void)
_e_fm2_mime_app_edje = eina_stringshare_add("application/x-extension-edj");
_e_fm2_mime_text_uri_list = eina_stringshare_add("text/uri-list");
_e_fm2_xds = eina_stringshare_add("XdndDirectSave0");
+ _e_fm2_mime_xmozurl = eina_stringshare_add("text/x-moz-url");
_e_fm2_favorites_thread = ecore_thread_run(_e_fm2_favorites_thread_cb,
_e_fm2_thread_cleanup_cb,
@@ -871,6 +874,7 @@ e_fm2_shutdown(void)
eina_stringshare_replace(&_e_fm2_mime_app_edje, NULL);
eina_stringshare_replace(&_e_fm2_mime_text_uri_list, NULL);
eina_stringshare_replace(&_e_fm2_xds, NULL);
+ eina_stringshare_replace(&_e_fm2_mime_xmozurl, NULL);
E_FREE_LIST(_e_fm_handlers, ecore_event_handler_del);
@@ -1617,7 +1621,7 @@ e_fm2_window_object_get(Evas_Object *obj)
EAPI void
e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj)
{
- const char *drop[] = {"text/uri-list", "XdndDirectSave0"};
+ const char *drop[] = {"text/uri-list", "text/x-moz-url", "XdndDirectSave0"};
EFM_SMART_CHECK();
sd->eobj = eobj;
@@ -1628,7 +1632,7 @@ e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj)
_e_fm2_cb_dnd_move,
_e_fm2_cb_dnd_leave,
_e_fm2_cb_dnd_selection_notify,
- drop, 2,
+ drop, 3,
sd->x, sd->y, sd->w, sd->h);
e_drop_handler_responsive_set(sd->drop_handler);
e_drop_handler_xds_set(sd->drop_handler, _e_fm2_cb_dnd_drop);
@@ -6701,14 +6705,14 @@ _e_fm2_cb_dnd_selection_notify_post_mount_timer(E_Fm2_Icon *ic)
static void
_e_fm2_cb_dnd_selection_notify(void *data, const char *type, void *event)
{
- E_Fm2_Smart_Data *sd;
- E_Event_Dnd_Drop *ev;
+ E_Fm2_Smart_Data *sd = data;
+ E_Event_Dnd_Drop *ev = event;
E_Fm2_Icon *ic;
Eina_List *fsel, *l, *ll, *il, *isel = NULL;
char buf[PATH_MAX];
const char *fp;
+ Evas_Coord ox, oy;
Evas_Object *obj;
- Evas_Coord ox, oy, x, y;
int adjust_icons = 0;
char dirpath[PATH_MAX];
char *args = NULL;
@@ -6717,10 +6721,67 @@ _e_fm2_cb_dnd_selection_notify(void *data, const char *type, void *event)
Eina_Bool lnk = EINA_FALSE, memerr = EINA_FALSE, mnt = EINA_FALSE;
E_Fm2_Device_Mount_Op *mop = NULL;
- sd = data;
- ev = event;
if (!_e_fm2_dnd_type_implemented(type)) return;
+#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
+ if (type == _e_fm2_mime_xmozurl)
+ {
+ const char **name, *s;
+ Efreet_Desktop *desktop;
+ E_Dnd_X_Moz_Url *moz = ev->data;
+ unsigned int x = 0;
+ EINA_INARRAY_FOREACH(moz->link_names, name)
+ {
+ int p;
+
+ s = *name;
+ for (p = 0; p < 7; p++)
+ {
+ Eina_Bool done = EINA_FALSE;
+
+ if (!s[p]) break;
+ if ((s[p] == ':') && (s[p + 1] == '/'))
+ {
+ s = ecore_file_file_get(s);
+ done = EINA_TRUE;
+ }
+ if (done) break;
+ }
+ if (!s[0]) s = ecore_file_file_get(*name);
+ if (!s)
+ {
+ s = *(char**)eina_inarray_nth(moz->links, x);
+ s = ecore_file_file_get(s);
+ }
+ /* FIXME: should this filename be sanitized somehow? */
+ if (sd->drop_icon && sd->drop_after == -1)
+ {
+ //into drop_icon
+ if (S_ISDIR(sd->drop_icon->info.statinfo.st_mode))
+ {
+ if (sd->drop_icon->info.link)
+ snprintf(dirpath, sizeof(dirpath), "%s/Link to %s.desktop", sd->drop_icon->info.link, s);
+ else
+ snprintf(dirpath, sizeof(dirpath), "%s/%s/Link to %s.desktop", sd->realpath, sd->drop_icon->info.file, s);
+ }
+ else
+ snprintf(buf, sizeof(buf), "%s/Link to %s.desktop", sd->realpath, s);
+ }
+ else
+ snprintf(buf, sizeof(buf), "%s/Link to %s.desktop", sd->realpath, s);
+ desktop = efreet_desktop_empty_new(buf);
+ desktop->type = EFREET_DESKTOP_TYPE_LINK;
+ snprintf(buf, sizeof(buf), "Link to %s", *name);
+ desktop->name = strdup(buf);
+ desktop->icon = strdup("text-html");
+ desktop->url = strdup(*(char**)eina_inarray_nth(moz->links, x));
+ efreet_desktop_save(desktop);
+ efreet_desktop_free(desktop);
+ x++;
+ }
+ return;
+ }
+#endif
fsel = e_fm2_uri_path_list_get(ev->data);
fp = eina_list_data_get(fsel);
if (fp && sd->realpath && ((sd->drop_all) || (!sd->drop_icon)))
@@ -6780,6 +6841,8 @@ _e_fm2_cb_dnd_selection_notify(void *data, const char *type, void *event)
*/
if (sd->drop_all) /* drop arbitrarily into the dir */
{
+ Evas_Coord x, y;
+
/* move file into this fm dir */
for (ll = fsel, il = isel; ll; ll = eina_list_next(ll), il = eina_list_next(il))
{