@matheusbsbs / matheus-bagliano / commits / a4bee59713
Fork 0

git-gui: Refactor some UI init to occur earlier

I'm starting to setup a main window that the user can use to locate an existing repository, clone an existing repository, or create a new repository from scratch. To help do that I want most of our common UI support already defined before we start to look for the Git repository, this way if it was not found we can open a window to help the user locate it. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Sep 21, 2007 at 03:41 UTC a4bee597134aee9883adba1e79be926a92f80367
1 file changed +94 -94
git-gui.sh
+94 -94
@@ -521,6 +521,99 @@ proc rmsel_tag {text} {
521 return $text
522 }
523
524 +set root_exists 0
525 +bind . <Visibility> {
526 + bind . <Visibility> {}
527 + set root_exists 1
528 +}
529 +
530 +######################################################################
531 +##
532 +## config defaults
533 +
534 +set cursor_ptr arrow
535 +font create font_diff -family Courier -size 10
536 +font create font_ui
537 +catch {
538 + label .dummy
539 + eval font configure font_ui [font actual [.dummy cget -font]]
540 + destroy .dummy
541 +}
542 +
543 +font create font_uiitalic
544 +font create font_uibold
545 +font create font_diffbold
546 +font create font_diffitalic
547 +
548 +foreach class {Button Checkbutton Entry Label
549 + Labelframe Listbox Menu Message
550 + Radiobutton Spinbox Text} {
551 + option add *$class.font font_ui
552 +}
553 +unset class
554 +
555 +if {[is_Windows] || [is_MacOSX]} {
556 + option add *Menu.tearOff 0
557 +}
558 +
559 +if {[is_MacOSX]} {
560 + set M1B M1
561 + set M1T Cmd
562 +} else {
563 + set M1B Control
564 + set M1T Ctrl
565 +}
566 +
567 +proc bind_button3 {w cmd} {
568 + bind $w <Any-Button-3> $cmd
569 + if {[is_MacOSX]} {
570 + # Mac OS X sends Button-2 on right click through three-button mouse,
571 + # or through trackpad right-clicking (two-finger touch + click).
572 + bind $w <Any-Button-2> $cmd
573 + bind $w <Control-Button-1> $cmd
574 + }
575 +}
576 +
577 +proc apply_config {} {
578 + global repo_config font_descs
579 +
580 + foreach option $font_descs {
581 + set name [lindex $option 0]
582 + set font [lindex $option 1]
583 + if {[catch {
584 + foreach {cn cv} $repo_config(gui.$name) {
585 + font configure $font $cn $cv -weight normal
586 + }
587 + } err]} {
588 + error_popup [strcat [mc "Invalid font specified in %s:" "gui.$name"] "\n\n$err"]
589 + }
590 + foreach {cn cv} [font configure $font] {
591 + font configure ${font}bold $cn $cv
592 + font configure ${font}italic $cn $cv
593 + }
594 + font configure ${font}bold -weight bold
595 + font configure ${font}italic -slant italic
596 + }
597 +}
598 +
599 +set default_config(merge.diffstat) true
600 +set default_config(merge.summary) false
601 +set default_config(merge.verbosity) 2
602 +set default_config(user.name) {}
603 +set default_config(user.email) {}
604 +
605 +set default_config(gui.matchtrackingbranch) false
606 +set default_config(gui.pruneduringfetch) false
607 +set default_config(gui.trustmtime) false
608 +set default_config(gui.diffcontext) 5
609 +set default_config(gui.newbranchtemplate) {}
610 +set default_config(gui.fontui) [font configure font_ui]
611 +set default_config(gui.fontdiff) [font configure font_diff]
612 +set font_descs {
613 + {fontui font_ui {mc "Main Font"}}
614 + {fontdiff font_diff {mc "Diff/Console Font"}}
615 +}
616 +
617 ######################################################################
618 ##
619 ## find git
@@ -1448,16 +1541,6 @@ unset i
1541 ##
1542 ## util
1543
1451 -proc bind_button3 {w cmd} {
1452 - bind $w <Any-Button-3> $cmd
1453 - if {[is_MacOSX]} {
1454 - # Mac OS X sends Button-2 on right click through three-button mouse,
1455 - # or through trackpad right-clicking (two-finger touch + click).
1456 - bind $w <Any-Button-2> $cmd
1457 - bind $w <Control-Button-1> $cmd
1458 - }
1459 -}
1460 -
1544 proc scrollbar2many {list mode args} {
1545 foreach w $list {eval $w $mode $args}
1546 }
@@ -1659,87 +1742,10 @@ proc add_range_to_selection {w x y} {
1742
1743 ######################################################################
1744 ##
1662 -## config defaults
1663 -
1664 -set cursor_ptr arrow
1665 -font create font_diff -family Courier -size 10
1666 -font create font_ui
1667 -catch {
1668 - label .dummy
1669 - eval font configure font_ui [font actual [.dummy cget -font]]
1670 - destroy .dummy
1671 -}
1672 -
1673 -font create font_uiitalic
1674 -font create font_uibold
1675 -font create font_diffbold
1676 -font create font_diffitalic
1677 -
1678 -foreach class {Button Checkbutton Entry Label
1679 - Labelframe Listbox Menu Message
1680 - Radiobutton Spinbox Text} {
1681 - option add *$class.font font_ui
1682 -}
1683 -unset class
1684 -
1685 -if {[is_Windows] || [is_MacOSX]} {
1686 - option add *Menu.tearOff 0
1687 -}
1688 -
1689 -if {[is_MacOSX]} {
1690 - set M1B M1
1691 - set M1T Cmd
1692 -} else {
1693 - set M1B Control
1694 - set M1T Ctrl
1695 -}
1696 -
1697 -proc apply_config {} {
1698 - global repo_config font_descs
1699 -
1700 - foreach option $font_descs {
1701 - set name [lindex $option 0]
1702 - set font [lindex $option 1]
1703 - if {[catch {
1704 - foreach {cn cv} $repo_config(gui.$name) {
1705 - font configure $font $cn $cv -weight normal
1706 - }
1707 - } err]} {
1708 - error_popup [strcat [mc "Invalid font specified in %s:" "gui.$name"] "\n\n$err"]
1709 - }
1710 - foreach {cn cv} [font configure $font] {
1711 - font configure ${font}bold $cn $cv
1712 - font configure ${font}italic $cn $cv
1713 - }
1714 - font configure ${font}bold -weight bold
1715 - font configure ${font}italic -slant italic
1716 - }
1717 -}
1718 -
1719 -set default_config(merge.diffstat) true
1720 -set default_config(merge.summary) false
1721 -set default_config(merge.verbosity) 2
1722 -set default_config(user.name) {}
1723 -set default_config(user.email) {}
1745 +## ui construction
1746
1725 -set default_config(gui.matchtrackingbranch) false
1726 -set default_config(gui.pruneduringfetch) false
1727 -set default_config(gui.trustmtime) false
1728 -set default_config(gui.diffcontext) 5
1729 -set default_config(gui.newbranchtemplate) {}
1730 -set default_config(gui.fontui) [font configure font_ui]
1731 -set default_config(gui.fontdiff) [font configure font_diff]
1732 -set font_descs {
1733 - {fontui font_ui {mc "Main Font"}}
1734 - {fontdiff font_diff {mc "Diff/Console Font"}}
1735 -}
1747 load_config 0
1748 apply_config
1738 -
1739 -######################################################################
1740 -##
1741 -## ui construction
1742 -
1749 set ui_comm {}
1750
1751 # -- Menu Bar
@@ -2039,12 +2045,6 @@ if {$browser ne {}} {
2045 }
2046 unset browser doc_path doc_url
2047
2042 -set root_exists 0
2043 -bind . <Visibility> {
2044 - bind . <Visibility> {}
2045 - set root_exists 1
2046 -}
2047 -
2048 # -- Standard bindings
2049 #
2050 wm protocol . WM_DELETE_WINDOW do_quit