[gedit] document-panel: add text/plain target for dropping on other windows
- From: Sebastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] document-panel: add text/plain target for dropping on other windows
- Date: Mon, 10 Mar 2014 23:48:56 +0000 (UTC)
commit 3dfdebf92c888528898f687839611fad819c0b86
Author: Sebastien Lafargue <slafargue src gnome org>
Date: Mon Mar 10 20:11:57 2014 +0100
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.
https://bugzilla.gnome.org/show_bug.cgi?id=726054
gedit/gedit-documents-panel.c | 37 ++++++++++++++++++++++++++++++++++---
1 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/gedit/gedit-documents-panel.c b/gedit/gedit-documents-panel.c
index 785ae36..92018e6 100644
--- a/gedit/gedit-documents-panel.c
+++ b/gedit/gedit-documents-panel.c
@@ -26,6 +26,7 @@
#include "gedit-documents-panel.h"
#include "gedit-debug.h"
+#include "gedit-document.h"
#include "gedit-multi-notebook.h"
#include "gedit-notebook.h"
#include "gedit-notebook-popup-menu.h"
@@ -1136,19 +1137,48 @@ 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);
+ GdkAtom result;
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));
+ return;
}
+
+ result = gtk_drag_dest_find_target (widget, context, priv->source_targets);
+
+ if (result != GDK_NONE)
+ {
+ 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))
+ {
+ GFile *file = gedit_document_get_location (doc);
+ full_name = g_file_get_parse_name (file);
+ g_object_unref (file);
+
+ 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 *
@@ -1404,6 +1434,7 @@ 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));
+ gtk_target_list_add_text_targets (panel->priv->source_targets, 0);
gtk_drag_dest_set (GTK_WIDGET (panel), 0,
panel_targets, G_N_ELEMENTS (panel_targets),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]