def updateeditordesc(self): openers = images.besthandler(self.activeselected[0].split(":")[0]).canopenwith() self.activeeditor = max(0, min(self.activeeditor, len(openers)-1)) self.builder.get_object("currenteditor").set_text(openers[self.activeeditor]) #this doesn't actually go here but is always done at the same time takentime = datetime.datetime.fromtimestamp(self.activeselected[2]) self.builder.get_object("takentime").set_text(str(takentime))
def updateeditordesc(self): openers = images.besthandler( self.activeselected[0].split(":")[0]).canopenwith() self.activeeditor = max(0, min(self.activeeditor, len(openers) - 1)) self.builder.get_object("currenteditor").set_text( openers[self.activeeditor]) #this doesn't actually go here but is always done at the same time takentime = datetime.datetime.fromtimestamp(self.activeselected[2]) self.builder.get_object("takentime").set_text(str(takentime))
def main(): if len(sys.argv) > 1 and sys.argv[1] == "help": print("usage: " + sys.argv[0] + " command [commandargs]") print("add filename1 [filename2 [filename3 [...]]]") print("reloaddates") print("newdb") print("makethumbs") print("info") elif len(sys.argv) > 2 and sys.argv[1] == "add": db = database.pdb("test.pdb") for i in range(2, len(sys.argv)): db.add(sys.argv[i], photodate=images.besthandler(sys.argv[i]).takentime( sys.argv[i])) #print sys.argv[i] db.save() elif len(sys.argv) > 1 and sys.argv[1] == "reloaddates": db = database.pdb("test.pdb") item = db.fetchone() while item != None: oldestdate = 10000000000 for f in item[0].split(":"): newdate = images.besthandler(f).takentime(f) if newdate < oldestdate: oldestdate = newdate newitem = (item[0], item[1], oldestdate) db.edit(item, newitem) item = db.fetchone() db.save() elif len(sys.argv) > 1 and sys.argv[1] == "newdb": database.makenew("test.pdb") elif len(sys.argv) > 1 and sys.argv[1] == "makethumbs": db = database.pdb("test.pdb") item = db.fetchone() while item != None: thumbload.loadthumb(item[0].split(":")[0]) item = db.fetchone() elif len(sys.argv) > 1 and sys.argv[1] == "info": db = database.pdb("test.pdb") print("number of images: " + str(db.howmany())) else: mw = mainwin() gtk.main()
def main(): if len(sys.argv) > 1 and sys.argv[1] == "help": print("usage: "+sys.argv[0]+" command [commandargs]") print("add filename1 [filename2 [filename3 [...]]]") print("reloaddates") print("newdb") print("makethumbs") print("info") elif len(sys.argv) > 2 and sys.argv[1] == "add": db = database.pdb("test.pdb") for i in range(2,len(sys.argv)): db.add(sys.argv[i], photodate=images.besthandler(sys.argv[i]).takentime(sys.argv[i])) #print sys.argv[i] db.save() elif len(sys.argv) > 1 and sys.argv[1] == "reloaddates": db = database.pdb("test.pdb") item = db.fetchone() while item != None: oldestdate = 10000000000 for f in item[0].split(":"): newdate = images.besthandler(f).takentime(f) if newdate < oldestdate: oldestdate = newdate newitem = (item[0],item[1],oldestdate) db.edit(item, newitem) item = db.fetchone() db.save() elif len(sys.argv) > 1 and sys.argv[1] == "newdb": database.makenew("test.pdb") elif len(sys.argv) > 1 and sys.argv[1] == "makethumbs": db = database.pdb("test.pdb") item = db.fetchone() while item != None: thumbload.loadthumb(item[0].split(":")[0]) item = db.fetchone() elif len(sys.argv) > 1 and sys.argv[1] == "info": db = database.pdb("test.pdb") print("number of images: "+str(db.howmany())) else: mw = mainwin() gtk.main()
def loadthumb(filename): thumb = None if filename in __cached: return __cached[filename] #print("loading from disk:"+filetothumb(filename)) if len(__cached) > 100: del __cached[random.choice(__cached.keys())] #print "deleted one" try: thumb = gtk.gdk.pixbuf_new_from_file(filetothumb(filename)) __cached[filename] = thumb except:#FIXME:shouldn't use except with no args try: images.besthandler(filename).genthumb(filename, filetothumb(filename)) thumb = gtk.gdk.pixbuf_new_from_file(filetothumb(filename)) __cached[filename] = thumb except: thumb = gtk.gdk.pixbuf_new_from_file("missingthumb.jpg") __cached[filename] = thumb return thumb
def loadthumb(filename): thumb = None if filename in __cached: return __cached[filename] #print("loading from disk:"+filetothumb(filename)) if len(__cached) > 100: del __cached[random.choice(__cached.keys())] #print "deleted one" try: thumb = gtk.gdk.pixbuf_new_from_file(filetothumb(filename)) __cached[filename] = thumb except: #FIXME:shouldn't use except with no args try: images.besthandler(filename).genthumb(filename, filetothumb(filename)) thumb = gtk.gdk.pixbuf_new_from_file(filetothumb(filename)) __cached[filename] = thumb except: thumb = gtk.gdk.pixbuf_new_from_file("missingthumb.jpg") __cached[filename] = thumb return thumb
def forcereload(filename): os.remove(filetothumb(filename))#XXX:DANGEROUS SHIT RIGHT HERE images.besthandler(filename).genthumb(filename, filetothumb(filename)) del __cached[filename]
def forcereload(filename): os.remove(filetothumb(filename)) #XXX:DANGEROUS SHIT RIGHT HERE images.besthandler(filename).genthumb(filename, filetothumb(filename)) del __cached[filename]
def cbpressedkeymain(self, widget, event, data=None): if event.keyval == 93: #FIXME:don't use literal here (]) for sel in self.selected.keys(): nu = list(sel) files = sel[0].split(":") nu[0] = files[-1] for f in files[:-1]: nu[0] += ":" + f print("change " + str(sel) + " to " + str(nu)) self.testdb.edit(sel, nu) del self.selected[sel] self.selected[tuple(nu)] = 1 #FIXME:this doesn't work if self.activeselected == sel: self.activeselected = tuple(nu) self.testdb.save() self.updateplist() #self.builder.get_object("drawingarea1").draw(gtk.gdk.Rectangle(0,0,10000,10000)) self.redrawwhenyougetaroundtoit() elif event.keyval == 65366: #FIXME:don't use literal here (page up) self.scrollrows = max( min(self.scrollrows + 1, self.testdb.howmany() / self.thumbsacross), 0) self.scrollbar.get_adjustment().value = self.scrollrows elif event.keyval == 65365: #FIXME:don't use literal here (page down) self.scrollrows = max( min(self.scrollrows - 1, self.testdb.howmany() / self.thumbsacross), 0) self.scrollbar.get_adjustment().value = self.scrollrows elif event.keyval == 33: #regenerate thumbnail for f in self.selected: thumbload.forcereload(f[0].split(":")[0]) #reload creation date oldestdate = 10000000000 for g in f[0].split(":"): newdate = images.besthandler(g).takentime(g) if newdate < oldestdate: oldestdate = newdate newitem = (f[0], f[1], oldestdate) self.testdb.edit(f, newitem) self.redrawwhenyougetaroundtoit() elif event.keyval >= 48 and event.keyval <= 53: for sel in self.selected.keys(): nu = list(sel) nu[1] = " ".join( filter( lambda x: x not in [ "#0stars", "#1stars", "#2stars", "#3stars", "#4stars", "#5stars" ], nu[1].split(" "))) nu[1] += " #" + str(event.keyval - 48) + "stars" self.testdb.edit(sel, nu) del self.selected[sel] self.selected[tuple(nu)] = 1 self.testdb.save() self.updateplist() self.redrawwhenyougetaroundtoit() elif event.keyval == 106: #j #self.testdb.rewind((self.scrollrows-1)*self.thumbsacross) self.testdb.rewind() derp = self.testdb.fetchone() while derp != self.activeselected and derp != None: derp = self.testdb.fetchone() for i in range(0, self.thumbsacross - 1): self.testdb.fetchone() self.activeselected = self.testdb.fetchone() self.scrollrows += 1 self.scrollbar.get_adjustment().value = self.scrollrows #self.redrawwhenyougetaroundtoit() elif event.keyval == 107: #k self.testdb.rewind() prev = [] for i in range(0, self.thumbsacross): prev.append(self.testdb.fetchone()) tmp = self.testdb.fetchone() while tmp != self.activeselected and tmp != None: prev.append(tmp) prev.pop(0) tmp = self.testdb.fetchone() self.activeselected = prev[0] self.scrollrows -= 1 self.scrollbar.get_adjustment().value = self.scrollrows elif event.keyval == 108: #l self.testdb.rewind() numpassed = 1 while self.testdb.fetchone() != self.activeselected: numpassed += 1 self.activeselected = self.testdb.fetchone() if numpassed % self.thumbsacross == 0: self.scrollrows += 1 self.scrollbar.get_adjustment().value = self.scrollrows else: self.redrawwhenyougetaroundtoit() elif event.keyval == 32: #space if self.activeselected in self.selected: del self.selected[self.activeselected] else: self.selected[self.activeselected] = 1 elif event.keyval == 104: #h print "dis is hard" self.testdb.rewind() prev = self.testdb.fetchone() tmp = self.testdb.fetchone() numpassed = 1 while tmp != self.activeselected and tmp != None: prev = tmp tmp = self.testdb.fetchone() numpassed += 1 self.activeselected = prev if numpassed % self.thumbsacross == 0: self.scrollrows -= 1 self.scrollbar.get_adjustment().value = self.scrollrows else: self.redrawwhenyougetaroundtoit() elif event.keyval == 99 and event.state & gtk.gdk.CONTROL_MASK: buf = "" for img in self.selected.keys(): buf += '"' + img[0].split(":")[0] + '" ' gtk.Clipboard().set_text(buf) elif event.keyval == 65535: #delete for sel in self.selected.keys(): nu = list(sel) if "#trash" not in sel[1]: nu[1] += " #trash" self.testdb.edit(sel, nu) del self.selected[sel] self.selected[tuple(nu)] = 1 self.testdb.save() self.updateplist() self.redrawwhenyougetaroundtoit() elif event.keyval == 111: #o self.activeeditor -= 1 elif event.keyval == 112: #p self.activeeditor += 1 else: print(event.keyval) self.updateeditordesc()
def cbpressedkeymain(self, widget, event, data=None): if event.keyval == 93:#FIXME:don't use literal here (]) for sel in self.selected.keys(): nu = list(sel) files = sel[0].split(":") nu[0] = files[-1] for f in files[:-1]: nu[0] += ":"+f print("change "+str(sel)+" to "+str(nu)) self.testdb.edit(sel, nu) del self.selected[sel] self.selected[tuple(nu)] = 1#FIXME:this doesn't work if self.activeselected == sel: self.activeselected = tuple(nu) self.testdb.save() self.updateplist() #self.builder.get_object("drawingarea1").draw(gtk.gdk.Rectangle(0,0,10000,10000)) self.redrawwhenyougetaroundtoit() elif event.keyval == 65366:#FIXME:don't use literal here (page up) self.scrollrows = max(min(self.scrollrows+1, self.testdb.howmany()/self.thumbsacross), 0) self.scrollbar.get_adjustment().value = self.scrollrows elif event.keyval == 65365:#FIXME:don't use literal here (page down) self.scrollrows = max(min(self.scrollrows-1, self.testdb.howmany()/self.thumbsacross), 0) self.scrollbar.get_adjustment().value = self.scrollrows elif event.keyval ==33: #regenerate thumbnail for f in self.selected: thumbload.forcereload(f[0].split(":")[0]) #reload creation date oldestdate = 10000000000 for g in f[0].split(":"): newdate = images.besthandler(g).takentime(g) if newdate < oldestdate: oldestdate = newdate newitem = (f[0],f[1],oldestdate) self.testdb.edit(f, newitem) self.redrawwhenyougetaroundtoit() elif event.keyval >= 48 and event.keyval <= 53: for sel in self.selected.keys(): nu = list(sel) nu[1] = " ".join(filter(lambda x:x not in ["#0stars","#1stars", "#2stars", "#3stars", "#4stars", "#5stars"] ,nu[1].split(" "))) nu[1] += " #"+str(event.keyval-48)+"stars" self.testdb.edit(sel, nu) del self.selected[sel] self.selected[tuple(nu)] = 1 self.testdb.save() self.updateplist() self.redrawwhenyougetaroundtoit() elif event.keyval == 106:#j #self.testdb.rewind((self.scrollrows-1)*self.thumbsacross) self.testdb.rewind() derp = self.testdb.fetchone() while derp != self.activeselected and derp != None: derp = self.testdb.fetchone() for i in range(0,self.thumbsacross -1): self.testdb.fetchone() self.activeselected = self.testdb.fetchone() self.scrollrows += 1 self.scrollbar.get_adjustment().value = self.scrollrows #self.redrawwhenyougetaroundtoit() elif event.keyval == 107:#k self.testdb.rewind() prev = [] for i in range(0,self.thumbsacross): prev.append(self.testdb.fetchone()) tmp = self.testdb.fetchone() while tmp != self.activeselected and tmp != None: prev.append(tmp) prev.pop(0) tmp = self.testdb.fetchone() self.activeselected = prev[0] self.scrollrows -= 1 self.scrollbar.get_adjustment().value = self.scrollrows elif event.keyval == 108:#l self.testdb.rewind() numpassed = 1 while self.testdb.fetchone() != self.activeselected: numpassed +=1 self.activeselected = self.testdb.fetchone() if numpassed % self.thumbsacross ==0: self.scrollrows += 1 self.scrollbar.get_adjustment().value = self.scrollrows else: self.redrawwhenyougetaroundtoit() elif event.keyval == 32:#space if self.activeselected in self.selected: del self.selected[self.activeselected] else: self.selected[self.activeselected] = 1 elif event.keyval == 104:#h print "dis is hard" self.testdb.rewind() prev = self.testdb.fetchone() tmp = self.testdb.fetchone() numpassed = 1 while tmp != self.activeselected and tmp != None: prev = tmp tmp = self.testdb.fetchone() numpassed +=1 self.activeselected = prev if numpassed % self.thumbsacross ==0: self.scrollrows -= 1 self.scrollbar.get_adjustment().value = self.scrollrows else: self.redrawwhenyougetaroundtoit() elif event.keyval == 99 and event.state & gtk.gdk.CONTROL_MASK: buf = "" for img in self.selected.keys(): buf += '"'+img[0].split(":")[0]+'" ' gtk.Clipboard().set_text(buf) elif event.keyval == 65535:#delete for sel in self.selected.keys(): nu = list(sel) if "#trash" not in sel[1]: nu[1] += " #trash" self.testdb.edit(sel, nu) del self.selected[sel] self.selected[tuple(nu)] = 1 self.testdb.save() self.updateplist() self.redrawwhenyougetaroundtoit() elif event.keyval ==111:#o self.activeeditor -= 1 elif event.keyval ==112:#p self.activeeditor += 1 else: print(event.keyval) self.updateeditordesc()