Using APT to search for pkg and apturl to install them
This commit is contained in:
parent
cf6b1e7a53
commit
e8380e8584
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
|||||||
|
mintmenu (5.0.0) julia; urgency=low
|
||||||
|
|
||||||
|
* Filtering now uses APT to fetch results and apturl to install packages
|
||||||
|
|
||||||
|
-- Clement Lefebvre <root@linuxmint.com> Mon, 06 Sep 2010 15:21:00 +0000
|
||||||
|
|
||||||
mintmenu (4.9.9) isadora; urgency=low
|
mintmenu (4.9.9) isadora; urgency=low
|
||||||
|
|
||||||
* Custom places: now understands ~ signs and listens to changes in the path
|
* Custom places: now understands ~ signs and listens to changes in the path
|
||||||
|
@ -25,11 +25,23 @@ from filemonitor import monitor as filemonitor
|
|||||||
#import xdg.Menu
|
#import xdg.Menu
|
||||||
import gmenu
|
import gmenu
|
||||||
|
|
||||||
|
import apt
|
||||||
|
|
||||||
from user import home
|
from user import home
|
||||||
|
|
||||||
# i18n
|
# i18n
|
||||||
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
||||||
|
|
||||||
|
|
||||||
|
def print_timing(func):
|
||||||
|
def wrapper(*arg):
|
||||||
|
t1 = time.time()
|
||||||
|
res = func(*arg)
|
||||||
|
t2 = time.time()
|
||||||
|
print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
|
||||||
|
return res
|
||||||
|
return wrapper
|
||||||
|
|
||||||
# Evil patching
|
# Evil patching
|
||||||
#def xdgParsePatched(filename=None):
|
#def xdgParsePatched(filename=None):
|
||||||
# # conver to absolute path
|
# # conver to absolute path
|
||||||
@ -152,11 +164,15 @@ class Menu:
|
|||||||
class SuggestionButton ( gtk.Button ):
|
class SuggestionButton ( gtk.Button ):
|
||||||
|
|
||||||
def __init__( self, iconName, iconSize, label ):
|
def __init__( self, iconName, iconSize, label ):
|
||||||
|
|
||||||
|
|
||||||
gtk.Button.__init__( self )
|
gtk.Button.__init__( self )
|
||||||
|
|
||||||
|
|
||||||
iconSize = self.get_icon_size(iconSize)
|
iconSize = self.get_icon_size(iconSize)
|
||||||
self.iconName = iconName
|
self.iconName = iconName
|
||||||
self.set_relief( gtk.RELIEF_NONE )
|
self.set_relief( gtk.RELIEF_NONE )
|
||||||
self.set_size_request( 10, 10 )
|
self.set_size_request( -1, -1 )
|
||||||
Align1 = gtk.Alignment( 0, 0.5, 1.0, 0 )
|
Align1 = gtk.Alignment( 0, 0.5, 1.0, 0 )
|
||||||
HBox1 = gtk.HBox()
|
HBox1 = gtk.HBox()
|
||||||
labelBox = gtk.VBox( False, 2 )
|
labelBox = gtk.VBox( False, 2 )
|
||||||
@ -177,6 +193,11 @@ class SuggestionButton ( gtk.Button ):
|
|||||||
self.add( Align1 )
|
self.add( Align1 )
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_icon_size (self, iconSize):
|
def get_icon_size (self, iconSize):
|
||||||
if isinstance(iconSize, int):
|
if isinstance(iconSize, int):
|
||||||
if iconSize >= 4:
|
if iconSize >= 4:
|
||||||
@ -190,7 +211,7 @@ class SuggestionButton ( gtk.Button ):
|
|||||||
return iconSize
|
return iconSize
|
||||||
|
|
||||||
def set_text( self, text):
|
def set_text( self, text):
|
||||||
self.label.set_text(text)
|
self.label.set_markup(text)
|
||||||
|
|
||||||
def set_icon_size (self, size):
|
def set_icon_size (self, size):
|
||||||
size = self.get_icon_size(size)
|
size = self.get_icon_size(size)
|
||||||
@ -203,8 +224,11 @@ class pluginclass( object ):
|
|||||||
toFav = [ ( "FAVORITES", gtk.TARGET_SAME_APP, TARGET_TYPE_FAV ), ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) ]
|
toFav = [ ( "FAVORITES", gtk.TARGET_SAME_APP, TARGET_TYPE_FAV ), ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) ]
|
||||||
fromFav = [ ( "FAVORITES", gtk.TARGET_SAME_APP, TARGET_TYPE_FAV ) ]
|
fromFav = [ ( "FAVORITES", gtk.TARGET_SAME_APP, TARGET_TYPE_FAV ) ]
|
||||||
|
|
||||||
|
@print_timing
|
||||||
def __init__( self, mintMenuWin, toggleButton ):
|
def __init__( self, mintMenuWin, toggleButton ):
|
||||||
|
|
||||||
|
self.apt_cache = apt.Cache()
|
||||||
|
|
||||||
self.mintMenuWin = mintMenuWin
|
self.mintMenuWin = mintMenuWin
|
||||||
|
|
||||||
self.mainMenus = [ ]
|
self.mainMenus = [ ]
|
||||||
@ -322,17 +346,8 @@ class pluginclass( object ):
|
|||||||
return ( 0, 0 )
|
return ( 0, 0 )
|
||||||
|
|
||||||
#sizeIcon = gtk.icon_size_lookup( sizeIcon )
|
#sizeIcon = gtk.icon_size_lookup( sizeIcon )
|
||||||
|
self.suggestions = []
|
||||||
#self.suggestSearchAppButton = SuggestionButton(gtk.STOCK_FIND, self.iconSize, "")
|
self.current_suggestion = None
|
||||||
self.suggestSearchButton = SuggestionButton(gtk.STOCK_FIND, self.iconSize, "")
|
|
||||||
self.suggestShowButton = SuggestionButton(gtk.STOCK_INFO, self.iconSize, "")
|
|
||||||
self.suggestInstallButton = SuggestionButton(gtk.STOCK_ADD, self.iconSize, "")
|
|
||||||
|
|
||||||
#self.suggestSearchAppButton.connect("clicked", self.search_mint)
|
|
||||||
self.suggestSearchButton.connect("clicked", self.search_apt)
|
|
||||||
self.suggestShowButton.connect("clicked", self.show_apt)
|
|
||||||
self.suggestInstallButton.connect("clicked", self.install_apt)
|
|
||||||
|
|
||||||
self.get_panel()
|
self.get_panel()
|
||||||
|
|
||||||
def get_panel(self):
|
def get_panel(self):
|
||||||
@ -345,20 +360,8 @@ class pluginclass( object ):
|
|||||||
self.panel = gconf.client_get_default().get_string("/apps/panel/applets/" + applet + "/toplevel_id")
|
self.panel = gconf.client_get_default().get_string("/apps/panel/applets/" + applet + "/toplevel_id")
|
||||||
self.panel_position = gconf.client_get_default().get_int("/apps/panel/applets/" + applet + "/position") + 1
|
self.panel_position = gconf.client_get_default().get_int("/apps/panel/applets/" + applet + "/position") + 1
|
||||||
|
|
||||||
def search_mint(self, widget):
|
def apturl_install(self, widget, pkg_name):
|
||||||
os.system("/usr/bin/mint-search-portal " + self.suggestion + " &")
|
os.system("xdg-open apt://" + pkg_name + " &")
|
||||||
self.mintMenuWin.hide()
|
|
||||||
|
|
||||||
def search_apt(self, widget):
|
|
||||||
os.system("/usr/bin/mint-search-apt " + self.suggestion + " &")
|
|
||||||
self.mintMenuWin.hide()
|
|
||||||
|
|
||||||
def show_apt(self, widget):
|
|
||||||
os.system("/usr/bin/mint-show-apt " + self.suggestion + " &")
|
|
||||||
self.mintMenuWin.hide()
|
|
||||||
|
|
||||||
def install_apt(self, widget):
|
|
||||||
os.system("/usr/bin/mint-make-cmd " + self.suggestion + " &")
|
|
||||||
self.mintMenuWin.hide()
|
self.mintMenuWin.hide()
|
||||||
|
|
||||||
def __del__( self ):
|
def __del__( self ):
|
||||||
@ -427,12 +430,6 @@ class pluginclass( object ):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#self.suggestSearchAppButton.set_icon_size( self.iconSize )
|
|
||||||
self.suggestSearchButton.set_icon_size( self.iconSize )
|
|
||||||
self.suggestShowButton.set_icon_size( self.iconSize )
|
|
||||||
self.suggestInstallButton.set_icon_size( self.iconSize )
|
|
||||||
|
|
||||||
|
|
||||||
def changeFavIconSize( self, client, connection_id, entry, args ):
|
def changeFavIconSize( self, client, connection_id, entry, args ):
|
||||||
self.faviconsize = entry.get_value().get_int()
|
self.faviconsize = entry.get_value().get_int()
|
||||||
|
|
||||||
@ -608,10 +605,9 @@ class pluginclass( object ):
|
|||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
#print "FILTER"
|
#print "FILTER"
|
||||||
#self.applicationsBox.remove(self.suggestSearchAppButton)
|
for suggestion in self.suggestions:
|
||||||
self.applicationsBox.remove(self.suggestSearchButton)
|
self.applicationsBox.remove(suggestion)
|
||||||
self.applicationsBox.remove(self.suggestShowButton)
|
self.suggestions = []
|
||||||
self.applicationsBox.remove(self.suggestInstallButton)
|
|
||||||
|
|
||||||
if widget == self.searchEntry:
|
if widget == self.searchEntry:
|
||||||
if self.donotfilterapps:
|
if self.donotfilterapps:
|
||||||
@ -626,23 +622,40 @@ class pluginclass( object ):
|
|||||||
showns = True
|
showns = True
|
||||||
|
|
||||||
if (not showns and os.path.exists("/usr/lib/linuxmint/mintInstall/icon.svg")):
|
if (not showns and os.path.exists("/usr/lib/linuxmint/mintInstall/icon.svg")):
|
||||||
self.suggestion = text
|
if len(text) >= 3:
|
||||||
|
if self.current_suggestion is not None and self.current_suggestion in text:
|
||||||
|
# We're restricting our search...
|
||||||
|
for pkg in self.current_results:
|
||||||
|
if text in pkg.name:
|
||||||
|
name = pkg.name.replace(text, "<b>%s</b>" % text);
|
||||||
|
suggestionButton = SuggestionButton(gtk.STOCK_ADD, self.iconSize, "")
|
||||||
|
suggestionButton.connect("clicked", self.apturl_install, pkg.name)
|
||||||
|
suggestionButton.set_text(_("Install package '%s'") % name)
|
||||||
|
suggestionButton.set_tooltip_text(_("%s\n\n%s\n\n\n%s") % (pkg.name, pkg.summary.capitalize(), pkg.description))
|
||||||
|
suggestionButton.set_icon_size(self.iconSize)
|
||||||
|
self.applicationsBox.add(suggestionButton)
|
||||||
|
self.suggestions.append(suggestionButton)
|
||||||
|
else:
|
||||||
|
self.current_results = []
|
||||||
|
for pkg in self.apt_cache:
|
||||||
|
if text in pkg.name:
|
||||||
|
name = pkg.name.replace(text, "<b>%s</b>" % text);
|
||||||
|
suggestionButton = SuggestionButton(gtk.STOCK_ADD, self.iconSize, "")
|
||||||
|
suggestionButton.connect("clicked", self.apturl_install, pkg.name)
|
||||||
|
suggestionButton.set_text(_("Install package '%s'") % name)
|
||||||
|
suggestionButton.set_tooltip_text(_("%s\n\n%s\n\n%s") % (pkg.name, pkg.summary.capitalize(), pkg.description))
|
||||||
|
suggestionButton.set_icon_size(self.iconSize)
|
||||||
|
self.applicationsBox.add(suggestionButton)
|
||||||
|
self.suggestions.append(suggestionButton)
|
||||||
|
self.current_results.append(pkg)
|
||||||
|
|
||||||
#self.applicationsBox.add(self.suggestSearchAppButton)
|
self.current_suggestion = text
|
||||||
#self.suggestSearchAppButton.set_text(_("Search portal for '%s'") % text)
|
else:
|
||||||
#self.suggestSearchAppButton.set_tooltip_text(_("Search portal for '%s'") % text)
|
self.current_suggestion = None
|
||||||
|
self.current_results = []
|
||||||
self.applicationsBox.add(self.suggestSearchButton)
|
else:
|
||||||
self.suggestSearchButton.set_text(_("Search repositories for '%s'") % text)
|
self.current_suggestion = None
|
||||||
self.suggestSearchButton.set_tooltip_text(_("Search repositories for '%s'") % text)
|
self.current_results = []
|
||||||
|
|
||||||
self.applicationsBox.add(self.suggestShowButton)
|
|
||||||
self.suggestShowButton.set_text(_("Show package '%s'") % text)
|
|
||||||
self.suggestShowButton.set_tooltip_text(_("Show package '%s'") % text)
|
|
||||||
|
|
||||||
self.applicationsBox.add(self.suggestInstallButton)
|
|
||||||
self.suggestInstallButton.set_text(_("Install package '%s'") % text)
|
|
||||||
self.suggestInstallButton.set_tooltip_text(_("Install package '%s'") % text)
|
|
||||||
|
|
||||||
for i in self.categoriesBox.get_children():
|
for i in self.categoriesBox.get_children():
|
||||||
i.set_relief( gtk.RELIEF_NONE )
|
i.set_relief( gtk.RELIEF_NONE )
|
||||||
@ -1454,4 +1467,3 @@ class pluginclass( object ):
|
|||||||
# newApplicationsList.append( { "entry": item, "category": "" } )
|
# newApplicationsList.append( { "entry": item, "category": "" } )
|
||||||
|
|
||||||
return newApplicationsList
|
return newApplicationsList
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user