Skip to content
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

System tray icon #868

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

wl2776
Copy link
Contributor

@wl2776 wl2776 commented Jan 4, 2025

Implements #805

General description

When this feature is enabled, first launched instance of SourceGit doesn't quit when window closing button is pressed. Instead it hides in system tray and stays running.

This feature can be enabled or disabled either from "Preferences" dialog (menu -> Preferences -> Appearance) or by manually editing preference.json file.

Implementation details

Window hiding

Sourcegit intercepts OnClosing event, cancels it and calls Hide instead (link to code)

Preventing from creation of several system tray icons

When another instance of the SourceHGit is launched from the command line or from the system launcher, it will create another identical icon in the system tray, if no additional checking is performed.

To prevent this, every SourceGit instance tries to create a lock file in the system temporary directory (link to code). If this operation fails, it means that another SourceGit is running and the system tray icon is already created. In this case, no system tray icons are created, and OnClosing event causes exit.

On MacOS no lock file is created, thus relying on the OS guarantees to launch only one instance of a packaged application.

Why?

Because opening application that is already running is still much faster than launch a new instance.

Note

Tested on Windows and Linux only.
MacOS is NOT tested.

@wl2776
Copy link
Contributor Author

wl2776 commented Jan 4, 2025

Probably, there could be some minor issues in preferences dialog on Windows.
I would be grateful if someone could fix them.

Fixed

@wl2776 wl2776 marked this pull request as draft January 5, 2025 08:54
@wl2776
Copy link
Contributor Author

wl2776 commented Jan 5, 2025

Could anyone check how it works on MacOS? @love-linger?

My goal is to make it staying in dock and keep running when window closing button is clicked.

Unfortunately, I cannot check it myself.

@wl2776 wl2776 force-pushed the feature/system-tray-icon branch 7 times, most recently from 4bcf01c to 329650e Compare January 9, 2025 08:11
wl2776 added 4 commits January 9, 2025 17:05
Add code for creation of system tray icon, menu and handle menu events
only first launched instance creates system tray icon and does not quit
@wl2776 wl2776 force-pushed the feature/system-tray-icon branch from 329650e to a3d1f78 Compare January 9, 2025 14:05
@wl2776 wl2776 marked this pull request as ready for review January 9, 2025 14:18
@wl2776
Copy link
Contributor Author

wl2776 commented Jan 9, 2025

Please, check this PR on MacOS

@love-linger
Copy link
Collaborator

I'm sorry. As I said in Discussions #805, there's no plan to add this feature into SourceGit

@wl2776
Copy link
Contributor Author

wl2776 commented Jan 10, 2025

Ok. I understand that you don't want to invest your time in this feature.
I did it. Why not to use?

If you are worried that you will have to support this feature, then, please, don't. I'm not going to disappear.

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

Successfully merging this pull request may close these issues.

2 participants