[gedit/wip/gtkapp] Handle stdin



commit 8aebd7f85195a951ef0fc250f9089bd5483b750c
Author: Paolo Borelli <pborelli gnome org>
Date:   Wed Nov 28 20:04:48 2012 +0100

    Handle stdin
    
    Note that we now require "-" to be specified on the command line.
    (The actual call is commented out until the API is added to glib)

 gedit/gedit-app.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index c197c5c..7f3ed7d 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -100,6 +100,7 @@ static gboolean background = FALSE;
 static gboolean standalone = FALSE;
 static gchar **remaining_args = NULL;
 static const GeditEncoding *encoding = NULL;
+static GInputStream *stdin_stream = NULL;
 static GSList *file_list = NULL;
 static gint line_position = 0;
 static gint column_position = 0;
@@ -439,6 +440,22 @@ gedit_app_activate (GApplication *application)
 		                           geometry);
 	}
 
+	if (stdin_stream)
+	{
+		gedit_debug_message (DEBUG_APP, "Load stdin");
+
+/* Until https://bugzilla.gnome.org/show_bug.cgi?id=668210 lands */
+#if 0
+		doc_created = gedit_window_create_tab_from_stream (window,
+		                                                   stdin_stream,
+		                                                   encoding,
+		                                                   line_position,
+		                                                   column_position,
+		                                                   TRUE) != NULL;
+#endif
+		g_input_stream_close (stdin_stream, NULL, NULL);
+	}
+
 	if (file_list != NULL)
 	{
 		GSList *loaded;
@@ -450,7 +467,7 @@ gedit_app_activate (GApplication *application)
 		                                            line_position,
 		                                            column_position);
 
-		doc_created = loaded != NULL;
+		doc_created = doc_created || loaded != NULL;
 		g_slist_free (loaded);
 	}
 
@@ -512,6 +529,7 @@ clear_options (void)
 	g_free (encoding_charset);
 	g_strfreev (remaining_args);
 	g_free (geometry);
+	g_clear_object (&stdin_stream);
 	g_slist_free_full (file_list, g_object_unref);
 
 	help = FALSE;
@@ -621,6 +639,10 @@ gedit_app_command_line (GApplication            *application,
 							                  &column_position);
 					}
 				}
+				else if (*remaining_args[i] == '-' && *(remaining_args[i] + 1) == '\0')
+				{
+					stdin_stream = g_application_command_line_get_stdin (command_line);
+				}
 				else
 				{
 					GFile *file;



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