gnome-terminal r2982 - trunk/src



Author: chpe
Date: Thu Aug 14 19:38:19 2008
New Revision: 2982
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2982&view=rev

Log:
Bug 519191 â Request: automatically insert space after receiving drag-and-drop text
Based on a patch by Maxim Ermilov.

Modified:
   trunk/src/terminal-screen.c
   trunk/src/terminal-util.c
   trunk/src/terminal-util.h
   trunk/src/terminal-window.c

Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c	(original)
+++ trunk/src/terminal-screen.c	Thu Aug 14 19:38:19 2008
@@ -1966,6 +1966,7 @@
     {
       char **uris;
       char *text;
+      gsize len;
 
       uris = gtk_selection_data_get_uris (selection_data);
       if (!uris)
@@ -1973,8 +1974,8 @@
 
       terminal_util_transform_uris_to_quoted_fuse_paths (uris);
 
-      text = g_strjoinv (" ", uris);
-      vte_terminal_feed_child (VTE_TERMINAL (screen), text, strlen (text));
+      text = terminal_util_concat_uris (uris, &len);
+      vte_terminal_feed_child (VTE_TERMINAL (screen), text, len);
       g_free (text);
 
       g_strfreev (uris);
@@ -2016,8 +2017,9 @@
 
     case TARGET_MOZ_URL:
       {
-        char *utf8_data, *newline;
+        char *utf8_data, *newline, *text;
         char *uris[2];
+        gsize len;
         
         /* MOZ_URL is in UCS-2 but in format 8. BROKEN!
          *
@@ -2043,15 +2045,18 @@
         uris[1] = NULL;
         terminal_util_transform_uris_to_quoted_fuse_paths (uris); /* This may replace uris[0] */
 
-        vte_terminal_feed_child (VTE_TERMINAL (screen), uris[0], strlen (uris[0]));
+        text = terminal_util_concat_uris (uris, &len);
+        vte_terminal_feed_child (VTE_TERMINAL (screen), text, len);
+        g_free (text);
         g_free (uris[0]);
       }
       break;
 
     case TARGET_NETSCAPE_URL:
       {
-        char *utf8_data, *newline;
+        char *utf8_data, *newline, *text;
         char *uris[2];
+        gsize len;
         
         /* The data contains the URL, a \n, then the
          * title of the web page.
@@ -2068,7 +2073,9 @@
         uris[1] = NULL;
         terminal_util_transform_uris_to_quoted_fuse_paths (uris); /* This may replace uris[0] */
 
-        vte_terminal_feed_child (VTE_TERMINAL (screen), uris[0], strlen (uris[0]));
+        text = terminal_util_concat_uris (uris, &len);
+        vte_terminal_feed_child (VTE_TERMINAL (screen), text, len);
+        g_free (text);
         g_free (uris[0]);
       }
       break;

Modified: trunk/src/terminal-util.c
==============================================================================
--- trunk/src/terminal-util.c	(original)
+++ trunk/src/terminal-util.c	Thu Aug 14 19:38:19 2008
@@ -257,6 +257,31 @@
     }
 }
 
+char *
+terminal_util_concat_uris (char **uris,
+                           gsize *length)
+{
+  GString *string;
+  gsize len;
+  guint i;
+
+  len = 0;
+  for (i = 0; uris[i]; ++i)
+    len += strlen (uris[i]) + 1;
+
+  if (length)
+    *length = len;
+
+  string = g_string_sized_new (len + 1);
+  for (i = 0; uris[i]; ++i)
+    {
+      g_string_append (string, uris[i]);
+      g_string_append_c (string, ' ');
+    }
+
+  return g_string_free (string, FALSE);
+}
+
 gboolean
 terminal_util_load_builder_file (const char *filename,
                                  const char *object_name,

Modified: trunk/src/terminal-util.h
==============================================================================
--- trunk/src/terminal-util.h	(original)
+++ trunk/src/terminal-util.h	Thu Aug 14 19:38:19 2008
@@ -48,6 +48,9 @@
 
 void terminal_util_transform_uris_to_quoted_fuse_paths (char **uris);
 
+char *terminal_util_concat_uris (char **uris,
+                                 gsize *length);
+
 gboolean terminal_util_load_builder_file (const char *filename,
                                           const char *object_name,
                                           ...);

Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c	(original)
+++ trunk/src/terminal-window.c	Thu Aug 14 19:38:19 2008
@@ -2708,6 +2708,7 @@
                             PasteData *data)
 {
   char *text;
+  gsize len;
 #if !GTK_CHECK_VERSION (2, 13, 4)
   char **uris;
 
@@ -2723,8 +2724,8 @@
   if (data->uris_as_paths)
     terminal_util_transform_uris_to_quoted_fuse_paths (uris);
 
-  text = g_strjoinv (" ", uris);
-  vte_terminal_feed_child (VTE_TERMINAL (data->screen), text, strlen (text));
+  text = terminal_util_concat_uris (uris, &len);
+  vte_terminal_feed_child (VTE_TERMINAL (data->screen), text, len);
   g_free (text);
 
   g_strfreev (uris);



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