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