如何在 Debian 10 中的 GTK 2 和 3 应用程序中获取传统滚动条?

如何在 Debian 10 中的 GTK 2 和 3 应用程序中获取传统滚动条?

我在 Debian 10 上使用 XFce4。

打开 GTK 2 应用程序时,滚动条显示正常,顶部和底部有一个大滚动条和箭头。

打开 GTK 3 应用程序时,滚动条很细,难以单击和查看,任何地方都没有箭头,有时甚至完全消失。

如果我选择像 Adwaita 或 Breeze 这样的主题,那么 GTK 2 应用程序将与 GTK 3 应用程序匹配,但使用难以使用和查看的滚动条。

有没有办法为 GTK 2 和 GTK 3 应用程序提供更传统的滚动条和更大的按钮?

答案1

GTK+2

我在 GTK+2 中的滚动条没有遇到任何问题。也许你使用的主题不遗余力地“损害”它们。尝试切换到不同的主题;我用GreenMotif例如。

为了减少更多愚蠢,请安装xcursor-themesDebian 软件包并运行:sudo update-alternatives --set x-cursor-theme /etc/X11/cursors/core.theme

Qt5

这似乎也很容易。确保它不使用 GTK 引擎或主题。我个人已经安装了qt5-style-plugin-motifDebian 软件包并使用它。

您可能需要kcminputrc_mouse_cursortheme=core~/.config/startupconfig其他地方进行设置。 GUI 设置对话框往往不显示core“主题”作为选项;您可以选择任何其他光标主题,然后在点文件中搜索出现的情况并全部更改(这就是我所做的)。

GTK+3

设计这个东西是永无休止的 PITA。我有记录了一种让 GTK+3 不那么难以忍受的方法通过修复滚动;我将在下面内联大部分答案,使用看起来非常像 Xfce4“基本”主题的主题,该主题似乎默认在 Debian Stretch 上使用。我建议仍然访问该代码片段,因为它有类似 Windows® 95 的替代方案和更多背景信息等,最重要的是,还有屏幕截图! ☺

~/.config/gtk-3.0/gtk2xfce4basic.css

使用以下内容创建此文件(或从上面的链接下载原始文件):

/*
 * to install, copy to ~/.config/gtk-3.0/gtk2xfce4basic.css
 * and append the line…
 *
 *  @import 'gtk2xfce4basic.css';
 *
 * to ~/.config/gtk-3.0/gtk.css
 */

/* somewhat unfuck GTK+3, by mirabilos, Ⓕ CC0 — theme Xfce basic */

/*-
 * append to ~/.xsessionrc or so, ~/.pam_environment or ~/.profile maybe
 *
 * GTK_OVERLAY_SCROLLING=0; export GTK_OVERLAY_SCROLLING
 *
 * merge into ~/.config/gtk-3.0/settings.ini
 *
 * [Settings]
 * gtk-xft-rgba=none
 * gtk-cursor-theme-name=core
 * gtk-enable-animations=0
 * gtk-primary-button-warps-slider=false
 *
 * Firefox about:config set: pref("widget.non-native-theme.enabled", false);
 * and consider a userContent.css to disable website-styled scroll“bar”s (see
 * https://edugit.org/-/snippets/31 for how).
 *
 * Try: GTK_DEBUG=interactive gtk3-demo
 */

/* remove dotted lines from GTK+3 applications */
.undershoot.top, .undershoot.right, .undershoot.bottom, .undershoot.left {
    background-image:none;
}
undershoot.top, undershoot.right, undershoot.bottom, undershoot.left {
    background-image:none;
}

/* force scrollbar arrows */
.scrollbar, scrollbar {
    -GtkScrollbar-has-backward-stepper:true !important;
    -GtkScrollbar-has-forward-stepper:true !important;
}

/* GTK+2-style scrollbar with Xfce basic theme colours {{{ */

scrollbar.horizontal, scrollbar.horizontal content,
scrollbar.horizontal button.up, scrollbar.horizontal button.up:disabled,
scrollbar.horizontal trough, scrollbar.horizontal slider,
scrollbar.horizontal button.down, scrollbar.horizontal button.down:disabled,
scrollbar.vertical, scrollbar.vertical content,
scrollbar.vertical button.up, scrollbar.vertical button.up:disabled,
scrollbar.vertical trough, scrollbar.vertical slider,
scrollbar.vertical button.down, scrollbar.vertical button.down:disabled {
    margin:0px;
    outline:0px;
    -gtk-outline-radius:0;
    border-radius:0px;
    border:0px;
    box-shadow:none;
    padding:0px;
    background-color:inherit;
}

scrollbar.horizontal button.up, scrollbar.horizontal button.up:disabled,
scrollbar.horizontal button.down, scrollbar.horizontal button.down:disabled,
scrollbar.vertical button.up, scrollbar.vertical button.up:disabled,
scrollbar.vertical button.down, scrollbar.vertical button.down:disabled {
    -gtk-icon-source:none;
}

scrollbar.horizontal {
    min-height:14px;
    box-shadow:
        inset 1px 1px 0 0 #8C8982,
        inset -1px -1px 0 0 #FBFBFA;
    padding:1px;
    background-color:#C4C2BD;
}

scrollbar.horizontal contents {
    min-height:14px;
}

scrollbar.horizontal button.up {
    min-width:11px;
    background:
        linear-gradient(to top right,    transparent 49.5%, #000000 50%) 5px 6px / 3px 3px,
        linear-gradient(to bottom right, transparent 49.5%, #000000 50%) 5px 4px / 3px 3px,
        linear-gradient(to top right,    transparent 49.5%, #434341 50%) 4px 6px / 4px 4px,
        linear-gradient(to bottom right, transparent 49.5%, #434341 50%) 4px 3px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.horizontal button.up:disabled {
    min-width:11px;
    background:
        linear-gradient(to top right,    transparent 49.5%, #757575 50%) 5px 6px / 3px 3px,
        linear-gradient(to bottom right, transparent 49.5%, #757575 50%) 5px 4px / 3px 3px,
        linear-gradient(to top right,    transparent 49.5%, #9D9D9D 50%) 4px 6px / 4px 4px,
        linear-gradient(to bottom right, transparent 49.5%, #959493 50%) 4px 3px / 4px 4px,
        linear-gradient(to top right,    transparent 49.5%, #FFFFFF 50%) 6px 7px / 3px 3px,
        linear-gradient(to bottom right, transparent 49.5%, #FFFFFF 50%) 6px 5px / 3px 3px,
        linear-gradient(to top right,    transparent 49.5%, #F0EFED 50%) 5px 7px / 4px 4px,
        linear-gradient(to bottom right, transparent 49.5%, #F0EFED 50%) 5px 4px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.horizontal trough {
    min-height:14px;
}

scrollbar.horizontal slider {
    min-width:18px;
}

scrollbar.horizontal button.down {
    min-width:11px;
    background:
        linear-gradient(to bottom left, transparent 49.5%, #000000 50%) 5px 4px / 3px 3px,
        linear-gradient(to top left,    transparent 49.5%, #000000 50%) 5px 6px / 3px 3px,
        linear-gradient(to bottom left, transparent 49.5%, #434341 50%) 5px 3px / 4px 4px,
        linear-gradient(to top left,    transparent 49.5%, #434341 50%) 5px 6px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.horizontal button.down:disabled {
    min-width:11px;
    background:
        linear-gradient(to bottom left, transparent 49.5%, #757575 50%) 5px 4px / 3px 3px,
        linear-gradient(to top left,    transparent 49.5%, #757575 50%) 5px 6px / 3px 3px,
        linear-gradient(to bottom left, transparent 49.5%, #959493 50%) 5px 3px / 4px 4px,
        linear-gradient(to top left,    transparent 49.5%, #9D9D9D 50%) 5px 6px / 4px 4px,
        linear-gradient(to bottom left, transparent 49.5%, #FFFFFF 50%) 6px 5px / 3px 3px,
        linear-gradient(to top left,    transparent 49.5%, #FFFFFF 50%) 6px 7px / 3px 3px,
        linear-gradient(to bottom left, transparent 49.5%, #F0EFED 50%) 6px 4px / 4px 4px,
        linear-gradient(to top left,    transparent 49.5%, #F0EFED 50%) 6px 7px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.horizontal button.up, scrollbar.horizontal button.up:disabled,
scrollbar.horizontal slider,
scrollbar.horizontal button.down, scrollbar.horizontal button.down:disabled {
    min-height:11px;
    box-shadow:
        inset -2px -2px 0 0 #9E9A91,
        inset 1px 1px 0 0 #FFFFFF,
        inset -1px -1px 0 0 #000000;
    /*      ↑   →   ↓   ←   */
    padding:1px 2px 2px 1px;
    background-color:#DCDAD5;
}

scrollbar.vertical {
    min-width:14px;
    box-shadow:
        inset 1px 1px 0 0 #8C8982,
        inset -1px -1px 0 0 #FBFBFA;
    padding:1px;
    background-color:#C4C2BD;
}

scrollbar.vertical contents {
    min-width:14px;
}

scrollbar.vertical button.up {
    min-height:11px;
    background:
        linear-gradient(to bottom right, transparent 49.5%, #000000 50%) 4px 5px / 3px 3px,
        linear-gradient(to bottom left,  transparent 49.5%, #000000 50%) 6px 5px / 3px 3px,
        linear-gradient(to bottom right, transparent 49.5%, #434341 50%) 3px 4px / 4px 4px,
        linear-gradient(to bottom left,  transparent 49.5%, #434341 50%) 6px 4px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.vertical button.up:disabled {
    min-height:11px;
    background:
        linear-gradient(to bottom right, transparent 49.5%, #757575 50%) 4px 5px / 3px 3px,
        linear-gradient(to bottom left,  transparent 49.5%, #757575 50%) 6px 5px / 3px 3px,
        linear-gradient(to bottom right, transparent 49.5%, #959493 50%) 3px 4px / 4px 4px,
        linear-gradient(to bottom left,  transparent 49.5%, #9D9D9D 50%) 6px 4px / 4px 4px,
        linear-gradient(to bottom right, transparent 49.5%, #FFFFFF 50%) 5px 6px / 3px 3px,
        linear-gradient(to bottom left,  transparent 49.5%, #FFFFFF 50%) 7px 6px / 3px 3px,
        linear-gradient(to bottom right, transparent 49.5%, #F0EFED 50%) 4px 5px / 4px 4px,
        linear-gradient(to bottom left,  transparent 49.5%, #F0EFED 50%) 7px 5px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.vertical trough {
    min-width:14px;
}

scrollbar.vertical slider {
    min-height:18px;
}

scrollbar.vertical button.down {
    min-height:11px;
    background:
        linear-gradient(to top left,  transparent 49.5%, #000000 50%) 6px 5px / 3px 3px,
        linear-gradient(to top right, transparent 49.5%, #000000 50%) 4px 5px / 3px 3px,
        linear-gradient(to top left,  transparent 49.5%, #434341 50%) 6px 5px / 4px 4px,
        linear-gradient(to top right, transparent 49.5%, #434341 50%) 3px 5px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.vertical button.down:disabled {
    min-height:11px;
    background:
        linear-gradient(to top left,  transparent 49.5%, #757575 50%) 6px 5px / 3px 3px,
        linear-gradient(to top right, transparent 49.5%, #757575 50%) 4px 5px / 3px 3px,
        linear-gradient(to top left,  transparent 49.5%, #9D9D9D 50%) 6px 5px / 4px 4px,
        linear-gradient(to top right, transparent 49.5%, #959493 50%) 3px 5px / 4px 4px,
        linear-gradient(to top left,  transparent 49.5%, #FFFFFF 50%) 7px 6px / 3px 3px,
        linear-gradient(to top right, transparent 49.5%, #FFFFFF 50%) 5px 6px / 3px 3px,
        linear-gradient(to top left,  transparent 49.5%, #F0EFED 50%) 7px 6px / 4px 4px,
        linear-gradient(to top right, transparent 49.5%, #F0EFED 50%) 4px 6px / 4px 4px;
    background-repeat:no-repeat;
}

scrollbar.vertical button.up, scrollbar.vertical button.up:disabled,
scrollbar.vertical slider,
scrollbar.vertical button.down, scrollbar.vertical button.down:disabled {
    min-width:11px;
    box-shadow:
        inset -2px -2px 0 0 #9E9A91,
        inset 1px 1px 0 0 #FFFFFF,
        inset -1px -1px 0 0 #000000;
    /*      ↑   →   ↓   ←   */
    padding:1px 2px 2px 1px;
    background-color:#DCDAD5;
}

/* }}} end of GTK+2-style scrollbar */

~/.config/gtk-3.0/gtk.css

添加以下行:

@import 'gtk2xfce4basic.css';

~/.config/gtk-3.0/settings.ini

将以下(或其他合适的)设置添加到该[Settings]部分:

gtk-xft-rgba=none     
gtk-cursor-theme-name=core   
gtk-enable-animations=0   
gtk-primary-button-warps-slider=false     

环境

确保GTK_OVERLAY_SCROLLING=0为您的 X11 会话进行设置。 (这通常可以通过将其放入 或以下内容来完成,具体~/.pam_environment取决于您的操作系统、初始化系统以及启动 X11 的方式;是~/.profile~/.xinitrc~/.xsessionrc~/.xsessionrc通常Debian 及其衍生产品上最简单的一个。)

GTK_OVERLAY_SCROLLING=0
export GTK_OVERLAY_SCROLLING

火狐浏览器

最近的版本使用 GTK+3 并坚持绘制自己的滚动条。因此,上述修复是不够的,您需要向 Firefox 添加额外的配置,然后它只能得到关闭,但每一点都有帮助……

about:config

pref("widget.non-native-theme.enabled", false);

userContent.css

将以下行放入您的userContent.css文件中:

* {
    scrollbar-color:unset !important;
    scrollbar-width:unset !important;
}

如果你没有这样的文件(完全,或工作)但是,你需要启用它第一的。这将为您提供 Twitter、StackExchange 等上可用的滚动条。 ☻

相关内容