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() current_keyword = self.searchEntry.get_text()
try:
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,33 +692,29 @@ 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() if keyword == self.searchEntry.get_text() and len(found_packages) > 0:
try: last_separator = Gtk.EventBox()
if keyword == self.searchEntry.get_text() and len(found_packages) > 0: last_separator.add(Gtk.HSeparator())
last_separator = Gtk.EventBox() last_separator.set_size_request(-1, 20)
last_separator.add(Gtk.HSeparator()) last_separator.type = "separator"
last_separator.set_size_request(-1, 20) self.mintMenuWin.SetPaneColors( [ last_separator ] )
last_separator.type = "separator" last_separator.show_all()
self.mintMenuWin.SetPaneColors( [ last_separator ] ) self.applicationsBox.add(last_separator)
last_separator.show_all() self.suggestions.append(last_separator)
self.applicationsBox.add(last_separator) for pkg in found_packages:
self.suggestions.append(last_separator) name = pkg.name
for pkg in found_packages: for word in keywords:
name = pkg.name if word != "":
for word in keywords: name = name.replace(word, "<b>%s</b>" % word);
if word != "": suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
name = name.replace(word, "<b>%s</b>" % word); suggestionButton.connect("clicked", self.apturl_install, pkg.name)
suggestionButton = SuggestionButton(gtk.STOCK_ADD, self.iconSize, "") suggestionButton.set_text(_("Install package '%s'") % name)
suggestionButton.connect("clicked", self.apturl_install, pkg.name) suggestionButton.set_tooltip_text("%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description))
suggestionButton.set_text(_("Install package '%s'") % name) suggestionButton.set_icon_size(self.iconSize)
suggestionButton.set_tooltip_text("%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description)) self.applicationsBox.add(suggestionButton)
suggestionButton.set_icon_size(self.iconSize) self.suggestions.append(suggestionButton)
self.applicationsBox.add(suggestionButton) #if cache != self.current_results:
self.suggestions.append(suggestionButton) # self.current_results.append(pkg)
#if cache != self.current_results:
# 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