mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 20:30:41 +02:00
Merged revision(s) 62003 #d3daac07ac, 62020 #690b7498e7, 62062 #c164409c0a from trunk:
LCL-GTK2: Improve logic for loading LibAppIndicator3 for TrayIcon. Based on research by D.Bannon. Issue #35723. ........ LCL-GTK2: Add Debian to the list of distros that need the AppIndicator lib. Optimize a little. Issue #35723. ........ LCL-GTK2: Improve the logic for loading LibAppIndicator3 lib. Support an environment variable LAZUSEAPPIND. Issue #35723, patch from David. ........ git-svn-id: branches/fixes_2_0@62083 -
This commit is contained in:
parent
1583512c04
commit
8e223c396b
@ -10,14 +10,21 @@ interface
|
|||||||
uses
|
uses
|
||||||
GLib2, Gtk2, Gdk2Pixbuf,
|
GLib2, Gtk2, Gdk2Pixbuf,
|
||||||
Classes, SysUtils, dynlibs,
|
Classes, SysUtils, dynlibs,
|
||||||
Graphics, Controls, Forms, ExtCtrls, WSExtCtrls, LCLType, LazUTF8;
|
Graphics, Controls, Forms, ExtCtrls, WSExtCtrls, LCLType, LazUTF8,
|
||||||
|
FileUtil;
|
||||||
|
|
||||||
{ Changed priority, now use libappindicator_3 if available. ~_3 is, nominally
|
{ Changed October 2019, we now try and identify those Linux distributions that
|
||||||
a Unity thing but Ubuntu and several other distros ship it (and support it) with
|
need to use LibAppIndicator3 and allow the remainder to use the older and
|
||||||
Gnome desktops.
|
more functional SystemTray. Only a few old distributions can use LibAppIndicator_1
|
||||||
|
so don't bother to try it, rely, here on LibAppIndicator3
|
||||||
|
|
||||||
As of U19.04, libappindicator_1, even if present, does not seem to work.
|
The 'look up table' in NeedAppIndicator() can be overridden.
|
||||||
|
Introduce an optional env var, LAZUSEAPPIND that can be unset or set to
|
||||||
|
YES, NO or INFO - YES forces an attempt to use LibAppIndicator3, NO prevents
|
||||||
|
an attempt, any non blank value (eg INFO) displays to std out what is happening.
|
||||||
|
|
||||||
|
Note we assume this env var will only be used in Linux were its always safe to
|
||||||
|
write to stdout.
|
||||||
DRB
|
DRB
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,9 +260,40 @@ var
|
|||||||
Initialized: Boolean;
|
Initialized: Boolean;
|
||||||
|
|
||||||
function UnityAppIndicatorInit: Boolean;
|
function UnityAppIndicatorInit: Boolean;
|
||||||
var
|
var
|
||||||
Module: HModule;
|
Module: HModule;
|
||||||
DeskTop: String;
|
UseAppInd : string;
|
||||||
|
|
||||||
|
function NeedAppIndicator: boolean;
|
||||||
|
var
|
||||||
|
DeskTop, VersionSt : String;
|
||||||
|
ProcFile: TextFile;
|
||||||
|
begin
|
||||||
|
DeskTop := GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP');
|
||||||
|
// See the wiki for details of what extras these desktops require !!
|
||||||
|
if (DeskTop = 'Unity')
|
||||||
|
or (Desktop = 'Enlightenment')
|
||||||
|
then exit(True);
|
||||||
|
if (DeskTop = 'GNOME') then begin
|
||||||
|
{$PUSH}
|
||||||
|
{$IOChecks off}
|
||||||
|
AssignFile(ProcFile, '/proc/version');
|
||||||
|
reset(ProcFile);
|
||||||
|
if IOResult<>0 then exit(false);
|
||||||
|
{$POP}
|
||||||
|
readln(ProcFile, VersionSt);
|
||||||
|
CloseFile(ProcFile);
|
||||||
|
if ( (pos('mageia', VersionSt) > 0) or
|
||||||
|
(pos('Debian', VersionSt) > 0) or
|
||||||
|
(pos('Red Hat', VersionSt) > 0) or
|
||||||
|
(pos('SUSE', VersionSt) > 0) )
|
||||||
|
// 19.04 and earlier Ubuntu Gnome does not need LibAppIndicator3
|
||||||
|
then exit(True);
|
||||||
|
end;
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TryLoad(const ProcName: string; var Proc: Pointer): Boolean;
|
function TryLoad(const ProcName: string; var Proc: Pointer): Boolean;
|
||||||
begin
|
begin
|
||||||
@ -268,17 +306,29 @@ begin
|
|||||||
if Loaded then
|
if Loaded then
|
||||||
Exit(Initialized);
|
Exit(Initialized);
|
||||||
Loaded := True;
|
Loaded := True;
|
||||||
DeskTop := GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP');
|
|
||||||
if (DeskTop = 'KDE') or (DeskTop = 'X-Cinnamon') then
|
|
||||||
begin
|
|
||||||
Initialized := False;
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
if Initialized then
|
if Initialized then
|
||||||
Exit(True);
|
Exit(True);
|
||||||
Module := LoadLibrary(libappindicator_3); // thats the one we want here.
|
UseAppInd := getEnvironmentVariable('LAZUSEAPPIND');
|
||||||
if Module = 0 then // no libappindicator_3
|
if UseAppInd = 'NO' then
|
||||||
Exit; // hope libappindicator_1 can help you ....
|
begin
|
||||||
|
Initialized := False;
|
||||||
|
writeln('APPIND Debug : Choosing to not try AppIndicator3');
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
if (UseAppInd <> 'YES') and (not NeedAppIndicator()) then // ie its NO or blank or INFO
|
||||||
|
begin
|
||||||
|
Initialized := False;
|
||||||
|
if UseAppInd <> '' then
|
||||||
|
writeln('APPIND Debug : Will not use AppIndicator3');
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
if UseAppInd = 'YES' then // either a YES or OS needs it
|
||||||
|
writeln('APPIND Debug : Will try to force AppIndicator3')
|
||||||
|
else
|
||||||
|
if UseAppInd <> '' then writeln('APPIND Debug : OS and Desktop request AppIndicator3');
|
||||||
|
Module := LoadLibrary(libappindicator_3); // might have several package names, see wiki
|
||||||
|
if Module = 0 then
|
||||||
|
Exit;
|
||||||
Result :=
|
Result :=
|
||||||
TryLoad('app_indicator_get_type', @app_indicator_get_type) and
|
TryLoad('app_indicator_get_type', @app_indicator_get_type) and
|
||||||
TryLoad('app_indicator_new', @app_indicator_new) and
|
TryLoad('app_indicator_new', @app_indicator_new) and
|
||||||
@ -300,6 +350,8 @@ begin
|
|||||||
TryLoad('app_indicator_get_label', @app_indicator_get_label) and
|
TryLoad('app_indicator_get_label', @app_indicator_get_label) and
|
||||||
TryLoad('app_indicator_get_label_guide', @app_indicator_get_label_guide) and
|
TryLoad('app_indicator_get_label_guide', @app_indicator_get_label_guide) and
|
||||||
TryLoad('app_indicator_get_ordering_index', @app_indicator_get_ordering_index);
|
TryLoad('app_indicator_get_ordering_index', @app_indicator_get_ordering_index);
|
||||||
|
if UseAppInd <> '' then
|
||||||
|
writeln('APPIND Debug : AppIndicator3 has loaded ' + booltostr(Result, True));
|
||||||
Initialized := Result;
|
Initialized := Result;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user