[gedit/wip/gtkapp: 172/197] Handle the command line



commit 34bec12c5dd2a6c9433ff0107be77b03803babfa
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri May 11 13:34:42 2012 +0200

    Handle the command line

 gedit/gedit-app.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index f539109..9f1967b 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -49,6 +49,7 @@
 #include "gedit-settings.h"
 #include "gedit-app-activatable.h"
 #include "gedit-plugins-engine.h"
+#include "gedit-command-line.h"
 
 #ifdef OS_OSX
 #include "gedit-app-osx.h"
@@ -270,6 +271,33 @@ gedit_app_activate (GApplication *application)
 
 	gedit_debug_message (DEBUG_APP, "Show window");
 	gtk_widget_show (GTK_WIDGET (window));
+
+	g_message ("activate");
+}
+
+static gint
+gedit_app_command_line (GApplication            *application,
+                        GApplicationCommandLine *cmdline)
+{
+	GeditCommandLine *command_line;
+	gchar **argv;
+	gint argc;
+
+	g_message ("command line");
+
+	command_line = gedit_command_line_get_default ();
+
+	argv = g_application_command_line_get_arguments (cmdline, &argc);
+
+	if (!gedit_command_line_parse (command_line, &argc, &argv))
+	{
+		g_strfreev (argv);
+		return 1;
+	}
+
+	g_strfreev (argv);
+
+	return 0;
 }
 
 static gboolean
@@ -572,6 +600,7 @@ gedit_app_class_init (GeditAppClass *klass)
 
 	app_class->startup = gedit_app_startup;
 	app_class->activate = gedit_app_activate;
+	app_class->command_line = gedit_app_command_line;
 	app_class->shutdown = gedit_app_shutdown;
 
 	klass->last_window_destroyed = gedit_app_last_window_destroyed_impl;
@@ -748,7 +777,7 @@ gedit_app_get_default (void)
 
 	return GEDIT_APP (g_object_new (type,
 	                                "application-id", "org.gnome.Gedit",
-	                                // FIXME: should be HANDLES_COMMAND_LINE
+	                                "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
 	                                NULL));
 }
 



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