diff options
-rw-r--r-- | library/systray.tcl | 60 | ||||
-rw-r--r-- | macosx/tkMacOSXSysTray.c | 56 | ||||
-rwxr-xr-x | unix/tkUnixSysNotify.c | 3 |
3 files changed, 58 insertions, 61 deletions
diff --git a/library/systray.tcl b/library/systray.tcl index d22efa3..66ad350 100644 --- a/library/systray.tcl +++ b/library/systray.tcl @@ -38,11 +38,11 @@ proc _balloon_show {w arg} { # Additional infrastructure for Windows callbacks. proc _win_callback {msg icn script} { global _cb_1 - global _cb_2 + global _cb_3 switch -exact -- $msg { WM_LBUTTONDOWN { - eval $_cb_2 + eval $_cb_3 } WM_RBUTTONDOWN { eval $_cb_1 @@ -118,8 +118,8 @@ global _iconlist set _iconlist {} global _cb_1 set _cb_1 "" -global _cb_2 -set _cb_2 "" +global _cb_3 +set _cb_3 "" # systray -- # This procedure creates an icon display in the platform-specific system tray. @@ -131,14 +131,14 @@ set _cb_2 "" # image - Tk image to display. # text - string to display in tooltip over image. # b1_callback - Tcl proc to invoke on <Button-1> event. -# b2_callback - Tcl proc to invoke on <Button-2> event. +# b3_callback - Tcl proc to invoke on <Button-3> event. # modify - change one of the systray properties. # Arguments (only one required): # image - Tk image to update. # text - string to update. # b1_callback - Tcl proc to change. -# b2_callback - Tcl proc to change. +# b3_callback - Tcl proc to change. # destroy - destroy systray icon. # Arguments: # none. @@ -157,12 +157,12 @@ proc ::tk::systray {args} { global _ico global _iconlist global _cb_1 - global _cb_2 + global _cb_3 set _img "" set _txt "" set _cb_1 "" - set _cb_2 "" + set _cb_3 "" #Remove the systray icon. if {[lindex $args 0] eq "destroy" && [llength $args] == 1} { @@ -187,14 +187,14 @@ proc ::tk::systray {args} { #Create the system tray icon. if {[lindex $args 0] eq "create"} { if {[llength $args] != 5} { - error "wrong # args: should be \"tk systray create image ?text? ?b1_callback? b2_callback?\"" + error "wrong # args: should be \"tk systray create image ?text? ?b1_callback? b3_callback?\"" } - set _img [lindex $args 1] - set _txt [lindex $args 2] - set _cb_1 [lindex $args 3] - set _cb_2 [lindex $args 4] - switch -- [tk windowingsystem] { - "win32" { + set _img [lindex $args 1] + set _txt [lindex $args 2] + set _cb_1 [lindex $args 3] + set _cb_3 [lindex $args 4] + switch -- [tk windowingsystem] { + "win32" { if {[llength $_iconlist] > 0} { error "Only one system tray \ icon supported per interpeter" @@ -203,7 +203,7 @@ proc ::tk::systray {args} { _systray taskbar add $_ico -text $_txt -callback [list _win_callback %m %i] lappend _iconlist "ico#[llength _iconlist]" } - "x11" { + "x11" { if [winfo exists ._tray] { error "Only one system tray \ icon supported per interpeter" @@ -212,17 +212,17 @@ proc ::tk::systray {args} { _systray ._tray -image $_img -visible true _balloon ._tray $_txt bind ._tray <Button-1> $_cb_1 - bind ._tray <Button-2> $_cb_2 + bind ._tray <Button-3> $_cb_3 } "aqua" { - _systray create $_img $_txt $_cb_1 $_cb_2 + _systray create $_img $_txt $_cb_1 $_cb_3 } } } #Modify the system tray icon properties. if {[lindex $args 0] eq "modify"} { if {[llength $args] != 3} { - error "wrong # args: \"tk systray modify image | text | b1_callback | b2_callback option?\"" + error "wrong # args: \"tk systray modify image | text | b1_callback | b3_callback option?\"" } switch -- [tk windowingsystem] { "win32" { @@ -240,8 +240,8 @@ proc ::tk::systray {args} { set _cb_1 [lindex $args 2] _systray taskbar modify $_ico -callback [list _win_callback %m %i] } - if {[lindex $args 1 ] eq "b2_callback"} { - set _cb_2 [lindex $args 2] + if {[lindex $args 1 ] eq "b3_callback"} { + set _cb_3 [lindex $args 2] _systray taskbar modify $_ico -callback [list _win_callback %m %i] } @@ -264,11 +264,11 @@ proc ::tk::systray {args} { set _cb_1 [lindex $args 2] bind ._tray <Button-1> $_cb_1 } - if {[lindex $args 1 ] eq "b2_callback"} { - set _cb_2 "" + if {[lindex $args 1 ] eq "b3_callback"} { + set _cb_3 "" bind ._tray <Button-1> "" - set _cb_2 [lindex $args 2] - bind ._tray <Button-1> $_cb_2 + set _cb_3 [lindex $args 2] + bind ._tray <Button-1> $_cb_3 } } "aqua" { @@ -281,12 +281,12 @@ proc ::tk::systray {args} { _systray modify text $_txt } if {[lindex $args 1 ] eq "b1_callback"} { - set _cb [lindex $args 2] - _systray modify callback $_cb_1 + set _cb_1 [lindex $args 2] + _systray modify b1_callback $_cb_1 } - if {[lindex $args 1 ] eq "b2_callback"} { - set _cb [lindex $args 2] - _systray modify callback $_cb_2 + if {[lindex $args 1 ] eq "b3_callback"} { + set _cb_3 [lindex $args 2] + _systray modify b3_callback $_cb_3 } } } diff --git a/macosx/tkMacOSXSysTray.c b/macosx/tkMacOSXSysTray.c index 7b9a897..1bb6a8c 100644 --- a/macosx/tkMacOSXSysTray.c +++ b/macosx/tkMacOSXSysTray.c @@ -28,14 +28,14 @@ static const char ASSOC_KEY[] = "tk::tktray"; NSString * tooltip; Tcl_Interp * interp; Tcl_Obj * b1_callback; - Tcl_Obj * b2_callback; + Tcl_Obj * b3_callback; } - (id) init : (Tcl_Interp *) interp; - (void) setImagewithImage : (NSImage *) image; - (void) setTextwithString : (NSString *) string; - (void) setB1Callback : (Tcl_Obj *) callback; -- (void) setB2Callback : (Tcl_Obj *) callback; +- (void) setB3Callback : (Tcl_Obj *) callback; - (void) clickOnStatusItem: (id) sender; - (void) dealloc; @@ -54,7 +54,7 @@ static const char ASSOC_KEY[] = "tk::tktray"; statusItem.visible = YES; interp = interpreter; b1_callback = NULL; - b2_callback = NULL; + b3_callback = NULL; return self; } @@ -83,15 +83,15 @@ static const char ASSOC_KEY[] = "tk::tktray"; b1_callback = obj; } -- (void) setB2Callback : (Tcl_Obj *) obj +- (void) setB3Callback : (Tcl_Obj *) obj { if (obj != NULL) { Tcl_IncrRefCount(obj); } - if (b2_callback != NULL) { - Tcl_DecrRefCount(b1_callback); + if (b3_callback != NULL) { + Tcl_DecrRefCount(b3_callback); } - b2_callback = obj; + b3_callback = obj; } - (void) clickOnStatusItem: (id) sender @@ -103,8 +103,8 @@ static const char ASSOC_KEY[] = "tk::tktray"; Tcl_BackgroundException(interp, result); } } else { - if (([event type] == NSEventTypeRightMouseUp) && (b2_callback != NULL)) { - int result = Tcl_EvalObjEx(interp, b2_callback, TCL_EVAL_GLOBAL); + if (([event type] == NSEventTypeRightMouseUp) && (b3_callback != NULL)) { + int result = Tcl_EvalObjEx(interp, b3_callback, TCL_EVAL_GLOBAL); if (result != TCL_OK) { Tcl_BackgroundException(interp, result); } @@ -125,8 +125,8 @@ static const char ASSOC_KEY[] = "tk::tktray"; if (b1_callback != NULL) { Tcl_DecrRefCount(b1_callback); } - if (b2_callback != NULL) { - Tcl_DecrRefCount(b2_callback); + if (b3_callback != NULL) { + Tcl_DecrRefCount(b3_callback); } } @@ -244,8 +244,8 @@ MacSystrayObjCmd( typedef enum {TRAY_CREATE, TRAY_MODIFY, TRAY_DESTROY} optionsEnum; static const char *modifyOptions[] = - {"image", "text", "b1_callback", "b2_callback", NULL}; - typedef enum {TRAY_IMAGE, TRAY_TEXT, TRAY_B1_CALLBACK, TRAY_B2_CALLBACK} modifyOptionsEnum; + {"image", "text", "b1_callback", "b3_callback", NULL}; + typedef enum {TRAY_IMAGE, TRAY_TEXT, TRAY_B1_CALLBACK, TRAY_B3_CALLBACK} modifyOptionsEnum; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "create | modify | destroy"); @@ -261,15 +261,15 @@ MacSystrayObjCmd( switch((optionsEnum)idx) { case TRAY_CREATE: { - if (objc < 6) { - Tcl_WrongNumArgs(interp, 1, objv, "create image ?text? ?b1_callback? b2_callback?"); + if (objc < 3 || objc > 6) { + Tcl_WrongNumArgs(interp, 1, objv, "create image ?text? ?b1_callback? b3_callback?"); return TCL_ERROR; } if (info->tk_item == NULL) { info->tk_item = [[TkStatusItem alloc] init: interp]; } else { - Tcl_AppendResult(interp, "Only one system tray icon supported per interpeter", NULL); + Tcl_AppendResult(interp, "Only one system tray icon supported per interpreter", NULL); return TCL_ERROR; } @@ -312,13 +312,13 @@ MacSystrayObjCmd( * Set the proc for the callback. */ - [info->tk_item setB1Callback : objv[4]]; - [info->tk_item setB2Callback : objv[5]]; + [info->tk_item setB1Callback : (objc > 4) ? objv[4] : NULL]; + [info->tk_item setB3Callback : (objc > 5) ? objv[5] : NULL]; break; } case TRAY_MODIFY: { - if (objc < 5) { + if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "modify object item"); return TCL_ERROR; } @@ -380,26 +380,24 @@ MacSystrayObjCmd( [info->tk_item setB1Callback : objv[3]]; break; } - case TRAY_B2_CALLBACK: { - [info->tk_item setB2Callback : objv[4]]; + case TRAY_B3_CALLBACK: { + [info->tk_item setB3Callback : objv[3]]; break; } - break; - } + } + break; + } - case TRAY_DESTROY: { + case TRAY_DESTROY: { /* we don't really distroy, just reset the image, text and callback */ [info->tk_item setImagewithImage: nil]; [info->tk_item setTextwithString: nil]; [info->tk_item setB1Callback : NULL]; - [info->tk_item setB2Callback : NULL]; - // /* do nothing */ + [info->tk_item setB3Callback : NULL]; break; } - break; - } - return TCL_OK; } + return TCL_OK; } diff --git a/unix/tkUnixSysNotify.c b/unix/tkUnixSysNotify.c index 3a3b789..bc64906 100755 --- a/unix/tkUnixSysNotify.c +++ b/unix/tkUnixSysNotify.c @@ -73,9 +73,8 @@ static int SysNotifyCmd( { const char *title; const char *message; - char *icon; + const char *icon; NotifyNotification *notif; - GdkPixbuf * notifyimage; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "title message"); |