More code re-use
This commit is contained in:
parent
e3043a06f6
commit
581d2cb41a
|
@ -787,18 +787,16 @@ void on_view_drag_data_received(GtkWidget * widget, GdkDragContext * context,
|
|||
Browser * browser = data;
|
||||
GtkTreePath * path;
|
||||
GtkTreeIter iter;
|
||||
char * p;
|
||||
char * dest;
|
||||
|
||||
if(seldata->length <= 0 || seldata->data == NULL)
|
||||
return;
|
||||
path = gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(browser->iconview),
|
||||
x, y);
|
||||
if(path == NULL)
|
||||
return; /* FIXME then use the current directory */
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(browser->store), &iter, path);
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(browser->store), &iter, BR_COL_PATH,
|
||||
&p, -1);
|
||||
if(_common_drag_data_received(context, seldata, p) != 0)
|
||||
&dest, -1);
|
||||
if(_common_drag_data_received(context, seldata, dest) != 0)
|
||||
browser_error(browser, "fork", 0);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,8 @@ static int _common_drag_data_received(GdkDragContext * context,
|
|||
GList * s;
|
||||
#endif
|
||||
|
||||
if(seldata->length <= 0 || seldata->data == NULL)
|
||||
return;
|
||||
len = seldata->length;
|
||||
for(i = 0; i < len; i += strlen((char*)&seldata->data[i]) + 1)
|
||||
selection = g_list_append(selection, &seldata->data[i]);
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
* NonCommercial-ShareAlike 3.0 along with Browser; if not, browse to
|
||||
* http://creativecommons.org/licenses/by-nc-sa/3.0/ */
|
||||
/* FIXME:
|
||||
* - enable drag and drop as a source
|
||||
* - factorize code with browser (drag and drop, exec) */
|
||||
* - enable drag and drop as a source */
|
||||
|
||||
|
||||
|
||||
|
@ -469,37 +468,9 @@ static void _on_icon_drag_data_received(GtkWidget * widget,
|
|||
gpointer data)
|
||||
{
|
||||
DesktopIcon * desktopicon = data;
|
||||
size_t len;
|
||||
size_t i;
|
||||
GList * selection = NULL;
|
||||
#ifdef DEBUG
|
||||
GList * s;
|
||||
#else
|
||||
int ret = 0;
|
||||
#endif
|
||||
|
||||
if(seldata->length <= 0 || seldata->data == NULL)
|
||||
return;
|
||||
len = seldata->length;
|
||||
for(i = 0; i < len; i += strlen((char*)&seldata->data[i]) + 1)
|
||||
selection = g_list_append(selection, &seldata->data[i]);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%s%s%s%s%s", "DEBUG: ",
|
||||
context->suggested_action == GDK_ACTION_COPY ? "copying"
|
||||
: "moving", " to \"", desktopicon->path, "\":\n");
|
||||
for(s = selection; s != NULL; s = s->next)
|
||||
fprintf(stderr, "DEBUG: \"%s\" to \"%s\"\n", seldata->data,
|
||||
desktopicon->path);
|
||||
#else
|
||||
selection = g_list_append(selection, desktopicon->path);
|
||||
if(context->suggested_action == GDK_ACTION_COPY)
|
||||
ret = _common_exec("copy", "-ir", selection);
|
||||
else if(context->suggested_action == GDK_ACTION_MOVE)
|
||||
ret = _common_exec("move", "-i", selection);
|
||||
if(ret != 0)
|
||||
if(_common_drag_data_received(context, seldata, desktopicon->path) != 0)
|
||||
desktop_error(desktopicon->desktop, "fork", 0);
|
||||
#endif
|
||||
g_list_free(selection);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user