[Gambas-user] Inhibit shutdown/logout/etc if unsaved files.

Bruce Steers bsteers4 at gmail.com
Thu Feb 23 03:26:17 CET 2023


Seems qt does have an alternative as kate editor does it using qt session
manager
https://doc.qt.io/qt-5/qsessionmanager.html

i do not really understand kate code but i think this could be it's inhibit
routine. (or part of it)
https://invent.kde.org/utilities/kate/-/blob/master/apps/kate/main.cpp#L572

I found gedit worked on gnome2 and gnome3 variants but not on kde
kate on the other hand seems to inhibit on unsaved changes on all the above
so must be using a better method.

Respects
BruceS

On Wed, 22 Feb 2023 at 18:11, Bruce Steers <bsteers4 at gmail.com> wrote:

> Benoit, gedit does inhibit on a gtk level using gtk_application_inhibit()
> could gb.gui implement inhibit?  (if a qt alternative)
>
> https://docs.gtk.org/gtk3/method.Application.inhibit.html
>
> gedit inhibit code..
>
> if (can_close && (priv->inhibition_cookie != 0))
> 	{
> 		gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
> 					   priv->inhibition_cookie);
> 		priv->inhibition_cookie = 0;
> 	}
> 	else if (!can_close && (priv->inhibition_cookie == 0))
> 	{
> 		priv->inhibition_cookie = gtk_application_inhibit (GTK_APPLICATION (g_application_get_default ()),
> 		                                                   GTK_WINDOW (window),
> 		                                                   GTK_APPLICATION_INHIBIT_LOGOUT,
> 		                                                   _("There are unsaved documents"));
>
> Respects
>
> BruceS
>
>
> On Tue, 21 Feb 2023 at 20:08, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>> Please
>> if you have made inhibit work on anything other than gnome2
>> gnome.SassionManager,
>> Or if you want a challenge and try to make it work on your system and
>> have success.
>>
>> Then share the code on this post or the gambas.one forum topic i started,
>> https://forum.gambas.one/viewtopic.php?t=1483
>>
>> Wishing well
>> BruceS
>>
>>
>> On Tue, 21 Feb 2023 at 19:48, Bruce Steers <bsteers4 at gmail.com> wrote:
>>
>>> Well i got part way then hit a roadblock.
>>> See this discussion for more details and a demo-app / screenshot of it
>>> working with gambas IDE.
>>> https://forum.gambas.one/viewtopic.php?t=1483
>>>
>>> The class is currently very simple but limited to only working on gnome2
>>> based os's (mate, cinnamon, gnomoe-fallback)
>>> does not work for gnome3 (gnome shell), kde plasma, others
>>>
>>> But i use MATE and now my system CANNOT close down with an open unsaved
>>> gambas project running so i'm pretty happy about that. :)
>>>
>>> (it's a tiny 17k so i'll attach my demo to this post, i've added the
>>> same class to my gambas and edited the editors Modify and Save methods to
>>> enable/kill the inhibitors
>>> https://gitlab.com/bsteers4/gambas/-/tree/bruces-patched/app/src/gambas3/.src
>>> )
>>>
>>> the roadblock is that org.gnome.SessionManager.Inhibit was the only one
>>> i could get to work properly. and that seems to only work on gnome2 systems.
>>>
>>> I have looked into many other ways.
>>> org.freedesktop.portal.Desktop (doesn't seem to work)
>>> System://org.freedesktop.login1 (just gives me segfault 11)
>>> a few others.
>>>
>>> I've tried various methods. the gnome.SessionManager is absolute
>>> simplicity compared to others.
>>>
>>> Anyone had any success with Inhibit on anything other than
>>> gnome.SessionManager ?
>>>
>>> Respects
>>> BruceS
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230223/84c28466/attachment.htm>


More information about the User mailing list