[gedit/wip/gtkapp: 9/19] Handle the window creation and loading of files



commit 42f237845fac55184ec9cf3ad5e89fe8fab4aa4e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Jul 30 16:42:53 2012 +0200

    Handle the window creation and loading of files

 gedit/gedit-app.c |   50 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 7e75b38..60af879 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -322,10 +322,6 @@ command_line_handler (gpointer data)
 	gboolean wait = FALSE;
 	gboolean background = FALSE;
 	gchar **remaining_args = NULL;
-	GSList *file_list = NULL;
-	gint line_position = 0;
-	gint column_position = 0;
-	const GeditEncoding *encoding;
 	gint i;
 
 	const GOptionEntry options[] =
@@ -453,6 +449,14 @@ command_line_handler (gpointer data)
 	}
 	else
 	{
+		GSList *file_list = NULL;
+		gint line_position = 0;
+		gint column_position = 0;
+		const GeditEncoding *encoding = NULL;
+		GeditApp *app;
+		GeditWindow *window;
+		gboolean doc_created = FALSE;
+
 		if (remaining_args)
 		{
 			for (i = 0; remaining_args[i]; i++)
@@ -498,13 +502,49 @@ command_line_handler (gpointer data)
 
 			g_free (encoding_charset);
 		}
+
+		app = GEDIT_APP (g_object_get_data (G_OBJECT (command_line), "application"));
+
+		gedit_debug_message (DEBUG_APP, "Create main window");
+		window = gedit_app_create_window (app, NULL);
+
+		gedit_debug_message (DEBUG_APP, "Show window");
+		gtk_widget_show (GTK_WIDGET (window));
+
+		if (geometry)
+		{
+			gtk_window_parse_geometry (GTK_WINDOW (window),
+			                           geometry);
+		}
+
+		if (file_list != NULL)
+		{
+			GSList *loaded;
+
+			gedit_debug_message (DEBUG_APP, "Load files");
+			loaded = _gedit_cmd_load_files_from_prompt (window,
+				                                    file_list,
+				                                    encoding,
+				                                    line_position,
+				                                    column_position);
+
+			doc_created = loaded != NULL;
+			g_slist_free (loaded);
+		}
+
+		if (!doc_created || new_document)
+		{
+			gedit_debug_message (DEBUG_APP, "Create tab");
+			gedit_window_create_tab (window, TRUE);
+		}
+
+		g_slist_free_full (file_list, g_object_unref);
 	}
 
 	g_option_context_free (context);
 	g_free (encoding_charset);
 	g_strfreev (remaining_args);
 	g_free (geometry);
-	g_slist_free_full (file_list, g_object_unref);
 
 	/* we are done handling this commandline */
 	g_object_unref (command_line);



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