Avoid calling unnecessary domain_parser

The construction of the domain_parser can generate RPC calls so it is better to
avoid construct it if possible.

issue5918
review26741002
This commit is contained in:
Cédric Krier committed 2016-10-05 22:39:06 +02:00
1 parent b2265c6d76
commit 6802d9925d
2 files changed
+20 -18

No files matched your search

+2 -1
View File
@@ -288,7 +288,8 @@ class Screen(SignalEvent):
def search_domain(self, search_string=None, set_text=False):
domain = []
if self.domain_parser and not self.parent:
# Test first parent to avoid calling unnecessary domain_parser
if not self.parent and self.domain_parser:
if search_string is not None:
domain = self.domain_parser.parse(search_string)
else:
@@ -347,24 +347,25 @@ class ScreenContainer(object):
self.do_search()
def bookmark_match(self):
current_text = self.get_text()
current_domain = self.screen.domain_parser.parse(current_text)
self.search_entry.set_icon_activatable(gtk.ENTRY_ICON_SECONDARY,
bool(current_text))
self.search_entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY,
bool(current_text))
icon_stock = self.search_entry.get_icon_stock(gtk.ENTRY_ICON_SECONDARY)
for id_, name, domain in self.bookmarks():
text = self.screen.domain_parser.string(domain)
domain = self.screen.domain_parser.parse(text.decode('utf-8'))
if (text == current_text
or domain == current_domain):
if icon_stock != 'tryton-star':
self.search_entry.set_icon_from_stock(
gtk.ENTRY_ICON_SECONDARY, 'tryton-star')
self.search_entry.set_icon_tooltip_text(
gtk.ENTRY_ICON_SECONDARY, _('Remove this bookmark'))
return id_
current_text = self.get_text()
if current_text:
current_domain = self.screen.domain_parser.parse(current_text)
self.search_entry.set_icon_activatable(gtk.ENTRY_ICON_SECONDARY,
bool(current_text))
self.search_entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY,
bool(current_text))
for id_, name, domain in self.bookmarks():
text = self.screen.domain_parser.string(domain)
domain = self.screen.domain_parser.parse(text.decode('utf-8'))
if (text == current_text
or domain == current_domain):
if icon_stock != 'tryton-star':
self.search_entry.set_icon_from_stock(
gtk.ENTRY_ICON_SECONDARY, 'tryton-star')
self.search_entry.set_icon_tooltip_text(
gtk.ENTRY_ICON_SECONDARY, _('Remove this bookmark'))
return id_
if icon_stock != 'tryton-unstar':
self.search_entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY,
'tryton-unstar')