[Goodies-commits] r3980 - ristretto/trunk/src
Stephan Arts
stephan at xfce.org
Fri Feb 22 00:07:12 CET 2008
Author: stephan
Date: 2008-02-21 23:07:12 +0000 (Thu, 21 Feb 2008)
New Revision: 3980
Modified:
ristretto/trunk/src/main_window.c
ristretto/trunk/src/picture_viewer.c
Log:
Made first attempt to add Drag and Drop
Modified: ristretto/trunk/src/main_window.c
===================================================================
--- ristretto/trunk/src/main_window.c 2008-02-21 22:04:24 UTC (rev 3979)
+++ ristretto/trunk/src/main_window.c 2008-02-21 23:07:12 UTC (rev 3980)
@@ -1241,7 +1241,7 @@
resize_to_content_vbox = gtk_vbox_new(FALSE, 0);
resize_to_content_frame = xfce_create_framebox_with_content(_("Resize to content"), resize_to_content_vbox);
- resize_on_maximize_check = gtk_check_button_new_with_mnemonic(_("Resize on maximize"));
+ resize_on_maximize_check = gtk_check_button_new_with_mnemonic(_("Rescale image on maximize/restore"));
gtk_box_pack_start(GTK_BOX(resize_to_content_vbox), resize_on_maximize_check, FALSE, TRUE, 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resize_on_maximize_check), window->priv->settings.scale_to_100);
Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c 2008-02-21 22:04:24 UTC (rev 3979)
+++ ristretto/trunk/src/picture_viewer.c 2008-02-21 23:07:12 UTC (rev 3980)
@@ -1213,9 +1213,48 @@
}
static void
-rstto_picture_viewer_drag_data_received()
+rstto_picture_viewer_drag_data_received(GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time)
{
- g_debug("%s", __FUNCTION__);
+ RsttoPictureViewer *picture_viewer = widget;
+ gchar **array = gtk_selection_data_get_uris (selection_data);
+
+ context->action = GDK_ACTION_PRIVATE;
+
+ if (array == NULL)
+ {
+ gtk_drag_finish (context, FALSE, FALSE, time);
+ }
+
+ gchar **_array = array;
+
+ while(*_array)
+ {
+ ThunarVfsPath *path = thunar_vfs_path_new(*_array, NULL);
+ ThunarVfsInfo *info = thunar_vfs_info_new_for_path(path, NULL);
+ gchar *file_media = thunar_vfs_mime_info_get_media(info->mime_info);
+ if(!strcmp(file_media, "image"))
+ {
+ RsttoNavigatorEntry *entry = rstto_navigator_entry_new(picture_viewer->priv->navigator, info);
+ rstto_navigator_add (picture_viewer->priv->navigator, entry, TRUE);
+ gchar *uri = thunar_vfs_path_dup_uri(info->path);
+ g_free(uri);
+ }
+ else
+ {
+
+ }
+ g_free(file_media);
+ thunar_vfs_path_unref(path);
+ _array++;
+ }
+
+ gtk_drag_finish (context, TRUE, FALSE, time);
}
static gboolean
@@ -1225,8 +1264,23 @@
gint y,
guint time)
{
- g_debug("%s", __FUNCTION__);
- gtk_drag_finish(context, FALSE, FALSE, time);
+ GdkAtom target;
+
+ /* determine the drop target */
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+ if (G_LIKELY (target == gdk_atom_intern ("text/uri-list", FALSE)))
+ {
+ /* set state so the drag-data-received handler
+ * knows that this is really a drop this time.
+ */
+
+ /* request the drag data from the source. */
+ gtk_drag_get_data (widget, context, target, time);
+ }
+ else
+ {
+ return FALSE;
+ }
return TRUE;
}
@@ -1237,6 +1291,12 @@
gint y,
guint time)
{
- g_debug("%s", __FUNCTION__);
+ GdkAtom target;
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+ if (G_UNLIKELY (target != gdk_atom_intern ("text/uri-list", FALSE)))
+ {
+ /* we cannot handle the drop */
+ return FALSE;
+ }
return TRUE;
}
More information about the Goodies-commits
mailing list