Ubuntu + Eclipse 4.2 - 深色主题 - 如何使侧边栏背景变暗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12238773/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:17:46  来源:igfitidea点击:

Ubuntu + Eclipse 4.2 - Dark theme - How to darken sidebar backgrounds?

eclipseubuntunetbeansgtk

提问by KomodoDave

Due to spending 24/7 programming in front of a computer screen (job, thesis), it's beneficial to view dark colours as much as possible.

由于在计算机屏幕前进行 24/7 编程(作业、论文),因此尽可能多地查看深色是有益的。

Ubuntu's Ambiance theme can be neatly enhanced using Solancer's customisations, and Eclipse Juno looks mostly consistent after applying Roger Dudler's dark Juno theme.

Ubuntu 的 Ambiance 主题可以使用Solancer 的自定义来巧妙地增强,而 Eclipse Juno 在应用Roger Dudler 的深色 Juno 主题后看起来基本一致。

However, there is a problem with using a dark Juno theme like Dudler's. The background colour of (in)active elements within Package Explorer, Project Explorerand other Eclipse views displays white/grey colours that are not only inconsistent, but actually obscures important display components like expansion arrows.

但是,使用像 Dudler 这样的深色 Juno 主题存在问题。内(在)有源元件的背景色Package ExplorerProject Explorer以及其他Eclipse视图显示白色/灰色的颜色,不仅是不一致的,但实际上掩盖样扩张箭头重要的显示组件。

After much googling, it seems such colours are inherited from the OS, and therefore cannot be changed from within Eclipse Preferences. I'd hoped that the dark GTK 3 / Unity theme (Solancer's Ambiance) would supply the necessary dark colours, but this is not the case.

经过多次谷歌搜索,似乎这些颜色是从操作系统继承的,因此无法从 Eclipse 内部更改Preferences。我希望黑暗的 GTK 3 / Unity 主题(Solancer's Ambiance)能够提供必要的深色,但事实并非如此。

I've used sed to replace allpredefined colours in allthe .cssfiles under /opt/eclipse/plugins/org.eclipse.platform_4.2.0.v*/csswith #FF0000to establish whether any colours defined there affect the white/grey problem colours; sadly they do not.

我用的sed替换所有预定义的色彩在所有.css下的文件/opt/eclipse/plugins/org.eclipse.platform_4.2.0.v*/css#FF0000建立任何颜色是否定义存在影响了白/灰问题的颜色; 可悲的是他们没有。

Having seen mention of a ~/.e4cssfolder online which may contain overriding CSS definitions for such properties, I sought the folder on my local machine, only to find it does not exist.

~/.e4css网上看到一个文件夹可能包含这些属性的覆盖 CSS 定义后,我在本地机器上寻找该文件夹,却发现它不存在。

Similar questions to this exist on SO, yet none explicitly specify how to "fix" these colours.

SO 上存在与此类似的问题,但没有明确说明如何“修复”这些颜色。

My question is simple: is there a GTK+ 3.0 CSS property (group) that can be defined to specify these colours for Eclipse 4.x, and where should it be configured?

我的问题很简单:是否有一个 GTK+ 3.0 CSS 属性(组)可以定义为 Eclipse 4.x 指定这些颜色,应该在哪里配置?

The light - it burns!

光 - 它燃烧!

采纳答案by KomodoDave

Finally found the solution through searching GTK configuration files manually myself.

最终通过自己手动搜索GTK配置文件找到了解决方案。

It turns out Eclipse uses GTK+ 2.0 .

事实证明 Eclipse 使用 GTK+ 2.0 。

If you install a custom GTK theme in Ubuntu (all are compatible with Unity too) you'll extract the theme folder into ~/.themes.

如果您在 Ubuntu 中安装自定义 GTK 主题(也都与 Unity 兼容),您会将主题文件夹解压缩到~/.themes.

GTK+ 3.0 is configured via css, e.g. ~/.themes/YourTheme/gtk-3.0/gtk.css

GTK+ 3.0 是通过 css 配置的,例如 ~/.themes/YourTheme/gtk-3.0/gtk.css

GTK+ 2.0 is configured via an rcfile, e.g. ~/.themes/YourTheme/gtk-2.0/gtkrc

GTK+ 2.0 通过rc文件配置,例如~/.themes/YourTheme/gtk-2.0/gtkrc

Most GTK+ 3.0 themes contain both of these configuration folders due to many applications being GTK+ 2.0 specific.

由于许多应用程序是特定于 GTK+ 2.0 的,因此大多数 GTK+ 3.0 主题都包含这两个配置文件夹。

The leading line in the GTK+ 2.0 gtkrcfile contains fundamental foreground and background colours; these are what must be changed.

GTK+ 2.0gtkrc文件中的前导行包含基本的前景色和背景色;这些是必须改变的。

To modify the selected, active element bg colour in Eclipse views you must change colour base_color. To modify the unselected element bg colour, you must change selected_bg_color. Font colour is changed with the equivalent fg_colorproperties (in the case of base_colorthis is simply 'fg_color').

要在 Eclipse 视图中修改选定的活动元素 bg 颜色,您必须更改 color base_color。要修改未选中的元素 bg 颜色,您必须更改selected_bg_color. 字体颜色随等效fg_color属性而改变(在这种情况下base_color只是'fg_color')。

Bear in mind this will affect all GTK applications, so you may need to tweak according to personal taste. Also note that you must reload the active GTK theme and restart Eclipse to see changes in effect. The quickest way to do this is to sudo apt-get install myunity, launch and leave it open while you restart Eclipse during colour changes, and select another theme followed by your desired theme each time you wish to load your gtkrcchanges.

请记住,这将影响所有 GTK 应用程序,因此您可能需要根据个人喜好进行调整。另请注意,您必须重新加载活动的 GTK 主题并重新启动 Eclipse 才能看到更改生效。执行此操作的最快方法是sudo apt-get install myunity,在颜色更改期间重新启动 Eclipse 时启动并使其保持打开状态,并在每次您希望加载gtkrc更改时选择另一个主题,然后选择您想要的主题。

The original gtkrcleading line in my active GTK theme read:

gtkrc我的活动 GTK 主题中的原始引导行是:

gtk-color-scheme = "base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#ffffff\nselected_bg_color:#f07746\nselected_fg_color:#FFFFFF\ntext_color:#3C3C3C\nbg_color:#F2F1F0\ntooltip_bg_color:#000000\nlink_color:#DD4814"

After much experimentation I settled on this replacement configuration:

经过大量实验,我决定采用这种替换配置:

gtk-color-scheme = "base_color:#555555\nfg_color:#000000\ntooltip_fg_color:#999999\nselected_bg_color:#666666\nselected_fg_color:#ffffff\ntext_color:#000000\nbg_color:#333333\ntooltip_bg_color:#000000\nlink_color:#DD4814"

The change across the entire OS is very pleasing! Here's how Eclipse looks now, no obscuring this time:

整个操作系统的变化非常令人愉悦!这是 Eclipse 现在的样子,这次没有遮掩:

Sweet mother of darkness

甜蜜的黑暗之母

Hope you like the new look :)

希望你喜欢新外观:)

P.S. As you'd predict, the process for Netbeans is equivalent.

PS 正如您所预测的,Netbeans 的过程是等效的。

UPDATE

更新

This is supplementary info, the above process is still correct when using a custom theme such as Dudler's.

这是补充信息,当使用自定义主题(例如 Dudler's)时,上述过程仍然正确。

After further experimentation it's now clear why editing /opt/eclipse/plugins/org.eclipse.platform_4.2.0.v*/css/*.cssdidn't have any effect:

经过进一步的实验,现在很清楚为什么编辑/opt/eclipse/plugins/org.eclipse.platform_4.2.0.v*/css/*.css没有任何效果:

Let's say you're editing e4_default_gtk.cssin that location - the effects of changed styles in that file will only apply when you select GTKin Window -> Preferences -> Appearance -> [Theme].

比方说,你正在编辑e4_default_gtk.css在该位置-当你选择的款式改变该文件中的作用将只适用GTKWindow -> Preferences -> Appearance -> [Theme]

You can relate the themes listed in this dropdown, along with your Operating System, to the names of the .css files in the aforementioned filesystem location.

您可以将此下拉列表中列出的主题以及您的操作系统与上述文件系统位置中的 .css 文件的名称相关联。

回答by Martin Wallgren

If you don't want to change the look of the entire desktop you can launch a separate GTK+ theme for Eclipse by setting GTK2_RC_FILES flag in the command to start Eclipse.

如果您不想更改整个桌面的外观,您可以通过在启动 Eclipse 的命令中设置 GTK2_RC_FILES 标志来为 Eclipse 启动一个单独的 GTK+ 主题。

Example:

例子:

GTK2_RC_FILES=/path/to/gtk/theme/gtkrc /opt/eclipse/eclipse

That means that you can create a copy of your GTK+ theme and tweak it for Eclipse without effecting any other part of your desktop.

这意味着您可以创建 GTK+ 主题的副本并针对 Eclipse 对其进行调整,而不会影响桌面的任何其他部分。

回答by John Carmak

You finally don't need to change your GTK theme to have a dark Package Explorer or Project Explorer etc. windows. Try the solution posted here, for me it works well both on Ubuntu and Windows without changing system theme.

你终于不需要改变你的 GTK 主题来拥有一个黑暗的包资源管理器或项目资源管理器等窗口。试试这里发布的解决方案,对我来说,它在 Ubuntu 和 Windows 上都运行良好,无需更改系统主题。

回答by user2223633

Even in 2013, some items still can not be 'themed', and not only in Eclipse IDE. Only way to fight with color hardcoders (people who define item color via constant, not via theme parameter) is Compiz Color Filter. I develop such filter which preserve colours while inverting. So no problem with anysoftware anymore.

即使在 2013 年,有些项目仍然不能“主题化”,不仅在 Eclipse IDE 中。与颜色硬编码器(通过常量而不是通过主题参数定义项目颜色的人)对抗的唯一方法是 Compiz 颜色过滤器。我开发了这样的过滤器,可以在反转时保留颜色。所以任何软件都没有问题了。

Unfortunately, color filtering will not work on latest Ubuntu's as i know.

不幸的是,据我所知,颜色过滤不适用于最新的 Ubuntu。

Please read more here http://ubuntuforums.org/showthread.php?t=1419702&page=3

请在此处阅读更多内容http://ubuntuforums.org/showthread.php?t=1419702&page=3

!!ARBfp1.0
TEMP temp, neg, YPbPr;
TEX temp, fragment.texcoord[0], texture[0], RECT;
RCP neg.a, temp.a;
MAD temp.rgb, -neg.a, temp, 1.0;
MUL temp.rgb, temp.a, temp;
MUL temp, fragment.color, temp;
DP3 YPbPr.x, temp, {0.333, 0.333, 0.333, 1};
SUB YPbPr.y, YPbPr.x, temp.b;
SUB YPbPr.z, YPbPr.x, temp.r;
ADD temp.r, YPbPr.x, YPbPr.z; 
ADD temp.b, YPbPr.x, YPbPr.y;
SUB temp.g, YPbPr.x, YPbPr.z; 
SUB temp.g, temp.g, YPbPr.y;

MOV result.color, temp;
END

# DO NOT MOVE LINE #2 (TEMP...) below, i.e. do not insert comments before it!
# do not insert comments before 'END' token: SOMETIMES not work!

# replace file /usr/share/compiz/filters/negative with this file.

#  Color filter: negative, but preserve colours. Tested on Ubuntu LTS 10.04.

# compiled from [1], [2] by [email protected], www.bdyssh.ru
# [1] http://hronir.blogspot.com/2008/09/compiz-fusion-color-filter-for-hue.html
# [2] http://ubuntuforums.org/showthread.php?t=1419702

# add to line 15:  MUL temp.b, 0.5, temp.b;  - for warm/melatonine colors, or 
#  MUL temp.g, 0.5, temp.g;  - for cold colors.

回答by Attila Perger

For Eclipse 4.5: 1. Create a file like the inserted snippet 2. Save it as "/usr/share/themes/..used theme../gtk-3.0/apps/eclipse.css" 3. Include it "/usr/share/themes/..used theme../gtk-3.0/gtk-main.css"

对于 Eclipse 4.5: 1. 创建一个类似于插入片段的文件 2. 将其另存为“/usr/share/themes/..used theme../gtk-3.0/apps/eclipse.css” 3. 包含它“/usr /share/themes/..used 主题../gtk-3.0/gtk-main.css"

@define-color ecl_scrollbutton_color #7C7C7C;
@define-color ecl_scrollbutton_color_hover #FB7A00;
 
.scrollbar,
.scrollbar.vertical {
    -GtkScrollbar-has-backward-stepper: 0;
    -GtkScrollbar-has-forward-stepper: 0;
    -GtkRange-slider-width: 14;

    border-radius: 20px;

    border-image: none;
}

/*.scrollbar.trough,
.scrollbar.trough.vertical {
}
*/
.scrollbar.slider,
.scrollbar.slider.horizontal,
.scrollbar.slider.vertical,
.scrollbar.button,
.scrollbar.button.horizontal,
.scrollbar.button.vertical {
    border-width: 0.5px;
    border-style: solid;
    border-color: shade (@ecl_scrollbutton_color, 0.66);
    background-image: -gtk-gradient (linear, left top, right top,
                                     from (shade (@ecl_scrollbutton_color, 1)),
                                     color-stop (0.5, @ecl_scrollbutton_color),
                                     to (shade (@ecl_scrollbutton_color, 1)));
    box-shadow: inset 1px 0 shade (@bg_color, 1.1),
                inset -1px 0 shade (@bg_color, 1.01),
                inset 0 1px shade (@bg_color, 1.1),
                inset 0 -1px shade (@bg_color, 1.1);
}

.scrollbar.slider:hover,
.scrollbar.slider.vertical:hover,
.scrollbar.slider.horizontal:hover {
    background-image: -gtk-gradient (linear, left top, left bottom,
                                     from (shade (@ecl_scrollbutton_color_hover, 1)),
                                     color-stop (0.5, @ecl_scrollbutton_color_hover),
                                     to (shade (@ecl_scrollbutton_color_hover, 1)));
    box-shadow: inset 1px 0 shade (@bg_color, 1.1),
                inset -1px 0 shade (@bg_color, 1.1),
                inset 0 1px shade (@bg_color, 1.1),
                inset 0 -1px shade (@bg_colo