diff --git a/src/gourmet/Undo.py b/src/gourmet/Undo.py index 85ad7aca..60469d94 100644 --- a/src/gourmet/Undo.py +++ b/src/gourmet/Undo.py @@ -363,6 +363,7 @@ def get_text (self): return self.buffer.get_text(self.buffer.get_start_iter(), self.buffer.get_end_iter()) + class UndoHistoryList (list): """An UndoHistoryList.""" def __init__ (self, undo_widget, redo_widget, reapply_widget=None, signal='activate'): @@ -426,13 +427,14 @@ def reapply (self, *args): action.reapply() for h in self.action_hooks: h(self,action,'reapply') - def set_sensitive (self,w,val): - debug('set_sensitive',0) + def set_sensitive (self, w: Gtk.Action, is_sensitive: bool): + # FIXME: this function should not exist. + # It's only here to deal with the case where self.reapply_widget is + # None. This function is only used within this object. + debug('set_sensitive', 0) if not w: - #import traceback; traceback.print_stack() - #print 'No widget to sensitize',w,val return - w.set_sensitive(val) + w.set_sensitive(is_sensitive) def gui_update (self): debug('gui_update',0) diff --git a/src/gourmet/reccard.py b/src/gourmet/reccard.py index 89a2a74d..901dfd11 100644 --- a/src/gourmet/reccard.py +++ b/src/gourmet/reccard.py @@ -640,9 +640,7 @@ def update_yields_multiplier (self, val): def forget_remembered_optional_ingredients (self): pass - def offer_url (self, label, url, from_thread=False): - if from_thread: - gt.gtk_enter() + def offer_url (self, label, url): if hasattr(self,'progress_dialog'): self.hide_progress_dialog() # Clear existing messages... @@ -651,16 +649,16 @@ def offer_url (self, label, url, from_thread=False): # Add new message l = Gtk.Label() l.set_markup(label) - l.connect('activate-link',lambda lbl, uri: webbrowser.open_new_tab(uri)) + l.connect('activate-link', lambda lbl, + uri: webbrowser.open_new_tab(uri)) infobar = Gtk.InfoBar() infobar.set_message_type(Gtk.MessageType.INFO) infobar.get_content_area().add(l) infobar.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) - infobar.connect('response', lambda ib, response_id: self.messagebox.hide()) + infobar.connect('response', + lambda ib, response_id: self.messagebox.hide()) self.messagebox.pack_start(infobar, True, True, 0) self.messagebox.show_all() - if from_thread: - gt.gtk_leave() class IngredientDisplay: @@ -1029,7 +1027,8 @@ def save_cb (self, *args): self.rg.rd.update_hashes(self.current_rec) self.rg.rmodel.update_recipe(self.current_rec) if 'title' in newdict: - self.window.set_title("%s %s"%(self.edit_title,self.current_rec.title.strip())) + self.window.set_title(f'{self.edit_title} ' + f'{self.current_rec.title.strip()}') self.set_edited(False) self.reccard.new = False self.reccard.update_recipe(self.current_rec) # update display (if any) diff --git a/src/gourmet/recindex.py b/src/gourmet/recindex.py index ad7679a4..f901da15 100644 --- a/src/gourmet/recindex.py +++ b/src/gourmet/recindex.py @@ -1,6 +1,6 @@ from gettext import gettext as _ from gettext import ngettext -from typing import List, Union +from typing import List, Tuple, Union from gi.repository import Gdk, GdkPixbuf, GObject, Gtk, Pango @@ -244,7 +244,8 @@ def rmodel_page_changed_cb (self, rmodel): self.last_button.set_sensitive(True) self.set_reccount() - def rmodel_sort_cb(self, rmodel, sorts): + def rmodel_sort_cb(self, rmodel: 'RecipeModel', + sorts: List[Tuple[str, int]]): self.sort_by = sorts self.last_search = {} self.search()