OSDN Git Service

updates
authorshy <shy>
Sat, 24 Mar 2007 03:51:08 +0000 (03:51 +0000)
committershy <shy>
Sat, 24 Mar 2007 03:51:08 +0000 (03:51 +0000)
ChangeLog
lib/ninix/alias.py
lib/ninix/balloon.py
lib/ninix/config.py
lib/ninix/dll/bln.py
lib/ninix/kinoko.py
lib/ninix/main.py
lib/ninix/menu.py
lib/ninix/nekodorif.py
lib/ninix/surface.py
lib/ninix/version.py

index 08b5ed2..dfb515e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Sat March 24 2007   Shyouzou Sugitani <shy@users.sourceforge.jp>
+       * メニューアイコンの管理を各ゴーストからApplicationクラスに移した.
+
 Sun December 10 2006   Shyouzou Sugitani <shy@users.sourceforge.jp>
        * バージョン3.9.3リリース.
 
index d8f1d25..6153f81 100644 (file)
@@ -10,7 +10,7 @@
 #  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 #  PURPOSE.  See the GNU General Public License for more details.
 #
-# $Id: alias.py,v 1.8 2005/09/07 03:52:04 shy Exp $
+# $Id: alias.py,v 1.9 2007/03/24 03:51:08 shy Exp $
 #
 
 import __builtin__
@@ -33,6 +33,7 @@ def open(path):
         if not line:
             continue
         buf.append(line)
+    f.close()
     return new_alias(buf)
 
 def new_alias(buf):
index b8eb695..0928974 100644 (file)
@@ -501,18 +501,18 @@ class BalloonWindow:
             self.sstp.append((x, y)) # sstp message
         # arrow pixmaps and masks
         x, y = self.arrow[0]
-        pixbuf = self.pixbuf['arrow0'][0]
+        pixbuf, (w, h) = self.pixbuf['arrow0']
         scale = self.get_scale()
-        w = max(1, int(pixbuf.get_width() * scale / 100))
-        h = max(1, int(pixbuf.get_height() * scale / 100))
+        w = max(1, int(w * scale / 100))
+        h = max(1, int(h * scale / 100))
         pixmap, mask = pixbuf.scale_simple(
             w, h, gtk.gdk.INTERP_BILINEAR).render_pixmap_and_mask(255)
         self.arrow0_pixmap = pixmap, mask, (w, h)
         self.arrow0_gc = self.new_mask_gc(mask, x, y)
         x, y = self.arrow[1]
-        pixbuf = self.pixbuf['arrow1'][0]
-        w = max(1, int(pixbuf.get_width() * scale / 100))
-        h = max(1, int(pixbuf.get_height() * scale / 100))
+        pixbuf, (w, h) = self.pixbuf['arrow1']
+        w = max(1, int(w * scale / 100))
+        h = max(1, int(h * scale / 100))
         pixmap, mask = pixbuf.scale_simple(
             w, h, gtk.gdk.INTERP_BILINEAR).render_pixmap_and_mask(255)
         self.arrow1_pixmap = pixmap, mask, (w, h)
@@ -520,9 +520,9 @@ class BalloonWindow:
         # sstp marker pixmap and mask
         if self.side == 0 and 'sstp' in self.pixbuf:
             x, y = self.sstp[0]
-            pixbuf = self.pixbuf['sstp'][0]
-            w = max(1, int(pixbuf.get_width() * scale / 100))
-            h = max(1, int(pixbuf.get_height() * scale / 100))
+            pixbuf, (w, h) = self.pixbuf['sstp']
+            w = max(1, int(w * scale / 100))
+            h = max(1, int(h * scale / 100))
             pixmap, mask = pixbuf.scale_simple(
                 w, h, gtk.gdk.INTERP_BILINEAR).render_pixmap_and_mask(255)
             self.sstp_pixmap = pixmap, mask, (w, h)
@@ -764,9 +764,8 @@ class BalloonWindow:
             x, y = self.sstp[0]
             w, h = self.sstp_pixmap[2]
             if self.sstp_message:
-                pixmap = self.sstp_pixmap[0]
                 self.darea.window.draw_drawable(
-                    self.sstp_gc, pixmap, 0, 0, x, y, w, h)
+                    self.sstp_gc, self.sstp_pixmap[0], 0, 0, x, y, w, h)
             else:
                 self.redraw_area(x, y, w, h)
         # draw/erase sstp message
@@ -780,20 +779,20 @@ class BalloonWindow:
 
     def redraw_arrow0(self, clear=1):
         x, y = self.arrow[0]
-        pixmap, mask, (w, h) = self.arrow0_pixmap
+        w, h = self.arrow0_pixmap[2]
         if self.lineno > 0:
             self.darea.window.draw_drawable(
-                self.arrow0_gc, pixmap, 0, 0, x, y, w, h)
+                self.arrow0_gc, self.arrow0_pixmap[0], 0, 0, x, y, w, h)
         elif clear:
             self.redraw_area(x, y, w, h)
 
     def redraw_arrow1(self, clear=1):
         x, y = self.arrow[1]
-        pixmap, mask, (w, h) = self.arrow1_pixmap
+        w, h = self.arrow1_pixmap[2]
         if self.lineno + self.lines < len(self.text_buffer) or \
            self.sakura.script_mode == self.sakura.PAUSE_MODE:
             self.darea.window.draw_drawable(
-                self.arrow1_gc, pixmap, 0, 0, x, y, w, h)
+                self.arrow1_gc, self.arrow1_pixmap[0], 0, 0, x, y, w, h)
         elif clear:
             self.redraw_area(x, y, w, h)
 
@@ -895,15 +894,15 @@ class BalloonWindow:
                                          x, y, self.layout)
             for l, c in self.sstp_marker:
                 if l == i:
-                    pixmap, mask, (mw, mh) = self.sstp_pixmap
+                    mw, mh = self.sstp_pixmap[2]
                     self.layout.set_text(self.text_buffer[i][:c])
                     text_w, text_h = self.layout.get_pixel_size()
                     mx = x + text_w
                     my = y + (self.font_height + self.line_space) / 2
                     my = my - mh / 2
-                    gc = self.new_mask_gc(mask, mx, my)
+                    gc = self.new_mask_gc(self.sstp_pixmap[1], mx, my)
                     self.darea.window.draw_drawable(
-                        gc, pixmap, 0, 0, mx, my, mw, mh)
+                        gc, self.sstp_pixmap[0], 0, 0, mx, my, mw, mh)
             i += 1
             line += 1
         if self.side == 0 and self.sstp_message:
@@ -1245,15 +1244,15 @@ class BalloonWindow:
                 self.darea.queue_draw_area(x, y, w, h)
             for l, c in self.sstp_marker:
                 if l == line:
-                    pixmap, mask, (mw, mh) = self.sstp_pixmap
+                    mw, mh = self.sstp_pixmap[2]
                     self.layout.set_text(self.text_buffer[l][:c])
                     text_w, text_h = self.layout.get_pixel_size()
                     mx = x + text_w
                     my = y + (self.font_height + self.line_space) / 2
                     my = my - mh / 2
-                    gc = self.new_mask_gc(mask, mx, my)
+                    gc = self.new_mask_gc(self.sstp_pixmap[1], mx, my)
                     self.darea.window.draw_drawable(
-                        gc, pixmap, 0, 0, mx, my, mw, mh)
+                        gc, self.sstp_pixmap[0], 0, 0, mx, my, mw, mh)
         else:
             self.redraw()
             while line >= self.lineno + self.lines:
index 6efd041..da4f141 100644 (file)
@@ -10,7 +10,7 @@
 #  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 #  PURPOSE.  See the GNU General Public License for more details.
 #
-# $Id: config.py,v 1.13 2005/09/07 03:53:19 shy Exp $
+# $Id: config.py,v 1.14 2007/03/24 03:51:08 shy Exp $
 #
 
 import __builtin__
@@ -73,6 +73,7 @@ def open(path):
         if not line.strip():
             continue
         buf.append(line)
+    f.close()
     return new_config(buf)
 
 def new_config(buf):
index 6f43793..f4d806e 100644 (file)
@@ -238,7 +238,7 @@ class Balloon:
             h = max(1, int(h * self.scale / 100))
             balloon_pixbuf = balloon_pixbuf.scale_simple(
                 w, h, gtk.gdk.INTERP_BILINEAR)
-        balloon_pixmap, self.mask_pixmap = balloon_pixbuf.render_pixmap_and_mask(1)
+        balloon_pixmap, mask_pixmap = balloon_pixbuf.render_pixmap_and_mask(1)
         if self.position == 'lefttop':
             pass
         elif self.position == 'leftbottom':
@@ -311,7 +311,7 @@ class Balloon:
             self.top = int(int(data['disparea.top']) * self.scale / 100)
         if 'disparea.bottom' in data:
             self.bottom = int(int(data['disparea.bottom']) * self.scale / 100)
-        self.window.shape_combine_mask(self.mask_pixmap, 0, 0)
+        self.window.shape_combine_mask(mask_pixmap, 0, 0)
         self.script = None
         self.darea = gtk.DrawingArea()
         self.darea.set_events(gtk.gdk.EXPOSURE_MASK)
index 8b4afae..3057201 100644 (file)
@@ -231,11 +231,10 @@ class Skin:
         path = os.path.join(self.data['dir'], self.data['base'])
         try:
             self.pixbuf = ninix.pix.create_pixbuf_from_file(path)
-            surface_pixbuf = self.pixbuf.copy()
             if self.__scale != 100:
-                w = max(1, surface_pixbuf.get_width() * self.__scale / 100)
-                h = max(1, surface_pixbuf.get_height() * self.__scale / 100)
-                surface_pixbuf = surface_pixbuf.scale_simple(
+                w = max(1, self.pixbuf.get_width() * self.__scale / 100)
+                h = max(1, self.pixbuf.get_height() * self.__scale / 100)
+                surface_pixbuf = self.pixbuf.scale_simple(
                     w, h, gtk.gdk.INTERP_BILINEAR)
             image, mask = surface_pixbuf.render_pixmap_and_mask(255)
         except: ## FIXME
@@ -244,9 +243,7 @@ class Skin:
         ## FIXME
         self.w, self.h = image.get_size()
         self.set_position()
-        self.surface_pixmap = image
-        self.mask_pixmap = mask
-        self.window.shape_combine_mask(self.mask_pixmap, 0, 0)
+        self.window.shape_combine_mask(mask, 0, 0)
         self.darea = gtk.DrawingArea()
         self.darea.set_events(gtk.gdk.EXPOSURE_MASK)
         self.darea.connect('expose_event', self.redraw)
@@ -305,13 +302,6 @@ class Skin:
     def redraw(self, widget, event): ## FIXME
         pass
 
-    def show_surface(self):
-        self.darea.window.set_back_pixmap(self.surface_pixmap, False)
-        self.window.shape_combine_mask(self.mask_pixmap, 0, 0)
-        #print 'DRAW:', dir(self.darea)
-        #self.darea.queue_draw_area(0, 0, w, h)
-        self.darea.queue_draw()
-
     def get_pixbuf(self, surface_id):
         path = os.path.join(self.data['dir'], ''.join(('surface', str(surface_id), '.png')))
         if os.path.exists(path):
@@ -337,10 +327,13 @@ class Skin:
             h = max(1, surface_pixbuf.get_height() * self.__scale / 100)
             surface_pixbuf = surface_pixbuf.scale_simple(
                 w, h, gtk.gdk.INTERP_BILINEAR)
-        self.surface_pixmap, self.mask_pixmap = \
-                             surface_pixbuf.render_pixmap_and_mask(255)
+        image, mask = surface_pixbuf.render_pixmap_and_mask(255)
         self.w, self.h = self.surface_pixmap.get_size()
-        self.show_surface()
+        self.darea.window.set_back_pixmap(image, False)
+        self.window.shape_combine_mask(mask, 0, 0)
+        #print 'DRAW:', dir(self.darea)
+        #self.darea.queue_draw_area(0, 0, w, h)
+        self.darea.queue_draw()
 
     def terminate(self):
         self.seriko.terminate()
index 0a2c3cd..ebd00f2 100755 (executable)
@@ -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.138 2006/10/05 15:16:44 shy Exp $
+# $Id: main.py,v 1.139 2007/03/24 03:51:08 shy Exp $
 #
 
 import getopt
@@ -560,6 +560,17 @@ class Application:
                 icon_path = None
         else:
             icon_path = None
+        if icon_path is not None:
+            try:
+                pixbuf = ninix.pix.create_pixbuf_from_file(icon_path, is_pnr=0)
+            except:
+                pixbuf = None
+            if pixbuf is not None:
+                icon = pixbuf.scale_simple(16, 16, gtk.gdk.INTERP_BILINEAR)
+            else:
+                icon = None
+        else:
+            icon = None
         name = desc.get('name',
                         ''.join((unicode(_('Ghost'), 'utf-8'),
                                  '#%d' % (i + 1))))
@@ -570,7 +581,7 @@ class Application:
             shell_list.append((shell_name, value))
         item = {}
         item['name'] = name
-        item['icon'] = icon_path
+        item['icon'] = icon
         item['shell'] = shell_list
         item['instance'] = None
         return item
index 75dc098..2065460 100644 (file)
@@ -256,9 +256,8 @@ class Menu:
                 sidebar_width, 0, width, height,
                 0, 0,
                 1.0, 1.0, gtk.gdk.INTERP_BILINEAR, 255)
-            pixbuf = new_pixbuf
             self.__sidebar_width = sidebar_width
-            pixmap, mask = pixbuf.render_pixmap_and_mask(255)
+            pixmap, mask = new_pixbuf.render_pixmap_and_mask(255)
         else:
             self.__sidebar_width = 0
         self.__pixmap_with_sidebar = pixmap
@@ -297,8 +296,7 @@ class Menu:
                 sidebar_width, 0, width, height,
                 0, 0,
                 1.0, 1.0, gtk.gdk.INTERP_BILINEAR, 255)
-            pixbuf = new_pixbuf
-            pixmap, mask = pixbuf.render_pixmap_and_mask(255)
+            pixmap, mask = new_pixbuf.render_pixmap_and_mask(255)
         self.__pixmap_prelight_with_sidebar = pixmap
 
     def __set_mayuna_menu(self, side):
@@ -597,27 +595,16 @@ class Menu:
         self.__menu_list['Recommend'][3] = 1 # changed
 
     def __update_ghost_menu(self, set_list):
-        ##if self.__ghost_list is None:
-        ##    self.__create_ghost_menu(set_list)
-        ##else:
         ghost_menu = gtk.Menu()
         for i in range(len(set_list)):
             if set_list[i] is None:
                 continue
             name = set_list[i]['name']
-            icon_path = set_list[i]['icon']
-            pixbuf = None
-            if icon_path is not None:
-                try:
-                    pixbuf = ninix.pix.create_pixbuf_from_file(icon_path,
-                                                               is_pnr=0)
-                except:
-                    pixbuf = None
+            icon = set_list[i]['icon']
             shell_list = set_list[i]['shell']
-            if pixbuf is not None:
-                pixbuf = pixbuf.scale_simple(16, 16, gtk.gdk.INTERP_BILINEAR)
+            if icon is not None:
                 image = gtk.Image()
-                image.set_from_pixbuf(pixbuf)
+                image.set_from_pixbuf(icon)
                 image.show()
                 item = gtk.ImageMenuItem(name)
                 item.set_image(image)
@@ -651,35 +638,25 @@ class Menu:
         menuitem =  self.ui_manager.get_widget(''.join(('/popup/', 'Change')))
         menuitem.set_submenu(ghost_menu)
         self.__menu_list['Change'][3] = 1
-        self.__ghost_list = set_list
+        ##self.__ghost_list = set_list
 
     def __set_ghost_menu(self):
         ghosts = self.__ghost.app.get_ghost_list() ## FIXME
-        self.__update_ghost_menu(ghosts)
-        self.__update_summon_menu(ghosts)
+        if ghosts != self.__ghost_list or self.__ghost_list is None:
+            self.__update_ghost_menu(ghosts)
+            self.__update_summon_menu(ghosts)
 
     def __update_summon_menu(self, set_list):
-        ##if self.__ghost_list is None:
-        ##    self.__create_ghost_menu(set_list)
-        ##else:
         ghost_menu = gtk.Menu()
         for i in range(len(set_list)):
             if set_list[i] is None:
                 continue
             name = set_list[i]['name']
-            icon_path = set_list[i]['icon']
-            pixbuf = None
-            if icon_path is not None:
-                try:
-                    pixbuf = ninix.pix.create_pixbuf_from_file(icon_path,
-                                                               is_pnr=0)
-                except:
-                    pixbuf = None
+            icon = set_list[i]['icon']
             shell_list = set_list[i]['shell']
-            if pixbuf is not None:
-                pixbuf = pixbuf.scale_simple(16, 16, gtk.gdk.INTERP_BILINEAR)
+            if icon is not None:
                 image = gtk.Image()
-                image.set_from_pixbuf(pixbuf)
+                image.set_from_pixbuf(icon)
                 image.show()
                 item = gtk.ImageMenuItem(name)
                 item.set_image(image)
@@ -710,7 +687,7 @@ class Menu:
         menuitem = self.ui_manager.get_widget(''.join(('/popup/', 'Summon')))
         menuitem.set_submenu(ghost_menu)
         self.__menu_list['Summon'][3] = 1
-        self.__ghost_list = set_list
+        ##self.__ghost_list = set_list
 
     def __update_shell_menu(self, set_list):
         ##if self.__shell_list is None:
index e7761f0..387c444 100644 (file)
@@ -334,10 +334,9 @@ class Skin:
             self.nekoninni.finalize()
             return
         self.w, self.h = image.get_size()
-        self.mask_pixmap = mask
         self.darea.set_size_request(self.w, self.h)
         self.darea.window.set_back_pixmap(image, False)        
-        self.window.shape_combine_mask(self.mask_pixmap, 0, 0)
+        self.window.shape_combine_mask(mask, 0, 0)
 
     def set_position(self, reset=0):
         scrn_w = gtk.gdk.screen_width()
@@ -527,10 +526,9 @@ class Katochan:
             self.nekoninni.finalize()
             return
         self.w, self.h = image.get_size()
-        self.mask_pixmap = mask
         self.darea.set_size_request(self.w, self.h)
         self.darea.window.set_back_pixmap(image, False)
-        self.window.shape_combine_mask(self.mask_pixmap, 0, 0)
+        self.window.shape_combine_mask(mask, 0, 0)
         self.darea.queue_draw_area(0, 0, self.w, self.h)
 
     def load(self, data):
index 976aef5..86a7698 100644 (file)
@@ -1066,7 +1066,7 @@ class SurfaceWindow:
                 dest_y = y
             overlay.composite(pixbuf, dest_x, dest_y,
                               w, h, x, y, 1.0, 1.0,
-                              gtk.gdk.INTERP_BILINEAR, 255)        
+                              gtk.gdk.INTERP_BILINEAR, 255)
         return pixbuf
 
     def get_pixbuf(self, pixbuf_id):
@@ -1123,8 +1123,8 @@ class SurfaceWindow:
             h = max(1, surface_pixbuf.get_height() * self.__scale / 100)
             surface_pixbuf = surface_pixbuf.scale_simple(
                 w, h, gtk.gdk.INTERP_BILINEAR)
-        surface_pixmap, self.mask_pixmap = \
-                        surface_pixbuf.render_pixmap_and_mask(1)
+        surface_pixmap, mask_pixmap = surface_pixbuf.render_pixmap_and_mask(1)
+        self.window.shape_combine_mask(mask_pixmap, 0, 0)
         self.current_surface_pixbuf = surface_pixbuf
         self.darea.queue_draw()
 
@@ -1135,7 +1135,6 @@ class SurfaceWindow:
         cr.paint()
         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()
 
index 3499d54..a5a0894 100644 (file)
@@ -10,7 +10,7 @@
 #  PURPOSE.  See the GNU General Public License for more details.
 #
 
-NUMBER = '3.9.3'
+NUMBER = '3.9.4'
 CODENAME = '"I see no more YASAGURE here."'
 
 VERSION = '%s (%s)' % (NUMBER, CODENAME)