【问题标题】:Dark theme for git guigit gui 的深色主题
【发布时间】:2018-09-30 19:39:56
【问题描述】:

几天前,我偶然发现了这张带有深色主题的 git gui 的图片。

我浏览了文档,搜索了它的菜单并询问了 DuckDuckGo,但到目前为止我还没有弄清楚如何更改主题。怎么办?

编辑:我使用深色主题的 Ubuntu 16.04。 Git gui 完成忽略了我的 DE 的主题设置,因此我无法想象它可能是相关的,as kowsky suggests below

【问题讨论】:

    标签: git git-gui


    【解决方案1】:

    我猜你是从here那里拍的?

    发布屏幕截图的用户声明

    [...] 我正在为我的 Windows 使用深色主题,[...]

    Git-GUI(主窗口)必须使用 Windows 原生颜色 [...]

    因此,我怀疑他通过相应地设置他的默认窗口颜色主题来实现这个“黑暗主题”。

    【讨论】:

    • 对不起,我没有提到我的系统 - 我没有想到它可能是相关的。
    • 我也在暗模式下使用 Windows。但是 Git Gui 对我来说仍然是白色的
    【解决方案2】:

    颜色是硬编码的,在名为choose_repository.tcl 的文件中定义。不确定 Ubuntu,但在 Windows 中它位于C:\Program Files\Git\mingw64\share\git-gui\lib\choose_repository.tcl。将颜色更改为您喜欢的颜色。我的这个补丁看起来像这样:


    
    @@ -91,17 +91,18 @@ constructor pick {} {
        ${NS}::frame $w_body
        text $opts \
            -cursor $::cursor_ptr \
            -relief flat \
            -background [get_bg_color $w_body] \
    +       -foreground lime \
            -wrap none \
            -spacing1 5 \
            -width 50 \
            -height 3
        pack $opts -anchor w -fill x
    
    -   $opts tag conf link_new -foreground blue -underline 1
    +   $opts tag conf link_new -underline 1
        $opts tag bind link_new <1> [cb _next new]
        $opts insert end [mc "Create New Repository"] link_new
        $opts insert end "\n"
        if {$m_repo ne {}} {
            $m_repo add command \
    @@ -110,11 +111,11 @@ constructor pick {} {
                -label [mc "New..."]
            bind $top <$M1B-n> [cb _next new]
            bind $top <$M1B-N> [cb _next new]
        }
    
    -   $opts tag conf link_clone -foreground blue -underline 1
    +   $opts tag conf link_clone -underline 1
        $opts tag bind link_clone <1> [cb _next clone]
        $opts insert end [mc "Clone Existing Repository"] link_clone
        $opts insert end "\n"
        if {$m_repo ne {}} {
            if {[tk windowingsystem] eq "win32"} {
    @@ -128,11 +129,11 @@ constructor pick {} {
                -label [mc "Clone..."]
            bind $top <$M1B-[string tolower $key]> [cb _next clone]
            bind $top <$M1B-[string toupper $key]> [cb _next clone]
        }
    
    -   $opts tag conf link_open -foreground blue -underline 1
    +   $opts tag conf link_open -underline 1
        $opts tag bind link_open <1> [cb _next open]
        $opts insert end [mc "Open Existing Repository"] link_open
        $opts insert end "\n"
        if {$m_repo ne {}} {
            $m_repo add command \
    @@ -169,12 +170,12 @@ constructor pick {} {
                -background [get_bg_color $w_body.recentlabel] \
                -wrap none \
                -width 50 \
                -height $lenrecent
            $w_recentlist tag conf link \
    -           -foreground blue \
    -           -underline 1
    +           -foreground yellow \
    +           -underline 0
            set home $::env(HOME)
            if {[is_Cygwin]} {
                set home [exec cygpath --windows --absolute $home]
            }
            set home "[file normalize $home]/"
    
    

    【讨论】:

    • 也许它位于/usr/share/git-gui/lib/choose_repository.tcl。至少,这是我的猜测。
    • 看起来我们很亲密。不幸的是,该补丁对choose_repository.tcl 失败了。此文件可能因版本而异(我使用的是 2.17.1)。你能提供更通用的东西吗?
    • @LuísdeSousa,你能找到那些台词吗?我添加了补丁以将您指向需要更改的行。该文件会随着时间而改变,但相关部分仍应与此差异中的部分相似
    • 我手工应用了这些线条。现在,初始屏幕中有几行以黄色表示。除了 GUI 看起来像以前一样。
    【解决方案3】:

    上面 Plakhoy 的回答显示了如何设置 choose_repository 页面的样式。要将应用程序的其余部分更改为暗模式,请遵循以下我的建议。我没有足够的声誉来发布图片,但您可以更改几行代码来为 Git Gui 启用暗模式。

    这将创建一个带有浅色(几乎是白色)文本的黑色背景。

    文件位置:C:\Program Files\Git\mingw64\share\git-gui\lib\themed.tcl

    themed.tcl 第 14-20 行原始设置(灯光模式)。

    proc sync_with_theme {} {  
        set base_bg             [ttk::style lookup . -background]  
        set base_fg             [ttk::style lookup . -foreground]  
        set text_bg             [ttk::style lookup Treeview -background]  
        set text_fg             [ttk::style lookup Treeview -foreground]  
        set select_bg           [ttk::style lookup Default -selectbackground]  
        set select_fg           [ttk::style lookup Default -selectforeground]  
    

    在themed.tcl 中将第14-20 行更改如下(暗模式)。

    proc sync_with_theme {} {  
        set base_bg             #282a36  
        set base_fg             #f8f8f2  
        set text_bg             #282a36  
        set text_fg             #f8f8f2  
        set select_bg           #f8f8f2  
        set select_fg           #282a36
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-12
      • 2020-03-17
      • 1970-01-01
      • 2017-11-16
      • 2019-05-10
      • 2013-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多