+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: 本体設定でサーフェス/バルーンのアルファ
チャンネルを変更すると落ちる問題を修正.
+Ver.3.8以降の変更点
+-------------------
+- サーフェスとバルーンの描画処理の一部に Cairo グラフィックライブラリ
+ (http://cairographics.org/) を使用するよう変更しました.
+ そのため GTK+(pygtk) 2.8 以降が必要となります.
+ この変更の結果, デスクトップ側の環境が対応していれば, pna もしくは
+ 本体設定によるサーフェスとバルーンの半透明化が可能です.
+ X Window System であれば Composite 拡張と composition manager
+ (xcompmgr, etc.) が必要です.
+- ddp暗号化ファイルのサポートを追加しました.
+ (「理夢」がサーフェスで使用しています.)
+
Ver.3.8の変更点
---------------
- メニューフォアグラウンドの画像およびフォントカラー設定に対応しました。
確認しています。バージョン 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を使用しているため必要になります。
# 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
# 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
#
# 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
import gtk
import gobject
import pango
+ import cairo
import pix
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)
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)
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
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:
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]
#
# 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
# 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
#
# 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
# 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
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
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)
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
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:
# -*- 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
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)
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)
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'))
if 'DISPLAY' in os.environ:
import gtk
+ import cairo
import ninix.seriko
import ninix.menu
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)
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)
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
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()