[geany/geany] ad1c08: Load the default session even if opening file(s)

Dimitar Zhekov git-noreply at xxxxx
Thu Jul 26 00:03:25 UTC 2012


Branch:      refs/heads/document-messages
Author:      Dimitar Zhekov <dimitar.zhekov at gmail.com>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Mon, 20 Feb 2012 18:42:56
Commit:      ad1c08ebbe6a7e33bddfea15fafb8f94fea95fb5
             https://github.com/geany/geany/commit/ad1c08ebbe6a7e33bddfea15fafb8f94fea95fb5

Log Message:
-----------
Load the default session even if opening file(s)

A slightly simplified variant of the "rewritten load startup files"
from Geany patch tracker. Does not check for CLI files when deciding
whether to load the default session.


Modified Paths:
--------------
    src/main.c

Modified: src/main.c
60 files changed, 30 insertions(+), 30 deletions(-)
===================================================================
@@ -798,12 +798,10 @@ gboolean main_handle_filename(const gchar *locale_filename)
 
 
 /* open files from command line */
-static gboolean open_cl_files(gint argc, gchar **argv)
+static void open_cl_files(gint argc, gchar **argv)
 {
 	gint i;
 
-	if (argc <= 1) return FALSE;
-
 	for (i = 1; i < argc; i++)
 	{
 		gchar *filename = main_get_argv_filename(argv[i]);
@@ -828,7 +826,6 @@ static gboolean open_cl_files(gint argc, gchar **argv)
 		}
 		g_free(filename);
 	}
-	return TRUE;
 }
 
 
@@ -882,39 +879,42 @@ void main_load_project_from_command_line(const gchar *locale_filename, gboolean
 
 static void load_startup_files(gint argc, gchar **argv)
 {
-	gboolean load_project_from_cl = FALSE;
-
-	/* ATM when opening a project file any other filenames are ignored */
-	load_project_from_cl = (argc > 1) && g_str_has_suffix(argv[1], ".geany");
-	if (load_project_from_cl && argc > 2)
-		g_print("Ignoring extra filenames after %s", argv[1]);
+	gboolean load_session = FALSE;
 
-	if (load_project_from_cl || ! open_cl_files(argc, argv))
+	if (argc > 1 && g_str_has_suffix(argv[1], ".geany"))
 	{
-		if (prefs.load_session)
-		{
-			if (load_project_from_cl)
-			{
-				main_load_project_from_command_line(argv[1], FALSE);
-			}
-			else if (cl_options.load_session && !cl_options.new_instance)
-				load_session_project_file();
+		/* project file specified: load it, but decide the session later */
+		main_load_project_from_command_line(argv[1], FALSE);
+		argc--, argv++;
+		/* force session load if using project-based session files */
+		load_session = project_prefs.project_session;
+	}
 
-			/* when we want a new instance, we still load project session files unless -s
-			 * was passed */
-			if (!cl_options.load_session || (!load_project_from_cl && cl_options.new_instance))
-				return;
+	/* Load the default session if:
+	 * 1. "Load files from the last session" is active.
+	 * 2. --no-session is not specified.
+	 * 3. We are a primary instance.
+	 * Has no effect if a CL project is loaded and using project-based session files. */
+	if (prefs.load_session && cl_options.load_session && !cl_options.new_instance)
+	{
+		if (app->project == NULL)
+			load_session_project_file();
+		load_session = TRUE;
+	}
 
-			/* load session files into tabs, as they are found in the session_files variable */
-			configuration_open_files();
+	if (load_session)
+	{
+		/* load session files into tabs, as they are found in the session_files variable */
+		configuration_open_files();
 
-			if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0)
-			{
-				ui_update_popup_copy_items(NULL);
-				ui_update_popup_reundo_items(NULL);
-			}
+		if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0)
+		{
+			ui_update_popup_copy_items(NULL);
+			ui_update_popup_reundo_items(NULL);
 		}
 	}
+
+	open_cl_files(argc, argv);
 }
 
 


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list