def vcodec_combos(self): # clear data self.widgets['preferences']['vcodec_name'].get_model().clear() self.widgets['preferences']['vcodec'].get_model().clear() self.widgets['add']['vcodec'].get_model().clear() self.vcodecs_ids = {} self.vcodecs_ids[0] = None self.widgets['preferences']['vcodec_name'].insert_text(0, '') self.widgets['add']['vcodec'].insert_text(0, _('N/A')) self.widgets['preferences']['vcodec'].insert_text(0, _('N/A')) for i, vcodec in enumerate( self.db.session.query(db.VCodec.vcodec_id, db.VCodec.name).all()): self.vcodecs_ids[i + 1] = vcodec.vcodec_id self.widgets['preferences']['vcodec_name'].insert_text( i + 1, vcodec.name) self.widgets['add']['vcodec'].insert_text(i + 1, vcodec.name) self.widgets['preferences']['vcodec'].insert_text(i + 1, vcodec.name) self.widgets['preferences']['vcodec_name'].show_all() self.widgets['add']['vcodec'].show_all() self.widgets['preferences']['vcodec'].show_all() pos = gutils.findKey(self.config.get('vcodec', 0, section='defaults'), self.vcodecs_ids) if pos is not None: self.widgets['preferences']['vcodec'].set_active(int(pos)) else: self.widgets['preferences']['vcodec'].set_active(0) self.widgets['preferences']['vcodec_name'].set_active(0)
def vcodec_combos(self): # clear data self.widgets['preferences']['vcodec_name'].get_model().clear() self.widgets['preferences']['vcodec'].get_model().clear() self.widgets['add']['vcodec'].get_model().clear() self.vcodecs_ids = {} self.vcodecs_ids[0] = None self.widgets['preferences']['vcodec_name'].insert_text(0, '') self.widgets['add']['vcodec'].insert_text(0, _('N/A')) self.widgets['preferences']['vcodec'].insert_text(0, _('N/A')) i = 1 for vcodec in self.db.session.query(db.VCodec).all(): self.vcodecs_ids[i] = vcodec.vcodec_id self.widgets['preferences']['vcodec_name'].insert_text(int(i), str(vcodec.name)) self.widgets['add']['vcodec'].insert_text(int(i), str(vcodec.name)) self.widgets['preferences']['vcodec'].insert_text(int(i), str(vcodec.name)) i += 1 self.widgets['preferences']['vcodec_name'].show_all() self.widgets['add']['vcodec'].show_all() self.widgets['preferences']['vcodec'].show_all() pos = gutils.findKey(self.config.get('vcodec', 0, section='defaults'), self.vcodecs_ids) if pos is not None: self.widgets['preferences']['vcodec'].set_active(int(pos)) else: self.widgets['preferences']['vcodec'].set_active(0) self.widgets['preferences']['vcodec_name'].set_active(0)
def media_combos(self): # clear data self.widgets['preferences']['medium_name'].get_model().clear() self.widgets['preferences']['media'].get_model().clear() self.widgets['add']['media'].get_model().clear() self.media_ids = {} self.media_ids[0] = None self.widgets['preferences']['medium_name'].insert_text(0, '') self.widgets['add']['media'].insert_text(0, _('N/A')) self.widgets['preferences']['media'].insert_text(0, _('N/A')) for i, medium in enumerate( self.db.session.query(db.Medium.medium_id, db.Medium.name).all()): self.media_ids[i + 1] = medium.medium_id self.widgets['preferences']['medium_name'].insert_text( i + 1, medium.name) self.widgets['add']['media'].insert_text(i + 1, medium.name) self.widgets['preferences']['media'].insert_text(i + 1, medium.name) self.widgets['preferences']['medium_name'].show_all() self.widgets['add']['media'].show_all() self.widgets['preferences']['media'].show_all() if self.config.has_key('media', section='defaults'): pos = gutils.findKey(self.config.get('media', section='defaults'), self.media_ids) if pos is not None: self.widgets['preferences']['media'].set_active(int(pos)) else: self.widgets['preferences']['media'].set_active(0) else: self.widgets['preferences']['media'].set_active(0) self.widgets['preferences']['medium_name'].set_active(0)
def media_combos(self): # clear data self.widgets['preferences']['medium_name'].get_model().clear() self.widgets['preferences']['media'].get_model().clear() self.widgets['add']['media'].get_model().clear() self.media_ids = {} self.media_ids[0] = None self.widgets['preferences']['medium_name'].insert_text(0, '') self.widgets['add']['media'].insert_text(0, _('N/A')) self.widgets['preferences']['media'].insert_text(0, _('N/A')) i = 1 for medium in self.db.session.query(db.Medium).all(): self.media_ids[i] = medium.medium_id self.widgets['preferences']['medium_name'].insert_text(int(i), str(medium.name)) self.widgets['add']['media'].insert_text(int(i), str(medium.name)) self.widgets['preferences']['media'].insert_text(int(i), str(medium.name)) i += 1 self.widgets['preferences']['medium_name'].show_all() self.widgets['add']['media'].show_all() self.widgets['preferences']['media'].show_all() if self.config.has_key('media', section='defaults'): pos = gutils.findKey(self.config.get('media', section='defaults'), self.media_ids) if pos is not None: self.widgets['preferences']['media'].set_active(int(pos)) else: self.widgets['preferences']['media'].set_active(0) else: self.widgets['preferences']['media'].set_active(0) self.widgets['preferences']['medium_name'].set_active(0)
def media_combos(self): # clear data self.widgets["preferences"]["medium_name"].get_model().clear() self.widgets["preferences"]["media"].get_model().clear() self.widgets["add"]["media"].get_model().clear() self.media_ids = {} self.media_ids[0] = None self.widgets["preferences"]["medium_name"].insert_text(0, "") self.widgets["add"]["media"].insert_text(0, _("N/A")) self.widgets["preferences"]["media"].insert_text(0, _("N/A")) i = 1 for medium in self.db.Medium.select(): self.media_ids[i] = medium.medium_id self.widgets["preferences"]["medium_name"].insert_text(int(i), str(medium.name)) self.widgets["add"]["media"].insert_text(int(i), str(medium.name)) self.widgets["preferences"]["media"].insert_text(int(i), str(medium.name)) i += 1 self.widgets["preferences"]["medium_name"].show_all() self.widgets["add"]["media"].show_all() self.widgets["preferences"]["media"].show_all() if self.config.has_key("media", section="defaults"): pos = gutils.findKey(self.config.get("media", section="defaults"), self.media_ids) if pos is not None: self.widgets["preferences"]["media"].set_active(int(pos)) else: self.widgets["preferences"]["media"].set_active(0) else: self.widgets["preferences"]["media"].set_active(0)
def vcodec_combos(self): # clear data self.widgets["preferences"]["vcodec_name"].get_model().clear() self.widgets["preferences"]["vcodec"].get_model().clear() self.widgets["add"]["vcodec"].get_model().clear() self.vcodecs_ids = {} self.vcodecs_ids[0] = None self.widgets["preferences"]["vcodec_name"].insert_text(0, "") self.widgets["add"]["vcodec"].insert_text(0, _("N/A")) self.widgets["preferences"]["vcodec"].insert_text(0, _("N/A")) i = 1 for vcodec in self.db.VCodec.select(): self.vcodecs_ids[i] = vcodec.vcodec_id self.widgets["preferences"]["vcodec_name"].insert_text(int(i), str(vcodec.name)) self.widgets["add"]["vcodec"].insert_text(int(i), str(vcodec.name)) self.widgets["preferences"]["vcodec"].insert_text(int(i), str(vcodec.name)) i += 1 self.widgets["preferences"]["vcodec_name"].show_all() self.widgets["add"]["vcodec"].show_all() self.widgets["preferences"]["vcodec"].show_all() pos = gutils.findKey(self.config.get("vcodec", 0, section="defaults"), self.vcodecs_ids) if pos is not None: self.widgets["preferences"]["vcodec"].set_active(int(pos)) else: self.widgets["preferences"]["vcodec"].set_active(0)
def fill_volumes_combo(self, default=0): self.widgets['add']['volume'].get_model().clear() for i in self.volume_combo_ids: vol_id = self.volume_combo_ids[i] if vol_id>0: name = self.db.Volume.get_by(volume_id=vol_id).name else: name = '' self.widgets['add']['volume'].insert_text(int(i), str(name)) self.widgets['add']['volume'].show_all() i = gutils.findKey(default, self.volume_combo_ids) if i is not None: self.widgets['add']['volume'].set_active(int(i)) self.widgets['add']['volume'].set_wrap_width(3)
def fill_volumes_combo(self, default=0): _tmp = self.initialized self.initialized = False # don't refresh main treeview self.widgets['add']['volume'].get_model().clear() for i in self.volume_combo_ids: vol_id = self.volume_combo_ids[i] if vol_id>0: name = self.db.session.query(db.Volume).filter_by(volume_id=vol_id).first().name else: name = '' self.widgets['add']['volume'].insert_text(int(i), str(name)) self.widgets['add']['volume'].show_all() i = gutils.findKey(default, self.volume_combo_ids) if i is not None: self.widgets['add']['volume'].set_active(int(i)) self.widgets['add']['volume'].set_wrap_width(3) self.initialized = _tmp
def fill_volumes_combo(self, default=0): _tmp = self.initialized self.initialized = False # don't refresh main treeview self.widgets['add']['volume'].get_model().clear() for i in self.volume_combo_ids: vol_id = self.volume_combo_ids[i] if vol_id > 0: name = self.db.session.query(db.Volume.name).filter_by(volume_id=vol_id).first().name else: name = '' self.widgets['add']['volume'].insert_text(int(i), name) self.widgets['add']['volume'].show_all() i = gutils.findKey(default, self.volume_combo_ids) if i is not None: self.widgets['add']['volume'].set_active(int(i)) self.widgets['add']['volume'].set_wrap_width(3) self.initialized = _tmp
def fill_collections_combo(self, default=0): self.widgets['add']['collection'].get_model().clear() self.widgets['filter']['collection'].get_model().clear() for i in self.collection_combo_ids: col_id = self.collection_combo_ids[i] if col_id>0: name = self.db.Collection.query.filter_by(collection_id=col_id).first().name else: name = '' self.widgets['add']['collection'].insert_text(int(i), str(name)) self.widgets['filter']['collection'].insert_text(int(i), str(name)) self.widgets['add']['collection'].show_all() self.widgets['filter']['collection'].show_all() self.widgets['filter']['collection'].set_active(0) i = gutils.findKey(default, self.collection_combo_ids) if i is not None: self.widgets['add']['collection'].set_active(int(i)) self.widgets['add']['collection'].set_wrap_width(2)
def fill_collections_combo(self, default=0): self.widgets['add']['collection'].get_model().clear() self.widgets['filter']['collection'].get_model().clear() for i in self.collection_combo_ids: col_id = self.collection_combo_ids[i] if col_id>0: name = self.db.Collection.get_by(collection_id=col_id).name else: name = '' # add some white spaces to prevent scrollbar hides parts of the names self.widgets['add']['collection'].insert_text(int(i), str(name) + ' ') self.widgets['filter']['collection'].insert_text(int(i), str(name) + ' ') self.widgets['add']['collection'].show_all() self.widgets['filter']['collection'].show_all() self.widgets['filter']['collection'].set_active(0) i = gutils.findKey(default, self.collection_combo_ids) if i is not None: self.widgets['add']['collection'].set_active(int(i)) self.widgets['add']['collection'].set_wrap_width(2)
def fill_collections_combo(self, default=0): _tmp = self.initialized self.initialized = False # don't refresh main treeview self.widgets['add']['collection'].get_model().clear() self.widgets['filter']['collection'].get_model().clear() for i in self.collection_combo_ids: col_id = self.collection_combo_ids[i] if col_id > 0: name = self.db.session.query(db.Collection.name).filter_by(collection_id=col_id).first().name else: name = '' self.widgets['add']['collection'].insert_text(int(i), name) # add some white spaces to prevent scrollbar hides parts of the names self.widgets['filter']['collection'].insert_text(int(i), name + ' ') self.widgets['add']['collection'].show_all() self.widgets['filter']['collection'].show_all() self.widgets['filter']['collection'].set_active(0) i = gutils.findKey(default, self.collection_combo_ids) if i is not None: self.widgets['add']['collection'].set_active(int(i)) self.widgets['add']['collection'].set_wrap_width(2) self.initialized = _tmp
def fill_volumes_combo(self, default=0): _tmp = self.initialized self.initialized = False # don't refresh main treeview self.widgets["add"]["volume"].get_model().clear() self.widgets["filter"]["volume"].get_model().clear() for i in self.volume_combo_ids: vol_id = self.volume_combo_ids[i] if vol_id > 0: name = self.db.Volume.get_by(volume_id=vol_id).name else: name = "" self.widgets["add"]["volume"].insert_text(int(i), str(name)) # add some white spaces to prevent scrollbar hides parts of the names self.widgets["filter"]["volume"].insert_text(int(i), str(name) + " ") self.initialized = _tmp self.widgets["add"]["volume"].show_all() self.widgets["filter"]["volume"].show_all() self.widgets["filter"]["volume"].set_active(0) i = gutils.findKey(default, self.volume_combo_ids) if i is not None: self.widgets["add"]["volume"].set_active(int(i)) self.widgets["add"]["volume"].set_wrap_width(3)
def fill_collections_combo(self, default=0): _tmp = self.initialized self.initialized = False # don't refresh main treeview self.widgets['add']['collection'].get_model().clear() self.widgets['filter']['collection'].get_model().clear() for i in self.collection_combo_ids: col_id = self.collection_combo_ids[i] if col_id>0: name = self.db.session.query(db.Collection).filter_by(collection_id=col_id).first().name else: name = '' self.widgets['add']['collection'].insert_text(int(i), str(name)) # add some white spaces to prevent scrollbar hides parts of the names self.widgets['filter']['collection'].insert_text(int(i), str(name) + ' ') self.widgets['add']['collection'].show_all() self.widgets['filter']['collection'].show_all() self.widgets['filter']['collection'].set_active(0) i = gutils.findKey(default, self.collection_combo_ids) if i is not None: self.widgets['add']['collection'].set_active(int(i)) self.widgets['add']['collection'].set_wrap_width(2) self.initialized = _tmp
def show_preferences(self, page=None): w = self.widgets['preferences'] # number if self.config.get('number', True, section='mainlist') == False: w['view_number'].set_active(False) else: w['view_number'].set_active(True) # image if self.config.get('image', True, section='mainlist') == False: w['view_image'].set_active(False) else: w['view_image'].set_active(True) # original title if self.config.get('otitle', True, section='mainlist') == False: w['view_o_title'].set_active(False) else: w['view_o_title'].set_active(True) # title if self.config.get('title', True, section='mainlist') == False: w['view_title'].set_active(False) else: w['view_title'].set_active(True) # director if self.config.get('director', True, 'mainlist') == False: w['view_director'].set_active(False) else: w['view_director'].set_active(True) # genre if self.config.get('genre', True, 'mainlist') == False: w['view_genre'].set_active(False) else: w['view_genre'].set_active(True) # seen if self.config.get('seen', True, 'mainlist') == False: w['view_seen'].set_active(False) else: w['view_seen'].set_active(True) # year if self.config.get('year', True, 'mainlist') == False: w['view_year'].set_active(False) else: w['view_year'].set_active(True) # runtime if self.config.get('runtime', True, 'mainlist') == False: w['view_runtime'].set_active(False) else: w['view_runtime'].set_active(True) # rating if self.config.get('rating', True, 'mainlist') == False: w['view_rating'].set_active(False) else: w['view_rating'].set_active(True) # created if self.config.get('created', True, 'mainlist') == False: w['view_created'].set_active(False) else: w['view_created'].set_active(True) # updated if self.config.get('updated', True, 'mainlist') == False: w['view_updated'].set_active(False) else: w['view_updated'].set_active(True) # email reminder if self.config.get('use_auth', False, section='mail') == False: w['mail_use_auth'].set_active(False) else: w['mail_use_auth'].set_active(True) if self.config.get('mail_use_tls', False, section='mail') == False: w['mail_use_tls'].set_active(False) else: w['mail_use_tls'].set_active(True) w['mail_smtp_server'].set_text( self.config.get('smtp_server', 'localhost', section='mail')) w['mail_smtp_port'].set_text( self.config.get('mail_smtp_port', '25', section='mail')) w['mail_username'].set_text(self.config.get('username', '', section='mail')) w['mail_password'].set_text(self.config.get('password', '', section='mail')) w['mail_email'].set_text( self.config.get('email', 'griffith@localhost', section='mail')) # pdf reader w['epdf_reader'].set_text(self.pdf_reader) # pdf font if self.config.get('font'): w['font'].set_filename(self.config.get('font')) if self.config.get('font_size'): try: w['font_size'].set_value(float(self.config.get('font_size'))) except: w['font_size'].set_value(18.0) # pdf elements pdf_elements = self.config.get('pdf_elements', 'image,director,genre,cast') for pdf_element in pdf_elements.split(','): if 'pdf_' + pdf_element.strip() in w: w['pdf_' + pdf_element.strip()].set_active(True) # defaults (for static data only) w['condition'].set_active( gutils.digits_only(self.config.get('condition', 0, section='defaults'), 5)) w['region'].set_active( gutils.digits_only(self.config.get('region', 0, section='defaults'), 8)) w['layers'].set_active( gutils.digits_only(self.config.get('layers', 0, section='defaults'), 4)) w['color'].set_active( gutils.digits_only(self.config.get('color', 0, section='defaults'), 3)) tmp = self.config.get('media', 0, section='defaults') if tmp is not None and int(tmp) in self.media_ids: if int(self.config.get('media', 0, section='defaults')) > 0: w['media'].set_active( gutils.findKey( int(self.config.get('media', 0, section='defaults')), self.media_ids)) else: w['media'].set_active(0) tmp = self.config.get('vcodec', 0, section='defaults') if tmp is not None and int(tmp) in self.vcodecs_ids: if int(self.config.get('vcodec', 0, section='defaults')) > 0: w['vcodec'].set_active( int( gutils.findKey( int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids))) else: w['vcodec'].set_active(0) w['seen'].set_active( bool(self.config.get('seen', True, section='defaults'))) # search for: w['s_classification'].set_active( bool(self.config.get('s_classification', True, section='add'))) w['s_country'].set_active( bool(self.config.get('s_country', True, section='add'))) w['s_director'].set_active( bool(self.config.get('s_director', True, section='add'))) w['s_genre'].set_active( bool(self.config.get('s_genre', True, section='add'))) w['s_image'].set_active( bool(self.config.get('s_image', True, section='add'))) w['s_notes'].set_active( bool(self.config.get('s_notes', True, section='add'))) w['s_o_site'].set_active( bool(self.config.get('s_o_site', True, section='add'))) w['s_o_title'].set_active( bool(self.config.get('s_o_title', True, section='add'))) w['s_plot'].set_active(bool(self.config.get('s_plot', True, section='add'))) w['s_rating'].set_active( bool(self.config.get('s_rating', True, section='add'))) w['s_runtime'].set_active( bool(self.config.get('s_runtime', True, section='add'))) w['s_site'].set_active(bool(self.config.get('s_site', True, section='add'))) w['s_studio'].set_active( bool(self.config.get('s_studio', True, section='add'))) w['s_title'].set_active( bool(self.config.get('s_title', True, section='add'))) w['s_trailer'].set_active( bool(self.config.get('s_trailer', True, section='add'))) w['s_cast'].set_active(bool(self.config.get('s_cast', True, section='add'))) w['s_year'].set_active(bool(self.config.get('s_year', True, section='add'))) w['s_screenplay'].set_active( bool(self.config.get('s_screenplay', True, section='add'))) w['s_cameraman'].set_active( bool(self.config.get('s_cameraman', True, section='add'))) w['s_resolution'].set_active( bool(self.config.get('s_resolution', True, section='add'))) w['s_barcode'].set_active( bool(self.config.get('s_barcode', True, section='add'))) if self.config.get('sortby', section='mainlist'): tmp = self.sort_criteria.index( self.config.get('sortby', section='mainlist')) w['sortby'].set_active(tmp) w['sortby_reverse'].set_active( bool(self.config.get('sortby_reverse', False, section='mainlist'))) w['s_limit'].set_value( gutils.digits_only(self.config.get('limit', 0, section='mainlist'))) plugins = gutils.read_plugins('PluginMovie', \ self.locations['movie_plugins']) plugins.sort() mcounter = 0 default_movie_plugin = self.config.get('default_movie_plugin') for p in plugins: plugin_module = os.path.basename(p).replace('.py', '') plugin_name = plugin_module.replace('PluginMovie', '') if plugin_name == default_movie_plugin: w['default_plugin'].set_active(mcounter) mcounter = mcounter + 1 # rating image try: rimage = int(self.config.get('rating_image', 0)) except: rimage = 0 w['rating_image'].set_active(rimage) # spellchecker if self.config.get('gtkspell', False, section='spell') == False: w['spellchecker'].set_active(False) else: w['spellchecker'].set_active(True) self.on_cb_spellchecker_pref_toggled(w['spellchecker']) if self.config.get('notes', True, section='spell') == False: w['spell_notes'].set_active(False) else: w['spell_notes'].set_active(True) if self.config.get('plot', True, section='spell') == False: w['spell_plot'].set_active(False) else: w['spell_plot'].set_active(True) w['spell_lang'].set_text( str(self.config.get('lang', 'en', section='spell'))) if page is not None: w['notebook'].set_current_page(page) w['window'].show()
def show_preferences(self): w = self.widgets['preferences'] # image if self.config.get('view_image', 'True')=='False': w['view_image'].set_active(False) else: w['view_image'].set_active(True) # original title if self.config.get('view_otitle', 'True')=='False': w['view_o_title'].set_active(False) else: w['view_o_title'].set_active(True) # title if self.config.get('view_title', 'True')=='False': w['view_title'].set_active(False) else: w['view_title'].set_active(True) # director if self.config.get('view_director', 'True')=='False': w['view_director'].set_active(False) else: w['view_director'].set_active(True) # email reminder if self.config.get('mail_use_auth', 'False') == 'False': w['mail_use_auth'].set_active(False) else: w['mail_use_auth'].set_active(True) w['mail_smtp_server'].set_text(self.config.get('mail_smtp_server', 'localhost')) w['mail_username'].set_text(self.config.get('mail_username', '')) w['mail_password'].set_text(self.config.get('mail_password', '')) w['mail_email'].set_text(self.config.get('mail_email', 'griffith')) # pdf reader w['epdf_reader'].set_text(self.pdf_reader) # pdf font if self.config.get('font'): w['font'].set_filename(self.config.get('font')) # defaults (for static data only) w['condition'].set_active( gutils.digits_only(self.config.get('condition', 0), 5) ) w['region'].set_active( gutils.digits_only(self.config.get('region', 0), 8) ) w['layers'].set_active( gutils.digits_only(self.config.get('layers', 0), 4) ) w['color'].set_active( gutils.digits_only(self.config.get('color', 0), 3 )) if self.config.get('media', 0) in self.media_ids: if self.config.get('media', 0) > 0: w['media'].set_active( gutils.findKey(self.config.get('media', 0), self.media_ids) ) else: w['media'].set_active(0) if self.config.get('vcodec', 0) in self.vcodecs_ids >- 1: if self.config.get('vcodec', 0) > 0: w['vcodec'].set_active( int(gutils.findKey(self.config.get('vcodec', 0), self.vcodecs_ids)) ) else: w['vcodec'].set_active(0) # search for: w['s_classification'].set_active(bool(self.config.get('s_classification', True))) w['s_country'].set_active(bool(self.config.get('s_country', True))) w['s_director'].set_active(bool(self.config.get('s_director', True))) w['s_genre'].set_active(bool(self.config.get('s_genre', True))) w['s_image'].set_active(bool(self.config.get('s_image', True))) w['s_notes'].set_active(bool(self.config.get('s_notes', True))) w['s_o_site'].set_active(bool(self.config.get('s_o_site', True))) w['s_o_title'].set_active(bool(self.config.get('s_o_title', True))) w['s_plot'].set_active(bool(self.config.get('s_plot', True))) w['s_rating'].set_active(bool(self.config.get('s_rating', True))) w['s_runtime'].set_active(bool(self.config.get('s_runtime', True))) w['s_site'].set_active(bool(self.config.get('s_site', True))) w['s_studio'].set_active(bool(self.config.get('s_studio', True))) w['s_title'].set_active(bool(self.config.get('s_title', True))) w['s_trailer'].set_active(bool(self.config.get('s_trailer', True))) w['s_cast'].set_active(bool(self.config.get('s_cast', True))) w['s_year'].set_active(bool(self.config.get('s_year', True))) if self.config.get('sortby'): tmp = self.sort_criteria.index(self.config.get('sortby')) w['sortby'].set_active(tmp) w['sortby_reverse'].set_active(bool(self.config.get('sortby_reverse', False))) plugins = gutils.read_plugins('PluginMovie', \ self.locations['movie_plugins']) plugins.sort() mcounter = 0 for p in plugins: plugin_module = os.path.basename(p).replace('.py','') plugin_name = plugin_module.replace('PluginMovie','') if self.config.get('default_movie_plugin') == plugin_name: w['default_plugin'].set_active(mcounter) self.d_plugin = mcounter mcounter = mcounter + 1 # rating image try: rimage = int(str(self.config.get('rating_image', '0'))) except: rimage = 0 w['rating_image'].set_active(rimage) # spellchecker if self.config.get('use_gtkspell', 'False')=='False': w['spellchecker'].set_active(False) else: w['spellchecker'].set_active(True) if self.config.get('spell_notes', 'True')=='False': w['spell_notes'].set_active(False) else: w['spell_notes'].set_active(True) if self.config.get('spell_plot', 'True')=='False': w['spell_plot'].set_active(False) else: w['spell_plot'].set_active(True) w['spell_lang'].set_text(str(self.config.get('spell_lang', 'en'))) w['amazon_locale'].set_active(self.config.get('amazon_locale', 0)) w['window'].show()
def set_details(self, item=None):#{{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: self._am_movie_id = item['movie_id'] else: self._am_movie_id = None w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() if 'o_title' in item and item['o_title']: w['o_title'].set_text(item['o_title']) else: w['o_title'].set_text('') if 'title' in item and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if 'number' in item and item['number']: w['number'].set_value(int(item['number'])) else: w['number'].set_value(int(gutils.find_next_available(self.db))) if 'title' in item and item['title']: w['title'].set_text(item['title']) if 'year' in item and item['year']: w['year'].set_value(gutils.digits_only(item['year'], 2100)) else: w['year'].set_value(0) if 'resolution' in item and item['resolution']: if self.config.get('use_resolution_alias', True): w['resolution'].set_text(item['resolution']) elif 'height' in item and item['height'] and 'width' in item and item['width']: w['resolution'].set_text("%dx%d" % (item['width'], item['height'])) else: # failback to 'resolution' w['resolution'].set_text(item['resolution']) else: w['resolution'].set_text('') if 'runtime' in item and item['runtime']: w['runtime'].set_value(gutils.digits_only(item['runtime'])) else: w['runtime'].set_value(0) if 'barcode' in item and item['barcode']: w['barcode'].set_text(item['barcode']) else: w['barcode'].set_text('') if 'cameraman' in item and item['cameraman']: w['cameraman'].set_text(item['cameraman']) else: w['cameraman'].set_text('') if 'screenplay' in item and item['screenplay']: w['screenplay'].set_text(item['screenplay']) else: w['screenplay'].set_text('') if 'country' in item and item['country']: w['country'].set_text(item['country']) else: w['country'].set_text('') if 'classification' in item and item['classification']: w['classification'].set_text(item['classification']) else: w['classification'].set_text('') if 'studio' in item and item['studio']: w['studio'].set_text(item['studio']) else: w['studio'].set_text('') if 'o_site' in item and item['o_site']: w['o_site'].set_text(item['o_site']) else: w['o_site'].set_text('') if 'director' in item and item['director']: w['director'].set_text(item['director']) else: w['director'].set_text('') if 'site' in item and item['site']: w['site'].set_text(item['site']) else: w['site'].set_text('') if 'trailer' in item and item['trailer']: w['trailer'].set_text(item['trailer']) else: w['trailer'].set_text('') if 'genre' in item and item['genre']: w['genre'].set_text(item['genre']) else: w['genre'].set_text('') if 'color' in item and item['color']: w['color'].set_active(gutils.digits_only(item['color'], 3)) else: w['color'].set_active(gutils.digits_only(self.config.get('color', 0, section='defaults'), 3)) if 'layers' in item and item['layers']: w['layers'].set_active(gutils.digits_only(item['layers'], 4)) else: w['layers'].set_active(gutils.digits_only(self.config.get('layers', 0, section='defaults'), 4)) if 'region' in item and item['region'] >= 0: w['region'].set_active(gutils.digits_only(item['region'], 8)) else: w['region'].set_active(gutils.digits_only(self.config.get('region', 0, section='defaults'), 8)) if 'cond' in item and item['cond'] >= 0: w['condition'].set_active(gutils.digits_only(item['cond'], 5)) else: w['condition'].set_active(gutils.digits_only(self.config.get('condition', 0, section='defaults'), 5)) if 'media_num' in item and item['media_num']: w['discs'].set_value(gutils.digits_only(item['media_num'])) else: w['discs'].set_value(1) if 'rating' in item and item['rating']: w['rating_slider'].set_value(gutils.digits_only(item['rating'], 10)) else: w['rating_slider'].set_value(0) if 'seen' in item and item['seen'] is True: w['seen'].set_active(True) else: w['seen'].set_active(False) if 'cast' in item and item['cast']: cast_buffer.set_text(item['cast']) else: cast_buffer.set_text('') if 'notes' in item and item['notes']: notes_buffer.set_text(item['notes']) else: notes_buffer.set_text('') if 'plot' in item and item['plot']: plot_buffer.set_text(item['plot']) else: plot_buffer.set_text('') pos = 0 if 'medium_id' in item and item['medium_id']: pos = gutils.findKey(item['medium_id'], self.media_ids) else: pos = gutils.findKey(int(self.config.get('media', 0, section='defaults')), self.media_ids) if pos is not None: w['media'].set_active(int(pos)) else: w['media'].set_active(0) pos = 0 if 'vcodec_id' in item and item['vcodec_id']: pos = gutils.findKey(item['vcodec_id'], self.vcodecs_ids) else: pos = gutils.findKey(int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids) if pos is not None: w['vcodec'].set_active(int(pos)) else: w['vcodec'].set_active(0) pos = 0 if 'volume_id' in item and item['volume_id']: pos = gutils.findKey(item['volume_id'], self.volume_combo_ids) if pos is not None: w['volume'].set_active(int(pos)) else: w['volume'].set_active(0) pos = 0 if 'collection_id' in item and item['collection_id']: pos = gutils.findKey(item['collection_id'], self.collection_combo_ids) if pos is not None: w['collection'].set_active(int(pos)) else: w['collection'].set_active(0) # tags for tag in self.am_tags: self.am_tags[tag].set_active(False) if 'tags' in item: for tag in item['tags']: i = gutils.findKey(tag.tag_id, self.tags_ids) self.am_tags[i].set_active(True) # languages w['lang_treeview'].get_model().clear() if 'languages' in item and len(item['languages']) > 0: for i in item['languages']: self.create_language_row(i) # poster if 'poster_md5' in item and item['poster_md5']: image_path = gutils.get_image_fname(item["poster_md5"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool w['image'].set_text(item['poster_md5']) elif 'image' in item and item['image']: if len(item['image']) == 32: # md5 image_path = gutils.get_image_fname(item["image"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool else: w['image'].set_text(item['image']) else: image_path = os.path.join(self.locations['posters'], "m_%s.jpg" % item['image']) log.warn("TODO: image=%s", item['image']) else: w['image'].set_text('') image_path = gutils.get_defaultimage_fname(self) if not os.path.isfile(image_path): image_path = gutils.get_defaultimage_fname(self) w['picture'].set_from_file(image_path) w['notebook'].set_current_page(0) w['o_title'].grab_focus()
def set_details(self, item=None):#{{{ if item is None: item = {} if item.has_key('movie_id') and item['movie_id']: self._am_movie_id = item['movie_id'] else: self._am_movie_id = None w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() if item.has_key('o_title') and item['o_title']: w['o_title'].set_text(item['o_title']) else: w['o_title'].set_text('') if item.has_key('title') and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if item.has_key('number') and item['number']: w['number'].set_value(int(item['number'])) else: w['number'].set_value(int(gutils.find_next_available(self.db))) if item.has_key('title') and item['title']: w['title'].set_text(item['title']) if item.has_key('year') and item['year']: w['year'].set_value( gutils.digits_only(item['year'], 2100)) else: w['year'].set_value(0) if item.has_key('runtime') and item['runtime']: w['runtime'].set_value( gutils.digits_only(item['runtime'])) else: w['runtime'].set_value(0) if item.has_key('country') and item['country']: w['country'].set_text(item['country']) else: w['country'].set_text('') if item.has_key('classification') and item['classification']: w['classification'].set_text(item['classification']) else: w['classification'].set_text('') if item.has_key('studio') and item['studio']: w['studio'].set_text(item['studio']) else: w['studio'].set_text('') if item.has_key('o_site') and item['o_site']: w['o_site'].set_text(item['o_site']) else: w['o_site'].set_text('') if item.has_key('director') and item['director']: w['director'].set_text(item['director']) else: w['director'].set_text('') if item.has_key('site') and item['site']: w['site'].set_text(item['site']) else: w['site'].set_text('') if item.has_key('trailer') and item['trailer']: w['trailer'].set_text(item['trailer']) else: w['trailer'].set_text('') if item.has_key('title') and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if item.has_key('genre') and item['genre']: w['genre'].set_text(item['genre']) else: w['genre'].set_text('') if item.has_key('color') and item['color']: w['color'].set_active( gutils.digits_only(item['color'], 3)) else: w['color'].set_active( gutils.digits_only(self.config.get('color', 0, section='defaults'), 3)) if item.has_key('layers') and item['layers']: w['layers'].set_active( gutils.digits_only(item['layers'], 4)) else: w['layers'].set_active( gutils.digits_only(self.config.get('layers', 0, section='defaults'), 4)) if item.has_key('region') and item['region']>=0: w['region'].set_active( gutils.digits_only(item['region'], 8)) else: w['region'].set_active( gutils.digits_only(self.config.get('region', 0, section='defaults'), 8)) if item.has_key('cond') and item['cond']>=0: w['condition'].set_active( gutils.digits_only( item['cond'], 5) ) else: w['condition'].set_active( gutils.digits_only( self.config.get('condition', 0, section='defaults'), 5)) if item.has_key('media_num') and item['media_num']: w['discs'].set_value( gutils.digits_only(item['media_num'])) else: w['discs'].set_value(1) if item.has_key('rating') and item['rating']: w['rating_slider'].set_value( gutils.digits_only(item['rating'], 10) ) else: w['rating_slider'].set_value(0) if item.has_key('seen') and item['seen'] is True: w['seen'].set_active(True) else: w['seen'].set_active(False) if item.has_key('cast') and item['cast']: cast_buffer.set_text(item['cast']) else: cast_buffer.set_text('') if item.has_key('notes') and item['notes']: notes_buffer.set_text(item['notes']) else: notes_buffer.set_text('') if item.has_key('plot') and item['plot']: plot_buffer.set_text(item['plot']) else: plot_buffer.set_text('') pos = 0 if item.has_key('medium_id') and item['medium_id']: pos = gutils.findKey(item['medium_id'], self.media_ids) else: pos = gutils.findKey(int(self.config.get('media', 0, section='defaults')), self.media_ids) if pos is not None: w['media'].set_active(int(pos)) else: w['media'].set_active(0) pos = 0 if item.has_key('vcodec_id') and item['vcodec_id']: pos = gutils.findKey(item['vcodec_id'], self.vcodecs_ids) else: pos = gutils.findKey(int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids) if pos is not None: w['vcodec'].set_active(int(pos)) else: w['vcodec'].set_active(0) pos = 0 if item.has_key('volume_id') and item['volume_id']: pos = gutils.findKey(item['volume_id'], self.volume_combo_ids) if pos is not None: w['volume'].set_active(int(pos)) else: w['volume'].set_active(0) pos = 0 if item.has_key('collection_id') and item['collection_id']: pos = gutils.findKey(item['collection_id'], self.collection_combo_ids) if pos is not None: w['collection'].set_active(int(pos)) else: w['volume'].set_active(0) # tags for tag in self.am_tags: self.am_tags[tag].set_active(False) if item.has_key('tags'): for tag in item['tags']: i = gutils.findKey(tag.tag_id, self.tags_ids) self.am_tags[i].set_active(True) # languages w['lang_treeview'].get_model().clear() if item.has_key('languages') and len(item['languages'])>0: for i in item['languages']: self.create_language_row(i) # poster if item.has_key('image') and item['image']: w['image'].set_text(item['image']) image_path = os.path.join(self.locations['posters'], "m_%s.jpg" % item['image']) else: w['image'].set_text('') image_path = os.path.join(self.locations['images'], 'default.png') if not os.path.isfile(image_path): image_path = os.path.join(self.locations['images'], 'default.png') w['picture'].set_from_file(image_path) w['notebook'].set_current_page(0) w['source'].set_active(self.d_plugin) w['o_title'].grab_focus()
def show_preferences(self): w = self.widgets['preferences'] # number if self.config.get('number', True, section='mainlist') == False: w['view_number'].set_active(False) else: w['view_number'].set_active(True) # image if self.config.get('image', True, section='mainlist') == False: w['view_image'].set_active(False) else: w['view_image'].set_active(True) # original title if self.config.get('otitle', True, section='mainlist') == False: w['view_o_title'].set_active(False) else: w['view_o_title'].set_active(True) # title if self.config.get('title', True, section='mainlist') == False: w['view_title'].set_active(False) else: w['view_title'].set_active(True) # director if self.config.get('director', True, 'mainlist') == False: w['view_director'].set_active(False) else: w['view_director'].set_active(True) # genre if self.config.get('genre', True, 'mainlist') == False: w['view_genre'].set_active(False) else: w['view_genre'].set_active(True) # seen if self.config.get('seen', True, 'mainlist') == False: w['view_seen'].set_active(False) else: w['view_seen'].set_active(True) # year if self.config.get('year', True, 'mainlist') == False: w['view_year'].set_active(False) else: w['view_year'].set_active(True) # runtime if self.config.get('runtime', True, 'mainlist') == False: w['view_runtime'].set_active(False) else: w['view_runtime'].set_active(True) # rating if self.config.get('rating', True, 'mainlist') == False: w['view_rating'].set_active(False) else: w['view_rating'].set_active(True) # email reminder if self.config.get('use_auth', False, section='mail') == False: w['mail_use_auth'].set_active(False) else: w['mail_use_auth'].set_active(True) if self.config.get('mail_use_tls', False, section='mail') == False: w['mail_use_tls'].set_active(False) else: w['mail_use_tls'].set_active(True) w['mail_smtp_server'].set_text(self.config.get('smtp_server', 'localhost', section='mail')) w['mail_smtp_port'].set_text(self.config.get('mail_smtp_port', '25', section='mail')) w['mail_username'].set_text(self.config.get('username', '', section='mail')) w['mail_password'].set_text(self.config.get('password', '', section='mail')) w['mail_email'].set_text(self.config.get('email', 'griffith@localhost', section='mail')) # pdf reader w['epdf_reader'].set_text(self.pdf_reader) # pdf font if self.config.get('font'): w['font'].set_filename(self.config.get('font')) # defaults (for static data only) w['condition'].set_active( gutils.digits_only(self.config.get('condition', 0, section='defaults'), 5) ) w['region'].set_active( gutils.digits_only(self.config.get('region', 0, section='defaults'), 8) ) w['layers'].set_active( gutils.digits_only(self.config.get('layers', 0, section='defaults'), 4) ) w['color'].set_active( gutils.digits_only(self.config.get('color', 0, section='defaults'), 3 )) tmp = self.config.get('media', 0, section='defaults') if tmp is not None and int(tmp) in self.media_ids: if int(self.config.get('media', 0, section='defaults')) > 0: w['media'].set_active( gutils.findKey(int(self.config.get('media', 0, section='defaults')), self.media_ids) ) else: w['media'].set_active(0) tmp = self.config.get('vcodec', 0, section='defaults') if tmp is not None and int(tmp) in self.vcodecs_ids: if int(self.config.get('vcodec', 0, section='defaults')) > 0: w['vcodec'].set_active( int(gutils.findKey(int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids)) ) else: w['vcodec'].set_active(0) # search for: w['s_classification'].set_active(bool(self.config.get('s_classification', True, section='add'))) w['s_country'].set_active(bool(self.config.get('s_country', True, section='add'))) w['s_director'].set_active(bool(self.config.get('s_director', True, section='add'))) w['s_genre'].set_active(bool(self.config.get('s_genre', True, section='add'))) w['s_image'].set_active(bool(self.config.get('s_image', True, section='add'))) w['s_notes'].set_active(bool(self.config.get('s_notes', True, section='add'))) w['s_o_site'].set_active(bool(self.config.get('s_o_site', True, section='add'))) w['s_o_title'].set_active(bool(self.config.get('s_o_title', True, section='add'))) w['s_plot'].set_active(bool(self.config.get('s_plot', True, section='add'))) w['s_rating'].set_active(bool(self.config.get('s_rating', True, section='add'))) w['s_runtime'].set_active(bool(self.config.get('s_runtime', True, section='add'))) w['s_site'].set_active(bool(self.config.get('s_site', True, section='add'))) w['s_studio'].set_active(bool(self.config.get('s_studio', True, section='add'))) w['s_title'].set_active(bool(self.config.get('s_title', True, section='add'))) w['s_trailer'].set_active(bool(self.config.get('s_trailer', True, section='add'))) w['s_cast'].set_active(bool(self.config.get('s_cast', True, section='add'))) w['s_year'].set_active(bool(self.config.get('s_year', True, section='add'))) if self.config.get('sortby', section='mainlist'): tmp = self.sort_criteria.index(self.config.get('sortby', section='mainlist')) w['sortby'].set_active(tmp) w['sortby_reverse'].set_active(bool(self.config.get('sortby_reverse', False, section='mainlist'))) w['s_limit'].set_value(gutils.digits_only(self.config.get('limit', 0, section='mainlist'))) plugins = gutils.read_plugins('PluginMovie', \ self.locations['movie_plugins']) plugins.sort() mcounter = 0 default_movie_plugin = self.config.get('default_movie_plugin') for p in plugins: plugin_module = os.path.basename(p).replace('.py','') plugin_name = plugin_module.replace('PluginMovie','') if plugin_name == default_movie_plugin: w['default_plugin'].set_active(mcounter) self.d_plugin = mcounter mcounter = mcounter + 1 # rating image try: rimage = int(self.config.get('rating_image', 0)) except: rimage = 0 w['rating_image'].set_active(rimage) # spellchecker if self.config.get('gtkspell', False, section='spell') == False: w['spellchecker'].set_active(False) else: w['spellchecker'].set_active(True) self.on_cb_spellchecker_pref_toggled(w['spellchecker']) if self.config.get('notes', True, section='spell') == False: w['spell_notes'].set_active(False) else: w['spell_notes'].set_active(True) if self.config.get('plot', True, section='spell') == False: w['spell_plot'].set_active(False) else: w['spell_plot'].set_active(True) w['spell_lang'].set_text(str(self.config.get('lang', 'en', section='spell'))) w['amazon_locale'].set_active(int(self.config.get('amazon_locale', 0, section='add'))) w['window'].show()
def treeview_clicked(self): try: tmp = self.initialized # if Griffith is not initialized, return false except: return if self.total: self.clear_details() treeselection = self.main_treeview.get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() id = tmp_model.get_value(tmp_iter,1) row = self.db.select_movie_by_num(id)[0] plot_buffer = self.e_plot.get_buffer() obs_buffer = self.e_obs.get_buffer() with_buffer = self.e_with.get_buffer() with_iter = with_buffer.get_start_iter() self.e_movie_id.set_text(str(row['id'])) self.e_number.set_text(str(row['number'])) self.e_original_title.set_text(str(row['original_title'])) self.e_title.set_text(str(row['title'])) self.e_director.set_text(str(row['director'])) plot_buffer.set_text(str(row['plot'])) self.e_discs.set_value(int(row['num_media'])) if str(row['year']) != "0": self.e_year.set_text(str(row['year'])) if str(row['runtime']) != "0": self.e_runtime.set_text(str(row['runtime'])) with_buffer.set_text(str(row['actors'])) self.e_country.set_text(str(row['country'])) self.e_genre.set_text(str(row['genre'])) if row['condition'] != "": self.e_condition.set_active(int(row['condition'])) if row['region'] != "": self.e_region.set_active(int(row['region'])) if row['layers'] != "": self.e_layers.set_active(int(row['layers'])) if row['color'] != "": self.e_color.set_active(int(row['color'])) self.e_classification.set_text(str(row['classification'])) self.e_studio.set_text(str(row['studio'])) self.e_site.set_text(str(row['site'])) self.e_imdb.set_text(str(row['imdb'])) if row['seen']: self.e_seen.set_active(True) else: self.e_seen.set_active(False) if row['rating']: self.image_rating.show() self.rating_slider.set_value(int(row['rating'])) else: self.image_rating.hide() self.e_trailer.set_text(str(row['trailer'])) if row['obs']<>None: obs_buffer.set_text(str(row['obs'])) self.e_media.set_active(int(row['media'])) # check loan status and adjust buttons and history box if row['loaned']: self.popup_loan.set_sensitive(False) self.popup_email.set_sensitive(True) self.popup_return.set_sensitive(True) self.loan_button.set_sensitive(False) self.b_email_reminder.set_sensitive(True) self.return_button.set_sensitive(True) else: self.popup_loan.set_sensitive(True) self.popup_email.set_sensitive(False) self.popup_return.set_sensitive(False) self.return_button.set_sensitive(False) self.b_email_reminder.set_sensitive(False) self.loan_button.set_sensitive(True) # poster tmp_dest = os.path.join(self.griffith_dir, "posters") tmp_img = os.path.join(tmp_dest, "m_%s.jpg"%row['image']) tmp_img2 = os.path.join(tmp_dest, "%s.jpg"%row['image']) if len(row['image']) and os.path.isfile(tmp_img2): image_path = tmp_img self.delete_poster.set_sensitive(True) self.zoom_poster.set_sensitive(True) else: image_path = os.path.join(self.locations['images'], "default.png") self.delete_poster.set_sensitive(False) self.zoom_poster.set_sensitive(False) # lets see if we have a scaled down medium image already created if os.path.isfile(image_path): pass else: # if not, lets make one for future use :D original_image = os.path.join(tmp_dest, "%s.jpg"%row['image']) if os.path.isfile(original_image): gutils.make_medium_image(self, "%s.jpg"%row['image']) else: self.Image.set_from_file(os.path.join(self.locations['images'], "default.png")) pixbuf = self.Image.get_pixbuf() handler = self.e_picture.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(image_path)) if row['loaned']: if row['collection_id'] > 0 and self.db.is_collection_loaned(row['collection_id']) == 1: data_loan = self.db.get_loan_info(collection_id=row['collection_id']) elif row['volume_id'] > 0 and self.db.is_volume_loaned(row['volume_id']) == 1: data_loan = self.db.get_loan_info(volume_id=row['volume_id']) else: data_loan = self.db.get_loan_info(movie_id=row['number']) data_person = self.db.select_person_by_id(data_loan[0]['person_id']) self.person_name = data_person[0]['name'] self.person_email = data_person[0]['email'] self.loan_date = str(data_loan[0]['date']) self.loan_info.set_label(self._("This movie has been loaned to ") + self.person_name + self._(" on ") + self.loan_date[:10]) else: self.loan_info.set_label(self._("Movie not loaned")) #loan history self.loans_treemodel.clear() loans = self.db.get_loan_history(collection_id=row['collection_id'], volume_id=row['volume_id'], movie_id=row['number']) for loan_row in loans: myiter = self.loans_treemodel.append(None) self.loans_treemodel.set_value(myiter, 0,'%s' % str(loan_row['date'])[:10]) if loan_row['return_date'] != '': self.loans_treemodel.set_value(myiter, 1, str(loan_row['return_date'])[:10]) else: self.loans_treemodel.set_value(myiter, 1, "---") person = self.db.select_person_by_id(loan_row['person_id']) self.loans_treemodel.set_value(myiter, 2, person[0]['name']) #volumes/collections i = gutils.findKey(row['volume_id'], self.volume_combo_ids) self.e_volume_combo.set_active(i) i = gutils.findKey(row['collection_id'], self.collection_combo_ids) self.e_collection_combo.set_active(i) self.e_volume_id.set_text(str(row['volume_id'])) self.e_collection_id.set_text(str(row['collection_id'])) self.e_volume_id.hide() self.e_collection_id.hide() #languages languages = self.db.get_all_data("movie_lang", where="movie_id='%s'" % row['id']) self.e_languages = [] # language widgets if len(languages) > 0: from initialize import create_language_hbox for i in languages: create_language_hbox(self, widget=self.e_lang_vbox, tab=self.e_languages, default=i['lang_id'], type=i['type']) #tags for tag in self.db.get_all_data("movie_tag", where="movie_id='%s'" % row['id'], what="tag_id"): i = gutils.findKey(tag['tag_id'], self.tags_ids) self.e_tags[i].set_active(True)
def set_details(self, item=None): #{{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: self._am_movie_id = item['movie_id'] else: self._am_movie_id = None w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() if 'o_title' in item and item['o_title']: w['o_title'].set_text(item['o_title']) else: w['o_title'].set_text('') if 'title' in item and item['title']: w['title'].set_text(item['title']) else: w['title'].set_text('') if 'number' in item and item['number']: w['number'].set_value(int(item['number'])) else: w['number'].set_value(int(gutils.find_next_available(self.db))) if 'title' in item and item['title']: w['title'].set_text(item['title']) if 'year' in item and item['year']: w['year'].set_value(gutils.digits_only(item['year'], 2100)) else: w['year'].set_value(0) if 'resolution' in item and item['resolution']: if self.config.get('use_resolution_alias', True): w['resolution'].get_child().set_text(item['resolution']) elif 'height' in item and item['height'] and 'width' in item and item[ 'width']: w['resolution'].get_child().set_text( "%dx%d" % (item['width'], item['height'])) else: # failback to 'resolution' w['resolution'].get_child().set_text(item['resolution']) else: w['resolution'].get_child().set_text('') if 'runtime' in item and item['runtime']: w['runtime'].set_value(gutils.digits_only(item['runtime'])) else: w['runtime'].set_value(0) if 'barcode' in item and item['barcode']: w['barcode'].set_text(item['barcode']) else: w['barcode'].set_text('') if 'cameraman' in item and item['cameraman']: w['cameraman'].set_text(item['cameraman']) else: w['cameraman'].set_text('') if 'screenplay' in item and item['screenplay']: w['screenplay'].set_text(item['screenplay']) else: w['screenplay'].set_text('') if 'country' in item and item['country']: w['country'].set_text(item['country']) else: w['country'].set_text('') if 'classification' in item and item['classification']: w['classification'].set_text(item['classification']) else: w['classification'].set_text('') if 'studio' in item and item['studio']: w['studio'].set_text(item['studio']) else: w['studio'].set_text('') if 'o_site' in item and item['o_site']: w['o_site'].set_text(item['o_site']) else: w['o_site'].set_text('') if 'director' in item and item['director']: w['director'].set_text(item['director']) else: w['director'].set_text('') if 'site' in item and item['site']: w['site'].set_text(item['site']) else: w['site'].set_text('') if 'trailer' in item and item['trailer']: w['trailer'].set_text(item['trailer']) else: w['trailer'].set_text('') if 'genre' in item and item['genre']: w['genre'].set_text(item['genre']) else: w['genre'].set_text('') if 'color' in item and item['color']: w['color'].set_active(gutils.digits_only(item['color'], 3)) else: w['color'].set_active( gutils.digits_only(self.config.get('color', 0, section='defaults'), 3)) if 'layers' in item and item['layers']: w['layers'].set_active(gutils.digits_only(item['layers'], 4)) else: w['layers'].set_active( gutils.digits_only( self.config.get('layers', 0, section='defaults'), 4)) if 'region' in item and item['region'] >= 0: w['region'].set_active(gutils.digits_only(item['region'], 11)) else: w['region'].set_active( gutils.digits_only( self.config.get('region', 0, section='defaults'), 11)) if 'cond' in item and item['cond'] >= 0: w['condition'].set_active(gutils.digits_only(item['cond'], 5)) else: w['condition'].set_active( gutils.digits_only( self.config.get('condition', 0, section='defaults'), 5)) if 'media_num' in item and item['media_num']: w['discs'].set_value(gutils.digits_only(item['media_num'])) else: w['discs'].set_value(1) if 'rating' in item and item['rating']: w['rating_slider'].set_value(gutils.digits_only(item['rating'], 10)) else: w['rating_slider'].set_value(0) if 'seen' in item: if item['seen'] is True: w['seen'].set_active(True) else: w['seen'].set_active(False) else: w['seen'].set_active( bool(self.config.get('seen', True, section='defaults'))) if 'cast' in item and item['cast']: cast_buffer.set_text(item['cast']) else: cast_buffer.set_text('') if 'notes' in item and item['notes']: notes_buffer.set_text(item['notes']) else: notes_buffer.set_text('') if 'plot' in item and item['plot']: plot_buffer.set_text(item['plot']) else: plot_buffer.set_text('') pos = 0 if 'medium_id' in item and item['medium_id']: pos = gutils.findKey(item['medium_id'], self.media_ids) else: pos = gutils.findKey( int(self.config.get('media', 0, section='defaults')), self.media_ids) if pos is not None: w['media'].set_active(int(pos)) else: w['media'].set_active(0) pos = 0 if 'vcodec_id' in item and item['vcodec_id']: pos = gutils.findKey(item['vcodec_id'], self.vcodecs_ids) else: pos = gutils.findKey( int(self.config.get('vcodec', 0, section='defaults')), self.vcodecs_ids) if pos is not None: w['vcodec'].set_active(int(pos)) else: w['vcodec'].set_active(0) pos = 0 if 'volume_id' in item and item['volume_id']: pos = gutils.findKey(item['volume_id'], self.volume_combo_ids) if pos is not None: w['volume'].set_active(int(pos)) else: w['volume'].set_active(0) pos = 0 if 'collection_id' in item and item['collection_id']: pos = gutils.findKey(item['collection_id'], self.collection_combo_ids) if pos is not None: w['collection'].set_active(int(pos)) else: w['collection'].set_active(0) # tags for tag in self.am_tags: self.am_tags[tag].set_active(False) if 'tags' in item: for tag in item['tags']: i = gutils.findKey(tag.tag_id, self.tags_ids) self.am_tags[i].set_active(True) # languages w['lang_treeview'].get_model().clear() if 'languages' in item and len(item['languages']) > 0: for i in item['languages']: self.create_language_row(i) # poster w['aremove_poster'].set_sensitive(True) if 'poster_md5' in item and item['poster_md5']: image_path = gutils.get_image_fname(item["poster_md5"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool w['aremove_poster'].set_sensitive(False) w['image'].set_text(item['poster_md5']) elif 'image' in item and item['image']: if len(item['image']) == 32: # md5 image_path = gutils.get_image_fname(item["image"], self.db, 'm') if not image_path: image_path = '' # isfile doesn't like bool w['aremove_poster'].set_sensitive(False) else: w['image'].set_text(item['image']) else: image_path = os.path.join(self.locations['posters'], "m_%s.jpg" % item['image']) log.warn("TODO: image=%s", item['image']) else: w['image'].set_text('') image_path = gutils.get_defaultimage_fname(self) w['aremove_poster'].set_sensitive(False) if not os.path.isfile(image_path): image_path = gutils.get_defaultimage_fname(self) w['aremove_poster'].set_sensitive(False) w['picture'].set_from_file(image_path) w['notebook'].set_current_page(0) w['o_title'].grab_focus()