diff --git a/debian/changelog b/debian/changelog index c472e6a..a8a4d39 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mintmenu (5.7.7) serena; urgency=medium + + * Add recently used applications + + -- Hrotkó Gábor Tue, 03 Jan 2017 21:30:58 +0000 + mintmenu (5.7.6) serena; urgency=medium * Reorganize imports diff --git a/makepot b/makepot index 70caf26..d80b2a3 100755 --- a/makepot +++ b/makepot @@ -1,4 +1,4 @@ #!/bin/bash -xgettext --language=Python --keyword=_ --output=mintmenu.pot usr/lib/linuxmint/mintMenu/mintMenu.py usr/lib/linuxmint/mintMenu/mintMenuConfig.py usr/lib/linuxmint/mintMenu/keybinding.py usr/lib/linuxmint/mintMenu/plugins/recent.py usr/lib/linuxmint/mintMenu/plugins/applications.py usr/lib/linuxmint/mintMenu/plugins/system_management.py usr/lib/linuxmint/mintMenu/plugins/places.py +xgettext --language=Python --keyword=_ --output=mintmenu.pot usr/lib/linuxmint/mintMenu/mintMenu.py usr/lib/linuxmint/mintMenu/mintMenuConfig.py usr/lib/linuxmint/mintMenu/keybinding.py usr/lib/linuxmint/mintMenu/plugins/recent.py usr/lib/linuxmint/mintMenu/plugins/applications.py usr/lib/linuxmint/mintMenu/plugins/system_management.py usr/lib/linuxmint/mintMenu/plugins/places.py usr/lib/linuxmint/mintMenu/plugins/recentHelper.py diff --git a/mintmenu.pot b/mintmenu.pot index 89b8d9a..6750aa6 100644 --- a/mintmenu.pot +++ b/mintmenu.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-23 15:36+0000\n" +"POT-Creation-Date: 2017-01-03 22:38+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,35 +17,35 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:48 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:34 msgid "Menu" msgstr "" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:247 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:219 msgid "Couldn't load plugin:" msgstr "" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:319 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:291 msgid "Couldn't initialize plugin" msgstr "" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:727 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:701 msgid "Advanced MATE Menu" msgstr "" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:815 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:789 msgid "Preferences" msgstr "" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:818 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:792 msgid "Edit menu" msgstr "" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:821 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:795 msgid "Reload plugins" msgstr "" -#: usr/lib/linuxmint/mintMenu/mintMenu.py:824 +#: usr/lib/linuxmint/mintMenu/mintMenu.py:798 msgid "About" msgstr "" @@ -126,7 +126,7 @@ msgid "Options" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:66 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:203 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:205 msgid "Applications" msgstr "" @@ -135,8 +135,8 @@ msgid "Theme" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:69 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:200 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:201 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:202 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:203 msgid "Favorites" msgstr "" @@ -250,27 +250,27 @@ msgid "Toggle Default Items:" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:105 -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:136 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:156 msgid "Software Manager" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:106 -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:143 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:163 msgid "Package Manager" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:107 -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:150 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:170 msgid "Control Center" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:108 -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:160 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:177 msgid "Terminal" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:109 -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:177 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:187 msgid "Lock Screen" msgstr "" @@ -279,7 +279,7 @@ msgid "Log Out" msgstr "" #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:111 -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:194 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:201 msgid "Quit" msgstr "" @@ -345,180 +345,178 @@ msgstr "" msgid "" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/recent.py:31 -msgid "Recent documents" +#: usr/lib/linuxmint/mintMenu/plugins/recent.py:32 +msgid "Recently used" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:198 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:200 msgid "Search:" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:202 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:204 msgid "All applications" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:595 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:597 #, python-format msgid "Search DuckDuckGo for %s" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:602 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:604 #, python-format msgid "Search Wikipedia for %s" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:618 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:620 #, python-format msgid "Lookup %s in Dictionary" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:625 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:627 #, python-format msgid "Search Computer for %s" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:703 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:756 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:705 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:758 #, python-format msgid "Install package '%s'" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:890 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:960 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:892 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:962 msgid "Add to desktop" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:891 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:961 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:893 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:963 msgid "Add to panel" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:893 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:942 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:895 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:944 msgid "Insert space" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:894 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:943 -msgid "Insert separator" -msgstr "" - #: usr/lib/linuxmint/mintMenu/plugins/applications.py:896 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:964 -msgid "Launch when I log in" +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:945 +msgid "Insert separator" msgstr "" #: usr/lib/linuxmint/mintMenu/plugins/applications.py:898 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:966 +msgid "Launch when I log in" +msgstr "" + +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:900 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:968 msgid "Launch" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:899 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:901 msgid "Remove from favorites" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:901 -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:970 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:903 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:972 msgid "Edit properties" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:941 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:943 msgid "Remove" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:963 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:965 msgid "Show in my favorites" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:967 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:969 msgid "Uninstall" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:968 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:970 msgid "Delete from menu" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1025 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1027 msgid "Search DuckDuckGo" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1032 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1034 msgid "Search Wikipedia" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1042 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1044 msgid "Lookup Dictionary" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1049 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1051 msgid "Search Computer" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1059 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1061 msgid "Find Software" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1066 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1068 msgid "Find Tutorials" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1073 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1075 msgid "Find Hardware" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1080 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1082 msgid "Find Ideas" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1087 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1089 msgid "Find Users" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1547 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1550 msgid "" "Couldn't save favorites. Check if you have write access to ~/.linuxmint/" "mintMenu" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1758 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1761 msgid "All" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1758 +#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1761 msgid "Show all applications" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:140 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:160 msgid "Browse and install available software" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:147 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:167 msgid "Install, remove and upgrade software packages" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:157 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:174 msgid "Configure your system" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:167 +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:184 msgid "Use the command line" msgstr "" -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:170 -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:187 -msgid "Logout" -msgstr "" - -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:174 #: usr/lib/linuxmint/mintMenu/plugins/system_management.py:191 -msgid "Log out or switch user" -msgstr "" - -#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:184 msgid "Requires password to unlock" msgstr "" +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:194 +msgid "Logout" +msgstr "" + #: usr/lib/linuxmint/mintMenu/plugins/system_management.py:198 +msgid "Log out or switch user" +msgstr "" + +#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:205 msgid "Shutdown, restart, suspend or hibernate" msgstr "" @@ -546,3 +544,9 @@ msgstr "" #: usr/lib/linuxmint/mintMenu/plugins/places.py:261 msgid "Empty trash" msgstr "" + +#: usr/lib/linuxmint/mintMenu/plugins/recentHelper.py:44 +msgid "" +"Couldn't save recent apps. Check if you have write access to ~/.linuxmint/" +"mintMenu" +msgstr "" diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 1d9ce18..f896ec4 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -19,6 +19,7 @@ from easybuttons import * from execute import Execute from easygsettings import EasyGSettings from easyfiles import * +import recentHelper as RecentHelper gtk = CDLL("libgtk-x11-2.0.so.0") @@ -168,6 +169,7 @@ class pluginclass( object ): @print_timing def __init__( self, mintMenuWin, toggleButton, de ): self.mintMenuWin = mintMenuWin + RecentHelper.mintMenuWin = mintMenuWin self.mainMenus = [ ] @@ -259,7 +261,7 @@ class pluginclass( object ): print detail self.currentFavCol = 0 self.favorites = [] - + self.content_holder.set_size_request( self.width, self.height ) self.categoriesBox.set_size_request( self.width / 3, -1 ) self.applicationsBox.set_size_request( self.width / 2, -1 ) @@ -292,8 +294,7 @@ class pluginclass( object ): self.icon_theme = Gtk.IconTheme.get_default(); self.icon_theme.connect("changed", self.on_icon_theme_changed) - - + def refresh_apt_cache(self): if self.useAPT: os.system("mkdir -p %s/.linuxmint/mintMenu/" % home) @@ -445,6 +446,7 @@ class pluginclass( object ): self.Todos() self.buildFavorites() + RecentHelper.buildRecentApps() self.RebuildPlugin() def GetGSettingsEntries( self ): @@ -1302,6 +1304,7 @@ class pluginclass( object ): def do_plugin( self ): self.Todos() self.buildFavorites() + RecentHelper.buildRecentApps() # Scroll button into view def scrollItemIntoView( self, widget, event = None ): @@ -1374,7 +1377,7 @@ class pluginclass( object ): favButton.connect( "popup-menu", self.favPopup ) favButton.connect( "button-press-event", self.favPopup ) favButton.connect( "focus-in-event", self.scrollItemIntoView ) - favButton.connect( "clicked", lambda w: self.mintMenuWin.hide() ) + favButton.connect( "clicked", RecentHelper.applicationButtonClicked ) self.mintMenuWin.setTooltip( favButton, favButton.getTooltip() ) favButton.type = "location" @@ -1513,7 +1516,7 @@ class pluginclass( object ): self.favoritesReorder( favButton.position, position ) self.favoritesSave() - + def favoritesRemove( self, position ): tmp = self.favorites[ position ] self.favorites.remove( self.favorites[ position ] ) @@ -1720,7 +1723,7 @@ class pluginclass( object ): self.mintMenuWin.setTooltip( item["button"], item["button"].getTooltip() ) item["button"].connect( "button-press-event", self.menuPopup ) item["button"].connect( "focus-in-event", self.scrollItemIntoView ) - item["button"].connect( "clicked", lambda w: self.mintMenuWin.hide() ) + item["button"].connect( "clicked", RecentHelper.applicationButtonClicked ) if self.activeFilter[0] == 0: item["button"].filterText( self.activeFilter[1] ) else: diff --git a/usr/lib/linuxmint/mintMenu/plugins/recent.glade b/usr/lib/linuxmint/mintMenu/plugins/recent.glade index a567995..65ea1d2 100644 --- a/usr/lib/linuxmint/mintMenu/plugins/recent.glade +++ b/usr/lib/linuxmint/mintMenu/plugins/recent.glade @@ -20,7 +20,7 @@ True False - False + True diff --git a/usr/lib/linuxmint/mintMenu/plugins/recent.py b/usr/lib/linuxmint/mintMenu/plugins/recent.py index 0759a3b..38e14f3 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/recent.py +++ b/usr/lib/linuxmint/mintMenu/plugins/recent.py @@ -9,6 +9,7 @@ from easygsettings import EasyGSettings from execute import Execute from easyfiles import * from easybuttons import * +import recentHelper as RecentHelper class pluginclass: """This is the main class for the plugin""" @@ -28,12 +29,17 @@ class pluginclass: self.window = self.builder.get_object( "window1" ) #Set 'heading' property for plugin - self.heading = _("Recent documents") + self.heading = _("Recently used") #This should be the first item added to the window in glade self.content_holder = self.builder.get_object( "eventbox1" ) self.recentBox = self.builder.get_object("RecentBox") + self.recentAppBox = self.builder.get_object("RecentApps") + RecentHelper.recentAppBox = self.recentAppBox + + #self.recentApps = [] + self.recentVBox = self.builder.get_object( "vbox1" ) #Specify plugin width @@ -49,12 +55,15 @@ class pluginclass: self.settings.notifyAdd( 'num-recent-docs', self.RegenPlugin ) self.settings.notifyAdd( 'recent-font-size', self.RegenPlugin ) + self.appSettings = EasyGSettings( "com.linuxmint.mintmenu.plugins.applications" ) + self.appSettings.notifyAdd( "icon-size", self.RegenPlugin ) + self.FileList=[] self.RecManagerInstance = Gtk.RecentManager.get_default() self.recentManagerId = self.RecManagerInstance.connect("changed", self.DoRecent) self.RegenPlugin() - self.builder.get_object( "RecentTabs" ).set_current_page(1) + self.builder.get_object( "RecentTabs" ).set_current_page(0) #Connect event handlers self.builder.get_object("ClrBtn").connect("clicked", self.clrmenu) @@ -79,6 +88,8 @@ class pluginclass: self.recenth = self.settings.get( 'int', 'height' ) self.recentw = self.settings.get( 'int', 'width' ) self.numentries = self.settings.get( 'int', 'num-recent-docs' ) + RecentHelper.numentries = self.numentries + self.recentfontsize = self.settings.get( 'int', 'recent-font-size' ) # Hide vertical dotted separator @@ -88,6 +99,7 @@ class pluginclass: # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get( "bool", "sticky" ) self.minimized = self.settings.get( "bool", "minimized" ) + RecentHelper.iconSize = self.appSettings.get( "int", "icon-size") self.RebuildPlugin() def SetHidden( self, state ): @@ -105,7 +117,7 @@ class pluginclass: def DoRecent( self, *args, **kargs ): for i in self.recentBox.get_children(): i.destroy() - + self.recentVBox.set_size_request( self.recentw, self.recenth ) if len( self.recentBox.get_children() ) < self.numentries: n=len( self.recentBox.get_children() )-1 @@ -121,6 +133,9 @@ class pluginclass: if Name != None: self.AddRecentBtn( Name, self.IconList[loc] ) loc = loc + 1 + + RecentHelper.doRecentApps() + return True def clrmenu(self, *args, **kargs): @@ -224,3 +239,4 @@ class pluginclass: def do_plugin(self): self.DoRecent() + \ No newline at end of file diff --git a/usr/lib/linuxmint/mintMenu/plugins/recentHelper.py b/usr/lib/linuxmint/mintMenu/plugins/recentHelper.py new file mode 100644 index 0000000..db7ab59 --- /dev/null +++ b/usr/lib/linuxmint/mintMenu/plugins/recentHelper.py @@ -0,0 +1,133 @@ +#!/usr/bin/python2 + +import gi +gi.require_version("Gtk", "2.0") + +import os +import string +from user import home +from easyfiles import * +from easybuttons import * + +recentApps = [] +mintMenuWin = None +recentAppBox = None +numentries = 10 +iconSize = 16 + +def recentAppsAdd( recentAppsButton ): + if recentAppsButton: + + recentApps.insert(0, recentAppsButton ) + + counter = 0 + for recentApp in recentApps: + if counter != 0 and ( recentApp.desktopFile == recentAppsButton.desktopFile or counter >= numentries ): + del recentApps[counter] + counter = counter + 1 + +def recentAppsSave(): + try: + if (not os.path.exists(home + "/.linuxmint/mintMenu/recentApplications.list")): + os.system("touch " + home + "/.linuxmint/mintMenu/recentApplications.list") + recentAppListFile = open( os.path.join( os.path.expanduser( "~"), ".linuxmint", "mintMenu", "recentApplications.list" ) , "w" ) + + for recentApp in recentApps: + if not hasattr(recentApp, "type") or recentApp.type == "location": + recentAppListFile.write( "location:" + recentApp.desktopFile + "\n" ) + else: + recentAppListFile.write( recentApp.type + "\n" ) + + recentAppListFile.close( ) + except Exception, e: + print e + msgDlg = Gtk.MessageDialog( None, gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save recent apps. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" ) + msgDlg.run(); + msgDlg.destroy(); + +def recentAppBuildLauncher( location ): + try: + ButtonIcon = None + # For Folders and Network Shares + location = string.join( location.split( "%20" ) ) + + if location.startswith( "file" ): + ButtonIcon = "mate-fs-directory" + + if location.startswith( "smb" ) or location.startswith( "ssh" ) or location.startswith( "network" ): + ButtonIcon = "mate-fs-network" + + #For Special locations + if location == "x-nautilus-desktop:///computer": + location = "/usr/share/applications/nautilus-computer.desktop" + elif location == "x-nautilus-desktop:///home": + location = "/usr/share/applications/nautilus-home.desktop" + elif location == "x-nautilus-desktop:///network": + location = "/usr/share/applications/network-scheme.desktop" + elif location.startswith( "x-nautilus-desktop:///" ): + location = "/usr/share/applications/nautilus-computer.desktop" + + if location.startswith( "file://" ): + location = location[7:] + appButton = ApplicationLauncher( location, iconSize) + + if appButton.appExec: + appButton.show() + appButton.connect( "clicked", applicationButtonClicked ) + appButton.type = "location" + return appButton + except Exception, e: + print u"File in recentapp not found: '" + location + "'", e + + return None + + +def buildRecentApps(): + del recentApps[:] + try: + if (not os.path.exists(home + "/.linuxmint/mintMenu/recentApplications.list")): + os.system("touch " + home + "/.linuxmint/mintMenu/recentApplications.list") + recentAppListFile = open( os.path.join( os.path.expanduser( "~"), ".linuxmint", "mintMenu", "recentApplications.list" ) , "r" ) + + recentApplicationsList = recentAppListFile.readlines() + + for app in recentApplicationsList : + app = app.strip() + + if app[0:9] == "location:": + appButton = recentAppBuildLauncher( app[9:] ) + else: + if ( app.endswith( ".desktop" ) ): + appButton = recentAppBuildLauncher( app ) + else: + appButton = None + + if appButton: + recentApps.append( appButton ) + except Exception, e: + print e + return recentApps + +def doRecentApps(): + for i in recentAppBox.get_children(): + i.destroy() + + # recent apps + buildRecentApps() + for AButton in recentApps: + + AButton.set_size_request( 200, -1 ) + AButton.set_relief( Gtk.ReliefStyle.NONE ) + + req = Gtk.Requisition() + AButton.size_request(req) + + recentAppBox.pack_start( AButton, False, True, 0 ) + + return True + +def applicationButtonClicked( widget ): + mintMenuWin.hide() + recentAppsAdd(widget) + recentAppsSave() + doRecentApps()