mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 13:20:21 +02:00
* Implemented TGtk2WSCustomTrayIcon.ShowBalloonHint
git-svn-id: trunk@17771 -
This commit is contained in:
parent
a8e24520cd
commit
ee3221683b
@ -43,7 +43,7 @@ var
|
||||
fTrayParent: TWindow;
|
||||
{$endif}
|
||||
|
||||
GtkForm: PGtkWidget;
|
||||
GtkForm: PGtkWidget = nil;
|
||||
Tips: PGtkTooltips;
|
||||
|
||||
{$ifdef HasX}
|
||||
@ -436,3 +436,69 @@ begin
|
||||
gdk_window_get_origin(WindowHandle, @Result.X, @Result.Y);
|
||||
end;
|
||||
|
||||
|
||||
function TrayMessageTimeOut(data:gpointer):gboolean;cdecl;
|
||||
var
|
||||
MsgNum: Integer absolute data;
|
||||
begin
|
||||
SendMessage(fWindow, SYSTEM_TRAY_CANCEL_MESSAGE, MsgNum, 0,0);
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
var
|
||||
TrayMsgNumber: Integer;// random data is ok for this value
|
||||
|
||||
{*******************************************************************
|
||||
* TGtk2WSCustomTrayIcon.ShowBalloonHint ()
|
||||
*
|
||||
* DESCRIPTION: Shows a hint next to out icon in the tray
|
||||
*
|
||||
* PARAMETERS: None
|
||||
*
|
||||
* RETURNS: Nothing
|
||||
*
|
||||
*******************************************************************}
|
||||
class function TGtk2WSCustomTrayIcon.ShowBalloonHint (
|
||||
const ATrayIcon: TCustomTrayIcon ) : Boolean;
|
||||
var
|
||||
Ev: TXEvent;
|
||||
WholeString: String;
|
||||
StrChunk: String;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if GtkForm = nil then
|
||||
exit;
|
||||
|
||||
// Title
|
||||
WholeString := ATrayIcon.BalloonTitle;
|
||||
if WholeString <> '' then
|
||||
WholeString := '<b>'+WholeString+'</b>'+LineEnding;
|
||||
|
||||
// Text
|
||||
WholeString := WholeString + ATrayIcon.BalloonHint;
|
||||
|
||||
SendMessage(fWindow, SYSTEM_TRAY_BEGIN_MESSAGE, ATrayIcon.BalloonTimeout, Length(WholeString), TrayMsgNumber);
|
||||
|
||||
|
||||
FillChar(Ev, SizeOf(TXEvent), $0);
|
||||
ev.xclient._type := ClientMessage;
|
||||
ev.xclient.window := fWindow;
|
||||
ev.xclient.message_type := XInternAtom (fDisplay, '_NET_SYSTEM_TRAY_MESSAGE_DATA', False );
|
||||
ev.xclient.format := 8;
|
||||
|
||||
repeat
|
||||
StrChunk := Copy(WholeString,1,20);
|
||||
Delete(WholeString,1,Length(StrChunk));
|
||||
Move(StrChunk[1], ev.xclient.data.b[0], Length(StrChunk));
|
||||
XSendEvent(fDisplay, fTrayParent, False, NoEventMask, @ev);
|
||||
until Length(WholeString) = 0;
|
||||
|
||||
// in case the systray chooses not to hide the message
|
||||
if ATrayIcon.BalloonTimeout > 0 then
|
||||
g_timeout_add(ATrayIcon.BalloonTimeout*2, @TrayMessageTimeOut, Pointer(PtrUInt(TrayMsgNumber)));
|
||||
|
||||
Inc(TrayMsgNumber);
|
||||
|
||||
end;
|
||||
|
||||
|
@ -177,6 +177,7 @@ type
|
||||
class function Show(const ATrayIcon: TCustomTrayIcon): Boolean; override;
|
||||
class procedure InternalUpdate(const ATrayIcon: TCustomTrayIcon); override;
|
||||
class function GetPosition(const ATrayIcon: TCustomTrayIcon): TPoint; override;
|
||||
class function ShowBalloonHint(const ATrayIcon: TCustomTrayIcon): Boolean; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
Loading…
Reference in New Issue
Block a user