Hi (sigh),

My first implementation was a bit naive. With "Project based session
files" turned off, specifying a CL project should have absolutely no
effect on the session loading. In particular, not only --no-session,
but any of "Load files from the last session" = off, --new-instance,
or CL file names after the project name should block the session.

Not much of a difference though...

-- 
E-gards: Jimmy
--- ./src/main.c.orig	2011-04-05 19:51:03.000000000 +0300
+++ ./src/main.c	2011-04-13 21:44:11.000000000 +0300
@@ -793,12 +793,10 @@
 
 
 /* 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]);
@@ -823,7 +821,6 @@
 		}
 		g_free(filename);
 	}
-	return TRUE;
 }
 
 
@@ -881,39 +878,43 @@
 
 static void load_startup_files(gint argc, gchar **argv)
 {
-	gboolean load_project_from_cl = FALSE;
+	gboolean load_session = FALSE;
+
+	if (argc > 1 && g_str_has_suffix(argv[1], ".geany"))
+	{
+		/* 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;
+	}
 
-	/* 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]);
+	/* Load the default session if:
+	 * 1. No command line project is specified, or the session files are not project-based.
+	 * 2. No filenames are specified on the command line.
+	 * 3. --no-session is not specified.
+	 * 4. "Load files from the last session" is active.
+	 * 5. We are the primary instance. */
+	if (!load_session && argc <= 1 && cl_options.load_session && prefs.load_session &&
+		!cl_options.new_instance)
+	{
+		load_session_project_file();
+		load_session = TRUE;
+	}
 
-	if (load_project_from_cl || ! open_cl_files(argc, argv))
+	if (load_session)
 	{
-		if (prefs.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)
 		{
-			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();
-
-			/* 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 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);
-			}
+			ui_update_popup_copy_items(NULL);
+			ui_update_popup_reundo_items(NULL);
 		}
 	}
+
+	open_cl_files(argc, argv);
 }
 
 
_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to