K.I.S.S. – 简单哲学 Linux, Freedom, Arch, Python, Gtk+, C … Keep It Simple, Stupid!

27五/090

在自己的 GTK+ 程序中加入 RGBA 透明支持

上次介绍了怎么在 Arch Linux 下启用 RGBA 透明窗口 ,然而,目前支持 的程序还很少,看起来有的透明,有的不透明,很不爽吧?
另外,+ 默认是不启用 支持的,我们自己编写程序的时候,怎么加入 ,达到这种酷炫的效果呢?
细心的同学可能已经发现,上次我发的图中最顶端那个程序就是我自己写的,而且已经实现了半透明效果。
加入 效果的方法并不难,仅仅是几条语句而已,看看下面的 patch:

From fb88cb790a08e928c5e6656f8334264c5ae9f93a Mon Sep 17 00:00:00 2001
From: Kevin Lange
Date: Wed, 5 Mar 2008 09:26:53 -0500
Subject: [PATCH] Added  colormap support to the GUI

---
 ccm/Window.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/ccm/Window.py b/ccm/Window.py
index 09306da..84f1d76 100644
--- a/ccm/Window.py
+++ b/ccm/Window.py
@@ -42,6 +42,10 @@ class MainWin(.Window):

     def __init__(self, Context, pluginPage=None, categoryName=None):
         .Window.__init__(self)
+        self.gtk_screen = self.get_screen()
+        colormap = self.gtk_screen.get_rgba_colormap()
+        if colormap:
+            .widget_set_default_colormap(colormap)
         self.ShowingPlugin = None
         self.Context = Context
         self.connect("destroy", self.Quit)
@@ -99,6 +103,7 @@ class MainWin(.Window):
             self.ToggleCategory(None, categoryName)

     def Quit(self, *args):
+        .widget_pop_colormap()
         .main_quit()

     def ResetMainWidgets(self):
--
1.5.2.5

呵呵,这是 CCSM 的 补丁,看到了吧,其实关键的也就那么几行而已,在初始化的时候试着载入 颜色表,在退出的时候对颜色表进行出栈,其他语言也是这个道理。
有了这几行代码,是不是想把桌面上的所有 + 程序 hack 掉?
呵呵,赶快在自己的程序里加入 支持吧!

转载请注明:转自K.I.S.S. - 简单哲学 - 在自己的 GTK+ 程序中加入 RGBA 透明支持

分享家:Addthis中国

你可能对这些感兴趣:

  1. 在 Arch Linux 下启用 RGBA 透明窗口
  2. 使用 PyGTK 和 Cairo 编写一个简单的时钟
  3. GtkApplication – GTK+ 3 中的 Application 支持

喜欢这个文章吗?

考虑订阅我们的RSS Feed吧!

评论 (0) 引用 (0)

还没有评论.


发表评论


还没有引用.