Hi, Following the idea in "Proposed patch to fix issues with command line file loading", here is a rewritten load_startup_files(), which:
1. Always loads the CL project. Currently it's ignored if "Load files from the last session" is unchecked, which is certainly a bug. (Well, almost always: if a primary instance is running and -i is not specified, the CL project should be open in the primary instance, but on my system that doesn't happen. Doesn't look like a problem with load_starup_files(), so ignoring it for now.) 2. Always loads the CL files. Presently, any files specified after the project file are ignored; I could not find a reason for this, other than the layout of the current load_startup_files(), and it's marked with ATM, aka "at the moment". Well, the moment came. 3. Ignores --no-session if specified together with a CL project and "Project based session files" is checked (it normally is). In this situation, the old implementation opens the project with an empty file list, which is then saved in the project - I believe nobody would want that. Attempting to "properly" (whatever that may be) apply -s to projects creates various problems. 4. Is cleaner, a bit shorter (except for the comments), and can be easily customized for things like XSM, preference to load the default session even if CL files are specified etc. I'd like this thread to be for fixing the current startup behaviour only. If you want any new functionality, please open a new thread, or continue "Proposed patch to fix issues [...]". Thanks in advance. -- E-gards: Jimmy
--- ./src/main.c.orig 2011-04-05 19:51:03.000000000 +0300 +++ ./src/main.c 2011-04-12 19:33:45.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,40 @@ static void load_startup_files(gint argc, gchar **argv) { - gboolean load_project_from_cl = FALSE; + gboolean load_session = 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]); + 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++; + /* ignore --no-session if respecting it will clear the project file list */ + load_session = project_prefs.project_session || cl_options.load_session; + } + /* Load the default session if: + * 1. No filenames are specified on the command line. + * 2. --no-session is not specified as well. + * 3. "Load files from the last session" is checked. + * 4. We are the primary instance. */ + else if (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