OSDN Git Service

updates
authorshy <shy>
Thu, 2 Feb 2006 14:06:31 +0000 (14:06 +0000)
committershy <shy>
Thu, 2 Feb 2006 14:06:31 +0000 (14:06 +0000)
ChangeLog
NEWS
README
lib/ninix-install.py
lib/ninix/balloon.py
lib/ninix/home.py
lib/ninix/main.py
lib/ninix/pix.py
lib/ninix/surface.py

index d0af0c6..ccc928a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu February 2 2006   Shyouzou Sugitani <shy@users.sourceforge.jp>
+       * バージョン3.8.1リリース.
+
+Tue January 31 2006   Shyouzou Sugitani <shy@users.sourceforge.jp>
+       * サーフェスとバルーンの描画処理の一部にCairoグラフィックライブラリ
+         (http://cairographics.org/)を使用するよう変更.
+         そのためGTK+(pygtk)2.8以降が必要となった.
+         pna, 本体設定によるサーフェスとバルーンの半透明化が可能.(NEWS参照)
+
 Thu January 26 2006   Shyouzou Sugitani <shy@users.sourceforge.jp>
        * lib/ninix/pix.py: 本体設定でサーフェス/バルーンのアルファ
        チャンネルを変更すると落ちる問題を修正.
diff --git a/NEWS b/NEWS
index 75d3bc9..b0ada54 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+Ver.3.8以降の変更点
+-------------------
+- サーフェスとバルーンの描画処理の一部に Cairo グラフィックライブラリ
+  (http://cairographics.org/) を使用するよう変更しました.
+  そのため GTK+(pygtk) 2.8 以降が必要となります.
+  この変更の結果, デスクトップ側の環境が対応していれば, pna もしくは
+  本体設定によるサーフェスとバルーンの半透明化が可能です.
+  X Window System であれば Composite 拡張と composition manager
+  (xcompmgr, etc.) が必要です.
+- ddp暗号化ファイルのサポートを追加しました.
+  (「理夢」がサーフェスで使用しています.)
+
 Ver.3.8の変更点
 ---------------
 - メニューフォアグラウンドの画像およびフォントカラー設定に対応しました。
diff --git a/README b/README
index d60677e..f7b8640 100644 (file)
--- a/README
+++ b/README
@@ -19,10 +19,9 @@ UNIX 対応デスクトップアクセサリninixに拡張機能を追加した
   確認しています。バージョン 2.3 以降であれば動くと思います。
 
 - GTK+ (http://www.gtk.org/)
-  X Window System 用の GUI ライブラリです。バージョン 2.4.2 での
-  動作を確認しています。バージョン 2.4 の API を使用していますので
+  X Window System 用の GUI ライブラリです。バージョン 2.8.10 での
+  動作を確認しています。バージョン 2.8 の API を使用していますので
   それ以前のバージョンでは動作しません。
-  バージョン 2.6 以降の使用を推奨します。
 
 - Numerical Python(http://numeric.scipy.org/)
   PyGTKのpixels_arrayを使用しているため必要になります。
index e574e8b..7ac6729 100755 (executable)
@@ -4,7 +4,7 @@
 #  ninix-install.py - a command-line installer for ninix
 #  Copyright (C) 2001, 2002 by Tamito KAJIYAMA
 #  Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net>
-#  Copyright (C) 2002-2005 by Shyouzou Sugitani <shy@users.sourceforge.jp>
+#  Copyright (C) 2002-2006 by Shyouzou Sugitani <shy@users.sourceforge.jp>
 #  Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp>
 #
 #  This program is free software; you can redistribute it and/or modify it
@@ -14,7 +14,7 @@
 #  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 #  PURPOSE.  See the GNU General Public License for more details.
 #
-#  $Id: ninix-install.py,v 1.38 2006/01/18 00:08:43 shy Exp $
+#  $Id: ninix-install.py,v 1.39 2006/02/02 14:06:31 shy Exp $
 #
 
 # env.var: NINIX_HOME, NINIX_USER, NINIX_ARCHIVE, TMPDIR
index ddfaff2..6aafa76 100644 (file)
@@ -2,7 +2,7 @@
 #
 #  Copyright (C) 2001, 2002 by Tamito KAJIYAMA
 #  Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net>
-#  Copyright (C) 2002-2005 by Shyouzou Sugitani <shy@users.sourceforge.jp>
+#  Copyright (C) 2002-2006 by Shyouzou Sugitani <shy@users.sourceforge.jp>
 #  Copyright (C) 2003 by Shun-ichi TAHARA <jado@flowernet.gr.jp>
 #
 #  This program is free software; you can redistribute it and/or modify it
@@ -19,6 +19,7 @@ if 'DISPLAY' in os.environ:
     import gtk
     import gobject
     import pango
+    import cairo
 
 import pix
 
@@ -69,11 +70,9 @@ class Balloon:
             balloon_window.reset_balloon()
 
     def set_alpha_channel(self, alpha):
-        assert 0 <= alpha <= 255 or alpha is None
-        if alpha == 255:
-            self.__alpha_channel = None
-        else:
-            self.__alpha_channel = alpha
+        if not 0.1 <= alpha <= 1.0 or alpha is None:
+            alpha = 1.0
+        self.__alpha_channel = alpha
         for balloon_window in self.window:
             balloon_window.set_alpha_channel(self.__alpha_channel)
 
@@ -92,7 +91,8 @@ class Balloon:
             balloon_window.set_scalling(flag)
 
     def create_gtk_window(self, title):
-        window = pix.TranslucentWindow(type=gtk.WINDOW_POPUP)
+        window = gtk.Window(type=gtk.WINDOW_POPUP)
+        pix.set_rgba_colormap(window)
         window.set_title(title)
         window.set_decorated(False)
         window.set_resizable(False)
@@ -411,8 +411,6 @@ class BalloonWindow:
         self.reset_pixbuf_cache()
 
     def set_alpha_channel(self, value):
-        if not self.window.translucency:
-            return
         if self.__alpha_channel == value:
             return
         self.__alpha_channel = value
@@ -753,13 +751,11 @@ class BalloonWindow:
             self.redraw_area(x, y, w, h)
 
     def redraw_area(self, x, y ,w ,h):
-        if self.__alpha_channel is not None:
-            pixbuf = self.balloon_pixbuf.copy()
-            pix.modify_pixbuf_alpha(pixbuf, self.__alpha_channel)
-            self.darea.window.draw_pixbuf(None, pixbuf, x, y, x, y, w, h)
-        else:
-            self.darea.window.draw_pixbuf(
-                None, self.balloon_pixbuf, x, y, x, y, w, h)
+        cr = self.darea.window.cairo_create()
+        cr.rectangle(x, y, w, h)
+        cr.clip()
+        cr.set_source_pixbuf(self.balloon_pixbuf, 0, 0)
+        cr.paint_with_alpha(self.__alpha_channel)
 
     def redraw(self, darea=None, event=None):
         if not self.__shown:
@@ -767,14 +763,9 @@ class BalloonWindow:
         if darea is None:
             darea = self.darea
         self.update_gc()
-        darea.window.clear()
-        if self.__alpha_channel is not None:
-            pixbuf = self.balloon_pixbuf.copy()
-            pix.modify_pixbuf_alpha(pixbuf, self.__alpha_channel)
-            self.darea.window.draw_pixbuf(None, pixbuf, 0, 0, 0, 0, -1, -1)
-        else:
-            darea.window.draw_pixbuf(
-                None, self.balloon_pixbuf, 0, 0, 0, 0, -1, -1)
+        cr = darea.window.cairo_create()
+        cr.set_source_pixbuf(self.balloon_pixbuf, 0, 0)
+        cr.paint_with_alpha(self.__alpha_channel)
         # draw foreground pixmap
         for i in range(len(self.images)):
             pixbuf, (w, h), (x, y) = self.images[i]
index fed2365..6ff38a7 100644 (file)
@@ -2,7 +2,7 @@
 #
 #  Copyright (C) 2001, 2002 by Tamito KAJIYAMA
 #  Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net>
-#  Copyright (C) 2002-2005 by Shyouzou Sugitani <shy@users.sourceforge.jp>
+#  Copyright (C) 2002-2006 by Shyouzou Sugitani <shy@users.sourceforge.jp>
 #
 #  This program is free software; you can redistribute it and/or modify it
 #  under the terms of the GNU General Public License (version 2) as
@@ -11,7 +11,7 @@
 #  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 #  PURPOSE.  See the GNU General Public License for more details.
 #
-# $Id: home.py,v 1.30 2006/01/18 00:08:43 shy Exp $
+# $Id: home.py,v 1.31 2006/02/02 14:06:31 shy Exp $
 #
 
 import os
index f9acd67..bb8296d 100755 (executable)
@@ -3,7 +3,7 @@
 #
 #  Copyright (C) 2001, 2002 by Tamito KAJIYAMA
 #  Copyright (C) 2002, 2003 by MATSUMURA Namihiko <nie@counterghost.net>
-#  Copyright (C) 2002-2005 by Shyouzou Sugitani <shy@users.sourceforge.jp>
+#  Copyright (C) 2002-2006 by Shyouzou Sugitani <shy@users.sourceforge.jp>
 #  Copyright (C) 2003-2005 by Shun-ichi TAHARA <jado@flowernet.gr.jp>
 #
 #  This program is free software; you can redistribute it and/or modify it
@@ -13,7 +13,7 @@
 #  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 #  PURPOSE.  See the GNU General Public License for more details.
 #
-# $Id: main.py,v 1.133 2005/10/06 02:59:13 shy Exp $
+# $Id: main.py,v 1.134 2006/02/02 14:06:31 shy Exp $
 #
 
 import getopt
@@ -110,6 +110,9 @@ if 'DISPLAY' in os.environ:
         sys.excepthook = _traceback
 
 def main():
+    if gtk.pygtk_version < (2,8,0):
+        print "PyGtk 2.8.0 or later required"
+        raise SystemExit
     # reopen stderr to avoid IOError
     sys.stderr = os.fdopen(sys.stderr.fileno(), 'w')
     # check if X is running
@@ -1551,8 +1554,8 @@ class PreferenceDialog:
         label = gtk.Label(unicode(_("Surfaces' alpha channel"), 'utf-8'))
         hbox.pack_start(label, False)
         label.show()
-        self.surface_alpha_adjustment = gtk.Adjustment(0, 0, 255, 1)
-        button = gtk.SpinButton(self.surface_alpha_adjustment)
+        self.surface_alpha_adjustment = gtk.Adjustment(1.0, 0.1, 1.0, 0.1, 0.5)
+        button = gtk.SpinButton(self.surface_alpha_adjustment, 0.2, 1)
         hbox.pack_start(button, False)
         button.show()
         hbox = gtk.HBox(spacing=5)
@@ -1561,8 +1564,8 @@ class PreferenceDialog:
         label = gtk.Label(unicode(_("Balloons' alpha channel"), 'utf-8'))
         hbox.pack_start(label, False)
         label.show()
-        self.balloon_alpha_adjustment = gtk.Adjustment(0, 0, 255, 1)
-        button = gtk.SpinButton(self.balloon_alpha_adjustment)
+        self.balloon_alpha_adjustment = gtk.Adjustment(1.0, 0.1, 1.0, 0.1, 0.5)
+        button = gtk.SpinButton(self.balloon_alpha_adjustment, 0.2, 1)
         hbox.pack_start(button, False)
         button.show()
         return page        
@@ -1922,21 +1925,21 @@ class PreferenceDialog:
 
     def set_surface_alpha(self, alpha):
         if alpha is None:
-            alpha = 255
+            alpha = 1.0
         self.surface_alpha_adjustment.set_value(alpha)
 
     def get_surface_alpha(self):
         alpha = self.surface_alpha_adjustment.get_value()
-        return int(alpha)
+        return float(alpha)
 
     def set_balloon_alpha(self, alpha):
         if alpha is None:
-            alpha = 255
+            alpha = 1.0
         self.balloon_alpha_adjustment.set_value(alpha)
 
     def get_balloon_alpha(self):
         alpha = self.balloon_alpha_adjustment.get_value()
-        return int(alpha)
+        return float(alpha)
 
 class RuleEditor:
 
index 0dc4504..2c122d5 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: ascii -*-
 #
-#  Copyright (C) 2003-2005 by Shyouzou Sugitani <shy@users.sourceforge.jp>
+#  Copyright (C) 2003-2006 by Shyouzou Sugitani <shy@users.sourceforge.jp>
 #
 #  This program is free software; you can redistribute it and/or modify it
 #  under the terms of the GNU General Public License (version 2) as
@@ -17,13 +17,20 @@ import md5
 if 'DISPLAY' in os.environ:
     import gtk
 
-def get_translucent_cmap():
-    try:
-        visual = gtk.gdk.visual_get_best_with_depth(32) # RGBA
-        return gtk.gdk.Colormap(visual, True)
+def set_rgba_colormap(widget):
+    screen = widget.get_screen()
+    try: # XXX
+        colormap = screen.get_rgba_colormap()
     except:
-        sys.stderr.write('Translucency is not available on this Xserver.\n')
-        return None
+        visual = gtk.gdk.visual_get_best_with_depth(32) # RGBA
+        if visual is not None:
+            colormap = gtk.gdk.Colormap(visual, True)
+        else:
+            colormap = None
+    if colormap is None:
+        sys.stderr.write('screen does NOT support alpha.\n')
+        colormap = screen.get_rgb_colormap()
+    widget.set_colormap(colormap)
 
 def create_blank_pixbuf(width, height):
     pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height)
@@ -93,17 +100,6 @@ def add_alpha_from_PNA_file(pixbuf, path):
         for j in range(width):
             pixbuf_array[i][j][3] = pna_array[i][j][0]
 
-def modify_pixbuf_alpha(pixbuf, value):
-    assert 0 <= value <= 255
-    if not pixbuf.get_has_alpha():
-        pixbuf = pixbuf.add_alpha(False, chr(0), chr(0), chr(0))
-    array = pixbuf.get_pixels_array()
-    width = pixbuf.get_width()
-    height = pixbuf.get_height()
-    for i in range(height):
-        for j in range(width):
-            array[i][j][3] = int(value * array[i][j][3].toscalar() / 255.0)
-
 def create_pixbuf_from_file(path, is_pnr=1, use_pna=0):
     head, tail = os.path.split(path)
     basename, suffix = os.path.splitext(tail)
@@ -157,19 +153,3 @@ def reduce_pixbuf(target_pixbuf, pixbuf, dest_x, dest_y):
                     if 0 <= x < dest_w and 0 <= y < dest_h:
                         target_array[y][x][3] = 0 # alpha
     return target_pixbuf
-
-
-class TranslucentWindow(gtk.Window):
-
-    def __init__(self, type=gtk.WINDOW_TOPLEVEL):
-        translucent_cmap = get_translucent_cmap()
-        if translucent_cmap:
-            self.translucency = 1
-        else:
-            self.translucency = 0
-        if self.translucency:
-            gtk.widget_push_colormap(translucent_cmap)
-        gtk.Window.__init__(self, type)
-        if self.translucency:
-            gtk.widget_pop_colormap()
-            self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
index 0f549cf..04c3203 100644 (file)
@@ -21,6 +21,7 @@ import random
 
 if 'DISPLAY' in os.environ:
     import gtk
+    import cairo
 
 import ninix.seriko
 import ninix.menu
@@ -76,11 +77,9 @@ class Surface:
             surface_window.reset_surface()
 
     def set_alpha_channel(self, alpha):
-        assert 0 <= alpha <= 255 or alpha is None
-        if alpha == 255:
-            self.__alpha_channel = None
-        else:
-            self.__alpha_channel = alpha
+        if not 0.1 <= alpha <= 1.0 or alpha is None:
+            alpha = 1.0
+        self.__alpha_channel = alpha
         for surface_window in self.window:
             surface_window.set_alpha_channel(self.__alpha_channel)
 
@@ -103,7 +102,8 @@ class Surface:
         self.__menu = None
 
     def create_gtk_window(self, title):
-        window = pix.TranslucentWindow()
+        window = gtk.Window()
+        pix.set_rgba_colormap(window)
         window.set_title(title)
         window.set_decorated(False)
         window.set_resizable(False)
@@ -847,8 +847,6 @@ class SurfaceWindow:
         self.reset_pixbuf_cache()
 
     def set_alpha_channel(self, value):
-        if not self.window.translucency:
-            return
         if self.__alpha_channel == value:
             return
         self.__alpha_channel = value
@@ -1094,13 +1092,13 @@ class SurfaceWindow:
                 w, h, gtk.gdk.INTERP_BILINEAR)
         surface_pixmap, self.mask_pixmap = \
                         surface_pixbuf.render_pixmap_and_mask(1)
-        if self.__alpha_channel is not None:
-            pix.modify_pixbuf_alpha(surface_pixbuf, self.__alpha_channel)
         self.current_surface_pixbuf = surface_pixbuf
         self.darea.queue_draw()
 
     def redraw(self, darea, event):
-        darea.window.draw_pixbuf(None, self.current_surface_pixbuf, 0, 0, 0, 0, -1, -1)
+        cr = darea.window.cairo_create()
+        cr.set_source_pixbuf(self.current_surface_pixbuf, 0, 0)
+        cr.paint_with_alpha(self.__alpha_channel)
         self.window.shape_combine_mask(self.mask_pixmap, 0, 0)
         if self.debug & 4096:
             self.draw_region()