Fix search suggestions hangup, apt search. Need to fix multiline though

This commit is contained in:
Michael Webster 2013-03-08 08:02:48 -05:00
parent a47e17dfbf
commit 5e69fefe8e

View File

@ -32,7 +32,7 @@ import matemenu
from user import home from user import home
Gdk.threads_init() GObject.threads_init()
# i18n # i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")
@ -187,7 +187,7 @@ class SuggestionButton ( Gtk.Button ):
self.image.show() self.image.show()
HBox1.pack_start( self.image, False, False, 5 ) HBox1.pack_start( self.image, False, False, 5 )
self.label = Gtk.Label() self.label = Gtk.Label()
self.label.set_ellipsize( Pango.EllipsizeMode.END ) #self.label.set_ellipsize( Pango.EllipsizeMode.END )
self.label.set_alignment( 0.0, 1.0 ) self.label.set_alignment( 0.0, 1.0 )
self.label.show() self.label.show()
labelBox.pack_start( self.label, False, False, 0 ) labelBox.pack_start( self.label, False, False, 0 )
@ -648,13 +648,8 @@ class pluginclass( object ):
def add_apt_filter_results(self, keyword): def add_apt_filter_results(self, keyword):
try: try:
# Wait to see if the keyword has changed.. before doing anything # Wait to see if the keyword has changed.. before doing anything
time.sleep(0.3)
current_keyword = keyword current_keyword = keyword
Gdk.threads_enter()
try:
current_keyword = self.searchEntry.get_text() current_keyword = self.searchEntry.get_text()
finally:
Gdk.threads_leave()
if keyword != current_keyword: if keyword != current_keyword:
return return
found_packages = [] found_packages = []
@ -697,8 +692,6 @@ class pluginclass( object ):
break break
found_packages.extend(found_in_name) found_packages.extend(found_in_name)
found_packages.extend(found_elsewhere) found_packages.extend(found_elsewhere)
Gdk.threads_enter()
try:
if keyword == self.searchEntry.get_text() and len(found_packages) > 0: if keyword == self.searchEntry.get_text() and len(found_packages) > 0:
last_separator = Gtk.EventBox() last_separator = Gtk.EventBox()
last_separator.add(Gtk.HSeparator()) last_separator.add(Gtk.HSeparator())
@ -713,7 +706,7 @@ class pluginclass( object ):
for word in keywords: for word in keywords:
if word != "": if word != "":
name = name.replace(word, "<b>%s</b>" % word); name = name.replace(word, "<b>%s</b>" % word);
suggestionButton = SuggestionButton(gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.apturl_install, pkg.name) suggestionButton.connect("clicked", self.apturl_install, pkg.name)
suggestionButton.set_text(_("Install package '%s'") % name) suggestionButton.set_text(_("Install package '%s'") % name)
suggestionButton.set_tooltip_text("%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description)) suggestionButton.set_tooltip_text("%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description))
@ -722,8 +715,6 @@ class pluginclass( object ):
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
#if cache != self.current_results: #if cache != self.current_results:
# self.current_results.append(pkg) # self.current_results.append(pkg)
finally:
Gdk.threads_leave()
#if len(found_packages) == 0: #if len(found_packages) == 0:
# gtk.gdk.threads_enter() # gtk.gdk.threads_enter()
@ -810,13 +801,12 @@ class pluginclass( object ):
#if (len(self.current_results) > 0): #if (len(self.current_results) > 0):
#self.add_apt_filter_results_sync(self.current_results, text) #self.add_apt_filter_results_sync(self.current_results, text)
#else: #else:
thr = threading.Thread(name="mint-menu-apt-filter", group=None, target=self.add_apt_filter_results, args=([text]), kwargs={}) GObject.timeout_add (300, self.add_apt_filter_results, text)
thr.start()
else: else:
self.current_results = [] self.current_results = []
self.add_search_suggestions(text) self.add_search_suggestions(text)
thr = threading.Thread(name="mint-menu-apt-filter", group=None, target=self.add_apt_filter_results, args=([text]), kwargs={}) GObject.timeout_add (300, self.add_apt_filter_results, text)
thr.start()
self.current_suggestion = text self.current_suggestion = text
else: else:
self.current_suggestion = None self.current_suggestion = None