From 65ffbd6f047393f5c91afcd9db2bb93f15615a95 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 5 Oct 2020 02:21:47 +0000 Subject: Now builds on Mac, still trying to get working; also numerous updates to documentation and script implementation --- doc/sysnotify.n | 41 ++++++-------- doc/systray.n | 53 +++++++----------- library/systray.tcl | 142 ++++++++++++++++++++++++----------------------- library/tk.tcl | 1 + macosx/TkMacOSXSysTray.c | 98 +++++++++++++++++--------------- 5 files changed, 163 insertions(+), 172 deletions(-) diff --git a/doc/sysnotify.n b/doc/sysnotify.n index dbffe07..21bb70e 100644 --- a/doc/sysnotify.n +++ b/doc/sysnotify.n @@ -1,34 +1,25 @@ .\" Text automatically generated by txt2man -.TH untitled "03 October 2020" "" "" -.RS -sysnotify n "" Tk "Tk Built-In Commands" +'\" +'\" Copyright (c) 2020 Kevin Walzer/WordTech Communications LLC. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +.TH sysnotify n "" Tk "Tk Built-In Commands" +.so man.macros .SH NAME -\fBsysnotify \fP- Creates a notification window with a title and message. -\fB +sysnotify \- Creates a notification window with a title and message. .SH SYNOPSIS -.nf -.fam C - -\fBsysnotify\fP \fInotify\fP \fItitle?\fP? \fImessage?\fP? - - -.fam T -.fi -.fam T -.fi +\fBsysnotify\fP \fInotify\fP \fItitle\fP? \fImessage\fR? +.BE .SH DESCRIPTION - +.PP The \fBsysnotify\fP command creates a platform-specific system notification alert. Its intent is to provide a brief, unobtrusive notification to the user by popping up a window that briefly appears in a corner of the screen. .SH EXAMPLE - -Here is an example of the \fBsysnotify\fP code: .PP -.nf -.fam C +Here is an example of the \fBsysnotify\fP code: +.CS sysnotify notify "Alert" "This is just a test of the Tk System Notification Code." - -.fam T -.fi +.CE .SH KEYWORDS - -\fInotify\fP, alert +notify, alert \ No newline at end of file diff --git a/doc/systray.n b/doc/systray.n index c47883b..94e197b 100644 --- a/doc/systray.n +++ b/doc/systray.n @@ -1,47 +1,36 @@ .\" Text automatically generated by txt2man -.TH untitled "03 October 2020" "" "" -.RS -systray n "" Tk "Tk Built-In Commands" +'\" +'\" Copyright (c) 2020 Kevin Walzer/WordTech Communications LLC. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +.TH systray n "" Tk "Tk Built-In Commands" +.so man.macros .SH NAME -\fBsystray \fP- Creates an icon display in the platform-specific system tray. -\fB +systray \- Creates an icon display in the platform-specific system tray. .SH SYNOPSIS -.nf -.fam C - -\fBsystray\fP \fIcreate\fP \fIimage?\fP? \fItext?\fP? \fIcallback?\fP? -\fBsystray\fP \fImodify\fP \fIoption?\fP? -\fBsystray\fP \fIdestroy\fP - -.fam T -.fi -.fam T -.fi +\fBsystray\fP \fIcreate\fP \fIimage\fP? \fItext\fP? \fIcallback\fR? +\fBsystray\fP \fImodify\fP \fIoption\fR? +\fBsystray\fP \fIdestroy\fR +.BE .SH DESCRIPTION - +.PP The \fBsystray\fP command creates an icon in the platform-specific tray. The widget is configured with a Tk \fIimage?\fP for the icon display, a string for display in a tooltip, and a \fIcallback?\fP is bound to . .SH EXAMPLE - -Here is an example of the \fBsystray\fP code: .PP -.nf -.fam C +Here is an example of the \fBsystray\fP code: +.CS image create photo book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw== systray create -image book -text "Systray sample" -callback {puts "Here is the systray output"} - -.fam T -.fi -Here is an example of modifying the \fBsystray\fP icon: +.CE .PP -.nf -.fam C +Here is an example of modifying the \fBsystray\fP icon: +.CS image create book_page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7 systray modify -image book_page systray modify -text "Updated sample" systray modify -callback {puts "Different output from the systray"} - -.fam T -.fi +.CE .SH KEYWORDS - -\fIimage?\fP, \fIcallback?\fP +image, callback diff --git a/library/systray.tcl b/library/systray.tcl index aa3202c..cab0b57 100644 --- a/library/systray.tcl +++ b/library/systray.tcl @@ -47,7 +47,7 @@ proc _win_callback {msg icn script} { # Pure-Tcl system notification window for use if native implementation not available. -image create photo _info -data {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} +image create photo _info -data {R0lGODlhIAAgAIQWAEWCtEaCtEeCtEWDtUuFtU6FtlGGtlSIt1KJuHCXvnKYv36ewoGhw52zzp+1z7DB1rHB1rzK3MDN3eTp8Ojs8v7+/////////////////////////////////////////yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAB8ALAAAAAAgACAAAAWO4CeOZGmeaKqubOuOQSzHrznfd/3hvPz2AUGv1YtULJKhqqewOC0J5Qm4eFoYQBQwMHFSANkpsOBoGLbirdpX2hIgjwdEbQMirAN0247Xk7Z3T3lhf3yCfjCGToNSiT2Bi4iOOJAWjDhaj32NhTyVlzmZlJuYS6OHpSs8B6wHPD9rbLBrOp2htbi5ursmIQA7} proc _notifywindow {msg} { catch {destroy ._notify} @@ -63,7 +63,6 @@ proc _notifywindow {msg} { } label $w.l -bg gray30 -fg white -image _info pack $w.l -fill both -expand yes -side left - } message $w.message -aspect 150 -bg gray30 -fg white -aspect 150 -text $msg -width 280 pack $w.message -side right -fill both -expand yes if {[tk windowingsystem] eq "x11"} { @@ -110,7 +109,7 @@ proc _fade_in {w} { global ico set ico "" -# ::tk::systray -- +# systray -- # This procedure creates an icon display in the platform-specific system tray. # # Subcommands: @@ -128,9 +127,9 @@ set ico "" # destroy - destroy systray icon. # Arguments: # none. -proc ::tk::systray {args} { +proc systray {args} { - global ico + global ico #Create dict for system tray icon properties. set icondata [dict create] @@ -148,90 +147,92 @@ proc ::tk::systray {args} { switch -- [tk windowingsystem] { "win32" { - set ico [_systray createfrom $img] - _systray taskbar add $ico -text $txt -callback [list _win_callback %m %i $cb] - } + set ico [_systray createfrom $img] + _systray taskbar add $ico -text $txt -callback [list _win_callback %m %i $cb] + } "x11" { - _systray ._tray -image $img -visible true - _balloon ._tray $text - bind [._tray bbox] [list $cb] - } + _systray ._tray -image $img -visible true + _balloon ._tray $text + bind [._tray bbox] [list $cb] + } "aqua" { - _systray create $img $txt $cb - } + _systray create $img $txt $cb + } } #Modify the system tray icon properties. Call into Windows and X11 C commands. if {[lindex $args 0] eq "modify"} { switch -- [tk windowingsystem] { "win32" { if [lindex $args 1] eq "image" { - set img [lindex $args 2] - _systray taskbar delete $ico - set ico [_systray createfrom $img] - dict set icondata image $img - _systray taskbar add $ico -text [dict get $icondata text] -callback [list \ - _win_callback %m %i [dict get $icondata callback]] + set img [lindex $args 2] + _systray taskbar delete $ico + set ico [_systray createfrom $img] + dict set icondata image $img + _systray taskbar add $ico -text [dict get $icondata text] -callback [list \ + _win_callback %m %i [dict get $icondata callback]] } if {[lindex $args 1] eq "text"} { - set txt [lindex $args 2] - dict set icondata text $txt - _systray taskbar modify $ico -text $txt + set txt [lindex $args 2] + dict set icondata text $txt + _systray taskbar modify $ico -text $txt } if {[lindex $args 1 ] eq "callback"} { - set cb [lindex $args 2] - dict set icondata callback $cb - _systray taskbar modify $ico -callback [list \ - _win_callback %m %i [dict get $icondata callback]] + set cb [lindex $args 2] + dict set icondata callback $cb + _systray taskbar modify $ico -callback [list \ + _win_callback %m %i [dict get $icondata callback]] } } "x11" { if [lindex $args 1] eq "image" { - set img [lindex $args 2] - dict set icondata image $img - ._tray configure -image $img + set img [lindex $args 2] + dict set icondata image $img + ._tray configure -image $img } if {[lindex $args 1] eq "text"} { - set txt [lindex $args 2] - dict set icondata text $txt - _balloon ._tray $text + set txt [lindex $args 2] + dict set icondata text $txt + _balloon ._tray $text } if {[lindex $args 1 ] eq "callback"} { - set cb [lindex $args 2] - dict set icondata callback $cb - bind [._tray bbox] [list $cb] + set cb [lindex $args 2] + dict set icondata callback $cb + bind [._tray bbox] [list $cb] } } - "aqua" { - if [lindex $args 1] eq "image" { - set img [lindex $args 2] - dict set icondata image $img - _systray modify image $img + "aqua" { + if [lindex $args 1] eq "image" { + set img [lindex $args 2] + dict set icondata image $img + _systray modify image $img } if {[lindex $args 1] eq "text"} { - set txt [lindex $args 2] - dict set icondata text $txt - _systray modify text $txt + set txt [lindex $args 2] + dict set icondata text $txt + _systray modify text $txt } if {[lindex $args 1 ] eq "callback"} { - set cb [lindex $args 2] - dict set icondata callback $cb - _systray modify callback $cb + set cb [lindex $args 2] + dict set icondata callback $cb + _systray modify callback $cb } - } - } - if {[lindex $args 0] eq "destroy"} { + } + } + if {[lindex $args 0] eq "destroy"} { switch -- [tk windowingsystem] { "win32" { - _systray taskbar delete $ico + _systray taskbar delete $ico } "x11" { - destroy ._tray + destroy ._tray + } + "aqua" { + _systray destroy } - "aqua" { - _systray destroy - } + } } } + } } # ::tk::sysnotify -- @@ -241,24 +242,25 @@ proc ::tk::systray {args} { # title - main text of alert. # message - body text of alert. -proc ::tk::systray {title message} { +proc sysnotify {title message} { -global ico + global ico -switch -- [tk windowingsystem] { - "win32" { - _sysnotify notify $ico $title $message - } - "x11" { - if {![info exists _sysnotify]} { - _notifywindow "$title\n\n$message" - } else { - _sysnotify $title $message - } + switch -- [tk windowingsystem] { + "win32" { + _sysnotify notify $ico $title $message + } + "x11" { + if {![info exists _sysnotify]} { + _notifywindow "$title\n\n$message" + } else { + _sysnotify $title $message + } + } + "aqua" { + _sysnotify $title $message + } } - "aqua" { - _sysnotify $title $message - } } diff --git a/library/tk.tcl b/library/tk.tcl index 85421ef..07ca5be 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -508,6 +508,7 @@ if {$::tk_library ne ""} { SourceLibFile scale SourceLibFile scrlbar SourceLibFile spinbox + SourceLibFile systray SourceLibFile text } } diff --git a/macosx/TkMacOSXSysTray.c b/macosx/TkMacOSXSysTray.c index f5ca6c9..a75997b 100644 --- a/macosx/TkMacOSXSysTray.c +++ b/macosx/TkMacOSXSysTray.c @@ -30,19 +30,18 @@ char * callbackproc; NSStatusBar * statusBar; NSImage * icon; NSString * tooltip; +} +-(id) init; +- (void) setImagewithImage : (NSImage * ) image; +- (void) setTextwithString : (NSString * ) string; +- (void) clickOnStatusItem: (id) sender; +- (void) dealloc; -- (id) init; -- (void) setImage: withImage: (NSImage * ) image; -- (void) setText: withString: (NSString * ) string; -- (void) clickOnStatusItem: (id) sender; -- (void) dealloc; - -} @end -@implementation TkStatusItem +@implementation TkStatusItem : NSObject - (id) init { [super init]; @@ -53,17 +52,17 @@ char * callbackproc; return self; } -- (void) setImage: withImage: (NSImage * ) image +- (void) setImagewithImage : (NSImage * ) image { icon = image; icon.template = YES; statusItem.button.image = icon; } -- (void) setText: withString: (NSString * ) string +- (void) setTextwithString : (NSString * ) string { tooltip = string; - statusItem.button.tooltip = tooltip; + statusItem.button.toolTip = tooltip; } - (void) clickOnStatusItem: (id) sender @@ -95,18 +94,19 @@ char * callbackproc; NSUserNotification *tk_notification; NSString *header; - NSString *info + NSString *info; +} - (id) init; -- (void) postNotification: withTitle: (NSString *) title andDetail: (NSString *) detail; +- (void) postNotificationWithTitle : (NSString *) title message: (NSString *) detail; - (BOOL) userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification; - (void) dealloc; -} + @end -@implementation: TkNotifyItem +@implementation TkNotifyItem : NSObject - (id) init { @@ -115,7 +115,7 @@ char * callbackproc; return self; } -- (void) postNotification: withTitle: (NSString * ) title andDetail: (NSString * ) detail +- (void) postNotificationWithTitle : (NSString * ) title message: (NSString * ) detail { header = title; tk_notification.title = header; @@ -140,6 +140,10 @@ char * callbackproc; @end +TkStatusItem *tk_item; +TkNotifyItem *notify_item; + + /* * Forward declarations for procedures defined in this file. @@ -183,12 +187,12 @@ MacSystrayCmd(ClientData clientData, Tcl_Interp * interp, int argc, const char * argv[]) { - if ((strcmp argv[1], "modify") == 0) { + if (strcmp (argv[1], "modify") == 0) { MacSystrayModifyCmd(clientData, interp, argc, argv); return TCL_OK; } - if ((strcmp argv[1], "destroy") == 0) { + if (strcmp (argv[1], "destroy") == 0) { MacSystrayDestroy(clientData); return TCL_OK; } @@ -198,17 +202,20 @@ MacSystrayCmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } + NSLog(@"creating the icon"); + /* * Create the icon. */ + int width, height; Tk_Window tkwin = Tk_MainWindow(interp); - TkWindow winPtr = (TkWindow) tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; Display * d; d = winPtr -> display; NSImage * icon; - char * tk_imagename = Tcl_GetString(argv[2]); + char * tk_imagename = (char*) argv[2]; Tk_Image tk_image; tk_image = Tk_GetImage(interp, tkwin, tk_imagename, NULL, NULL); if (tk_image == NULL) { @@ -218,28 +225,28 @@ MacSystrayCmd(ClientData clientData, Tcl_Interp * interp, Tk_SizeOfImage(tk_image, & width, & height); if (width != 0 && height != 0) { - icon = TkMacOSXGetNSImageFromTkImage(d, tk_icon, + icon = TkMacOSXGetNSImageFromTkImage(d, tk_image, width, height); - [tk_item setImage: withImage: icon]; + [tk_item setImagewithImage: icon]; } /* * Set the text for the tooltip. */ - NSString * tooltip = [NSString stringWithUTF8String: Tcl_GetString(argv[3])]; + NSString * tooltip = [NSString stringWithUTF8String: argv[3]]; if (tooltip == nil) { Tcl_AppendResult(interp, "unable to set tooltip for systray icon", (char * ) NULL); return TCL_ERROR; } - [tk_item setText: withString: tooltip]; + [tk_item setTextwithString: tooltip]; /* * Set the proc for the callback. */ - callbackproc = Tcl_GetString(argv[4]); + callbackproc = (char*) argv[4]; if (callbackproc == NULL) { Tcl_AppendResult(interp, "unable to get the callback for systray icon", (char * ) NULL); return TCL_ERROR; @@ -258,21 +265,22 @@ MacSystrayModifyCmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } - char * modifyitem = Tcl_GetString(argv[2]); + char * modifyitem = (char*) argv[2]; /* * Modify the icon. */ - if ((strcmp modifyitem, "image") == 0) { + if (strcmp (modifyitem, "image") == 0) { Tk_Window tkwin = Tk_MainWindow(interp); - TkWindow winPtr = (TkWindow) tkwin; + TkWindow *winPtr = (TkWindow*) tkwin; Display * d; d = winPtr -> display; NSImage * icon; + int width, height; - char * tk_imagename = Tcl_GetString(argv[3]); + char * tk_imagename = (char*) argv[3]; Tk_Image tk_image; tk_image = Tk_GetImage(interp, tkwin, tk_imagename, NULL, NULL); if (tk_image == NULL) { @@ -282,9 +290,9 @@ MacSystrayModifyCmd(ClientData clientData, Tcl_Interp * interp, Tk_SizeOfImage(tk_image, & width, & height); if (width != 0 && height != 0) { - icon = TkMacOSXGetNSImageFromTkImage(d, tk_icon, + icon = TkMacOSXGetNSImageFromTkImage(d, tk_image, width, height); - [tk_item setImage: withImage: icon]; + [tk_item setImagewithImage: icon]; } } @@ -292,23 +300,23 @@ MacSystrayModifyCmd(ClientData clientData, Tcl_Interp * interp, * Modify the text for the tooltip. */ - if ((strcmp modifyitem, "text") == 0) { + if (strcmp (modifyitem, "text") == 0) { - NSString * tooltip = [NSString stringWithUTF8String: Tcl_GetString(argv[2])]; + NSString * tooltip = [NSString stringWithUTF8String:argv[2]]; if (tooltip == nil) { Tcl_AppendResult(interp, "unable to set tooltip for systray icon", (char * ) NULL); return TCL_ERROR; } - [tk_item setText: withString: tooltip]; + [tk_item setTextwithString: tooltip]; } /* * Modify the proc for the callback. */ - if ((strcmp modifyitem, "callback") == 0) { - callbackproc = Tcl_GetString(argv[2]); + if (strcmp (modifyitem, "callback") == 0) { + callbackproc = (char*) argv[2]; if (callbackproc == NULL) { Tcl_AppendResult(interp, "unable to get the callback for systray icon", (char * ) NULL); return TCL_ERROR; @@ -337,6 +345,8 @@ MacSystrayModifyCmd(ClientData clientData, Tcl_Interp * interp, static void MacSystrayDestroy(ClientData clientData) { + (void) clientData; + [tk_item dealloc]; } @@ -394,9 +404,9 @@ static int SysNotifyCmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } - NSString *title = [NSString stringWithUTF8String: Tcl_GetString(argv[1])]; - NSString *message = [NSString stringWithUTF8String: Tcl_GetString(argv[2])]; - [notify_item postNotification: withTitle: title andDetail: message]; + NSString *title = [NSString stringWithUTF8String: argv[1]]; + NSString *message = [NSString stringWithUTF8String: argv[2]]; + [notify_item postNotificationWithTitle : title message: message]; return TCL_OK; } @@ -425,14 +435,14 @@ MacSystrayInit(Tcl_Interp * interp) { * Initialize TkStatusItem and TkNotifyItem. */ + tk_item = [[TkStatusItem alloc] init]; + notify_item = [[TkNotifyItem alloc] init]; + if ([NSApp macOSVersion] < 101000) { Tcl_AppendResult(interp, "Statusitem icons not supported on versions of macOS lower than 10.10", (char * ) NULL); return TCL_OK; } - - TkStatusItem *tk_item = [[TkStatusItem alloc] init]; - TkNotifyItem *notify_item = [[TkNotifyItem alloc] init]; - + Tcl_CreateCommand(interp, "_systray", MacSystrayCmd, (ClientData)interp, (Tcl_CmdDeleteProc *) MacSystrayDestroy); @@ -441,8 +451,6 @@ MacSystrayInit(Tcl_Interp * interp) { return TCL_OK; } -/ - /* * Local Variables: * mode: objc -- cgit v0.12