+ def show_comics(self, widget):
+ print "in comics dialog! yay!"
+ dialog = gtk.Dialog("Configure Search Engines", None, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR)
+ comiclist = comics.keys()
+ comiclist.sort()
+ buttonlist = {}
+ self.connlist = {}
+ for comicid in comiclist:
+ buttonlist[comicid] = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ print buttonlist[comicid].get_name()
+
+ print buttonlist[comicid].set_alignment(0, 0.5, 0, 0.5)
+ active = False
+ for acomic in self.active_comics:
+ if acomic == comicid:
+ active = True
+ break
+ if active:
+ buttonlist[comicid].set_text(comics[comicid]['name'] + " *", comicid + ": click to remove")
+ self.connlist[comicid] = buttonlist[comicid].connect("clicked", self.remove_comic)
+ else:
+ buttonlist[comicid].set_text(comics[comicid]['name'], comicid + ": click to add")
+ self.connlist[comicid] = buttonlist[comicid].connect("clicked", self.add_comic)
+ dialog.vbox.pack_start(buttonlist[comicid], True, True, 0)
+
+
+ dialog.show_all()
+ dialog.run()
+ dialog.destroy()
+
+ def add_comic(self, widget):
+ print "add " + widget.get_title()
+ splt = string.split(widget.get_value(), ':', 1)
+ comicid = splt[0]
+ if os.path.isfile(activecomics) == True:
+ print "added " + comicid + " to " + str(self.active_comics)
+ try:
+ found = self.active_comics.index(comicid)
+ except:
+ self.active_comics.append(comicid)
+ dbf = open(activecomics, 'w')
+ dbw = csv.writer(dbf)
+ dbw.writerow(self.active_comics)
+ dbf.close()
+ widget.set_text(comics[comicid]['name'] + " *", comicid + ": click to remove")
+ widget.disconnect(self.connlist[comicid])
+ self.connlist[comicid] = widget.connect("clicked", self.remove_comic)
+
+ def remove_comic(self, widget):
+ print "remove " + widget.get_title()
+ if len(self.active_comics) == 1:
+ return
+ splt = string.split(widget.get_value(), ':', 1)
+ comicid = splt[0]
+ if os.path.isfile(activecomics) == True:
+ print "removing " + comicid + " from " + str(self.active_comics)
+ try:
+ del self.active_comics[self.active_comics.index(comicid)]
+ except:
+ pass
+ dbf = open(activecomics, 'w')
+ dbw = csv.writer(dbf)
+ dbw.writerow(self.active_comics)
+ dbf.close()
+ 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
+