def __edit_prefs(self, *args): kmap = { 'hide-read':'bool', 'update-interval':'int', 'max-articles':'int', 'use-notify':'bool', 'on-the-fly':'bool', 'enable-debug':'bool', 'auto-update':'bool', 'live-search':'bool', 'auto-hide-search':'bool', 'show-status':'bool', } hmap = { 'hide-read':_('Hide Read Items'), 'update-interval':_('Update interval (in minutes)'), 'max-articles':_('Maximum number of articles to keep (excluding starred)'), 'auto-update':_('Allow the engine to download new articles automatically.'), 'on-the-fly':_('Start downloading articles for new feeds on-the-fly'), 'use-notify':_('Show notification on updates'), 'enable-debug':_('Enable detailed logs'), 'live-search':_('Return search results as you type'), 'auto-hide-search':_('Hide Search form on results'), 'show-status':_('Show the bottom status bar'), } data = [] for k,v in kmap.iteritems(): data.append({ 'type':v, 'name':k, 'header':hmap.get(k),#FIXME: can this be gotten from gsettings? }) d = Dialog(self, _('Edit preferences'), data, self.settings) r = d.run() d.destroy()
def edit_word(self, widget): # get selected row store, iter_list = self.list.get_selection().get_selected() pk = store[iter_list][0] record = Word.retrieve_by_id(pk) # show dialog and get button clicked code dialog = Dialog(self, record.word, record.translation) response = dialog.run() dialog.destroy() if response != Gtk.ResponseType.OK: return # get entered word & translation word = dialog.word.strip() translation = dialog.translation.strip() if word == '' or translation == '': return # update database field according to given column Word.update_by_id(pk, word, translation) # update edited list row store[iter_list][1] = word store[iter_list][2] = translation
def add_word(self, widget): # show dialog and get button clicked code dialog = Dialog(self) response = dialog.run() dialog.destroy() if response != Gtk.ResponseType.OK: return # get entered word & translation word = dialog.word.strip() translation = dialog.translation.strip() if word == '' or translation == '': return # insert new word entered in database record = Word(word=word, translation=translation, date=datetime.now()) pk = Word.insert(record) record = Word.retrieve_by_id(pk) # add inserted word to list view store = self.list.get_model() store.append([ record.id, record.word, record.translation, record.date.strftime("%Y-%m-%d %H:%M:%S") ])
def __add_feed(self, *args): data = [ {'type':'str','name':'url', 'header':_('Link') }, ] d = Dialog(self, _('Add a feed'), data) r = d.run() item = d.response item['type'] = 'feed' d.destroy() if r == Gtk.ResponseType.OK: self.__create(item)
def __add_category(self, *args): args = [ {'type':'str','name':'name', 'header':_('Name') }, ] d = Dialog(self, _('Add a category'), args) r = d.run() item = d.response item['type'] = 'category' d.destroy() if r == Gtk.ResponseType.OK: self.__create(item)
def __edit_item(self, *args): item = self.tree.current_item #FIXME: not good!! print item if item['type'] == 'category': args = [{'type':'str','name':'name', 'header':_('Name'), 'value':item['name'] },] d = Dialog(self, _('Edit this category'), args) elif item['type'] == 'feed': args = [{'type':'str','name':'url', 'header':_('Link'), 'value':item['url'] },] d = Dialog(self, _('Edit this feed'), args) r = d.run() o = d.response for k,v in o.iteritems(): item[k] = v d.destroy() if r == Gtk.ResponseType.OK: self.__edit(item)
def start(button): progressDialog = Dialog("", 40, 5) progress = Progressbar(38, 0, 10) progressDialog.addComponent(progress, 1, 2) progressDialog.center() dialog.unfocus() progressDialog.draw() progressDialog.focus() for i in range(1, 11): time.sleep(0.5) progress.setValue(i) time.sleep(0.5) progressDialog.destroy() dialog.focus()