summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <m.blumenkran@samsung.com>2013-05-29 13:43:55 +0100
committerMike Blumenkrantz <m.blumenkran@samsung.com>2013-05-29 13:45:48 +0100
commitbc86c5a8b5af9917b6d35591156d81f1a6e2e417 (patch)
tree15128f5a89c9144a45dc9a2cc43ac534a79f6d67
parentdb20c24837bf1a894b302e7582b10fda4e6fa8d5 (diff)
efm now supports text/x-moz-url dnd operations when using efl 1.8
-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 463b1b941..bdc3516be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12013-05-29 Mike Blumenkrantz
2
3 * added dnd support for text/x-moz-url
4
12013-05-24 Christopher Michael 52013-05-24 Christopher Michael
2 6
3 * added support for hotplugging monitors in randr code 7 * added support for hotplugging monitors in randr code
diff --git a/NEWS b/NEWS
index 9c5753019..304c69983 100644
--- a/NEWS
+++ b/NEWS
@@ -141,6 +141,7 @@ Improvements:
141 * improve efm mouse movement detection for icons 141 * improve efm mouse movement detection for icons
142 * add check for vmware window in another spot to disable key remapping 142 * add check for vmware window in another spot to disable key remapping
143 * border menu now has top-level item to set borderless state 143 * border menu now has top-level item to set borderless state
144 * added dnd support for text/x-moz-url
144 145
145Fixes: 146Fixes:
146 * IBar menu didn't allow to configure different icon sources, show contents menu even on empty IBar. 147 * 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 ca23b6b3c..f52b38227 100644
--- a/src/bin/e_dnd.c
+++ b/src/bin/e_dnd.c
@@ -61,7 +61,7 @@ static Eina_Stringshare **_e_dnd_types[] =
61{ 61{
62 &_type_text_uri_list, 62 &_type_text_uri_list,
63 &_type_xds, 63 &_type_xds,
64 //&_type_text_x_moz_url, 64 &_type_text_x_moz_url,
65 //&_type_enlightenment_x_file, 65 //&_type_enlightenment_x_file,
66 NULL 66 NULL
67}; 67};
@@ -1430,42 +1430,16 @@ _e_dnd_cb_event_dnd_selection(void *data __UNUSED__, int type __UNUSED__, void *
1430 } 1430 }
1431 else if (_type_text_x_moz_url == _xdnd->type) 1431 else if (_type_text_x_moz_url == _xdnd->type)
1432 { 1432 {
1433 /* FIXME: Create a ecore x parser for this type */ 1433#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
1434 Ecore_X_Selection_Data *sdata; 1434 Ecore_X_Selection_Data_X_Moz_Url *sel;
1435 Eina_List *l = NULL; 1435 E_Dnd_X_Moz_Url moz;
1436 char file[PATH_MAX]; 1436
1437 char *text; 1437 sel = ev->data;
1438 int size; 1438 moz.links = sel->links;
1439 1439 moz.link_names = sel->link_names;
1440 sdata = ev->data; 1440 _xdnd->data = &moz;
1441 text = (char *)sdata->data;
1442 size = MIN(sdata->length, PATH_MAX - 1);
1443 /* A moz url _shall_ contain a space */
1444 /* FIXME: The data is two-byte unicode. Somewhere it
1445 * is written that the url and the text is separated by
1446 * a space, but it seems like they are separated by
1447 * newline
1448 */
1449 for (i = 0; i < size; i++)
1450 {
1451 file[i] = text[i];
1452// printf("'%d-%c' ", text[i], text[i]);
1453 /*
1454 if (text[i] == ' ')
1455 {
1456 file[i] = '\0';
1457 break;
1458 }
1459 */
1460 }
1461// printf("\n");
1462 file[i] = '\0';
1463// printf("file: %d \"%s\"\n", i, file);
1464 l = eina_list_append(l, file);
1465
1466 _xdnd->data = l;
1467 _e_drag_xdnd_end(ev->win, _xdnd->x, _xdnd->y); 1441 _e_drag_xdnd_end(ev->win, _xdnd->x, _xdnd->y);
1468 eina_list_free(l); 1442#endif
1469 } 1443 }
1470 else 1444 else
1471 _e_drag_xdnd_end(ev->win, _xdnd->x, _xdnd->y); 1445 _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 57fd568c8..f868f5d49 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;
13typedef struct _E_Event_Dnd_Move E_Event_Dnd_Move; 13typedef struct _E_Event_Dnd_Move E_Event_Dnd_Move;
14typedef struct _E_Event_Dnd_Leave E_Event_Dnd_Leave; 14typedef struct _E_Event_Dnd_Leave E_Event_Dnd_Leave;
15typedef struct _E_Event_Dnd_Drop E_Event_Dnd_Drop; 15typedef struct _E_Event_Dnd_Drop E_Event_Dnd_Drop;
16typedef struct E_Dnd_X_Moz_Url E_Dnd_X_Moz_Url;
16 17
17#else 18#else
18#ifndef E_DND_H 19#ifndef E_DND_H
@@ -99,6 +100,12 @@ struct _E_Event_Dnd_Drop
99 int x, y; 100 int x, y;
100}; 101};
101 102
103struct E_Dnd_X_Moz_Url
104{
105 Eina_Inarray *links;
106 Eina_Inarray *link_names;
107};
108
102EINTERN int e_dnd_init(void); 109EINTERN int e_dnd_init(void);
103EINTERN int e_dnd_shutdown(void); 110EINTERN int e_dnd_shutdown(void);
104 111
diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c
index aa55ce91b..4a9b9a717 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;
488static const char *_e_fm2_mime_app_desktop = NULL; 488static const char *_e_fm2_mime_app_desktop = NULL;
489static const char *_e_fm2_mime_app_edje = NULL; 489static const char *_e_fm2_mime_app_edje = NULL;
490static const char *_e_fm2_mime_text_uri_list = NULL; 490static const char *_e_fm2_mime_text_uri_list = NULL;
491static const char *_e_fm2_mime_xmozurl = NULL;
491static const char *_e_fm2_xds = NULL; 492static const char *_e_fm2_xds = NULL;
492 493
493static Eina_List *_e_fm_handlers = NULL; 494static Eina_List *_e_fm_handlers = NULL;
@@ -496,6 +497,7 @@ static const char **_e_fm2_dnd_types[] =
496{ 497{
497 &_e_fm2_mime_text_uri_list, 498 &_e_fm2_mime_text_uri_list,
498 &_e_fm2_xds, 499 &_e_fm2_xds,
500 &_e_fm2_mime_xmozurl,
499 NULL 501 NULL
500}; 502};
501 503
@@ -843,6 +845,7 @@ e_fm2_init(void)
843 _e_fm2_mime_app_edje = eina_stringshare_add("application/x-extension-edj"); 845 _e_fm2_mime_app_edje = eina_stringshare_add("application/x-extension-edj");
844 _e_fm2_mime_text_uri_list = eina_stringshare_add("text/uri-list"); 846 _e_fm2_mime_text_uri_list = eina_stringshare_add("text/uri-list");
845 _e_fm2_xds = eina_stringshare_add("XdndDirectSave0"); 847 _e_fm2_xds = eina_stringshare_add("XdndDirectSave0");
848 _e_fm2_mime_xmozurl = eina_stringshare_add("text/x-moz-url");
846 849
847 _e_fm2_favorites_thread = ecore_thread_run(_e_fm2_favorites_thread_cb, 850 _e_fm2_favorites_thread = ecore_thread_run(_e_fm2_favorites_thread_cb,
848 _e_fm2_thread_cleanup_cb, 851 _e_fm2_thread_cleanup_cb,
@@ -871,6 +874,7 @@ e_fm2_shutdown(void)
871 eina_stringshare_replace(&_e_fm2_mime_app_edje, NULL); 874 eina_stringshare_replace(&_e_fm2_mime_app_edje, NULL);
872 eina_stringshare_replace(&_e_fm2_mime_text_uri_list, NULL); 875 eina_stringshare_replace(&_e_fm2_mime_text_uri_list, NULL);
873 eina_stringshare_replace(&_e_fm2_xds, NULL); 876 eina_stringshare_replace(&_e_fm2_xds, NULL);
877 eina_stringshare_replace(&_e_fm2_mime_xmozurl, NULL);
874 878
875 E_FREE_LIST(_e_fm_handlers, ecore_event_handler_del); 879 E_FREE_LIST(_e_fm_handlers, ecore_event_handler_del);
876 880
@@ -1617,7 +1621,7 @@ e_fm2_window_object_get(Evas_Object *obj)
1617EAPI void 1621EAPI void
1618e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj) 1622e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj)
1619{ 1623{
1620 const char *drop[] = {"text/uri-list", "XdndDirectSave0"}; 1624 const char *drop[] = {"text/uri-list", "text/x-moz-url", "XdndDirectSave0"};
1621 1625
1622 EFM_SMART_CHECK(); 1626 EFM_SMART_CHECK();
1623 sd->eobj = eobj; 1627 sd->eobj = eobj;
@@ -1628,7 +1632,7 @@ e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj)
1628 _e_fm2_cb_dnd_move, 1632 _e_fm2_cb_dnd_move,
1629 _e_fm2_cb_dnd_leave, 1633 _e_fm2_cb_dnd_leave,
1630 _e_fm2_cb_dnd_selection_notify, 1634 _e_fm2_cb_dnd_selection_notify,
1631 drop, 2, 1635 drop, 3,
1632 sd->x, sd->y, sd->w, sd->h); 1636 sd->x, sd->y, sd->w, sd->h);
1633 e_drop_handler_responsive_set(sd->drop_handler); 1637 e_drop_handler_responsive_set(sd->drop_handler);
1634 e_drop_handler_xds_set(sd->drop_handler, _e_fm2_cb_dnd_drop); 1638 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)
6701static void 6705static void
6702_e_fm2_cb_dnd_selection_notify(void *data, const char *type, void *event) 6706_e_fm2_cb_dnd_selection_notify(void *data, const char *type, void *event)
6703{ 6707{
6704 E_Fm2_Smart_Data *sd; 6708 E_Fm2_Smart_Data *sd = data;
6705 E_Event_Dnd_Drop *ev; 6709 E_Event_Dnd_Drop *ev = event;
6706 E_Fm2_Icon *ic; 6710 E_Fm2_Icon *ic;
6707 Eina_List *fsel, *l, *ll, *il, *isel = NULL; 6711 Eina_List *fsel, *l, *ll, *il, *isel = NULL;
6708 char buf[PATH_MAX]; 6712 char buf[PATH_MAX];
6709 const char *fp; 6713 const char *fp;
6714 Evas_Coord ox, oy;
6710 Evas_Object *obj; 6715 Evas_Object *obj;
6711 Evas_Coord ox, oy, x, y;
6712 int adjust_icons = 0; 6716 int adjust_icons = 0;
6713 char dirpath[PATH_MAX]; 6717 char dirpath[PATH_MAX];
6714 char *args = NULL; 6718 char *args = NULL;
@@ -6717,10 +6721,67 @@ _e_fm2_cb_dnd_selection_notify(void *data, const char *type, void *event)
6717 Eina_Bool lnk = EINA_FALSE, memerr = EINA_FALSE, mnt = EINA_FALSE; 6721 Eina_Bool lnk = EINA_FALSE, memerr = EINA_FALSE, mnt = EINA_FALSE;
6718 E_Fm2_Device_Mount_Op *mop = NULL; 6722 E_Fm2_Device_Mount_Op *mop = NULL;
6719 6723
6720 sd = data;
6721 ev = event;
6722 if (!_e_fm2_dnd_type_implemented(type)) return; 6724 if (!_e_fm2_dnd_type_implemented(type)) return;
6725#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
6726 if (type == _e_fm2_mime_xmozurl)
6727 {
6728 const char **name, *s;
6729 Efreet_Desktop *desktop;
6730 E_Dnd_X_Moz_Url *moz = ev->data;
6731 unsigned int x = 0;
6723 6732
6733 EINA_INARRAY_FOREACH(moz->link_names, name)
6734 {
6735 int p;
6736
6737 s = *name;
6738 for (p = 0; p < 7; p++)
6739 {
6740 Eina_Bool done = EINA_FALSE;
6741
6742 if (!s[p]) break;
6743 if ((s[p] == ':') && (s[p + 1] == '/'))
6744 {
6745 s = ecore_file_file_get(s);
6746 done = EINA_TRUE;
6747 }
6748 if (done) break;
6749 }
6750 if (!s[0]) s = ecore_file_file_get(*name);
6751 if (!s)
6752 {
6753 s = *(char**)eina_inarray_nth(moz->links, x);
6754 s = ecore_file_file_get(s);
6755 }
6756 /* FIXME: should this filename be sanitized somehow? */
6757 if (sd->drop_icon && sd->drop_after == -1)
6758 {
6759 //into drop_icon
6760 if (S_ISDIR(sd->drop_icon->info.statinfo.st_mode))
6761 {
6762 if (sd->drop_icon->info.link)
6763 snprintf(dirpath, sizeof(dirpath), "%s/Link to %s.desktop", sd->drop_icon->info.link, s);
6764 else
6765 snprintf(dirpath, sizeof(dirpath), "%s/%s/Link to %s.desktop", sd->realpath, sd->drop_icon->info.file, s);
6766 }
6767 else
6768 snprintf(buf, sizeof(buf), "%s/Link to %s.desktop", sd->realpath, s);
6769 }
6770 else
6771 snprintf(buf, sizeof(buf), "%s/Link to %s.desktop", sd->realpath, s);
6772 desktop = efreet_desktop_empty_new(buf);
6773 desktop->type = EFREET_DESKTOP_TYPE_LINK;
6774 snprintf(buf, sizeof(buf), "Link to %s", *name);
6775 desktop->name = strdup(buf);
6776 desktop->icon = strdup("text-html");
6777 desktop->url = strdup(*(char**)eina_inarray_nth(moz->links, x));
6778 efreet_desktop_save(desktop);
6779 efreet_desktop_free(desktop);
6780 x++;
6781 }
6782 return;
6783 }
6784#endif
6724 fsel = e_fm2_uri_path_list_get(ev->data); 6785 fsel = e_fm2_uri_path_list_get(ev->data);
6725 fp = eina_list_data_get(fsel); 6786 fp = eina_list_data_get(fsel);
6726 if (fp && sd->realpath && ((sd->drop_all) || (!sd->drop_icon))) 6787 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)
6780 */ 6841 */
6781 if (sd->drop_all) /* drop arbitrarily into the dir */ 6842 if (sd->drop_all) /* drop arbitrarily into the dir */
6782 { 6843 {
6844 Evas_Coord x, y;
6845
6783 /* move file into this fm dir */ 6846 /* move file into this fm dir */
6784 for (ll = fsel, il = isel; ll; ll = eina_list_next(ll), il = eina_list_next(il)) 6847 for (ll = fsel, il = isel; ll; ll = eina_list_next(ll), il = eina_list_next(il))
6785 { 6848 {