gnumeric r16487 - in trunk: . src



Author: jhellan
Date: Sun Mar 30 16:11:50 2008
New Revision: 16487
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16487&view=rev

Log:
2008-03-30  Jon K Hellan  <hellan acm org>

	* src/gui-clipboard.c (x_targets_received): Request text if holder
	of clipboard doesn't offer any target we understand. Broken apps,
	including jedit, have been seen to return a bogus list of targets,
	but nonetheless return text when asked.
	(utf8_content_received): New function. Passes text received from
	clipboard to text_to_cell_Region.


Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/src/gui-clipboard.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Sun Mar 30 16:11:50 2008
@@ -20,6 +20,9 @@
 	* Fix ssconvert win32.
 	* Merge some cygwin build patches. [#506366]
 
+Jon KÃre:
+        * Receive clipboard from broken apps. [#524756]
+
 Morten:
 	* Fix NPV doc problem.  [#506160]
 	* Fix python compilation problem.  [#509023]  [508988]

Modified: trunk/src/gui-clipboard.c
==============================================================================
--- trunk/src/gui-clipboard.c	(original)
+++ trunk/src/gui-clipboard.c	Sun Mar 30 16:11:50 2008
@@ -214,6 +214,37 @@
 	g_free (ctxt);
 }
 
+static void
+utf8_content_received (GtkClipboard *clipboard,  const gchar *text,
+		       gpointer closure)
+{
+	GnmGtkClipboardCtxt *ctxt = closure;
+	WBCGtk *wbcg = ctxt->wbcg;
+	WorkbookControl	   *wbc  = WORKBOOK_CONTROL (wbcg);
+	GnmPasteTarget	   *pt   = ctxt->paste_target;
+	GnmCellRegion *content = NULL;
+
+	/* Nothing on clipboard? */
+	if (!text || strlen(text) == 0) {
+		;
+	} else {
+		content = text_to_cell_region (wbcg, text, strlen(text), "UTF-8", TRUE);
+	} 
+	if (content) {
+		/*
+		 * if the conversion from the X selection -> a cellregion
+		 * was canceled this may have content sized -1,-1
+		 */
+		if (content->cols > 0 && content->rows > 0)
+			cmd_paste_copy (wbc, pt, content);
+
+		/* Release the resources we used */
+		cellregion_unref (content);
+	}
+	g_free (ctxt->paste_target);
+	g_free (ctxt);
+}
+
 /**
  * Use the file_opener plugin service to read into a temporary workbook, in
  * order to copy from it to the paste target. A temporary sheet would do just
@@ -397,8 +428,8 @@
 
 	/* Nothing on clipboard? */
 	if (targets == NULL || n_targets == 0) {
-		g_free (ctxt->paste_target);
-		g_free (ctxt);
+		gtk_clipboard_request_text (clipboard, utf8_content_received,
+					    ctxt);
 		return;
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]