orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
640 stars 38 forks source link

Add ability to use only a single instance on TextAdept Qt #361

Closed ghost closed 1 year ago

ghost commented 1 year ago

https://github.com/orbitalquark/textadept/releases/tag/textadept_12.0_alpha

The Qt version of Textadept is not a single-instance application, only the GTK version is.

Why? Is there any technical issues @orbitalquark?

orbitalquark commented 1 year ago

Yes, Qt does not provide a mechanism for this. GTK provides GApplication, which I believe uses dbus for single-instance functionality. I did write a Windows implementation of single-instance using named pipes because Windows doesn't have dbus, but I don't want to do this for the other platforms.

ghost commented 1 year ago

Yes, Qt does not provide a mechanism for this. GTK provides GApplication, which I believe uses dbus for single-instance functionality. I did write a Windows implementation of single-instance using named pipes because Windows doesn't have dbus, but I don't want to do this for the other platforms.

A quick Google searched showed me many examples of single instance applications in Qt. Where did you get the information that it doesn't provide a mechanism for this?

ghost commented 1 year ago

Alongside TextAdept, I also use KDE's Kate editor (Windows version). It's single instance by default.

orbitalquark commented 1 year ago

If you dig into those applications, how are they doing it? What Qt class are they using? I couldn't find one.

ghost commented 1 year ago

If you dig into those applications, how are they doing it? What Qt class are they using? I couldn't find one.

I'm not a programmer. But I find them easily with just a Google search. Maybe QtSingleApplication or https://github.com/itay-grudev/SingleApplication?

orbitalquark commented 1 year ago

Thanks for sharing. I am reluctant to add yet another dependency for such a critical component that ideally would be in Qt itself.

ousia commented 1 year ago

@orbitalquark avoiding dependencies is fine.

I cannot code, but how about https://stackoverflow.com/q/5006547?

At least for the ignorant, it might contain a sensible approach.

ousia commented 1 year ago

Sorry, I forgot: many thanks for your help.

orbitalquark commented 1 year ago

I believe the link posted earlier is the solution. I just have to get around to implementing it.

ousia commented 1 year ago

Many thanks for your reply, @orbitalquark.

Until single instance is implemented, I‘m afraid I have to stick to version 11.4 (to avoid data loss).

Many thanks for your help.

orbitalquark commented 1 year ago

I've implemented single-instance functionality on Qt here: https://github.com/orbitalquark/textadept/commit/703ab3f6e679c0fd0aab2d69627d6e86dcb521b1. It should be in the next nightly build.

ousia commented 1 year ago

Many thanks for the implementation, @orbitalquark.

I wonder whether a new stable release (in a not so distant future) could include this feature.

orbitalquark commented 1 year ago

I think this will require a beta release so a stable 12.2 probably won’t come earlier than 1 Nov.