This adds an option to hide the warning that is displayed when opening a project while one is already open. The default setting is to show the warning (current behavior).
Since projects autosave when closed, no work is lost and the project can just be reopened if needed. Depending on how the user manages project files, reopening the previous project can take less time than responding to the dialog. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/2949
-- Commit Summary --
* <a href="https://github.com/geany/geany/pull/2949/commits/cc2bb6b94de5e17e03d4cc10bf45d9e47725a122">Add option to hide project close/save warning when opening new project</a>
-- File Changes --
A po/.intltool-merge-cache.lock (0) M src/project.c (3) M src/ui_utils.c (2) M src/ui_utils.h (2)
-- Patch Links --
https://github.com/geany/geany/pull/2949.patch https://github.com/geany/geany/pull/2949.diff
@xiota pushed 1 commit.
edba29cd7bc5e27bb2e3eecf9320f5b483f7ded9 Don't open project when it is already open
@elextr commented on this pull request.
@@ -631,8 +631,13 @@ static void handle_input_filename(const gchar *buf)
{ if (g_str_has_suffix(locale_filename, ".geany")) { - if (project_ask_close()) - main_load_project_from_command_line(locale_filename, TRUE); + /* Don't open project when it is already opened */ + if (app->project != NULL && + g_strcmp0(app->project->file_name, locale_filename) != 0)
I think `app->project->file_name` is a UTF-8 filename, not a locale filename, so they might not compare in non-UTF-8 locales
@elextr commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /**< whether to show a warning when closing and saving a project to open a new one */
this documents the _preceeding_ member
@xiota commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /**< whether to show a warning when closing and saving a project to open a new one */
I'm following the pattern established by 3 other options in this section when the description is too long to fit on the same line. Would you like them all changed?
@elextr commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /**< whether to show a warning when closing and saving a project to open a new one */
You didn't look carefully enough :grin:, those lines have no `<` after the `/**` so they apply to the following member instead.
@elextr commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /**< whether to show a warning when closing and saving a project to open a new one */
See also https://www.doxygen.nl/manual/docblocks.html
@xiota pushed 1 commit.
53704f19283f4b1afa97c631cc6268b68f9d6d64 convert locale of project filename before comparison
@xiota commented on this pull request.
@@ -631,8 +631,13 @@ static void handle_input_filename(const gchar *buf)
{ if (g_str_has_suffix(locale_filename, ".geany")) { - if (project_ask_close()) - main_load_project_from_command_line(locale_filename, TRUE); + /* Don't open project when it is already opened */ + if (app->project != NULL && + g_strcmp0(app->project->file_name, locale_filename) != 0)
Thanks. Changed to convert the project filename before comparison.
@xiota pushed 1 commit.
744dc2053471f0cb2a74a2ccf3842a78b00e5176 Correct documentation comment
@xiota commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /**< whether to show a warning when closing and saving a project to open a new one */
Thanks for explaining. I've changed it.
@xiota pushed 1 commit.
8706b29cb7daa5a6bc59153f235150c091ae0824 Initialize some char pointers to NULL
@xiota pushed 1 commit.
0a25afc920cae77f254676fdf717663a402a9bdc fix project filename matching
@xiota pushed 1 commit.
55fa60e16ed13a5ae5aab4759c824f1206a9fd50 remove unnecessary variables
@elextr Think this PR is ready for re-review. Also, if you don't mind, would you look at #2947 (addition to manual to show use of GEANY_DEFAULT_FILETYPE_REGEX feature).
@elextr commented on this pull request.
@@ -631,8 +631,13 @@ static void handle_input_filename(const gchar *buf)
{ if (g_str_has_suffix(locale_filename, ".geany")) { - if (project_ask_close()) - main_load_project_from_command_line(locale_filename, TRUE); + /* Don't open project when it is already opened */
Why is this necessary as part of this PR? It looks unrelated to message or not.
@xiota commented on this pull request.
@@ -631,8 +631,13 @@ static void handle_input_filename(const gchar *buf)
{ if (g_str_has_suffix(locale_filename, ".geany")) { - if (project_ask_close()) - main_load_project_from_command_line(locale_filename, TRUE); + /* Don't open project when it is already opened */
It's not necessary in terms of adding the option to hide the warning, but it's related in terms of behavior when opening projects. (If the project is already open, a warning will be shown to close the project, even though it is the same project.) It can go in a different pull request if you want.
@elextr commented on this pull request.
@@ -631,8 +631,13 @@ static void handle_input_filename(const gchar *buf)
{ if (g_str_has_suffix(locale_filename, ".geany")) { - if (project_ask_close()) - main_load_project_from_command_line(locale_filename, TRUE); + /* Don't open project when it is already opened */
Yes, in general its best to keep unrelated things separate.
@xiota commented on this pull request.
@@ -631,8 +631,13 @@ static void handle_input_filename(const gchar *buf)
{ if (g_str_has_suffix(locale_filename, ".geany")) { - if (project_ask_close()) - main_load_project_from_command_line(locale_filename, TRUE); + /* Don't open project when it is already opened */
Okay. Will move it to it's own PR.
@xiota pushed 1 commit.
ea661bd1fc3108b762ef0bfea001bbcc24d30961 revert don't reopen projects that are already open
@elextr commented on this pull request.
Please remove the `po/.intltool-merge-cache.lock` otherwise I'm ok. Good that its documented in the manual and in the plugin API.
But lets see if anyone else loves or loathes it.
Added to 1.39 milestone so its not forgotten
Sorry about that lock file... is it okay if I add it to `.gitignore`?
@xiota pushed 1 commit.
0901f008ae6f8013491a66013780a705b6c683c1 remove lock file
Sorry about that lock file... is it okay if I add it to .gitignore?
Shouldn't need to https://github.com/geany/geany/commit/2977a91f6425d7062dc2d9130720ff5cdeff7d...
@eht16 commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /** whether to show a warning when closing a project to open a new one */ + gboolean warn_on_close_project;
Shouldn't we bump `GEANY_API_VERSION` when adding items here?
Tested and LGTM apart from the minor issue regarding bumping `GEANY_API_VERSION`.
Maybe the PR description could be updated to not mention "Don't re-open a project that is already open" which isn't part of this PR anymore?
@elextr commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /** whether to show a warning when closing a project to open a new one */ + gboolean warn_on_close_project;
Good catch, and since its at the end no need to do ABI.
@xiota commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /** whether to show a warning when closing a project to open a new one */ + gboolean warn_on_close_project;
@eht16 Where do I go to bump the `GEANY_API_VERSION`?
@eht16 I've edited the initial description. I don't know how to bump the `GEANY_API_VERSION`.
@eht16 commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /** whether to show a warning when closing a project to open a new one */ + gboolean warn_on_close_project;
Here: https://github.com/geany/geany/blob/master/src/plugindata.h#L61 Just increment it by 1.
@xiota pushed 1 commit.
50fbc7bde0cc53db1629c0942390a026949b48b6 define GEANY_API_VERSION 241
@xiota commented on this pull request.
@@ -69,6 +69,8 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ gint symbols_sort_mode; /**< symbol list sorting mode */ + /** whether to show a warning when closing a project to open a new one */ + gboolean warn_on_close_project;
Thanks. Done.
@elextr @eht16 Is `warn_on_close_project` okay? Or should it be `warn_on_project_close`?
I think I would prefer `warn_on_close_project` but don't mind much.
@eht16 The original name I chose was pretty ridiculous: `warn_close_save_project`.
I just saw... #2863 ... warning dialog when the project file is read-only... Does adding an option to hide that warning get it's own PR, or can it be added to this one?
@xiota Either name for the preference is fine by me.
Personally I am not in favour of #2863, its a strange use-case works as intended, even if erring on the safe if annoying side, so no it shouldn't be added here.
@xiota pushed 1 commit.
15bb0bfacc31bfd3b13630df512be5e6eda44587 rename option to warn_on_project_close
I decided to rename the option to `warn_on_project_close` because it would work better if more options are added in the future: `warn_on_project_*`, `warn_on_document_*`, etc.
For me this is fine to merge (whith squashed commits).
Force push to rebase and merge commits.
Merged #2949 into master.
🎉 🎊 🎉 🎊 🎉 🎊
github-comments@lists.geany.org