def get_pixbuf(self, attr, val): if attr == 'category': tbl = self.rd.recipe_table.join(self.rd.categories_table) col = self.rd.categories_table.c.category if hasattr(self, 'category_images'): stment = and_( col == val, self.rd.recipe_table.c.image != None, self.rd.recipe_table.c.image != '', not_(self.rd.recipe_table.c.title.in_( self.category_images))) else: stment = and_(col == val, self.rd.recipe_table.c.image != None, self.rd.recipe_table.c.image != '') result = tbl.select(stment, limit=1).execute().fetchone() if not hasattr(self, 'category_images'): self.category_images = [] if result: self.category_images.append(result.title) elif attr == 'rating': return star_generator.get_pixbuf(val) elif attr in ['preptime', 'cooktime']: return get_time_slice(val) else: tbl = self.rd.recipe_table col = getattr(self.rd.recipe_table.c, attr) stment = and_(col == val, self.rd.recipe_table.c.image != None, self.rd.recipe_table.c.image != '') result = tbl.select(stment, limit=1).execute().fetchone() if result and result.thumb: return scale_pb(get_pixbuf_from_jpg(result.image)) else: return self.get_base_icon(attr) or self.get_base_icon('category')
def get_pixbuf (self, attr,val): if attr=='category': tbl = self.rd.recipe_table.join(self.rd.categories_table) col = self.rd.categories_table.c.category if hasattr(self,'category_images'): stment = and_(col==val,self.rd.recipe_table.c.image!=None, self.rd.recipe_table.c.image!='', not_(self.rd.recipe_table.c.title.in_(self.category_images)) ) else: stment = and_(col==val,self.rd.recipe_table.c.image!=None,self.rd.recipe_table.c.image!='') result = tbl.select(stment,limit=1).execute().fetchone() if not hasattr(self,'category_images'): self.category_images = [] if result: self.category_images.append(result.title) elif attr=='rating': return star_generator.get_pixbuf(val) elif attr in ['preptime','cooktime']: return get_time_slice(val) else: tbl = self.rd.recipe_table col = getattr(self.rd.recipe_table.c,attr) stment = and_(col==val,self.rd.recipe_table.c.image!=None,self.rd.recipe_table.c.image!='') result = tbl.select(stment,limit=1).execute().fetchone() if result and result.thumb: return scale_pb(get_pixbuf_from_jpg(result.image)) else: return self.get_base_icon(attr) or self.get_base_icon('category')
def get_default_icon (self): if hasattr(self,'default_icon'): return self.default_icon else: #from gourmet.gglobals import imagedir path = os.path.join(curdir,'images','generic_category.png') self.default_icon = scale_pb(gtk.gdk.pixbuf_new_from_file(path),do_grow=True) return self.default_icon
def get_default_icon(self): if hasattr(self, 'default_icon'): return self.default_icon else: #from gourmet.gglobals import imagedir path = os.path.join(curdir, 'images', 'generic_category.png') self.default_icon = scale_pb(gtk.gdk.pixbuf_new_from_file(path), do_grow=True) return self.default_icon