##// END OF EJS Templates
hgk: use Ttk instead of plain Tk...
Andrew Shadura -
r17958:0f93bbe8 default
parent child Browse files
Show More
@@ -15,8 +15,43 b''
15 15 # The whole snipped is activated only under windows, mouse wheel
16 16 # bindings working already under MacOSX and Linux.
17 17
18 if {[catch {package require Ttk}]} {
19 # use a shim
20 namespace eval ttk {
21 proc style args {}
22
23 proc entry args {
24 eval [linsert $args 0 ::entry] -relief flat
25 }
26 }
27
28 interp alias {} ttk::button {} button
29 interp alias {} ttk::frame {} frame
30 interp alias {} ttk::label {} label
31 interp alias {} ttk::scrollbar {} scrollbar
32 interp alias {} ttk::optionMenu {} tk_optionMenu
33 } else {
34 proc ::ttk::optionMenu {w varName firstValue args} {
35 upvar #0 $varName var
36
37 if {![info exists var]} {
38 set var $firstValue
39 }
40 ttk::menubutton $w -textvariable $varName -menu $w.menu \
41 -direction flush
42 menu $w.menu -tearoff 0
43 $w.menu add radiobutton -label $firstValue -variable $varName
44 foreach i $args {
45 $w.menu add radiobutton -label $i -variable $varName
46 }
47 return $w.menu
48 }
49 }
50
18 51 if {[tk windowingsystem] eq "win32"} {
19 52
53 ttk::style theme use xpnative
54
20 55 set mw_classes [list Text Listbox Table TreeCtrl]
21 56 foreach class $mw_classes { bind $class <MouseWheel> {} }
22 57
@@ -72,6 +107,12 b' proc ::tk::MouseWheel {wFired X Y D {shi'
72 107 bind all <MouseWheel> [list ::tk::MouseWheel %W %X %Y %D 0]
73 108
74 109 # end of win32 section
110 } else {
111
112 if {[ttk::style theme use] eq "default"} {
113 ttk::style theme use clam
114 }
115
75 116 }
76 117
77 118
@@ -480,7 +521,7 b' proc error_popup msg {'
480 521 wm transient $w .
481 522 message $w.m -text $msg -justify center -aspect 400
482 523 pack $w.m -side top -fill x -padx 20 -pady 20
483 button $w.ok -text OK -command "destroy $w"
524 ttk::button $w.ok -text OK -command "destroy $w"
484 525 pack $w.ok -side bottom -fill x
485 526 bind $w <Visibility> "grab $w; focus $w"
486 527 tkwait window $w
@@ -526,11 +567,11 b' proc makewindow {} {'
526 567 set geometry(ctexth) [expr {($texth - 8) /
527 568 [font metrics $textfont -linespace]}]
528 569 }
529 frame .ctop.top
530 frame .ctop.top.bar
570 ttk::frame .ctop.top
571 ttk::frame .ctop.top.bar
531 572 pack .ctop.top.bar -side bottom -fill x
532 573 set cscroll .ctop.top.csb
533 scrollbar $cscroll -command {allcanvs yview} -highlightthickness 0
574 ttk::scrollbar $cscroll -command {allcanvs yview}
534 575 pack $cscroll -side right -fill y
535 576 panedwindow .ctop.top.clist -orient horizontal -sashpad 0 -handlesize 4
536 577 pack .ctop.top.clist -side top -fill both -expand 1
@@ -557,7 +598,7 b' proc makewindow {} {'
557 598 -command gotocommit -width 8
558 599 $sha1but conf -disabledforeground [$sha1but cget -foreground]
559 600 pack .ctop.top.bar.sha1label -side left
560 entry $sha1entry -width 40 -font $textfont -textvariable sha1string
601 ttk::entry $sha1entry -width 40 -font $textfont -textvariable sha1string
561 602 trace add variable sha1string write sha1change
562 603 pack $sha1entry -side left -pady 2
563 604
@@ -577,25 +618,25 b' proc makewindow {} {'
577 618 0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
578 619 0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
579 620 }
580 button .ctop.top.bar.leftbut -image bm-left -command goback \
621 ttk::button .ctop.top.bar.leftbut -image bm-left -command goback \
581 622 -state disabled -width 26
582 623 pack .ctop.top.bar.leftbut -side left -fill y
583 button .ctop.top.bar.rightbut -image bm-right -command goforw \
624 ttk::button .ctop.top.bar.rightbut -image bm-right -command goforw \
584 625 -state disabled -width 26
585 626 pack .ctop.top.bar.rightbut -side left -fill y
586 627
587 button .ctop.top.bar.findbut -text "Find" -command dofind
628 ttk::button .ctop.top.bar.findbut -text "Find" -command dofind
588 629 pack .ctop.top.bar.findbut -side left
589 630 set findstring {}
590 631 set fstring .ctop.top.bar.findstring
591 632 lappend entries $fstring
592 entry $fstring -width 30 -font $textfont -textvariable findstring
633 ttk::entry $fstring -width 30 -font $textfont -textvariable findstring
593 634 pack $fstring -side left -expand 1 -fill x
594 635 set findtype Exact
595 set findtypemenu [tk_optionMenu .ctop.top.bar.findtype \
636 set findtypemenu [ttk::optionMenu .ctop.top.bar.findtype \
596 637 findtype Exact IgnCase Regexp]
597 638 set findloc "All fields"
598 tk_optionMenu .ctop.top.bar.findloc findloc "All fields" Headline \
639 ttk::optionMenu .ctop.top.bar.findloc findloc "All fields" Headline \
599 640 Comments Author Committer Files Pickaxe
600 641 pack .ctop.top.bar.findloc -side right
601 642 pack .ctop.top.bar.findtype -side right
@@ -604,14 +645,14 b' proc makewindow {} {'
604 645
605 646 panedwindow .ctop.cdet -orient horizontal
606 647 .ctop add .ctop.cdet
607 frame .ctop.cdet.left
648 ttk::frame .ctop.cdet.left
608 649 set ctext .ctop.cdet.left.ctext
609 650 text $ctext -fg $fgcolor -bg $bgcolor -state disabled -font $textfont \
610 651 -width $geometry(ctextw) -height $geometry(ctexth) \
611 652 -yscrollcommand ".ctop.cdet.left.sb set" \
612 653 -xscrollcommand ".ctop.cdet.left.hb set" -wrap none
613 scrollbar .ctop.cdet.left.sb -command "$ctext yview"
614 scrollbar .ctop.cdet.left.hb -orient horizontal -command "$ctext xview"
654 ttk::scrollbar .ctop.cdet.left.sb -command "$ctext yview"
655 ttk::scrollbar .ctop.cdet.left.hb -orient horizontal -command "$ctext xview"
615 656 pack .ctop.cdet.left.sb -side right -fill y
616 657 pack .ctop.cdet.left.hb -side bottom -fill x
617 658 pack $ctext -side left -fill both -expand 1
@@ -643,12 +684,12 b' proc makewindow {} {'
643 684 $ctext tag conf found -back yellow
644 685 }
645 686
646 frame .ctop.cdet.right
687 ttk::frame .ctop.cdet.right
647 688 set cflist .ctop.cdet.right.cfiles
648 689 listbox $cflist -fg $fgcolor -bg $bgcolor \
649 690 -selectmode extended -width $geometry(cflistw) \
650 691 -yscrollcommand ".ctop.cdet.right.sb set"
651 scrollbar .ctop.cdet.right.sb -command "$cflist yview"
692 ttk::scrollbar .ctop.cdet.right.sb -command "$cflist yview"
652 693 pack .ctop.cdet.right.sb -side right -fill y
653 694 pack $cflist -side left -fill both -expand 1
654 695 .ctop.cdet add .ctop.cdet.right
@@ -901,7 +942,7 b' Copyright \xa9 2005 Paul Mackerras'
901 942 Use and redistribute under the terms of the GNU General Public License} \
902 943 -justify center -aspect 400
903 944 pack $w.m -side top -fill x -padx 20 -pady 20
904 button $w.ok -text Close -command "destroy $w"
945 ttk::button $w.ok -text Close -command "destroy $w"
905 946 pack $w.ok -side bottom
906 947 }
907 948
@@ -2417,8 +2458,7 b' proc selectline {l isnew} {'
2417 2458 set currentid $id
2418 2459 $sha1entry delete 0 end
2419 2460 $sha1entry insert 0 $id
2420 $sha1entry selection from 0
2421 $sha1entry selection to end
2461 $sha1entry selection range 0 end
2422 2462
2423 2463 $ctext conf -state normal
2424 2464 $ctext delete 0.0 end
@@ -3675,36 +3715,36 b' proc mkpatch {} {'
3675 3715 set patchtop $top
3676 3716 catch {destroy $top}
3677 3717 toplevel $top
3678 label $top.title -text "Generate patch"
3718 ttk::label $top.title -text "Generate patch"
3679 3719 grid $top.title - -pady 10
3680 label $top.from -text "From:"
3681 entry $top.fromsha1 -width 40 -relief flat
3720 ttk::label $top.from -text "From:"
3721 ttk::entry $top.fromsha1 -width 40
3682 3722 $top.fromsha1 insert 0 $oldid
3683 3723 $top.fromsha1 conf -state readonly
3684 3724 grid $top.from $top.fromsha1 -sticky w
3685 entry $top.fromhead -width 60 -relief flat
3725 ttk::entry $top.fromhead -width 60
3686 3726 $top.fromhead insert 0 $oldhead
3687 3727 $top.fromhead conf -state readonly
3688 3728 grid x $top.fromhead -sticky w
3689 label $top.to -text "To:"
3690 entry $top.tosha1 -width 40 -relief flat
3729 ttk::label $top.to -text "To:"
3730 ttk::entry $top.tosha1 -width 40
3691 3731 $top.tosha1 insert 0 $newid
3692 3732 $top.tosha1 conf -state readonly
3693 3733 grid $top.to $top.tosha1 -sticky w
3694 entry $top.tohead -width 60 -relief flat
3734 ttk::entry $top.tohead -width 60
3695 3735 $top.tohead insert 0 $newhead
3696 3736 $top.tohead conf -state readonly
3697 3737 grid x $top.tohead -sticky w
3698 button $top.rev -text "Reverse" -command mkpatchrev -padx 5
3738 ttk::button $top.rev -text "Reverse" -command mkpatchrev
3699 3739 grid $top.rev x -pady 10
3700 label $top.flab -text "Output file:"
3701 entry $top.fname -width 60
3740 ttk::label $top.flab -text "Output file:"
3741 ttk::entry $top.fname -width 60
3702 3742 $top.fname insert 0 [file normalize "patch$patchnum.patch"]
3703 3743 incr patchnum
3704 3744 grid $top.flab $top.fname -sticky w
3705 frame $top.buts
3706 button $top.buts.gen -text "Generate" -command mkpatchgo
3707 button $top.buts.can -text "Cancel" -command mkpatchcan
3745 ttk::frame $top.buts
3746 ttk::button $top.buts.gen -text "Generate" -command mkpatchgo
3747 ttk::button $top.buts.can -text "Cancel" -command mkpatchcan
3708 3748 grid $top.buts.gen $top.buts.can
3709 3749 grid columnconfigure $top.buts 0 -weight 1 -uniform a
3710 3750 grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -3755,23 +3795,23 b' proc mktag {} {'
3755 3795 set mktagtop $top
3756 3796 catch {destroy $top}
3757 3797 toplevel $top
3758 label $top.title -text "Create tag"
3798 ttk::label $top.title -text "Create tag"
3759 3799 grid $top.title - -pady 10
3760 label $top.id -text "ID:"
3761 entry $top.sha1 -width 40 -relief flat
3800 ttk::label $top.id -text "ID:"
3801 ttk::entry $top.sha1 -width 40
3762 3802 $top.sha1 insert 0 $rowmenuid
3763 3803 $top.sha1 conf -state readonly
3764 3804 grid $top.id $top.sha1 -sticky w
3765 entry $top.head -width 60 -relief flat
3805 ttk::entry $top.head -width 60
3766 3806 $top.head insert 0 [lindex $commitinfo($rowmenuid) 0]
3767 3807 $top.head conf -state readonly
3768 3808 grid x $top.head -sticky w
3769 label $top.tlab -text "Tag name:"
3770 entry $top.tag -width 60
3809 ttk::label $top.tlab -text "Tag name:"
3810 ttk::entry $top.tag -width 60
3771 3811 grid $top.tlab $top.tag -sticky w
3772 frame $top.buts
3773 button $top.buts.gen -text "Create" -command mktaggo
3774 button $top.buts.can -text "Cancel" -command mktagcan
3812 ttk::frame $top.buts
3813 ttk::button $top.buts.gen -text "Create" -command mktaggo
3814 ttk::button $top.buts.can -text "Cancel" -command mktagcan
3775 3815 grid $top.buts.gen $top.buts.can
3776 3816 grid columnconfigure $top.buts 0 -weight 1 -uniform a
3777 3817 grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -3835,27 +3875,27 b' proc writecommit {} {'
3835 3875 set wrcomtop $top
3836 3876 catch {destroy $top}
3837 3877 toplevel $top
3838 label $top.title -text "Write commit to file"
3878 ttk::label $top.title -text "Write commit to file"
3839 3879 grid $top.title - -pady 10
3840 label $top.id -text "ID:"
3841 entry $top.sha1 -width 40 -relief flat
3880 ttk::label $top.id -text "ID:"
3881 ttk::entry $top.sha1 -width 40
3842 3882 $top.sha1 insert 0 $rowmenuid
3843 3883 $top.sha1 conf -state readonly
3844 3884 grid $top.id $top.sha1 -sticky w
3845 entry $top.head -width 60 -relief flat
3885 ttk::entry $top.head -width 60
3846 3886 $top.head insert 0 [lindex $commitinfo($rowmenuid) 0]
3847 3887 $top.head conf -state readonly
3848 3888 grid x $top.head -sticky w
3849 label $top.clab -text "Command:"
3850 entry $top.cmd -width 60 -textvariable wrcomcmd
3889 ttk::label $top.clab -text "Command:"
3890 ttk::entry $top.cmd -width 60 -textvariable wrcomcmd
3851 3891 grid $top.clab $top.cmd -sticky w -pady 10
3852 label $top.flab -text "Output file:"
3853 entry $top.fname -width 60
3892 ttk::label $top.flab -text "Output file:"
3893 ttk::entry $top.fname -width 60
3854 3894 $top.fname insert 0 [file normalize "commit-[string range $rowmenuid 0 6]"]
3855 3895 grid $top.flab $top.fname -sticky w
3856 frame $top.buts
3857 button $top.buts.gen -text "Write" -command wrcomgo
3858 button $top.buts.can -text "Cancel" -command wrcomcan
3896 ttk::frame $top.buts
3897 ttk::button $top.buts.gen -text "Write" -command wrcomgo
3898 ttk::button $top.buts.can -text "Cancel" -command wrcomcan
3859 3899 grid $top.buts.gen $top.buts.can
3860 3900 grid columnconfigure $top.buts 0 -weight 1 -uniform a
3861 3901 grid columnconfigure $top.buts 1 -weight 1 -uniform a
General Comments 0
You need to be logged in to leave comments. Login now