mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
CtrlLib: Applying libnotify TrayIcon patch
git-svn-id: svn://ultimatepp.org/upp/trunk@1934 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a0e59ea606
commit
77990bcf29
3 changed files with 36 additions and 1 deletions
|
|
@ -27,6 +27,8 @@ library(OSX11) "X11 Xft fontconfig Xrender freetype expat";
|
|||
|
||||
library(FREEBSD) xcb;
|
||||
|
||||
library(POSIX !NOGTK) notify;
|
||||
|
||||
file
|
||||
SystemDraw readonly separator,
|
||||
DrawWin32.h,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "Draw/init"
|
||||
#include "plugin\bmp/init"
|
||||
#include "RichText/init"
|
||||
#define BLITZ_INDEX__ F3C3E3B6EE02571ABD722B97C1EFD180E
|
||||
#define BLITZ_INDEX__ F169BE3C1DD43CAF9259C7F00146DF6A2
|
||||
#include "CtrlCore.icpp"
|
||||
#undef BLITZ_INDEX__
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@
|
|||
NAMESPACE_UPP
|
||||
|
||||
#ifdef PLATFORM_X11
|
||||
|
||||
#if !defined(flagNOGTK)
|
||||
#include <glib.h>
|
||||
#include <libnotify/notify.h>
|
||||
#endif
|
||||
|
||||
Atom TraySelection()
|
||||
{
|
||||
return XAtom(Format("_NET_SYSTEM_TRAY_S%d", Xscreenno));
|
||||
|
|
@ -69,6 +75,7 @@ void TrayIcon::Message(const char *title, const char *text, int timeout)
|
|||
{
|
||||
if(!traywin)
|
||||
return;
|
||||
#if defined(flagNOGTK)
|
||||
int len = strlen(text);
|
||||
static int stamp;
|
||||
Call(1, 1000 * timeout, len, ++stamp);
|
||||
|
|
@ -88,6 +95,32 @@ void TrayIcon::Message(const char *title, const char *text, int timeout)
|
|||
XSync(Xdisplay, XFalse);
|
||||
}
|
||||
UntrapX11Errors(x11trap);
|
||||
#else
|
||||
Size size = this->icon.GetSize();
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkPixbuf *nicon = NULL;
|
||||
GError* error = NULL;
|
||||
NotifyNotification* notification;
|
||||
ImageDraw iw(size);
|
||||
iw.DrawRect(0, 0, size.cx, size.cy, Color(255, 0, 255)); // fuchsia color used for transparency
|
||||
iw.DrawImage(0, 0, this->icon);
|
||||
pixmap = gdk_pixmap_foreign_new(iw.GetDrawable());
|
||||
if (!pixmap)
|
||||
return;
|
||||
|
||||
nicon = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, icon.GetSize().cx, icon.GetSize().cy);
|
||||
nicon = gdk_pixbuf_add_alpha(nicon, TRUE, 255, 0, 255);
|
||||
if (!notify_init (GetAppName().Begin()))
|
||||
return;
|
||||
|
||||
notification = notify_notification_new (title, text, NULL , NULL);
|
||||
if (nicon)
|
||||
notify_notification_set_icon_from_pixbuf (notification, nicon);
|
||||
notify_notification_show (notification, &error);
|
||||
notify_uninit ();
|
||||
g_object_unref(pixmap);
|
||||
g_object_unref(nicon);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TrayIcon::HookProc(XEvent *event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue