~aleteoryx/tclircc

ref: 71f49993d7ef1290feb22e882119285f8790d110 tclircc/src/ui/main.tcl -rw-r--r-- 1.9 KiB
71f49993aleteoryx docs generation a month ago
                                                                                
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
#***
# [manpage_begin ui_thread tclircc 0.0.1]
# [titledesc {Thread tclircc::ui}]
# [description]

variable toplevel_count 0
variable toplevel_tabs
variable toplevel_classes

package require logger
set log [logger::init tclircc::ui]

${log}::debug "loading tk"
package require Tk
wm withdraw .
# TODO: tray handling
# use tktray on linux, use TWAPI on windows (packaged with magicsplat)

proc tab_update {window} {
  variable toplevel_tabs

  if ![llength [set toplevel_tabs($window)]] {
    destroy $window.tabs
    destroy $window.msg1 $window.msg2

    wm title $window "tclircc"

    label $window.msg1 -text "No tabs open!"
    label $window.msg2 -text "Use the titlebar to open a new tab."

    pack configure $window.msg1 -side top -pady {20 10}
    pack configure $window.msg2 -side top -pady {10 50} -padx {50}
  }
}

proc mk_toplevel {varname {takefocus 0}} {
  variable toplevel_count
  variable toplevel_tabs
  variable version
  upvar $varname window
  set window .win$toplevel_count
  toplevel $window -takefocus $takefocus
  incr toplevel_count

  ### MENUBAR ###
  menu $window.menu
  $window configure -menu "$window.menu"

  menu $window.menu.conn
  menu $window.menu.irc
  menu $window.menu.plugin

  menu $window.menu.me
  $window.menu.me add command -label "About" -command [subst {
    tk_messageBox -title "About tclircc" \
                  -message "tclircc $version" \
                  -detail "by Aleteoryx\nhttps://amehut.dev/~aleteoryx/tclircc\n\nThis software is in the public domain." \
                  -type ok \
                  -parent $window }]

  $window.menu add cascade -label "chat" -menu $window.menu.irc
  $window.menu add cascade -label "connection" -menu $window.menu.conn
  $window.menu add cascade -label "plugins" -menu $window.menu.plugin
  $window.menu add cascade -label "tclircc" -menu $window.menu.me

  ### TABS ###
  set toplevel_tabs($window) {}

  tab_update $window
}

${log}::debug "ui init done!"

#***
# [manpage_end]