nautilus 文字颜色变化与 light theme 的分析

转载时请注明出处和作者联系方式:http://blog.csdn.net/mimepp
作者联系方式:YU TAO <yut616 at sohu dot com>

在用 ubuntu 桌面时,近来更新后,出现桌面的 icon 下面的文字由原来的白色变成了黑色,和背景叠在一起看不清楚。

今天,再次更新后,文字又正常了。就追查了一下 open source 各个模块都改了什么,才出现这个问题,和这个问题是如何解决的。这里记录一下。

最开始先下载了 light-themes-0.1.8.25,其中 debian/changelog 有

light-themes (0.1.8.25) oneiric; urgency=low

  * New snapshot
    - the text on desktop icons doesn't adapt to the background
      color  (LP: #854401)

说明有解决本问题,并且 bug 是 854401。

google 搜索 “light-themes git 0.1.8.25” 看到一条:

Bug #854401 in nautilus (Ubuntu): “the text on desktop icons doesn't ...
https://code.launchpad.net/bugs/854401 - 网页快照4 days ago – You are not the bug assignee nor the maintainer of light-themes (Ubuntu .... http://git.gnome.org/browse/gnome-themes-standard/tree/themes/Adwaita/gtk-3.0/gnome ... This bug was fixed in the package light-themes - 0.1.8.25 ...

刚好是这个 bug 的记录:

https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/854401

里面有这个描述:

Sebastien Bacher (seb128) wrote on 2011-09-20:	 #5
upstream says we should update our theme:

"This is not really a bug; in the previous versions of Nautilus, the color and
"shadow" effect (which is what makes the text readable on different background
colors) was all hardcoded.
As part of some cleanups to make Nautilus more theme-friendly, in 3.1.92 I
changed it to use theme colors for this, and added some style classes so that
themes can choose colors they like.

For instance, Adwaita now uses pretty much the same color scheme that was
hardcoded in Nautilus before, from the CSS [1].

即老的 nautilus 代码有些是 hardcode 的,其进行了修改,但对应的 css 没有改,从而出现了这个问题。

并且有 9 个人遇到了这个问题。

搜索 “nautilus git” 找到版本 3.1.92,找到

http://git.gnome.org/browse/nautilus/diff/?id=3.1.92&ss=1

里面有:

17	* Strip the hardcoded theme bits

再找到 nautilus 的 changelog,逐行找相关内容,找到:

2011-09-08	icon-canvas-item: render the additional text with gtk_render_layout()	Cosimo Cecchi	1	-17/+15

即:

http://git.gnome.org/browse/nautilus/commit/?id=7732a6b35369c1cef56351cc491358c2f6623c5e

-	cairo_save (cr);
+	style_context = gtk_widget_get_style_context (widget);
+	gtk_style_context_save (style_context);
+	gtk_style_context_add_class (style_context, "icon-embedded-text");
 
-	cairo_rectangle (cr,
-			 x + item->details->embedded_text_rect.x,
-			 y + item->details->embedded_text_rect.y,
-			 item->details->embedded_text_rect.width,
-			 item->details->embedded_text_rect.height);
-	cairo_clip (cr);
-
-	cairo_set_source_rgb (cr, 0, 0, 0);
-	cairo_move_to (cr, 
-		       x + item->details->embedded_text_rect.x,
-		       y + item->details->embedded_text_rect.y);
-	pango_cairo_show_layout (cr, layout);
-
-	cairo_restore (cr);
+	gtk_render_layout (style_context, cr,
+			   x + item->details->embedded_text_rect.x,
+			   y + item->details->embedded_text_rect.y,
+			   layout);
+
+	gtk_style_context_restore (style_context);
也就是去掉了直接使用 hardcode 的方式,而使用了 style。

再回头查找 light theme 中 0.1.8.25 的修改 log,和前一个版本的差别:

http://launchpadlibrarian.net/80433370/light-themes_0.1.8.24_0.1.8.25.diff.gz

diff -Nru light-themes-0.1.8.24/Ambiance/gtk-3.0/apps/nautilus.css light-themes-0.1.8.25/Ambiance/gtk-3.0/apps/nautilus.css
--- light-themes-0.1.8.24/Ambiance/gtk-3.0/apps/nautilus.css	2011-09-08 19:14:14.000000000 +0000
+++ light-themes-0.1.8.25/Ambiance/gtk-3.0/apps/nautilus.css	2011-09-20 16:02:50.000000000 +0000
@@ -1,3 +1,32 @@
+/* desktop mode */
+.nautilus-desktop.nautilus-canvas-item {
+    color: @bg_color;
+    text-shadow: 1 1 alpha (#000000, 0.8);
+}......

这里 nautilus.css 增加了对应的内容,由于 nautilus 修改的代码引起的问题,也就用 light theme 解决了。

这里的 light theme 是 css 的,可以另外再讨论了。

这个问题的验证方法,你可以直接编辑:

/usr/share/themes/Ambiance/gtk-3.0/apps/nautilus.css

将 text-shadow 这几行注释掉,然后 logout,再 login, 就能看到文字颜色由白变黑了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值