trying to fix reboot bug
authorMarcus W <mece@LeChuck2.(none)>
Fri, 29 Jan 2010 23:18:01 +0000 (01:18 +0200)
committerMarcus W <mece@LeChuck2.(none)>
Fri, 29 Jan 2010 23:18:01 +0000 (01:18 +0200)
comic-widget.py

index 71f2169..56a2b2a 100644 (file)
@@ -8,9 +8,9 @@ import string
 import os
 import osso
 import cairo
 import os
 import osso
 import cairo
-import pango
 import datetime
 
 import datetime
 
+supports_alpha = False
 
 # constants. dbfile is the location of the csv
 # comiccache is the location of the images
 
 # constants. dbfile is the location of the csv
 # comiccache is the location of the images
@@ -251,6 +251,7 @@ class ComicDb():
 class ComicHomePlugin(hildondesktop.HomePluginItem):
        def __init__(self):
                hildondesktop.HomePluginItem.__init__(self)
 class ComicHomePlugin(hildondesktop.HomePluginItem):
        def __init__(self):
                hildondesktop.HomePluginItem.__init__(self)
+               global supports_alpha
                self.set_settings(True)
                self.connect("show-settings", self.show_options)
                self.osso_c = osso.Context("comic-widget", "0.0.1", False)
                self.set_settings(True)
                self.connect("show-settings", self.show_options)
                self.osso_c = osso.Context("comic-widget", "0.0.1", False)
@@ -262,6 +263,11 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                self.set_name = "comicwidget"
                screen = self.get_screen()
                colormap = screen.get_rgba_colormap()
                self.set_name = "comicwidget"
                screen = self.get_screen()
                colormap = screen.get_rgba_colormap()
+               if colormap == None:
+                       colormap = screen.get_rgb_colormap()
+                       supports_alpha = False
+               else:
+                       supports_alpha = True
                self.set_colormap(colormap)
                self.set_app_paintable(True)
                #setup internal area
                self.set_colormap(colormap)
                self.set_app_paintable(True)
                #setup internal area
@@ -372,11 +378,24 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
 
        # **************** Cairo draw functions ***************
 
 
        # **************** Cairo draw functions ***************
 
-       def realize(self):
+       def realize(self, widget):
+               global supports_alpha
+
+               # To check if the display supports alpha channels, get the colormap
                screen = self.get_screen()
                colormap = screen.get_rgba_colormap()
                screen = self.get_screen()
                colormap = screen.get_rgba_colormap()
+               if colormap == None:
+                       print 'Your screen does not support alpha channels!'
+                       colormap = screen.get_rgb_colormap()
+                       supports_alpha = False
+               else:
+               #      print 'Your screen supports alpha channels!'
+                       supports_alpha = True
+
+               # Now we have a colormap appropriate for the screen, use it
                self.set_colormap(colormap)
                self.set_colormap(colormap)
-               return None
+
+               return False
 
        def do_expose_event(widget, event):
                cr = widget.window.cairo_create()
 
        def do_expose_event(widget, event):
                cr = widget.window.cairo_create()
@@ -390,7 +409,11 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                region = gtk.gdk.region_rectangle(event.area)
                cr.region(region)
                bg_color=gtk.gdk.color_parse('#000000')
                region = gtk.gdk.region_rectangle(event.area)
                cr.region(region)
                bg_color=gtk.gdk.color_parse('#000000')
-               cr.set_source_rgba (0.0, 0.0, 0.0, 0.5)
+               if supports_alpha:
+                       cr.set_source_rgba (0.0, 0.0, 0.0, 0.5)
+               else:
+                       cr.set_source_rgb (0.0, 0.0, 0.0)
+                       
                cr.fill_preserve()
                return False
 
                cr.fill_preserve()
                return False
 
@@ -459,7 +482,7 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                                self.e_goweb.show_all()
 
                        elif func == 'switch':
                                self.e_goweb.show_all()
 
                        elif func == 'switch':
-                               self.keypointer = (self.keypointer + 1) % 2
+                               self.keypointer = (self.keypointer + 1) % 3
                                self.imgvpos = 0
                                self.db = []
                                print "switching to " + self.keys[self.keypointer]
                                self.imgvpos = 0
                                self.db = []
                                print "switching to " + self.keys[self.keypointer]
@@ -476,7 +499,7 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                                self.comic_image = self.get_resized_pixmap(self.db.get_comic(), self.imgvpos)
                                self.e_open.add(self.comic_image)
                                self.e_open.show_all()  
                                self.comic_image = self.get_resized_pixmap(self.db.get_comic(), self.imgvpos)
                                self.e_open.add(self.comic_image)
                                self.e_open.show_all()  
-                       
+
                        else:
                                return False                    
                self.draw(widget, "0")
                        else:
                                return False                    
                self.draw(widget, "0")
@@ -535,6 +558,24 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                print "vpos after fixing image: " + str(self.imgvpos)
                return retimg
 
                print "vpos after fixing image: " + str(self.imgvpos)
                return retimg
 
+       def screen_changed(self, widget, old_screen=None):
+               global supports_alpha
+
+               # To check if the display supports alpha channels, get the colormap
+               screen = self.get_screen()
+               colormap = screen.get_rgba_colormap()
+               if colormap == None:
+                       print 'Your screen does not support alpha channels!'
+                       colormap = screen.get_rgb_colormap()
+                       supports_alpha = False
+               else:
+               #      print 'Your screen supports alpha channels!'
+                       supports_alpha = True
+
+               # Now we have a colormap appropriate for the screen, use it
+               self.set_colormap(colormap)
+
+               return False
 
 # ************************* OPTIONS ********************************
 
 
 # ************************* OPTIONS ********************************