[gedit/wip/gtkapp: 23/26] Handle stdin
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/gtkapp: 23/26] Handle stdin
- Date: Fri, 28 Dec 2012 18:28:48 +0000 (UTC)
commit 96cc67ffa4f60746ab58f5ef734db2a657f3a052
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.
gedit/gedit-app.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 519eecd..81f1570 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;
@@ -529,6 +530,19 @@ gedit_app_activate (GApplication *application)
geometry);
}
+ if (stdin_stream)
+ {
+ gedit_debug_message (DEBUG_APP, "Load stdin");
+
+ doc_created = gedit_window_create_tab_from_stream (window,
+ stdin_stream,
+ encoding,
+ line_position,
+ column_position,
+ TRUE) != NULL;
+ g_input_stream_close (stdin_stream, NULL, NULL);
+ }
+
if (file_list != NULL)
{
GSList *loaded;
@@ -540,7 +554,7 @@ gedit_app_activate (GApplication *application)
line_position,
column_position);
- doc_created = loaded != NULL;
+ doc_created = doc_created || loaded != NULL;
g_slist_free (loaded);
}
@@ -602,6 +616,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;
@@ -711,6 +726,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]