After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 726054 - document-panel: add text/plain target for dropping on other windows
document-panel: add text/plain target for dropping on other windows
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: general
unspecified
Other All
: Normal trivial
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2014-03-10 19:15 UTC by sébastien lafargue
Modified: 2014-03-10 23:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
document-panel: add text/plain target for dropping on other windows (2.71 KB, patch)
2014-03-10 19:15 UTC, sébastien lafargue
needs-work Details | Review
document-panel: add text/plain target for dropping on other windows (2.93 KB, patch)
2014-03-10 23:44 UTC, sébastien lafargue
committed Details | Review

Description sébastien lafargue 2014-03-10 19:15:48 UTC
We can now drop a document row on app that accept text/plain
( terminal is the main example )
    
As a feature, you can also drop it on gedit source view for the same result.
Comment 1 sébastien lafargue 2014-03-10 19:15:52 UTC
Created attachment 271464 [details] [review]
document-panel: add text/plain target for dropping on other windows

We can now drop a document row on app that accept text/plain
( terminal is the main example )

As a feature, you can also drop it on gedit source view for the same result.
Comment 2 Paolo Borelli 2014-03-10 21:04:19 UTC
Comment on attachment 271464 [details] [review]
document-panel: add text/plain target for dropping on other windows

>From 4a50573a0ea8346a899a434fa6657142bf6db378 Mon Sep 17 00:00:00 2001
>From: Sebastien Lafargue <slafargue@src.gnome.org>
>Date: Mon, 10 Mar 2014 20:11:57 +0100
>Subject: [PATCH] document-panel: add text/plain target for dropping on other
> windows
>
>We can now drop a document row on app that accept text/plain
>( terminal is the main example )
>
>As a feature, you can also drop it on gedit source view for the same result.
>
>https://bugzilla.gnome.org/show_bug.cgi?id=726054
>---
> gedit/gedit-documents-panel.c | 35 ++++++++++++++++++++++++++++++++---
> 1 file changed, 32 insertions(+), 3 deletions(-)
>
>diff --git a/gedit/gedit-documents-panel.c b/gedit/gedit-documents-panel.c
>index 785ae36..07c83cd 100644
>--- a/gedit/gedit-documents-panel.c
>+++ b/gedit/gedit-documents-panel.c
>@@ -1136,19 +1136,45 @@ panel_on_drag_data_get (GtkWidget        *widget,
>                         guint             info,
>                         guint             time)
> {
>+	GeditDocumentsPanel *panel = GEDIT_DOCUMENTS_PANEL (widget);
>+	GeditDocumentsPanelPrivate *priv = panel->priv;
> 	GdkAtom target = gtk_selection_data_get_target (data);
> 
> 	if (target == gdk_atom_intern_static_string ("GEDIT_DOCUMENTS_DOCUMENT_ROW"))
> 	{
>-		GeditDocumentsPanel *panel = GEDIT_DOCUMENTS_PANEL (widget);
>-		GeditDocumentsPanelPrivate *priv = panel->priv;
>-
> 		gtk_selection_data_set (data,
> 		                        target,
> 		                        8,
> 		                        (void*)&priv->drag_document_row,
> 		                        sizeof (gpointer));
> 	}
>+	else if (target == gdk_atom_intern_static_string ("text/plain"))
>+	{
>+		GeditTab *tab;
>+		GeditDocument *doc;
>+		gchar *full_name;
>+
>+		tab = GEDIT_TAB (GEDIT_DOCUMENTS_DOCUMENT_ROW (priv->drag_document_row)->ref);
>+		doc = gedit_tab_get_document (tab);
>+
>+		if (gedit_document_is_untitled (doc))
>+		{
>+			full_name = g_strdup ("");
>+		}
>+		else
>+		{
>+			full_name = gedit_document_get_uri_for_display (doc);

I'd say just use g_file_get_parse_name directly here, since I think it makes more clear what is going to be in the clipboard (I never remember if uri_for_display is ellipsized etc).


>+		}
>+
>+		gtk_selection_data_set (data,
>+		                        target,
>+		                        8,
>+		                        (guchar *)full_name,
>+		                        strlen (full_name));
>+		g_free (full_name);
>+
>+		gtk_widget_show (priv->drag_document_row);
>+	}
> }
> 
> static GeditNotebook *
>@@ -1405,6 +1431,9 @@ gedit_documents_panel_init (GeditDocumentsPanel *panel)
> 	/* Drag and drop support */
> 	panel->priv->source_targets = gtk_target_list_new (panel_targets, G_N_ELEMENTS (panel_targets));
> 
>+	GdkAtom text_atom = gdk_atom_intern_static_string ("text/plain");
>+	gtk_target_list_add (panel->priv->source_targets, text_atom, GTK_TARGET_OTHER_APP, 0);

Declare the var at the start of the block

>+
> 	gtk_drag_dest_set (GTK_WIDGET (panel), 0,
> 	                   panel_targets, G_N_ELEMENTS (panel_targets),
> 	                   GDK_ACTION_MOVE);

Actually, for this case can't you use gtk_drag_dest_add_text_targets and/or add_uri_targets?

>-- 
>1.8.5.3
Comment 3 sébastien lafargue 2014-03-10 23:44:52 UTC
Created attachment 271495 [details] [review]
document-panel: add text/plain target for dropping on other windows

We can now drop a document row on app that accept text/plain
the result is a paste of the full file name.
( terminal is the main example )

As a feature, you can also drop it on gedit source view for the same result.
Comment 4 sébastien lafargue 2014-03-10 23:46:17 UTC
Review of attachment 271495 [details] [review]:

changes as Paolo Borelli said.
Comment 5 sébastien lafargue 2014-03-10 23:49:05 UTC
Attachment 271495 [details] pushed as 3dfdebf - document-panel: add text/plain target for dropping on other windows