Skip to content

Commit

Permalink
Add annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
cydanil authored May 2, 2021
1 parent 15abafa commit f631002
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
12 changes: 7 additions & 5 deletions src/gourmet/Undo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 7 additions & 8 deletions src/gourmet/reccard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/gourmet/recindex.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f631002

Please sign in to comment.