TclApps Library Source Code
Check-in [92b41aaa85]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Removed focused flag from hook arguments as this may be derived from the window Signed-off-by: Pat Thoyts <[email protected]>
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 92b41aaa85e53fa40eac44ef5e0d48e27f93b4d7
User & Date: patthoyts 2011-05-16 17:17:57.000
Context
2011-05-17
23:27
Implement system tray icon and notifications for freedesktop.org systems. If we can load tktray and dbus-tcl then show alert status in the system tray and display alert messages via the systems notification system. check-in: 3e131615de user: patthoyts tags: trunk
2011-05-16
17:17
Removed focused flag from hook arguments as this may be derived from the window Signed-off-by: Pat Thoyts <[email protected]> check-in: 92b41aaa85 user: patthoyts tags: trunk
17:14
Improved aqua support. Drops the ffidl code in favour of using tclgrowl and tkdock for alerts and n Fix some incorrect mouse bindings on this platform. [PT: Refactored this patch to use hooks, adding an alert hook at the same time] Signed-off-by: Kevin Walzer <[email protected]> Signed-off-by: Pat Thoyts <[email protected]> check-in: 925cd04255 user: patthoyts tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to apps/tkchat/tkchat.tcl.
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
    ::http::register http 80 ::socket_inet4
}

namespace eval ::tkchat {
    variable chatWindowTitle "The Tcler's Chat"

    variable HEADUrl {http://tcllib.cvs.sourceforge.net/*checkout*/tcllib/tclapps/apps/tkchat/tkchat.tcl?revision=HEAD}
    variable rcsid   {$Id: tkchat.tcl,v 1.484 2011/05/16 17:14:28 patthoyts Exp $}

    variable MSGS
    set MSGS(entered) [list \
	    "%user% has entered the chat!" \
	    "Out of a cloud of smoke, %user% appears!" \
	    "%user% saunters in." \
	    "%user% wanders in." \







|







256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
    ::http::register http 80 ::socket_inet4
}

namespace eval ::tkchat {
    variable chatWindowTitle "The Tcler's Chat"

    variable HEADUrl {http://tcllib.cvs.sourceforge.net/*checkout*/tcllib/tclapps/apps/tkchat/tkchat.tcl?revision=HEAD}
    variable rcsid   {$Id: tkchat.tcl,v 1.485 2011/05/16 17:17:57 patthoyts Exp $}

    variable MSGS
    set MSGS(entered) [list \
	    "%user% has entered the chat!" \
	    "Out of a cloud of smoke, %user% appears!" \
	    "%user% saunters in." \
	    "%user% wanders in." \
1133
1134
1135
1136
1137
1138
1139

1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150

1151
1152
1153
1154
1155

1156
1157
1158
1159
1160
1161
1162
# action.
#
proc ::tkchat::alertWhenIdle {w nick msg} {
    variable alert_pending

    if { ![info exists alert_pending] } {
	set alert_pending 1

	if { $::Options(AutoBookmark) && $w eq ".txt" && [focus] == {} } {
	    .txt mark set AddBookmark "end - 1 line linestart"
	    BookmarkToggle auto
	}
        set top [winfo toplevel $w]
        set focused [expr {[llength [focus -displayof $top]] != 0}]
        after idle [list [namespace origin Hook] run \
                        alert $w $focused $nick $msg]
    }
}


proc ::tkchat::alertCallback {w focused nick msg} {
    global Options
    variable alert_pending

    set top [winfo toplevel $w]

    unset -nocomplain alert_pending
    if {$Options(Alert,RAISE) && !$focused} {
	# Only call this if the window doesn't already have focus
	wm deiconify $top
	raise $top
    }
    if {$Options(Alert,SOUND)} bell







>
|



<
<
|
<



>
|




>







1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144


1145

1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
# action.
#
proc ::tkchat::alertWhenIdle {w nick msg} {
    variable alert_pending

    if { ![info exists alert_pending] } {
	set alert_pending 1
        set focused [expr {[focus -displayof [winfo toplevel $w]] ne {}}]
	if { $::Options(AutoBookmark) && $w eq ".txt" && !$focused } {
	    .txt mark set AddBookmark "end - 1 line linestart"
	    BookmarkToggle auto
	}


        after idle [list [namespace origin Hook] run alert $w $nick $msg]

    }
}

# Stock alert hook: raise app and/or sound bell depending on options.
proc ::tkchat::alertCallback {w nick msg} {
    global Options
    variable alert_pending

    set top [winfo toplevel $w]
    set focused [expr {[focus -displayof $top] ne {}}]
    unset -nocomplain alert_pending
    if {$Options(Alert,RAISE) && !$focused} {
	# Only call this if the window doesn't already have focus
	wm deiconify $top
	raise $top
    }
    if {$Options(Alert,SOUND)} bell
Changes to apps/tkchat/tkchat_aqua.tcl.
23
24
25
26
27
28
29
30
31
32
33
34

35
36
37
38
39

40
41
42
43
44
45
46
        # tkdock sites under lib beside tkchat.kit in the app bundle
        lappend auto_path $MacOS/lib
        bind all <FocusIn> +::tkdock::origIcon
    }
    InitAlertMenu
}

proc ::tkchat::aqua::AlertHook {w raise nick msg} {
    global Options
    variable growl
    variable tkdock
    variable Resources

    if {$raise && $growl && $Options(Alert,GROWL)} {
        growl::message TkChat "Message from $nick" $msg
    }
    if {$tkdock} {
        ::tkdock::switchIcon $Resources/tkchat_warn.icns

    }
}

# Hook the messages. If a message arrives and we are not focused, the
# message counter is incremented and we ammend the dock icon here.
# PT: is this correct, resetting the origIcon on missed messages?
proc ::tkchat::aqua::MessageHook {nick msg msgtype args} {







|




>
|
|
|
|
|
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        # tkdock sites under lib beside tkchat.kit in the app bundle
        lappend auto_path $MacOS/lib
        bind all <FocusIn> +::tkdock::origIcon
    }
    InitAlertMenu
}

proc ::tkchat::aqua::AlertHook {w nick msg} {
    global Options
    variable growl
    variable tkdock
    variable Resources
    if {[focus -displayof [winfo toplevel $w]] eq {}} {
        if {$growl && $Options(Alert,GROWL)} {
            growl::message TkChat "Message from $nick" $msg
        }
        if {$tkdock} {
            ::tkdock::switchIcon $Resources/tkchat_warn.icns
        }
    }
}

# Hook the messages. If a message arrives and we are not focused, the
# message counter is incremented and we ammend the dock icon here.
# PT: is this correct, resetting the origIcon on missed messages?
proc ::tkchat::aqua::MessageHook {nick msg msgtype args} {