On Sat, 18 Feb 2012 14:17:17 +0100 Colomban Wendling <lists....@herbesfolles.org> wrote:
> So I'd say "aye" to Dimitar since he gently volunteered :) Moreover > if it is a preference I don't see any loss; but I'd better see this > preference turned on by default for new configurations if the restore > session one is on. Here's the patch. There is no additional preference - if "Load files from the last session" is checked, they are loaded, and that's it. Though it'll be easy to make it a pref... -- E-gards: Jimmy
>From 23a085bbf5210572bce051649a0e73f4c5d0bbe3 Mon Sep 17 00:00:00 2001 From: Dimitar Zhekov <dimitar.zhe...@gmail.com> Date: Mon, 20 Feb 2012 19:18:21 +0200 Subject: [PATCH] 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. --- src/main.c | 60 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/main.c b/src/main.c index d17cfba..88034e9 100644 --- a/src/main.c +++ b/src/main.c @@ -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); } -- 1.7.9
_______________________________________________ Geany-devel mailing list Geany-devel@uvena.de https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel