print "comic db creation failed after copy"
+ def get_stored(self):
+ try:
+ idf = open(self.dbfile + ".last", 'r')
+ retval = idf.read()
+ print "got stored index :" + str(retval)
+ idf.close()
+ return int(retval)
+ except:
+ return 0
+
+ def store_last(self, sid = 0):
+ try:
+ idf = open(self.dbfile + ".last", 'w')
+ if sid > 0:
+ idf.write(str(sid))
+ else:
+ idf.write(str(self.currentcomic))
+ idf.close()
+ return True
+ except:
+ return False
+
+
def get_comic(self):
# print str(self.currentcomic)
if self.currentcomic < 0:
dbw = csv.writer(dbf)
dbw.writerow(irow)
dbf.close()
+ stored = self.get_stored()
+ if stored > 0:
+ self.store_last(stored + 1)
def insert_row_first(self, irow):
dbf = open(self.dbfile, 'w')
self.e_goweb.show_all()
elif func == 'switch':
+ # Check if store needed..
+ if not self.db.currentcomic == 0 and not self.db.currentcomic == (len(self.db.db) - 1):
+ print "Storing location " + str(self.db.currentcomic)
+ if self.db.store_last():
+ print "stored successfully"
+ else:
+ print "store failed"
+
self.active_comics = self.get_active_comics()
- print "closing log"
+ # print "closing log"
#sys.stdout.close()
#sys.stdout = sys.__stdout__
#sys.stderr.close()
#if not, write defaults
+ def goto_comic(self, index):
+ self.db.currentcomic = index
+ self.e_open.remove(self.comic_image)
+ 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.e_goweb.remove(self.label)
+ titl = str(self.db.db[self.db.currentcomic]['title'])
+ if len(titl) > 22:
+ titl = titl[:19] + "..."
+ self.label.set_markup(self.get_markup())
+ self.e_goweb.add(self.label)
+ self.e_goweb.show_all()
+
# ************************* OPTION DIALOGS ********************************
def show_options(self, widget):
comics_button.set_alignment(0,0,0,0)
comics_button.connect("clicked", self.show_comics)
+ navfirst_button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ navfirst_button.set_text("Go to earliest", "Jump to the earliest cached comic")
+ navfirst_button.set_alignment(0,0,0,0)
+ navfirst_button.connect("clicked", self.show_nav, "oldest")
+
+ navlast_button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ navlast_button.set_text("Go to latest", "Jump to the latest cached comic")
+ navlast_button.set_alignment(0,0,0,0)
+ navlast_button.connect("clicked", self.show_nav, "newest")
+
+ navstored_button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ navstored_button.set_text("Go to last visited", "Jump to where you were before you switched comics")
+ navstored_button.set_alignment(0,0,0,0)
+ navstored_button.connect("clicked", self.show_nav, "stored")
+
# 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(navstored_button, True, True, 0)
+ dialog.vbox.pack_start(navfirst_button, True, True, 0)
+ dialog.vbox.pack_start(navlast_button, True, True, 0)
dialog.vbox.pack_start(comics_button, True, True, 0)
print "adding about button"
dialog.vbox.pack_start(about_button, True, True, 0)
dialog.run()
dialog.destroy()
+ def show_nav(self, widget, goto):
+ if goto == "stored":
+ print "look for stored file"
+ self.goto_comic(self.db.get_stored())
+ elif goto == "newest":
+ self.goto_comic(0)
+ elif goto == "oldest":
+ self.goto_comic(len(self.db.db) - 1)
def show_about(self, widget):
print "in about dialog"
dialog = gtk.AboutDialog()