Skip to content

Save & restore default session independently of projects (fixes #267) #3125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2022

Conversation

kugel-
Copy link
Member

@kugel- kugel- commented Feb 11, 2022

The default session should be stored independently of projects, so that
it can be restored after closing projects; even across restarts of Geany.

To achieve that, internal refactoring is necessary. But more importantly,
the pref "Use project-based session files" must be always enabled,
because only with that enabled the project session files are stored in the
project file.

So the pref is removed. It was already enabled by default, and disabling
has no known sensible use case.

The rest of the refactoring allows "projects" to internally maintain its
open file list without destroying the default session.

@kugel- kugel- force-pushed the project_session branch 2 times, most recently from c484d7c to fa1221b Compare February 12, 2022 23:09
@kugel- kugel- changed the title Remove pref "Use project-based session files", now always enabled Save & restore default session independently of projects (fixes #267) Feb 12, 2022
@kugel-
Copy link
Member Author

kugel- commented Feb 17, 2022

I'll merge this in a few days if nobody objects.

As per geany#267 we agreed that this pref makes little sense. Especially
as we're considering to move the project session files to a completely
separate file (so neither geany.conf nor $project.geany).

Currently, if not checked, the project session files would be stored
in the (new) session.conf file, overwriting the non-project session.
This is what geany#267 is about.
This flag is actually set and cleared recursively:
- libmain.c sets it before calling load_startup_files()
- inside load_startup_files(), configuration_open_files() sets and clears
  the flag
- when libmain.c clears the flag, it's already unset

A counter allows such recursive usage to work as expected.
Currently, when loading "projects" (i.e. named sessions), the file list
overwrites the default session. Therefore, when loading a project, the
previously opened files are lost.

With this the default session is maintained separately. Any time a project
is opened it is written to session.conf and can be restored later on.
@elextr
Copy link
Member

elextr commented Feb 17, 2022

When you say "Use Project based session files is now always enabled" you mean when a project is open right?

I would like to know somebody has tested it before merge.

[Edit: by "somebody else" I mean not @kugel-, not neccessarily somebody other than me, but I can't until late next week at the earliest]

@kugel-
Copy link
Member Author

kugel- commented Feb 17, 2022

When you say "Use Project based session files is now always enabled" you mean when a project is open right?

Yes. When a project is open its session files are stored in the project file instead of session.conf (previously geany.conf). This has been the default for years.

I can wait another week or two, no problem. Just don't want that this rots for a long time without any feedback.

@kugel-
Copy link
Member Author

kugel- commented Mar 3, 2022

@elextr will merge very soon since no objection or further feedback came up the last two weeks.

@elextr
Copy link
Member

elextr commented Mar 3, 2022

Sorry, havn't had a chance to do anything, and won't for a while, things are a bit disrupted here 1.

Like I said, it would be nice if someone had time to test it, but I guess nobody is interested.

Footnotes

  1. link lifetime uncertain

@kugel-
Copy link
Member Author

kugel- commented Mar 4, 2022

I'm deeply sorry for your situation and wish you and the people around you all the best!

@kugel- kugel- merged commit 22aac44 into geany:master Mar 4, 2022
kugel- added a commit to kugel-/geany that referenced this pull request Aug 28, 2022
…ession files

PR geany#3125 (commit 22aac44) broke that accidentally by moving the
"switch to last used tab" to a idle callback (g_idle_add()). This
runs after opening files from the command line.

Now, the same callback is moved to libmain.c and is only registered
when there are no files from the command line.

Additionally, projects gains a private copy of the current_page loaded
from the keyfile.
kugel- added a commit to kugel-/geany that referenced this pull request Aug 28, 2022
…ession files

PR geany#3125 (commit 22aac44) broke that accidentally by moving the
"switch to last used tab" to a idle callback (g_idle_add()). This
runs after opening files from the command line.

Now, the same callback is moved to libmain.c and is only registered
when there are no files from the command line.

Additionally, projects gains a private copy of the current_page loaded
from the keyfile.

Fixes geany#3210
kugel- added a commit to kugel-/geany that referenced this pull request Apr 23, 2023
"switch to last used tab" to a idle callback (g_idle_add()). This
runs after opening files from the command line.

Now, showing the "current" document is generally done via an idle callback.
This is implemented in the new helper "document_show_tab_idle()" that
should be used during batch-opening.

document_show_tab_idle() is smart enough to only allow the last call
to be effective in case it's called multiple times before the idle
callback actually runs. command line files, of course, call this after
session files.

Fixes geany#3210
kugel- added a commit to kugel-/geany that referenced this pull request Apr 23, 2023
"switch to last used tab" to a idle callback (g_idle_add()). This
runs after opening files from the command line.

Now, showing the "current" document is generally done via an idle callback.
This is implemented in the new helper "document_show_tab_idle()" that
should be used during batch-opening.

document_show_tab_idle() is smart enough to only allow the last call
to be effective in case it's called multiple times before the idle
callback actually runs. command line files, of course, call this after
session files.

Fixes geany#3210
kugel- added a commit that referenced this pull request Jul 18, 2023
…ession files (#3267)

commit 22aac44 ("Save & restore default session independently of projects", PR #3125) 
broke that accidentally by moving the "switch to last used tab" to an idle callback. 
This runs after opening files from the command line.

Now, showing the "current" document is generally done via an idle callback.
This is implemented in the new helper "document_show_tab_idle()" that
should be used during batch-opening.

document_show_tab_idle() is smart enough to only allow the last call
to be effective in case it's called multiple times before the idle
callback actually runs. Command line files, of course, call this after
session files.

Fixes #3210
techee pushed a commit to techee/geany that referenced this pull request Oct 4, 2023
…ession files (geany#3267)

commit 22aac44 ("Save & restore default session independently of projects", PR geany#3125) 
broke that accidentally by moving the "switch to last used tab" to an idle callback. 
This runs after opening files from the command line.

Now, showing the "current" document is generally done via an idle callback.
This is implemented in the new helper "document_show_tab_idle()" that
should be used during batch-opening.

document_show_tab_idle() is smart enough to only allow the last call
to be effective in case it's called multiple times before the idle
callback actually runs. Command line files, of course, call this after
session files.

Fixes geany#3210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants