/* Copyright (C) 1999 Southern Gold Development * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gview.h" void startDragFile(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *data, guint info, guint time, gpointer inData) { sgview *view; gchar *file, *wdir, *tmpH; GList *selList; view = (sgview *) inData; if (GTK_CLIST (view->clist)->focus_row == -1) return; wdir = NULL; if (GTK_CLIST (view->clist)->selection) { selList = GTK_CLIST (view->clist)->selection; wdir = g_malloc(sizeof(gchar) * 2); wdir[0] = '\n'; wdir[1] = '\0'; while (selList) { gtk_clist_get_text(GTK_CLIST (view->clist), (int) selList->data, 0, &file); if ((strcmp(file, _(".. (parent)")) != 0) && (file[strlen(file) - 1] != '/')) { tmpH = g_strconcat("file:", view->currPath, file, "\n", NULL); wdir = g_strconcat(tmpH, wdir, NULL); } selList = selList->next; } } else { gtk_clist_get_text(GTK_CLIST (view->clist), GTK_CLIST(view->clist)->focus_row, 0, &file); if ((strcmp(file, _(".. (parent)")) != 0) && (file[strlen(file) - 1] != '/')) { wdir = g_strconcat("file:", view->currPath, file, "\n\n", NULL); } } if (wdir) { gtk_selection_data_set(data, data->target, 8, wdir, strlen(wdir)); g_free(wdir); } else { gtk_selection_data_set(data, data->target, 8, "", 0); } } void startDragSlide(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *data, guint info, guint time, gpointer inData) { ren *viewD; gint srow; gchar *send; viewD = (ren *) inData; if (GTK_CLIST (viewD->ent)->focus_row == -1) return; else srow = GTK_CLIST (viewD->ent)->focus_row; send = g_strdup_printf("rowmove://%d", srow); gtk_selection_data_set(data, data->target, 8, send, strlen(send)); g_free(send); } void dropDragFile(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer inData) { sgview *view; gchar *file, *wdir, *hnd; view = (sgview *) inData; if ((data->length >= 0) && (data->format == 8)) { hnd = (gchar *) data->data; file = strsep(&hnd, "\n"); if ((strncmp(file, "file:", 5) == 0) && (isImage(view, file))) { wdir = file + 5; loadPic(view, wdir); } #ifdef HAVE_NET if ((strncmp(file, "http://", 7) == 0) || (strncmp(file, "ftp://", 6) == 0)) { netload(view, file); } #endif /* HAVE_NET */ gtk_drag_finish(context, TRUE, FALSE, time); return; } gtk_drag_finish(context, FALSE, FALSE, time); } void dropDragSlide(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer inData) { sgview *view; gchar *file, *wdir, *hnd; gint dropRow, rowH, sourceRow; view = (sgview *) inData; if ((data->length >= 0) && (data->format == 8)) { hnd = (gchar *) data->data; if (strncmp(hnd, "rowmove://", 10) == 0) { file = hnd + 10; sourceRow = atoi(file); rowH = GTK_CLIST (widget)->row_height + 1; dropRow = ((y - GTK_CLIST (widget)->voffset) / rowH) - 1; if ((dropRow >= 0) && (dropRow < GTK_CLIST (widget)->rows)) moveSlide(view, GTK_CLIST (widget), sourceRow, dropRow); } else { file = strsep(&hnd, "\n"); while (file) { if ((strncmp(file, "file:", 5) == 0) && (isImage(view, file))) { wdir = g_strdup(file + 5); queueSlide(view, wdir); } file = strsep(&hnd, "\n"); } } refreshSlideList(view); } }