Tkabber plugins

Check-in [172f32a05b]
Login

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

Overview
Comment:Reformatted the code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:172f32a05b4fc98b99edef51e0b492b1791b6cad
User & Date: sgolovan 2015-05-09 13:15:48
Context
2015-05-09
13:19
Reformatted code. check-in: a0de3d4164 user: sgolovan tags: trunk
13:15
Reformatted the code. check-in: 172f32a05b user: sgolovan tags: trunk
13:10
Adapted the Reversi game plugin to the Ttk based interface. check-in: 6d3a6ab6a7 user: sgolovan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

1




2
3
4
5
6
7
8
2015-05-09  Sergei Golovan  <sgolovan@nes.ru>





	* reversi/reversi.tcl: Adapted the Reversi game plugin to the Ttk
	  based interface.

	* reversi/msgs/es.msg, reversi/msgs/nl.msg, reversi/msgs/pl.msg,
	  reversi/msgs/ru.msg, reversi/msgs/uk.msg,
	  reversi/pixmaps/checkers/icondef.xml,

>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2015-05-09  Sergei Golovan  <sgolovan@nes.ru>

	* singularity/INSTALL, singularity/README, singularity/msgs/pl.msg,
	  singularity/msgs/ru.msg, singularity/singularity.tcl: Reformatted
	  the code.

	* reversi/reversi.tcl: Adapted the Reversi game plugin to the Ttk
	  based interface.

	* reversi/msgs/es.msg, reversi/msgs/nl.msg, reversi/msgs/pl.msg,
	  reversi/msgs/ru.msg, reversi/msgs/uk.msg,
	  reversi/pixmaps/checkers/icondef.xml,

Changes to singularity/INSTALL.

1
2
3
4
5
6
7
8
9
10
As usually, copy this directory under the ~/.tkabber/plugins directory
so that you get a hierarchy like this:
  ~/.tkabber/plugins
  ~/.tkabber/plugins/singularity/
  ~/.tkabber/plugins/singularity/singularity.tcl

Restart Tkabber, to get the plugin loaded.

Consult the README file for the details about using this plugin.

|








<
1
2
3
4
5
6
7
8
9

As usual, copy this directory under the ~/.tkabber/plugins directory
so that you get a hierarchy like this:
  ~/.tkabber/plugins
  ~/.tkabber/plugins/singularity/
  ~/.tkabber/plugins/singularity/singularity.tcl

Restart Tkabber, to get the plugin loaded.

Consult the README file for the details about using this plugin.

Changes to singularity/README.

57
58
59
60
61
62
63
64

* If there are several chat windows to be closed when the new
  one is about to be opened, the order in which their
  conversation logs and input history records are collected
  is undefined.


# vim:tw=64:noet







|
57
58
59
60
61
62
63
64

* If there are several chat windows to be closed when the new
  one is about to be opened, the order in which their
  conversation logs and input history records are collected
  is undefined.


# vim:tw=64:et

Changes to singularity/msgs/pl.msg.

1
2
3
4
5
6
7



8
9







# pl.msg --
#
#	Polish messages for the Singularity plugin.
#
# Author: Irek Chmielowiec <irek.ch@gmail.com>

::msgcat::mcset pl "Allows closing obsolete chat windows for a contact when a new chat session window with that contact is about to be opened." "Pozwalaj na zamykanie niepotrzebnych okien rozmów kiedy otwierane jest nowe okno rozmowy z danym użytkownikiem."



::msgcat::mcset pl "Plugins options." "Ustawienia wtyczek."
::msgcat::mcset pl "Singularity plugin options. What this plugin makes is to do cleanup by closing obsolete chat windows opened for different resources of the same contact ensuring only one chat window for a contact is opened at any given time." "Opcje wtyczki singularity. Wtyczka ta pozwala na utrzymanie porządku w oknach rozmów poprzez zamykanie wielu okien rozmów dla różnych zasobów tego samego kontaktu."









|



|
>
>
>

|
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# pl.msg --
#
#       Polish messages for the Singularity plugin.
#
# Author: Irek Chmielowiec <irek.ch@gmail.com>

::msgcat::mcset pl "Allows closing obsolete chat windows for a contact when a\
        new chat session window with that contact is about to be opened." \
        "Pozwalaj na zamykanie niepotrzebnych okien rozmów kiedy otwierane\
        jest nowe okno rozmowy z danym użytkownikiem."
::msgcat::mcset pl "Plugins options." "Ustawienia wtyczek."
::msgcat::mcset pl "Singularity plugin options. What this plugin makes is to\
        do cleanup by closing obsolete chat windows opened for different\
        resources of the same contact ensuring only one chat window for a\
        contact is opened at any given time." "Opcje wtyczki singularity.\
        Wtyczka ta pozwala na utrzymanie porządku w oknach rozmów poprzez\
        zamykanie wielu okien rozmów dla różnych zasobów tego samego kontaktu."

# vim:ft=tcl:ts=8:sw=4:sts=4:et

Changes to singularity/msgs/ru.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13



# ru.msg --
#
#	Russian messages for the Singularity plugin.
#
# Author: Sergei Golovan <sgolovan@nes.ru>

::msgcat::mcset ru "Whether the Singularity plugin is loaded." \
	"Загружено ли расширение Signularity."
::msgcat::mcset ru "This plugin allows closing obsolete chat windows\
	for a contact when a new chat session window\
	with that contact is about to be opened." \
	"Это расширение позволяет закрывать существующие окна разговора с контактом, если\
	открывается новая сессия разговора с тем же контактом (с другим ресурсом)."





|




|

|
|
|
|
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# ru.msg --
#
#       Russian messages for the Singularity plugin.
#
# Author: Sergei Golovan <sgolovan@nes.ru>

::msgcat::mcset ru "Whether the Singularity plugin is loaded." \
        "Загружено ли расширение Signularity."
::msgcat::mcset ru "This plugin allows closing obsolete chat windows\
        for a contact when a new chat session window\
        with that contact is about to be opened." \
        "Это расширение позволяет закрывать существующие окна разговора с\
        контактом, если открывается новая сессия разговора с тем же контактом\
        (с другим ресурсом)."

# vim:ft=tcl:ts=8:sw=4:sts=4:et

Changes to singularity/singularity.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80
81
..
88
89
90
91
92
93
94
95
# singularity.tcl --
#
#	When a new chat window is about to be opened this plugin
#	checks whether any chats with other resources of this chat peer
#	are currently opened and closes them all, if any.
#	In other words, it ensures that only one chat window per bare
#	JID is opened at any given time.
#
# Author: Konstantin Khomoutov <flatworm@users.sourceforge.net>
#
# See license.terms for the terms of distribution.
# See README for usage details.

namespace eval singularity {
    ::msgcat::mcload [file join [file dirname [info script]] msgs]

    if {![::plugins::is_registered singularity]} {
	::plugins::register singularity \
			    -namespace [namespace current] \
			    -source [info script] \
			    -description [::msgcat::mc \
	    "Whether the Singularity plugin is loaded."]\n[::msgcat::mc \
		"This plugin allows closing obsolete chat windows\
		for a contact when a new chat session window\
		with that contact is about to be opened."] \
			    -loadcommand [namespace code load] \
			    -unloadcommand [namespace code unload]
	return
    }
}

proc singularity::load {} {
    variable contexts; array set contexts {}

    hook::add open_chat_pre_hook \
	[namespace current]::process_new_chat_opening
    hook::add open_chat_post_hook \
	[namespace current]::restore_chat_context
}

proc singularity::unload {} {
    hook::remove open_chat_pre_hook \
	[namespace current]::process_new_chat_opening
    hook::remove open_chat_post_hook \
	[namespace current]::restore_chat_context

    variable contexts; unset contexts
}

proc singularity::process_new_chat_opening {chatid type} {
    if {![string equal $type chat]} return

    set from [chat::get_jid $chatid]
    set barejid [::xmpp::jid::stripResource $from]
    if {[chat::is_groupchat [chat::chatid \
	[chat::get_xlib $chatid] $barejid]]} return

    variable contexts
    upvar 0 contexts(input,$chatid) savedinput
    upvar 0 contexts(history,$chatid) savedhistory
    variable [namespace parent]::history

    set savedinput ""
    set savedhistory [list {}]

    foreach cid [chat::opened] {
	set jid [chat::get_jid $cid]
	if {![::xmpp::jid::equal $from $jid] &&
		[::xmpp::jid::equal $barejid [::xmpp::jid::stripResource $jid]]} {
	    if {$savedinput != ""} { append savedinput \n }
	    append savedinput [[chat::input_win $cid] get 1.0 end-1c]

	    set savedhistory [concat $savedhistory [lrange $history(stack,$cid) 1 end]]
	    chat::close $cid
	}
    }
}

proc singularity::restore_chat_context {chatid type} {
    if {![string equal $type chat]} return

    variable contexts
................................................................................
    [chat::input_win $chatid] insert end $savedinput
    set history(stack,$chatid) $savedhistory
    set history(pos,$chatid) 0

    unset savedinput savedhistory
}

# vim:ts=8:sw=4:sts=4:noet


|
|
|
|
|










|
|
|
|
|
|
|
|
|
|
|







|

|




|

|










|










|
|
|
|
|
>
|
|
|







 







|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
..
89
90
91
92
93
94
95
96
# singularity.tcl --
#
#       When a new chat window is about to be opened this plugin
#       checks whether any chats with other resources of this chat peer
#       are currently opened and closes them all, if any.
#       In other words, it ensures that only one chat window per bare
#       JID is opened at any given time.
#
# Author: Konstantin Khomoutov <flatworm@users.sourceforge.net>
#
# See license.terms for the terms of distribution.
# See README for usage details.

namespace eval singularity {
    ::msgcat::mcload [file join [file dirname [info script]] msgs]

    if {![::plugins::is_registered singularity]} {
        ::plugins::register singularity \
                            -namespace [namespace current] \
                            -source [info script] \
                            -description [::msgcat::mc \
            "Whether the Singularity plugin is loaded."]\n[::msgcat::mc \
                "This plugin allows closing obsolete chat windows\
                for a contact when a new chat session window\
                with that contact is about to be opened."] \
                            -loadcommand [namespace code load] \
                            -unloadcommand [namespace code unload]
        return
    }
}

proc singularity::load {} {
    variable contexts; array set contexts {}

    hook::add open_chat_pre_hook \
        [namespace current]::process_new_chat_opening
    hook::add open_chat_post_hook \
        [namespace current]::restore_chat_context
}

proc singularity::unload {} {
    hook::remove open_chat_pre_hook \
        [namespace current]::process_new_chat_opening
    hook::remove open_chat_post_hook \
        [namespace current]::restore_chat_context

    variable contexts; unset contexts
}

proc singularity::process_new_chat_opening {chatid type} {
    if {![string equal $type chat]} return

    set from [chat::get_jid $chatid]
    set barejid [::xmpp::jid::stripResource $from]
    if {[chat::is_groupchat [chat::chatid \
        [chat::get_xlib $chatid] $barejid]]} return

    variable contexts
    upvar 0 contexts(input,$chatid) savedinput
    upvar 0 contexts(history,$chatid) savedhistory
    variable [namespace parent]::history

    set savedinput ""
    set savedhistory [list {}]

    foreach cid [chat::opened] {
        set jid [chat::get_jid $cid]
        if {![::xmpp::jid::equal $from $jid] &&
            [::xmpp::jid::equal $barejid [::xmpp::jid::stripResource $jid]]} {
            if {$savedinput != ""} { append savedinput \n }
            append savedinput [[chat::input_win $cid] get 1.0 end-1c]
            set savedhistory \
                [concat $savedhistory [lrange $history(stack,$cid) 1 end]]
            chat::close $cid
        }
    }
}

proc singularity::restore_chat_context {chatid type} {
    if {![string equal $type chat]} return

    variable contexts
................................................................................
    [chat::input_win $chatid] insert end $savedinput
    set history(stack,$chatid) $savedhistory
    set history(pos,$chatid) 0

    unset savedinput savedhistory
}

# vim:ts=8:sw=4:sts=4:et