deskbar-applet r2093 - in trunk: . data/art data/art/48x48 data/art/scalable deskbar/core deskbar/ui



Author: sebp
Date: Wed Apr  9 11:25:14 2008
New Revision: 2093
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2093&view=rev

Log:
Both horizontal and vertical panel show the same icon now.
Use PNG images for the icon when the panel is smaller 48 and SVG image above. (fixes #526536 completely)

Added:
   trunk/data/art/48x48/
   trunk/data/art/48x48/deskbar-applet.png
      - copied unchanged from r2081, /trunk/data/art/scalable/deskbar-applet.png
Removed:
   trunk/data/art/scalable/deskbar-applet.png
Modified:
   trunk/ChangeLog
   trunk/data/art/Makefile.am
   trunk/deskbar/core/Utils.py
   trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py
   trunk/deskbar/ui/DeskbarApplet.py
   trunk/deskbar/ui/DeskbarStatusIcon.py

Modified: trunk/data/art/Makefile.am
==============================================================================
--- trunk/data/art/Makefile.am	(original)
+++ trunk/data/art/Makefile.am	Wed Apr  9 11:25:14 2008
@@ -26,8 +26,8 @@
 32icondir = $(datadir)/icons/hicolor/32x32/apps
 32icon_DATA = 32x32/deskbar-applet.png
 
-icondir = $(datadir)/icons/hicolor/48x48/apps
-icon_DATA = scalable/deskbar-applet.png
+48icondir = $(datadir)/icons/hicolor/48x48/apps
+48icon_DATA = 48x48/deskbar-applet.png
 
 svgicondir = $(datadir)/icons/hicolor/scalable/apps
 svgicon_DATA = scalable/deskbar-applet.svg
@@ -50,7 +50,7 @@
 	$(16icon_DATA) \
 	$(22icon_DATA) \
 	$(32icon_DATA) \
-	$(icon_DATA) \
+	$(48icon_DATA) \
 	$(svgicon_DATA) \
 	16x16/deskbar-applet.svg \
 	22x22/deskbar-applet.svg \

Modified: trunk/deskbar/core/Utils.py
==============================================================================
--- trunk/deskbar/core/Utils.py	(original)
+++ trunk/deskbar/core/Utils.py	Wed Apr  9 11:25:14 2008
@@ -109,10 +109,10 @@
             elif icon.startswith("/"):
                 pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon, width, height)
             else:
-                pixbuf = ICON_THEME.load_icon(splitext(icon)[0], width, gtk.ICON_LOOKUP_USE_BUILTIN)
+                pixbuf = load_icon_from_icon_theme(splitext(icon)[0], width)
         except Exception, msg1:
             try:
-                pixbuf = ICON_THEME.load_icon(icon, width, gtk.ICON_LOOKUP_USE_BUILTIN)
+                pixbuf = load_icon_from_icon_theme(icon, width)
             except Exception, msg2:
                 LOGGER.warning ("Icon %s Load Error: %s (or %s)", icon, msg1, msg2)
                 pixbuf = _get_fall_back_icon()
@@ -122,12 +122,15 @@
         pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
     return pixbuf
 
+def load_icon_from_icon_theme(iconname, size):
+    return ICON_THEME.load_icon(iconname, size, gtk.ICON_LOOKUP_USE_BUILTIN)
+
 def _get_fall_back_icon():
     """
     @return: stock_unknown icon or C{None}
     """
     try:
-        return ICON_THEME.load_icon("stock_unknown", width, gtk.ICON_LOOKUP_USE_BUILTIN)
+        return load_icon_from_icon_theme("stock_unknown", width)
     except Exception, msg:
         LOGGER.warning ("Icon `stock_unknown' is not present in theme")
         return None

Modified: trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py
==============================================================================
--- trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py	(original)
+++ trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py	Wed Apr  9 11:25:14 2008
@@ -1,5 +1,6 @@
 from deskbar.core.CoreImpl import CoreImpl
 from deskbar.core.GconfStore import GconfStore
+from deskbar.core.Utils import load_icon_from_icon_theme
 from deskbar.ui.CuemiacAlignedView import CuemiacAlignedView
 from deskbar.ui.CuemiacWindowController import CuemiacWindowController
 from deskbar.ui.CuemiacWindowView import CuemiacWindowView
@@ -7,6 +8,8 @@
 import gtk
 import gobject
 
+ICON_NAME = "deskbar-applet"
+
 class AbstractCuemiacDeskbarIcon (object):
     
     def __init__(self):
@@ -79,6 +82,19 @@
                 return True
         return False
    
+    def get_deskbar_icon(self, size):
+        if size < 24:
+            size = 16
+        elif size < 32:
+            size = 22
+        elif size < 48:
+            size = 32
+        elif size >= 48:
+            if not self._has_svg_support():
+                size = 48
+        
+        return load_icon_from_icon_theme (ICON_NAME, size)
+        
     def on_loaded(self, sender):
         """
         Called when all modules have been loaded and

Modified: trunk/deskbar/ui/DeskbarApplet.py
==============================================================================
--- trunk/deskbar/ui/DeskbarApplet.py	(original)
+++ trunk/deskbar/ui/DeskbarApplet.py	Wed Apr  9 11:25:14 2008
@@ -39,25 +39,6 @@
         
         self.applet.show_all()
 
-    def get_image_filename_and_size(self, size):
-        """
-        Choose correct icon and calculate its size
-        """
-        image_name = "deskbar-applet-panel"
-        if self.applet.get_orient() in [gnomeapplet.ORIENT_UP, gnomeapplet.ORIENT_DOWN]:
-            image_name += "-h"
-        else:
-            image_name += "-v"
-        
-        if size > 31 and self._has_svg_support():
-            image_name += ".svg"
-            s = size - 12
-        else:
-            image_name += ".png"
-            s = -1 # Don't resize image
-            
-        return os.path.join(deskbar.ART_DATA_DIR, image_name), s
-        
     def on_allocate(self, applet, alloc):
         if self.applet.get_orient () in [gnomeapplet.ORIENT_UP, gnomeapplet.ORIENT_DOWN]:
             size_alloc = alloc.height
@@ -70,12 +51,7 @@
         """
         @param size_alloc: The space that's available in pixels
         """
-        filename, size = self.get_image_filename_and_size(size_alloc)
-        
-        if self.applet.get_orient() in [gnomeapplet.ORIENT_DOWN, gnomeapplet.ORIENT_UP]:
-            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (filename, -1, size)
-        else:
-            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (filename, size, -1)
+        pixbuf = self.get_deskbar_icon(size_alloc)
         
         self.applet.handler_block(self.handler_size_allocate_id)
         self.image.set_from_pixbuf (pixbuf)

Modified: trunk/deskbar/ui/DeskbarStatusIcon.py
==============================================================================
--- trunk/deskbar/ui/DeskbarStatusIcon.py	(original)
+++ trunk/deskbar/ui/DeskbarStatusIcon.py	Wed Apr  9 11:25:14 2008
@@ -78,29 +78,9 @@
         AbstractCuemiacDeskbarIcon.on_loaded (self, sender)
         self.set_visible (True)
     
-    def set_button_image_from_file (self, filename, size):
-        # We use an intermediate pixbuf to scale the image
-        if self.get_property("orientation") == gtk.ORIENTATION_HORIZONTAL:
-            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (filename, -1, size)
-        else:
-            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (filename, size, -1)
-        self.set_from_pixbuf (pixbuf)
-        
     def _on_size_changed (self, status_icon, size):
-        image_name = "deskbar-applet-panel"
-        if self.get_property("orientation") == gtk.ORIENTATION_HORIZONTAL:
-            image_name += "-h"
-        else:
-            image_name += "-v"
-        
-        if size > 36 and self._has_svg_support():
-            image_name += ".svg"
-            s = size-12
-        else:
-            image_name += ".png"
-            s = -1
-        
-        self.set_button_image_from_file (join(deskbar.ART_DATA_DIR, image_name), s)
+        pixbuf = self.get_deskbar_icon (size)
+        self.set_from_pixbuf (pixbuf)
         
     def _on_activate (self, status_icon):
         AbstractCuemiacDeskbarIcon.set_active (self, not self.active, gtk.get_current_event_time())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]