Skip to content

Commit

Permalink
fix default dialod warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Nov 23, 2018
1 parent 30824c2 commit 9407858
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gnomehud/handlers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
from gnomehud.utils.fuzzy import FuzzyMatch


def normalize_label(text):
return text.replace('&', '&')


def run_generator(function):
priority = GLib.PRIORITY_LOW
generator = function()
Expand Down Expand Up @@ -56,7 +60,7 @@ def __init__(self, *args, **kwargs):
self.label = Gtk.Label(margin=6, margin_left=10, margin_right=10)
self.label.set_justify(Gtk.Justification.LEFT)
self.label.set_halign(Gtk.Align.START)
self.label.set_label(self.value)
self.label.set_label(normalize_label(self.value))

self.connect('notify::query', self.on_query_notify)

Expand All @@ -76,9 +80,8 @@ def underline_matches(self):
words = self.query.replace(' ', '|')
regex = re.compile(words, re.IGNORECASE)
value = regex.sub(self.format_matched_string, self.value)
value = value.replace('&', '&')

self.label.set_markup(value)
self.label.set_markup(normalize_label(value))

def format_matched_string(self, match):
return '<u>%s</u>' % match.group(0)
Expand All @@ -88,7 +91,7 @@ def do_label_markup(self):
self.underline_matches()

elif '<u>' in self.label.get_label():
self.label.set_label(self.value)
self.label.set_label(normalize_label(self.value))

def on_query_notify(self, *args):
if self.visible:
Expand Down

0 comments on commit 9407858

Please sign in to comment.