/usr/share/amsn/plugins/devel/devel.tcl is in amsn-data 0.98.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 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 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 | namespace eval ::devel {
namespace export plugins
variable develwin
variable plugins
variable w
variable plugins
#variable loadedplugins
variable selection
variable mF
variable packloaded
variable namespaces
variable procs
variable console
proc InitPlugin { dir } {
variable develwin
variable packloaded
variable namespaces
variable procs
variable console
#RegisterPlugin
::plugins::RegisterPlugin "Devel"
#Register events
#::devel::RegisterEvent
#Set default values for config
::devel::ConfigArray
#Add items to configure window
::devel::ConfigList
set develwin ".develwin"
set console ".develconsole"
#bind . <Alt-d> ::devel::drawMainWindow
if {![catch {tk windowingsystem} wsystem] && $wsystem == "aqua"} {
bind . <Option-d> ::devel::drawMainWindow
} else {
bind . <Alt-d> ::devel::drawMainWindow
}
set packloaded [list "Package list not created"]
set procs [list "Proc list not created"]
log "Generating package list"
generatePackageList ""
log "generating proc list"
generateProcList ""
}
proc recursiveNamespace { namespaces } {
log "recu: $namespaces"
return recuriveNamespace [namespace children $namespaces]
}
proc DeInit { } {
variable packloaded
variable namespaces
variable procs
variable console
unset $packloaded
unset $namespaces
unset $procs
interp delete $console
if {![catch {tk windowingsystem} wsystem] && $wsystem == "aqua"} {
bind . <Option-d> ""
} else {
bind . <Alt-d> ""
}
}
proc ConfigArray {} {
array set ::devel::config {
help {0}
}
}
proc ConfigList {} {
set ::devel::configlist [list \
[list label "To activate the devel menu, hit alt-d" help] \
]
}
proc RegisterEvent {} {
}
proc drawMainWindow { } {
variable develwin
toplevel $develwin
::devel::buildForms
moveinscreen $develwin 200
}
#####################################################################
#
# Les onglets
#
#
#####################################################################
proc buildForms { } {
variable develwin
frame $develwin.nb -class Degt
set develNb $develwin.nb
NoteBook $develNb.nn
$develNb.nn insert end varlist -text "Var list"
#$develNb.nn insert end varsearch -text "Vars"
$develNb.nn insert end procs -text "Procs"
$develNb.nn insert end plugins -text "Plugins"
$develNb.nn insert end memstats -text "Memory"
$develNb.nn insert end dock -text "Dock"
$develNb.nn insert end packages -text "Packages"
$develNb.nn insert end images -text "Images"
$develNb.nn insert end pixmaps -text "Pixmaps"
$develNb.nn insert end svn -text "Svn"
#$develNb.nn insert end config -text "[trans config]"
$develNb.nn insert end console -text "Console"
$develNb.nn insert end logs -text "Logs"
$develNb.nn insert end about -text "[trans about]"
# .------.
# _| list |_____________
set frm [ $develNb.nn getframe varlist]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frm [ $frm.sw.sf getframe ]
::devel::buildFormList $frm
$develNb.nn compute_size
#[$develNb.nn getframe varlist].sw.sf compute_size
#[$develNb.nn getframe varlist] compute_size
## .--------.
## _| search |______
#set frm [$develNb.nn getframe varsearch]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frm [ $frm.sw.sf getframe ]
#::devel::buildFormSearch $frm
#$develNb.nn compute_size
#[$develNb.nn getframe varsearch ].sw.sf compute_size
# .---------.
# _| procs |____________
set frm [$develNb.nn getframe procs]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frame [ $frm.sw.sf getframe ]
::devel::buildProcs $frm
#$develNb.nn compute_size
#[$develNb.nn getframe procs ].sw.sf compute_size
## mem
set frm [$develNb.nn getframe memstats]
ScrolledWindow $frm.sw
ScrollableFrame $frm.sw.sf -constrainedwidth 1
$frm.sw setwidget $frm.sw.sf
pack $frm.sw -anchor n -side top -expand true -fill both
set frame [ $frm.sw.sf getframe ]
::devel::buildMemStats $frame
$develNb.nn compute_size
[$develNb.nn getframe memstats ].sw.sf compute_size
# .-----------.
# _| plugins |_________
set frm [$develNb.nn getframe plugins]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frm [ $frm.sw.sf getframe ]
::devel::plugins $frm
#$develNb.nn compute_size
#[$develNb.nn getframe plugins].sw.sf compute_size
# .-----.
# _| svn |_____
set frm [$develNb.nn getframe svn]
ScrolledWindow $frm.sw
ScrollableFrame $frm.sw.sf -constrainedwidth 1
$frm.sw setwidget $frm.sw.sf
pack $frm.sw -anchor n -side top -expand true -fill both
set frm [ $frm.sw.sf getframe ]
::devel::svnGetVersion $frm
#pack [button $frm.b -command exit -text Exit]
#load_console
button $frm.svnuptbtn -text "[trans update] svn" -command "::devel::svnUpdate $frm"
text $frm.svntext
$develNb.nn compute_size
[$develNb.nn getframe svn].sw.sf compute_size
# .------.
# _| dock |___
set frm [$develNb.nn getframe dock]
ScrolledWindow $frm.sw
ScrollableFrame $frm.sw.sf -constrainedwidth 1
$frm.sw setwidget $frm.sw.sf
pack $frm.sw -anchor n -side top -expand true -fill both
set frm [ $frm.sw.sf getframe ]
::devel::dock $frm
$develNb.nn compute_size
[$develNb.nn getframe dock].sw.sf compute_size
# .----------.
# _| packages |___
set frm [$develNb.nn getframe packages]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frm [ $frm.sw.sf getframe ]
::devel::packages $frm
#$develNb.nn compute_size
#[$develNb.nn getframe packages].sw.sf compute_size
# .----------.
# _| images |___
set frm [$develNb.nn getframe images]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frm [ $frm.sw.sf getframe ]
::devel::images $frm
#$develNb.nn compute_size
#[$develNb.nn getframe packages].sw.sf compute_size
# .----------.
# _| pixmap |___
set frm [$develNb.nn getframe pixmaps]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frm [ $frm.sw.sf getframe ]
::devel::pixmaps $frm
#$develNb.nn compute_size
#[$develNb.nn getframe packages].sw.sf compute_size
# .--------.
# _| console |____
set frm [$develNb.nn getframe console]
ScrolledWindow $frm.sw
ScrollableFrame $frm.sw.sf -constrainedwidth 1
$frm.sw setwidget $frm.sw.sf
pack $frm.sw -anchor n -side top -expand true -fill both
set frm [ $frm.sw.sf getframe ]
::devel::console $frm
$develNb.nn compute_size
[$develNb.nn getframe console].sw.sf compute_size
# .--------.
# _| logs |____
set frm [$develNb.nn getframe logs]
ScrolledWindow $frm.sw
ScrollableFrame $frm.sw.sf -constrainedwidth 1
$frm.sw setwidget $frm.sw.sf
pack $frm.sw -anchor n -side top -expand true -fill both
set frm [ $frm.sw.sf getframe ]
::devel::logs $frm
$develNb.nn compute_size
[$develNb.nn getframe logs].sw.sf compute_size
## .--------.
## _| config |____
#set frm [$develNb.nn getframe config]
#ScrolledWindow $frm.sw
#ScrollableFrame $frm.sw.sf -constrainedwidth 1
#$frm.sw setwidget $frm.sw.sf
#pack $frm.sw -anchor n -side top -expand true -fill both
#set frm [ $frm.sw.sf getframe ]
#::devel::config $frm
#$develNb.nn compute_size
#[$develNb.nn getframe config].sw.sf compute_size
# .--------.
# _| about |____
set frm [$develNb.nn getframe about]
ScrolledWindow $frm.sw
ScrollableFrame $frm.sw.sf -constrainedwidth 1
$frm.sw setwidget $frm.sw.sf
pack $frm.sw -anchor n -side top -expand true -fill both
set frm [ $frm.sw.sf getframe ]
::devel::about $frm
$develNb.nn compute_size
[$develNb.nn getframe about].sw.sf compute_size
####
set frm [ frame $develwin.save -class Degt ]
#button $frm.save -text [trans save] -default active -command "::devel::savePrefs; destroy $develwin"
#button $frm.cancel -text [trans close] -command "destroy $develwin"
button $frm.close -text [trans close] -default active -command "destroy $develwin"
#pack $frm.save $frm.cancel -side right -padx 10 -pady 10
pack $frm.close -side right -padx 10 -pady 10
pack $frm -side bottom -fill x
# fin, compactage
$develNb.nn raise varlist
pack $develNb.nn -expand true -fill both
pack $develwin.nb -side bottom -fill both -expand true -padx 5 -pady 5
bind $develwin <<Escape>> "destroy $develwin"
}
#####################################################################
#
# VAR
#
#
#####################################################################
proc buildFormList { win } {
#set frm [ frame $win.list ]
#
#foreach { key } [ lsort [ ::config::getKeys ] ] {
# set frame [frame $frm.f$key]
# ::devel::drawKeyVal $frame $key
#}
#pack $frm -side top -fill both -expand true
entry $win.texte -bg white -textvariable defaultSearch
entry $win.var -bg white
#label $win.textl -text "var :"
#button $win.btn -text "Search" -command ""
#pack $win.texte -side top -anchor nw -fill y
#pack $win.var -side top -anchor center -fill y
pack $win.texte -side top -anchor nw -fill both
pack $win.var -side top -anchor nw -fill both
pack $win -fill y
#pack $win.texte $win.btn -side top -anchor nw
bind $win.texte <KeyRelease> "::devel::updateVarSearch %A %W $win"
#pack $win.texte $win.textl $win.btn
listbox $win.l -listvariable listVar -font splainf -bg white -bg white \
-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
pack $win.l -side left
scrollbar $win.listbox_scroll -command "$win.l yview" -width 16 -highlightthickness 0
pack $win.listbox_scroll -side left -fill y
#bind $win.l <Double-B1-ButtonRelease> "::devel::setCommandValue $win [::config::getKey [.develwin.nb.nn.fvarlist.sw.sf.frame.l get active]]"
#bind $win.l <Double-B1-ButtonRelease> "::devel::onDoubleClick $win"
bind $win.l <Double-B1-ButtonRelease> "::devel::onDoubleClick $win"
# Draw the text widget.
text $win.t -yscrollcommand "$win.scroll set" \
-width 70 -height 100 -wrap word -font splainf -highlightthickness 0
#-width 70 -height 100 -wrap word -font LucidaGrande -highlightthickness 0
scrollbar $win.scroll -command "$win.t yview" -width 16
pack $win.scroll -side right -fill y
pack $win.t -expand yes -fill both
#bind $w.t <Double-B1-ButtonRelease> {::acv::editCommandValue [.acvWindow.l get active]}
# Set up the view in the listbox and text widget.
#log "win: $win"
setCommandValue $win "Please choose a variable from the list on the left."
#setCommandsList $win [lsort -dictionary [info procs "::*"]]
setCommandsList $win [lsort -dictionary [::config::getKeys]]
}
proc updateVarSearch { char w win } {
$win.l delete 1 end
set char [$win.texte get]
log "updateVarSearch: $win"
setCommandsList $win [lsort -dictionary [::devel::getVar "$char"]]
}
proc onDoubleClick { win } {
::devel::setCommandValue $win [::config::getKey [$win.l get active]]
}
################################################################
# ::acv::_alternate.listbox.colors(listWin, colList)
# Taken from: http://wiki.tcl.tk/9561
# Gives an alternating row background to a listbox.
# Arguments:
# - listWin => The path to the list item.
# - colList => A list with the colors to alternate between.
proc _alternate.listbox.colors {listWin color} {
#if {![winfo exists $listWin]} {
# return -code error {invalid window path}
#}
set listWinEnd [$listWin index end]
#set colCount 0
#set colListLength [llength $colList]
#for {set i 0} {$i < $listWinEnd} {incr i} {
# $listWin itemconfigure $i -background [lindex $colList $colCount]
# incr colCount
# if {$colCount >= $colListLength} {
# set colCount 0
# }
#}
for {set i 0} {$i < $listWinEnd} {set i [expr {$i+2}]} {
$listWin itemconfigure $i -background $color
}
}
################################################################
# ::acv::_updateReadOnlyTextBox(textItemPath, newText)
# Updates a read only text box item.
# Arguments:
# - textItemPath => The path to the text box item.
# - newText => The text to replace the current text with.
proc _updateReadOnlyTextBox {textItemPath newText} {
${textItemPath} configure -state normal
${textItemPath} delete 1.0 end
${textItemPath} insert end $newText
${textItemPath} configure -state disabled
}
################################################################
# ::acv::_updateAlternatingList(listItemPath, newItems)
# Helper function to update an alternating list box.
# Arguments:
# - listItemPath => The path to the list box item.
# - newItems => A list of new items to set as the contents of the list item.
proc _updateAlternatingList {listItemPath newItems color} {
#log "_updateAlternatingList $listItemPath :: $newItems"
${listItemPath} delete 0 end
foreach {item} $newItems {
${listItemPath} insert end $item
#log "_updateAlternatingList2: ${listItemPath} insert end $item"
}
#_alternate.listbox.colors ${listItemPath} [list white #edf3fe]
if { $color == 1} {
_alternate.listbox.colors ${listItemPath} "#edf3fe"
}
}
################################################################
# ::acv::setCommandValue(newDescription)
# Set the value of the text box to newDescription.
# Arguments:
# - newDescription => A string with the value of the current command.
proc setCommandValue {win newDescription} {
#upvar 1 win $win
_updateReadOnlyTextBox $win.t $newDescription
}
################################################################
# ::acv::setCommandsList(newList)
# Set the commands list box to the value of newList.
# Arguments:
# - newList => A list with the new values to set in the available commands list.
proc setCommandsList { win newList {color 1}} {
#log "setCommandsList: $win :: $newList"
#upvar 1 win $win
_updateAlternatingList $win.l $newList $color
}
#####################################################################
#
# Search vars
#
#
#####################################################################
#proc buildFormSearch { win } {
# set frm [ frame $win.search]
# set frmb [frame $win.box]
# set defaultSearch "*"
# entry $frm.texte -bg white -textvariable defaultSearch
# label $frm.textl -text "var :"
# button $frm.btn -text "Search" -command [list ::devel::searchFor "$frm.texte" "$frmb.box"]
# # todo: faire en sorte que quand on appuie sur enter ça lance la recherche
# #bind $frm.textl <Return> [list ::devel::searchFor "$frm.texte" "$frmb.box" ]
# bind $frm.texte <Return> [list ::devel::searchFor "$frm.texte" "$frmb.box"]
# pack $frm.textl -anchor w -side left -padx 40
# pack $frm.texte -anchor w -side left -fill x
# pack $frm.btn -anchor w -side left -fill x
# pack $frm -fill x
# # result list box
# listbox $frmb.box -background white -yscrollcommand "$frmb.scroll set"
# scrollbar $frmb.scroll -command "$frmb.box yview" -borderwidth 1
# pack $frmb.box -side left -anchor w -pady 0 -padx 0 -expand true -fill both
# pack $frmb.scroll -side left -anchor w -pady 0 -padx 0 -fill y
# pack $frmb -side top -expand true -fill x
# # variable edit box
# # partie en dessous, qui permettera de modifier la var
# set frmr [ frame $win.res ]
# label $frmr.textl
# entry $frmr.texte -bg white
# pack $frmr.textl -anchor w -side left
# pack $frmr.texte -anchor w -side left -fill x
# pack $frmr
#
# bind $frmb.box <Double-1> [list ::devel::searchShowVar $frmb.box $frmr]
#}
#proc searchShowVar { lb res } {
# $res.textl configure -text [$lb get [$lb curselection]]
# $res.texte configure -textvariable [::config::getVar [$lb get [$lb curselection]]]
#}
proc getKey { key } {
return [ array get ::config "*$key*" ]
}
proc getVar { key } {
log "looking for $key"
return [ array names ::config "*$key*" ]
}
proc drawKeyVal { win key } {
label $win.varl -text $key
entry $win.vare -textvariable [::config::getVar $key] -bg white
pack $win.varl -anchor w -side left -padx 40
pack $win.vare -anchor w -side left -fill x
pack $win -fill x
}
proc searchFor { search lb } {
variable develwin
set i 0
set search [$search get]
$lb delete 0 [$lb size]
foreach { key } [ lsort [::devel::getVar $search]] {
incr i
$lb insert end $key
}
}
#####################################################################
#
# Procs
#
#
#####################################################################
proc buildProcs { win } {
variable namespaces
variable procs
entry $win.texte -bg white
pack $win.texte -side top -anchor nw -fill both
bind $win.texte <KeyRelease> "::devel::updateProcSearch %A %W $win"
listbox $win.l -listvariable listProc -font splainf -bg white \
-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
#-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
pack $win.l -side left
scrollbar $win.listbox_scroll -command "$win.l yview" -width 16 -highlightthickness 0
pack $win.listbox_scroll -side left -fill y
bind $win.l <Double-B1-ButtonRelease> "::devel::onProcDoubleClick $win"
# Draw the text widget.
text $win.t -background white -yscrollcommand "$win.scroll set" \
-width 70 -height 100 -wrap word -font splainf -highlightthickness 0
#-width 70 -height 100 -wrap word -font LucidaGrande -highlightthickness 0
scrollbar $win.scroll -command "$win.t yview" -width 16
pack $win.scroll -side right -fill y
pack $win.t -expand yes -fill both
# Set up the view in the listbox and text widget.
#log "win: $win"
setCommandValue $win "Please choose a proc from the list on the left."
#setCommandsList $win [lsort -dictionary [info procs "::*"]]
log "setting procs in list"
setCommandsList $win $procs 0
log "procs in list"
}
proc updateProcSearch { char w win } {
variable procs
$win.l delete 1 end
set char [$win.texte get]
#log "updateVarSearch: $win"
setCommandsList $win [lsearch -all -inline $procs "*$char*"]
}
proc onProcDoubleClick { win } {
set proc1 [$win.l get active]
set txt "proc $proc1 { [info args $proc1] } {[info body $proc1]}"
::devel::setCommandValue $win $txt
}
#####################################################################
#
# Mem stats
#
#
#####################################################################
proc buildMemStats { win } {
global tcl_platform tk_patchLevel tcl_patchLevel
set frm [ frame $win.sysamsn ]
label $frm.tcl -text "aMSN version: "
label $frm.tclv -text "$::version from $::date"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.systcltk ]
label $frm.tcl -text "TCL/TK version: "
label $frm.tclv -text "$tcl_patchLevel $tk_patchLevel"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.systclplateforme ]
label $frm.tcl -text "Tcl platform: "
label $frm.tclv -text "[array get tcl_platform]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.statstclcmd ]
label $frm.tcl -text "Number of TCL Commands: "
label $frm.tclv -text "[llength [info commands ::* ]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.statstnr ]
label $frm.tcl -text " -> Number invoked: "
label $frm.tclv -text "[llength [info cmdcount ]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.statstglobals ]
label $frm.tcl -text "Nr of global vars: "
label $frm.tclv -text "[llength [info globals ::* ]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.statspackageload ]
label $frm.tcl -text "Packages loaded with 'load': "
label $frm.tclv -text "[llength [info loaded]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.statspackagerequire ]
label $frm.tcl -text "Packages loaded with package require: "
label $frm.tclv -text "[llength [package names]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.statsimg ]
label $frm.tcl -text "Number of images: "
label $frm.tclv -text "[llength [image names]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
#pixmaps
set frm [ frame $win.statspixmaps ]
label $frm.tcl -text "Loaded pixmaps: "
label $frm.tclv -text "[llength [array names ::skin::loaded_pixmaps]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.statstpix ]
label $frm.tcl -text "Pixmap names: "
label $frm.tclv -text "[llength [array names ::skin::pixmaps_names]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
set frm [ frame $win.imgnames ]
label $frm.tcl -text "Images names: "
label $frm.tclv -text "[llength [image names]]"
pack $frm.tcl -side left -anchor w -fill both
pack $frm.tclv -side left -anchor w
pack $frm -side top -expand true -fill x
}
#####################################################################
#
#
#
#
#####################################################################
proc plugins { win } {
# array that will hold information of plugins
variable plugins
# the variable that holds the path to the selection window
variable w
# list of all the loaded plugins
#variable loadedplugins
# array that holds info about currently selected plugin
variable selection
# the path to the frame where are displayed pieces of information for a plugin
variable mF
# clear the selection
set selection ""
# set the window path
set w $win
# update the information and list of plugins
::plugins::updatePluginsArray
# create window and give it it's title
#toplevel $w
#wm title $w [trans pluginselector]
#wm geometry $w 500x400
# create widgets
# listbox with all the plugins
listbox $w.plugin_list -background "white" -height 15 -yscrollcommand "$w.ys set" -relief flat -highlightthickness 0
scrollbar $w.ys -command "$w.plugin_list yview"
#Scrollableframe that will contain pieces of information about a plugin
ScrolledWindow $w.sw
ScrollableFrame $w.sw.sf -areaheight 0 -areawidth 0
$w.sw setwidget $w.sw.sf
set mF [$w.sw.sf getframe]
# holds the plugins info like name and description
label $mF.name_title -text [trans name] -font sboldf
label $mF.name -wraplength 280
label $mF.version_title -text [trans version] -font sboldf
label $mF.version
label $mF.author_title -text [trans author] -font sboldf
label $mF.author -wraplength 280
label $mF.desc_title -text [trans description] -font sboldf
# TODO make the -wraplength fit the label's width
label $mF.desc -wraplength 280 -justify left -anchor w
# holds the 'command center' buttons
label $w.getmore -text "[trans getmoreplugins]" -fg #0000FF
button $w.load -text "[trans load]" -command "::plugins::GUI_Load" -state disabled
button $w.config -text "[trans configure]" -command "::plugins::GUI_Config" ;#-state disabled
button $w.close -text [trans close] -command "::plugins::GUI_Close"
#loop through all the plugins and add them to the list
foreach {plugin} [lsort -dictionary [array names ::plugins::plugins *_name]] {
set name $::plugins::plugins(${plugin})
# add the plugin name to the list at counterid position
$w.plugin_list insert end $name
# if the plugin is loaded, color it one color. otherwise use other colors
#TODO: Why not use skins?
if {[lsearch "$::plugins::loadedplugins" $::plugins::plugins(${name}_name)] != -1} {
$w.plugin_list itemconfigure end -background #DDF3FE
} else {
$w.plugin_list itemconfigure end -background #FFFFFF
}
}
if {[$w.plugin_list size] > "15"} {
$w.plugin_list configure -height [$w.plugin_list size]
}
#do the bindings
bind $w.plugin_list <<ListboxSelect>> "::devel::GUI_NewSel"
#bind $w <<Escape>> "::plugins::GUI_Close"
pack $w.plugin_list -fill both -side left
pack $w.ys -fill both -side left
pack $mF.name_title -padx 5 -anchor w
pack $mF.name -padx 5 -anchor w
pack $mF.version_title -padx 5 -anchor w
pack $mF.version -padx 5 -anchor w
pack $mF.author_title -padx 5 -anchor w
pack $mF.author -padx 5 -anchor w
pack $mF.desc_title -padx 5 -anchor w
pack $mF.desc -anchor nw -expand true -fill x -padx 5
pack $w.sw -anchor w -side top -expand true -fill both
pack $w.getmore -side top -anchor e -padx 5
bind $w.getmore <Enter> "$w.getmore configure -font sunderf"
bind $w.getmore <Leave> "$w.getmore configure -font splainf"
set lang [::config::getGlobalKey language]
bind $w.getmore <ButtonRelease> "launch_browser $::weburl/plugins.php?lang=$lang"
pack $w.close $w.config $w.load -padx 5 -pady 5 -side right -anchor se
}
proc GUI_NewSel { } {
# window path
variable w
# selection array
variable selection
# plugins' info
variable plugins
# the loaded plugins
#variable loadedplugins
#set loadedplugins $::plugins::loadedplugins
# the path to the frame where are displayed pieces of information for a plugin
variable mF
# find the id of the currently selected plugin
if { [ $w.plugin_list curselection ] == "" } {
return
}
set selection [$w.plugin_list get [$w.plugin_list curselection]]
# if the selection is empty, end proc
if { $selection == "" } {
return
}
# update the description
$mF.name configure -text $selection
$mF.author configure -text [::plugins::getInfo $selection author]
$mF.version configure -text [::plugins::getInfo $selection plugin_version]
$mF.desc configure -text [::plugins::getInfo $selection description]
# update the buttons
$w.config configure -state normal
if {[lsearch "$::plugins::loadedplugins" $selection] != -1 } {
# if the plugin is loaded, enable the Unload button and update the colors
$w.load configure -state normal -text [trans unload] -command "::plugins::GUI_Unload"
$w.plugin_list itemconfigure [$w.plugin_list curselection] -background #DDF3FE
# if the plugin has a configlist, then enable configuration.
# Otherwise disable it
if {[info exists ::[::plugins::getInfo $selection plugin_namespace]::configlist] == 1} {
$w.config configure -state normal
} else {
$w.config configure -state disabled
}
} else { # plugin is not loaded
# enable the load button and disable config button and update color
$w.load configure -state normal -text "[trans load]" -command "::plugins::GUI_Load"
$w.plugin_list itemconfigure [$w.plugin_list curselection] -background #FFFFFF
$w.config configure -state disabled
}
}
proc UpdateAllPlugins {} {
foreach { plugin } [ ::plugins::getPlugins ] {
::plugins::UpdatePlugin $plugin
}
}
#####################################################################
#
# dock
#
#
#####################################################################
proc dock { win } {
set win [ frame $win.dock ]
label $win.txt -text "Enable dock :"
button $win.loaddock -text "[trans load]" -command "init_dock"
label $win.txt2 -text "Disable dock :"
button $win.closedock -text "[trans unload]" -command "close_dock"
pack $win.txt $win.loaddock -padx 10 -side left -anchor nw
pack $win.txt2 $win.closedock -padx 10 -side left -anchor nw
pack $win -side left -expand true -fill both
}
#####################################################################
#
# packages
# resquested by Billiob
#
#####################################################################
proc packages { win } {
listbox $win.l -font splainf -bg white \
-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
#-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
pack $win.l -side left
scrollbar $win.listbox_scroll -command "$win.l yview" -width 16 -highlightthickness 0
pack $win.listbox_scroll -side left -fill y
#bind $win.l <Double-B1-ButtonRelease> "::devel::onProcDoubleClick $win"
bind $win.l <Double-B1-ButtonRelease> "::devel::onPackDoubleClick $win"
# Draw the text widget.
text $win.t -yscrollcommand "$win.scroll set" \
-width 70 -height 100 -wrap word -font splainf -highlightthickness 0
#-width 70 -height 100 -wrap word -font LucidaGrande -highlightthickness 0
scrollbar $win.scroll -command "$win.t yview" -width 16
pack $win.scroll -side right -fill y
pack $win.t -expand yes -fill both
# Set up the view in the listbox and text widget.
setCommandValue $win "Please choose a package from the list on the left."
setCommandsList $win [lsort -dictionary [package names]]
}
proc onPackDoubleClick { win } {
variable packloaded
set pack1 [$win.l get active]
#log "pack is $pack1"
set loaded "Not Loaded"
if { [lsearch $packloaded [string tolower $pack1]] != -1 } {
set loaded "Loaded"
}
set version [package versions $pack1]
set txt "$pack1 $version $loaded"
::devel::setCommandValue $win $txt
}
#####################################################################
#
# Images
# resquested by Billiob
#
#####################################################################
proc images { win } {
listbox $win.l -font splainf -bg white \
-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
#-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
pack $win.l -side left
scrollbar $win.listbox_scroll -command "$win.l yview" -width 16 -highlightthickness 0
pack $win.listbox_scroll -side left -fill y
#bind $win.l <Double-B1-ButtonRelease> "::devel::onProcDoubleClick $win"
bind $win.l <Double-B1-ButtonRelease> "::devel::onPixDoubleClick $win"
# Draw the text widget.
label $win.t -width 70 -height 100 -highlightthickness 0
#-width 70 -height 100 -wrap word -font LucidaGrande -highlightthickness 0
scrollbar $win.scroll -command "$win.t yview" -width 16
pack $win.scroll -side right -fill y
pack $win.t -expand yes -fill both
# Set up the view in the listbox and text widget.
#setCommandValue $win "Please choose an image from the list on the left."
setCommandsList $win [lsort -dictionary [image names]]
}
proc onPixDoubleClick { win } {
set img [$win.l get active]
set txt "$img"
::devel::setImgValue $win $txt
}
################################################################
# ::acv::_updateReadOnlyTextBox(textItemPath, newText)
# Updates a read only text box item.
# Arguments:
# - textItemPath => The path to the text box item.
# - newText => The text to replace the current text with.
proc _updateImg {textItemPath newText} {
${textItemPath} configure -state normal
${textItemPath} configure -image $newText
}
################################################################
# ::acv::setCommandValue(newDescription)
# Set the value of the text box to newDescription.
# Arguments:
# - newDescription => A string with the value of the current command.
proc setImgValue {win newDescription} {
#upvar 1 win $win
_updateImg $win.t $newDescription
}
#####################################################################
#
# Pixmap
# resquested by Billiob
#
#####################################################################
proc pixmaps { win } {
listbox $win.l -font splainf -bg white \
-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
#-height 90 -width 30 -yscrollcommand "$win.listbox_scroll set"
pack $win.l -side left
scrollbar $win.listbox_scroll -command "$win.l yview" -width 16 -highlightthickness 0
pack $win.listbox_scroll -side left -fill y
#bind $win.l <Double-B1-ButtonRelease> "::devel::onProcDoubleClick $win"
bind $win.l <Double-B1-ButtonRelease> "::devel::onImgDoubleClick $win"
# Draw the text widget.
label $win.t -width 70 -height 100 -highlightthickness 0
#-width 70 -height 100 -wrap word -font LucidaGrande -highlightthickness 0
scrollbar $win.scroll -command "$win.t yview" -width 16
pack $win.scroll -side right -fill y
pack $win.t -expand yes -fill both
# Set up the view in the listbox and text widget.
#setCommandValue $win "Please choose an image from the list on the left."
setCommandsList $win [lsort -dictionary [array names ::skin::loaded_pixmaps]]
}
proc onImgDoubleClick { win } {
set img [$win.l get active]
set txt [::skin::loadPixmap $img]
::devel::setImgValue $win $txt
}
#####################################################################
#
#
#
#
#####################################################################
proc svnGetVersion { win } {
global program_dir
#status_log "devel: program_dir is $program_dir"
set data "Unable to fetch data"
catch { set data [ exec svn info $program_dir ] } svnerr
label $win.svninfot -text "Svn version: "
label $win.svninfov -text "$data"
pack $win.svninfot $win.svninfov -side top -anchor nw
pack $win -side top -expand true -fill both
}
proc svnUpdate { win } {
set svn [open "| svn co https://svn.sourceforge.net/svnroot/amsn/trunk/amsn" r]
fileevent $svn readable "::devel::getinput $if $win"
}
proc getinput {channel win} {
$win.svntext insert end [gets $channel]
}
#####################################################################
#
# config
#
#
#####################################################################
#proc config { win } {
# button $win.genProc -text "[trans genproc]" -command "::devel::generateProcList $win"
# button $win.genPack -text "[trans genpack]" -command "::devel::generatePackageList $win"
# label $win.status -text "[trans status]"
# pack $win.genProc
# pack $win.genPack
# pack $win.status
# pack $win
#}
proc generatePackageList { win } {
variable packloaded
set $packloaded [list]
foreach {packa} [lsort -dictionary [info loaded]] {
lappend packloaded [string tolower [lindex $packa 1]]
}
}
proc generateProcList { win } {
variable procs
set procs [list]
#set namespaces [list]
#lappend namespaces "::"
#foreach {n} [namespace children "::"] {
# lappend namespaces $n
# #log "get namespace $n"
# #lappend namespaces [recursiveNamespace $n]
#}
#log "getting procs ::"
foreach {p} [lsort -dictionary [info procs "::*"]] {
if { $win != "" } {
$win.status configure -text "status: $p"
}
lappend procs $p
}
#log "getting namespace childrens"
foreach {n} [lsort -dictionary [namespace children "::"]] {
#log "getting proc for namespace $n"
foreach {p} [lsort -dictionary [info procs "${n}::*"]] {
lappend procs $p
if { $win != "" } {
$win.status configure -text "status: $p"
}
}
}
if { $win != "" } {
$win.status configure -text "status: done"
}
#log "procs done"
#set procs [lsort -dictionary $procs]
#foreach {p} {
# if { $p != "" } {
# #log "checking $p"
# foreach {pr} [info procs "${p}::*"] {
# #lappend procs [info procs "${p}::*"]
# lappend procs $pr
# }
# } else {
# log "Oops: get empty namespace ?!"
# }
#}
#log "procs: $procs"
}
proc console { win } {
# variable console
# log "win is $win"
# global tk_library
# #interp delete
# set consoleInterp [interp create $console]
# $consoleInterp eval [list set tk_library $tk_library]
# $consoleInterp alias exit exit
# load "" Tk $consoleInterp
#
# if {[package vsatisfies [package provide Tk] 4]} {
# $consoleInterp alias interp consoleinterp
# } else {
# $consoleInterp alias consoleinterp consoleinterp
# }
# ## 4. Bind the <Destroy> event of the application interpreter's main
# ## window to kill the console (via tkConsoleExit)
# #bind . <Destroy> [list +if {[string match . %W]} [list catch \
# # [list $consoleInterp eval tkConsoleExit]]]
# #
# ## 5. Redefine the Tcl command 'puts' in the application interpreter
# ## so that messages to stdout and stderr appear in the console.
# ## 6. No matter what Tk_Main says, insist that this is an interactive shell
# #set tcl_interactive 1
# #########################################################################
# ## Evaluate the Tk library script console.tcl in the console interpreter
# #########################################################################
# ##$consoleInterp eval source [list [file join $tk_library console.tcl]]
# #$consoleInterp eval {
# # if {![llength [info commands tkConsoleExit]]} {
# # tk::unsupported::ExposePrivateCommand tkConsoleExit
# # }
# #}
# #$consoleInterp eval {
# # if {![llength [info commands tkConsoleOutput]]} {
# # tk::unsupported::ExposePrivateCommand tkConsoleOutput
# # }
# #}
# #if {[string match 8.3.4 $tk_patchLevel]} {
# # # Workaround bug in first draft of the tkcon enhancments
# # $consoleInterp eval {
# # bind Console <Control-Key-v> {}
# # }
# #}
# ## Restore normal [puts] if console widget goes away...
# #$consoleInterp alias Oc_RestorePuts Oc_RestorePuts $consoleInterp
# #$consoleInterp eval {
# # bind Console <Destroy> +Oc_RestorePuts
# #}
# #
# #unset consoleInterp
#
}
#proc console {consoleInterp win sub {optarg {}}} [subst -nocommands {
# switch -exact -- \$sub {
# title {
# $consoleInterp eval wm title . [list \$optarg]
# }
# hide {
# $consoleInterp eval wm withdraw .
# }
# show {
# $consoleInterp eval wm deiconify .
# }
# eval {
# $consoleInterp eval \$optarg
# }
# default {
# error "bad option \\\"\$sub\\\": should be hide, show, or title"
# }
# }
# }]
proc logs { win } {
}
#####################################################################
#
# About
#
#
#####################################################################
proc about { win } {
label $win.warn1 -text "Warning, you can modify EVERY amsn's var."
label $win.warn2 -text "This can damage your amsn's installation"
label $win.warn3 -text "Use with caution.\n\n"
label $win.about1 -text "Plugin written by Yoda-BZH"
label $win.about2 -text "yodabzh@gmail.com"
pack $win.warn1 $win.warn2 $win.warn3 $win.about1 $win.about2 -side top -anchor nw
pack $win -side top -expand true -fill both
}
#####################################################################
#
#
#
#
#####################################################################
proc log { txt } {
status_log "Devel: $txt"
plugins_log Devel "$txt"
}
}
|