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 cbredraw(self, widget, data=None): self.updateplist() #XXX:doesn't go here ctx = widget.window.cairo_create() ctx.set_antialias(cairo.ANTIALIAS_NONE) #ctx.set_filter(cairo.FILTER_FAST) #ctx.scale(0.5,0.5) #print(widget.window.get_size()) thumbsize = widget.window.get_size()[0] / self.thumbsacross ctx.set_line_width(2) linew = 2 if thumbsize < self.scalethumbsize: ctx.scale(thumbsize / float(self.scalethumbsize), thumbsize / float(self.scalethumbsize)) ctx.set_line_width(2 / (thumbsize / float(self.scalethumbsize))) linew = 2 / (thumbsize / float(self.scalethumbsize)) thumbsize = self.scalethumbsize #print("draw "+str(int(widget.window.get_size()[1]/(widget.window.get_size()[0]/self.thumbsacross))+1)) lasttime = self.plist[0][2] #lasttime = 0#FIXME:first one always black #onwhite = True for i in range( 0, int(widget.window.get_size()[1] / (widget.window.get_size()[0] / self.thumbsacross)) + 1): #TODO:whole thing needs to go in a separate thread for j in range(0, self.thumbsacross): if len(self.plist) > i * self.thumbsacross + j: ctx.set_source_pixbuf( thumbload.loadthumb(self.plist[i * self.thumbsacross + j][0].split(":")[0]), j * thumbsize, i * thumbsize) #print("drawing "+self.plist[i*self.thumbsacross+j][0]) ctx.get_source().set_filter(cairo.FILTER_FAST) else: continue #ctx.set_source_rgb(0,0,0) ctx.rectangle(j * thumbsize, i * thumbsize, thumbsize, thumbsize) ctx.fill() #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 30: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 30: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 3: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 3600: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 60: colorslist = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1), (0, 0, 0), (0.5, 0.5, 0), (0, 0.5, 0.5)] for farg in range(0, 9): if "#col" + str(farg) in self.plist[i * self.thumbsacross + j][1]: ctx.set_source_rgb(colorslist[farg][0], colorslist[farg][1], colorslist[farg][2]) break else: #ctx.set_source_rgb(0.5,0.5,0.5) #cola = 0.2+self.plist[i*self.thumbsacross+j][2]%3 * 0.1 cola = 0.2 + (self.scrollrows + i) / 2 % 2 * 0.4 ctx.set_source_rgb(cola, cola, cola) lasttime = self.plist[i * self.thumbsacross + j][2] ''' onwhite = not onwhite if onwhite: ctx.set_source_rgb(0.5,0.5,0.5) else: ctx.set_source_rgb(0,0,0)''' if self.plist[i * self.thumbsacross + j] in self.selected: ctx.set_source_rgb(0, 1, 0) if self.plist[i * self.thumbsacross + j] == self.activeselected: ctx.set_source_rgb(0.8, 1, 0) ''' ctx.set_dash((1,0,0,0,0)) else: ctx.set_dash((1,1,1,1,1,1,1,1))''' #ctx.set_line_width(2) ctx.rectangle( j * thumbsize, i * thumbsize, thumbsize - linew, thumbsize - linew ) #should fix it so this doesn't cover up the edges of thumbnail ctx.stroke() #draw number of versions ctx.set_source_rgb(0, 0, 0) numversions = self.plist[i * self.thumbsacross + j][0].count(":") if numversions > 0: ctx.set_font_size(30) ctx.move_to(j * thumbsize + thumbsize - 30, i * thumbsize + thumbsize - 10) ctx.show_text(str(numversions + 1)) ctx.stroke() stars = -1 for k in range(1, 6): if "#" + str(k) + "stars" in self.plist[i * self.thumbsacross + j][1]: stars = k break ctx.set_font_size(60) ctx.move_to(j * thumbsize + 10, i * thumbsize + thumbsize - 10) ctx.show_text(str("*" * stars)) ctx.stroke() ctx.set_font_size(20) ctx.move_to(j * thumbsize + thumbsize - 80, i * thumbsize + thumbsize - 40) ctx.show_text( images.describe(self.plist[i * self.thumbsacross + j][0].split(":")[0])) ctx.stroke()
def cbredraw(self, widget, data=None): self.updateplist()#XXX:doesn't go here ctx = widget.window.cairo_create() ctx.set_antialias(cairo.ANTIALIAS_NONE) #ctx.set_filter(cairo.FILTER_FAST) #ctx.scale(0.5,0.5) #print(widget.window.get_size()) thumbsize = widget.window.get_size()[0]/self.thumbsacross ctx.set_line_width(2) linew = 2 if thumbsize < self.scalethumbsize: ctx.scale(thumbsize/float(self.scalethumbsize), thumbsize/float(self.scalethumbsize)) ctx.set_line_width(2/(thumbsize/float(self.scalethumbsize))) linew = 2/(thumbsize/float(self.scalethumbsize)) thumbsize = self.scalethumbsize #print("draw "+str(int(widget.window.get_size()[1]/(widget.window.get_size()[0]/self.thumbsacross))+1)) lasttime = self.plist[0][2] #lasttime = 0#FIXME:first one always black #onwhite = True for i in range(0,int(widget.window.get_size()[1]/(widget.window.get_size()[0]/self.thumbsacross))+1):#TODO:whole thing needs to go in a separate thread for j in range(0,self.thumbsacross): if len(self.plist) > i*self.thumbsacross + j: ctx.set_source_pixbuf( thumbload.loadthumb(self.plist[i*self.thumbsacross+j][0].split(":")[0]),j*thumbsize,i*thumbsize) #print("drawing "+self.plist[i*self.thumbsacross+j][0]) ctx.get_source().set_filter(cairo.FILTER_FAST) else: continue #ctx.set_source_rgb(0,0,0) ctx.rectangle(j*thumbsize,i*thumbsize,thumbsize, thumbsize) ctx.fill() #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 30: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 30: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 3: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 3600: #if abs(self.plist[i*self.thumbsacross+j][2] - lasttime) > 60: colorslist = [(1,0,0),(0,1,0),(0,0,1),(0,1,1),(1,0,1),(1,1,0),(1,1,1),(0,0,0),(0.5,0.5,0),(0,0.5,0.5)] for farg in range(0,9): if "#col"+str(farg) in self.plist[i*self.thumbsacross+j][1]: ctx.set_source_rgb(colorslist[farg][0],colorslist[farg][1],colorslist[farg][2]) break else: #ctx.set_source_rgb(0.5,0.5,0.5) #cola = 0.2+self.plist[i*self.thumbsacross+j][2]%3 * 0.1 cola = 0.2+(self.scrollrows +i)/2%2*0.4 ctx.set_source_rgb(cola,cola,cola) lasttime = self.plist[i*self.thumbsacross+j][2] ''' onwhite = not onwhite if onwhite: ctx.set_source_rgb(0.5,0.5,0.5) else: ctx.set_source_rgb(0,0,0)''' if self.plist[i*self.thumbsacross+j] in self.selected: ctx.set_source_rgb(0,1,0) if self.plist[i*self.thumbsacross+j] == self.activeselected: ctx.set_source_rgb(0.8,1,0) ''' ctx.set_dash((1,0,0,0,0)) else: ctx.set_dash((1,1,1,1,1,1,1,1))''' #ctx.set_line_width(2) ctx.rectangle(j*thumbsize,i*thumbsize,thumbsize-linew, thumbsize-linew)#should fix it so this doesn't cover up the edges of thumbnail ctx.stroke() #draw number of versions ctx.set_source_rgb(0,0,0) numversions = self.plist[i*self.thumbsacross+j][0].count(":") if numversions > 0: ctx.set_font_size(30) ctx.move_to(j*thumbsize + thumbsize-30, i*thumbsize + thumbsize -10) ctx.show_text(str(numversions+1)) ctx.stroke() stars = -1 for k in range(1,6): if "#"+str(k)+"stars" in self.plist[i*self.thumbsacross+j][1]: stars = k break ctx.set_font_size(60) ctx.move_to(j*thumbsize +10, i*thumbsize + thumbsize -10) ctx.show_text(str("*"*stars)) ctx.stroke() ctx.set_font_size(20) ctx.move_to(j*thumbsize +thumbsize-80, i*thumbsize + thumbsize -40) ctx.show_text(images.describe(self.plist[i*self.thumbsacross+j][0].split(":")[0])) ctx.stroke()