possibility to change size with size.cfg
authormece <mece@mariehamn.(none)>
Thu, 4 Feb 2010 14:06:23 +0000 (16:06 +0200)
committermece <mece@mariehamn.(none)>
Thu, 4 Feb 2010 14:06:23 +0000 (16:06 +0200)
build_setup.py
debian/changelog
debian/copyright
debs/comic-widget_0.3.3-1_all.deb [new file with mode: 0644]
extras-devel/comic-widget_0.3.3-1.changes [new file with mode: 0644]
extras-devel/comic-widget_0.3.3-1.dsc [new file with mode: 0644]
extras-devel/comic-widget_0.3.3-1.tar.gz [new file with mode: 0644]
src/usr/lib/hildon-desktop/comicwidget.py

index 1a9d4b5..012acea 100644 (file)
@@ -36,10 +36,10 @@ if __name__ == "__main__":
         #  chmod +x /usr/bin/mclock.py""" #Set here your pre install script
         #  p.prer 1000 emove="""#!/bin/sh
         #  chmod +x /usr/bin/mclock.py""" #Set here your pre remove script
-        version = "0.3.2"           #Version of your software, e.g. "1.2.0" or "0.8.2"
-        build = "2"                 #Build number, e.g. "1" for the first build of this version of your software. Increment for later re-builds of the same version of your software.
+        version = "0.3.3"           #Version of your software, e.g. "1.2.0" or "0.8.2"
+        build = "1"                 #Build number, e.g. "1" for the first build of this version of your software. Increment for later re-builds of the same version of your software.
                                      #Text with changelog information to be displayed in the package "Details" tab of the Maemo Application Manager
-        changeloginformation = "fixed bug with comic list buttons" 
+        changeloginformation = "possibility to change size of the widget with a config file" 
         dir_name = "src"            #Name of the subfolder containing your package source files (e.g. usr\share\icons\hicolor\scalable\myappicon.svg, usr\lib\myapp\somelib.py). We suggest to leave it named src in all projects and will refer to that in the wiki article on maemo.org
         #Thanks to DareTheHair from talk.maemo.org for this snippet that recursively builds the file list 
         for root, dirs, files in os.walk(dir_name):
index 0d0618f..d3bdbde 100644 (file)
@@ -1,5 +1,5 @@
-comic-widget (0.3.2-2) stable; urgency=low
+comic-widget (0.3.3-1) stable; urgency=low
 
-  fixed bug with comic list buttons
+  possibility to change size of the widget with a config file
 
- -- Marcus Wikstrom <mece@ovi.com>  Thu, 04 Feb 2010 14:05:28 +0000
+ -- Marcus Wikstrom <mece@ovi.com>  Thu, 04 Feb 2010 16:02:22 +0000
index 2f1663e..968e228 100644 (file)
@@ -1,5 +1,5 @@
 This package was py2debianized(0.5.3) by Marcus Wikstrom <mece@ovi.com> on
-Thu, 04 Feb 2010 14:05:28 +0000.
+Thu, 04 Feb 2010 16:02:22 +0000.
 
 It was downloaded from 
 
diff --git a/debs/comic-widget_0.3.3-1_all.deb b/debs/comic-widget_0.3.3-1_all.deb
new file mode 100644 (file)
index 0000000..c0fbb47
Binary files /dev/null and b/debs/comic-widget_0.3.3-1_all.deb differ
diff --git a/extras-devel/comic-widget_0.3.3-1.changes b/extras-devel/comic-widget_0.3.3-1.changes
new file mode 100644 (file)
index 0000000..416c438
--- /dev/null
@@ -0,0 +1,17 @@
+Maintainer: Marcus Wikstrom <mece@ovi.com>
+Format: 1.7
+Source: comic-widget
+Version: 0.3.3-1
+Architecture: all
+Date: Thu, 04 Feb 2010 14:02:28 +0000
+Distribution: fremantle
+Urgency: low
+Description: 
+ A widget that displays comics taken from the web.
+Changes: 
+ possibility to change size of the widget with a config file
+Changed-By: Marcus Wikstrom <mece@ovi.com>
+Files:
+ 814a68376a710f604dbd5496b2da21b0 69699 user/desktop extras-devel comic-widget_0.3.3-1.tar.gz
+ 29b1491209094dcb0f79a8f61b589633 349 user/desktop extras-devel comic-widget_0.3.3-1.dsc
+
diff --git a/extras-devel/comic-widget_0.3.3-1.dsc b/extras-devel/comic-widget_0.3.3-1.dsc
new file mode 100644 (file)
index 0000000..6fbf835
--- /dev/null
@@ -0,0 +1,10 @@
+Source: comic-widget
+Version: 0.3.3-1
+Maintainer: Marcus Wikstrom <mece@ovi.com>
+Architecture: all
+Format: 1.0
+Build-Depends: python2.5, python-osso, python-gtk2, python-hildon, python-hildondesktop, python2.5-cairo, hildon-desktop-python-loader
+Standards-Version: 0.3.3-1
+Files:
+ 814a68376a710f604dbd5496b2da21b0 69699 comic-widget_0.3.3-1.tar.gz
+
diff --git a/extras-devel/comic-widget_0.3.3-1.tar.gz b/extras-devel/comic-widget_0.3.3-1.tar.gz
new file mode 100644 (file)
index 0000000..6c734b0
Binary files /dev/null and b/extras-devel/comic-widget_0.3.3-1.tar.gz differ
index 5838299..20b5eb4 100644 (file)
@@ -22,7 +22,7 @@ supports_alpha = False
 
 # constants. dbfile is the location of the csv
 # comiccache is the location of the images
-APP_VERSION = "0.3.2"
+APP_VERSION = "0.3.2-2"
 
 basedbdir = "/opt/comic-widget/db/"
 imagedir = "/opt/comic-widget/images/"
@@ -33,9 +33,11 @@ comics = {"xkcd":{"name":"xkcd","link":"http://xkcd.org/","start":666,"dbfile":d
                "sinfest":{"name":"Sinfest","link":"http://sinfest.com/","start":3400,"dbfile":dbdir + "comicdb.sinfest.csv"},
                "phd":{"name":"PHD Comics","link":"http://www.phdcomics.com/","start":1240,"dbfile":dbdir + "comicdb.phd.csv"},
                "dilbert":{"name":"Dilbert","link":"http://dilbert.com/","start":"2009-01-01","dbfile":dbdir + "comicdb.dilbert.csv"},
-               "cyanide":{"name":"Cyanide&amp;Happiness","link":"http://explosm.com/","start":"1920","dbfile":dbdir + "comicdb.cyanide.csv"},
+               "cyanide":{"name":"C and H","link":"http://explosm.com/","start":"1920","dbfile":dbdir + "comicdb.cyanide.csv"},
                }
-defaults = {}
+defaults = {'width':480,'height':230}
+#defaults = {'width':480,'height':240}
+sizefile = "/home/user/.comic-widget/size.cfg"
 previous = False
 next = False
 
@@ -515,6 +517,9 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                global supports_alpha
                self.set_settings(True)
                self.active_comics = self.get_active_comics()
+               self.sizes = self.get_size_settings()
+               self.new_width = self.sizes['width']
+               self.new_height = self.sizes['height']
                self.connect("show-settings", self.show_options)
                self.osso_c = osso.Context("comic-widget", "0.3.0", False)
                self.osso_rpc = osso.Rpc(self.osso_c)
@@ -534,7 +539,7 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                self.set_colormap(colormap)
                self.set_app_paintable(True)
                #setup internal area
-               self.set_size_request(480, 230)
+               self.set_size_request(self.sizes['width'], self.sizes['height'])
                self.imgvpos = 0;
                self.vbox = gtk.VBox()
                self.hbox = gtk.HBox()
@@ -639,6 +644,8 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                self.vbox.show_all()
                self.add(self.vbox)
 
+
+
        # **************** Cairo draw functions ***************
 
        def realize(self, widget):
@@ -799,23 +806,26 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
 
        def get_resized_pixmap(self, filename, vpos):
                print "vpos: " + str(vpos)
-
-               maxheight = 182
+               
+               width = int(self.sizes['width'])
+               height = int(self.sizes['height'])
+               picwidth = width - 2
+               maxheight = height - 48
 
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
-               parent_buf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pixbuf.get_has_alpha(), 8, 480, maxheight)
+               parent_buf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pixbuf.get_has_alpha(), 8, width, maxheight)
                parent_buf.fill(0xffffffff)
                retimg = gtk.Image()
                # get correct width/height
                new_height = 1
-               new_width = 478
-               new_height = int((478.0 / pixbuf.get_width()) * pixbuf.get_height())
+               new_width = picwidth
+               new_height = int((float(picwidth) / pixbuf.get_width()) * pixbuf.get_height())
                scaled_buf = pixbuf.scale_simple(new_width,new_height,gtk.gdk.INTERP_BILINEAR)
                print "scaled height: " + str(scaled_buf.get_height())
                if scaled_buf.get_height() > maxheight:
                        if scaled_buf.get_height() - (vpos + maxheight) < 0:
                                vpos = scaled_buf.get_height() - maxheight
-                       scaled_buf.copy_area(0,vpos,478,maxheight,parent_buf,1,0)
+                       scaled_buf.copy_area(0,vpos,picwidth,maxheight,parent_buf,1,0)
                        # parent_buf.composite(scaled_buf, 0, 0, 478, maxheight, 0, 0, 478, maxheight, gtk.gdk.INTERP_BILINEAR, 0)
                        self.imgvpos = vpos
                else:
@@ -823,10 +833,10 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                        if tmpy > 0:
                                tmpy = tmpy / 2
 
-                       scaled_buf.copy_area(0,0,478,scaled_buf.get_height(),parent_buf,1,tmpy)
+                       scaled_buf.copy_area(0,0,picwidth,scaled_buf.get_height(),parent_buf,1,tmpy)
                        self.imgvpos = 0
 #              test = parent_buf.render_pixmap_and_mask(0)
-               parent_buf.add_alpha(True,chr(255),chr(255),chr(255))
+#              parent_buf.add_alpha(True,chr(255),chr(255),chr(255))
                retimg.set_from_pixbuf(parent_buf)
                print retimg.get_pixel_size()
                print "vpos after fixing image: " + str(self.imgvpos)
@@ -912,10 +922,16 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                comics_button.set_alignment(0,0,0,0)
                comics_button.connect("clicked", self.show_comics)
 
+               # size_button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+               # size_button.set_text("Change size", "Change the size of the widget")
+               # size_button.set_alignment(0,0,0,0)
+               # size_button.connect("clicked", self.show_size)
+
                print "adding buttons to dialog, starting with comics"
                dialog.vbox.pack_start(comics_button, True, True, 0)
                print "adding about button"
                dialog.vbox.pack_start(about_button, True, True, 0)
+               # dialog.vbox.pack_start(size_button, True, True, 0)
                print "show!"
                dialog.show_all()
                dialog.run()
@@ -966,7 +982,7 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                dialog.show_all()
                dialog.run()
                dialog.destroy()
-                               
+
        def add_comic(self, widget):
                print "add " + widget.get_title()
                splt = string.split(widget.get_value(), ':', 1)
@@ -1004,6 +1020,41 @@ class ComicHomePlugin(hildondesktop.HomePluginItem):
                widget.set_text(comics[comicid]['name'], comicid + ": click to add")
                widget.disconnect(self.connlist[comicid])
                self.connlist[comicid] = widget.connect("clicked", self.add_comic)
+
+       def get_size_settings(self):
+               # defaults = {'width':480,'height':230}
+               # options: w 798 700 600 500 480 400
+               # options: h 420 360 310 270 240 200
+               print "checking to see if config file is available"
+               if os.path.isfile(sizefile) == True:
+                       print "found " + sizefile
+                       dbf = open(sizefile, 'r')
+                       dbr = csv.reader(dbf)
+                       try:
+                               cfg = dbr.next()
+                       except:
+                               dbf.close()
+                               print "empty config file"
+                               return defaults
+                       dbf.close()
+                       
+                       sizes = {'width':int(cfg[0]),'height':int(cfg[1])}
+                       if sizes['width'] > 798:
+                               sizes['width'] = 798
+                       if sizes['width'] < 400:
+                               sizes['width'] = 400
+                       if sizes['height'] > 420:
+                               sizes['height'] = 420
+                       if sizes['height'] < 200:
+                               sizes['height'] = 200
+                       
+                       return sizes
+                       
+                       
+               # if not, copy it.
+               else:
+                       print "no config file"
+                       return defaults
                
 hd_plugin_type = ComicHomePlugin