show recently used apps

This commit is contained in:
roti 2017-01-03 22:58:01 +01:00
parent c74b2b9816
commit aea328c5ad
7 changed files with 247 additions and 85 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
mintmenu (5.7.7) serena; urgency=medium
* Add recently used applications
-- Hrotkó Gábor <roti@profi-media.com> Tue, 03 Jan 2017 21:30:58 +0000
mintmenu (5.7.6) serena; urgency=medium mintmenu (5.7.6) serena; urgency=medium
* Reorganize imports * Reorganize imports

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/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

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,35 +17,35 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: usr/lib/linuxmint/mintMenu/mintMenu.py:48 #: usr/lib/linuxmint/mintMenu/mintMenu.py:34
msgid "Menu" msgid "Menu"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenu.py:247 #: usr/lib/linuxmint/mintMenu/mintMenu.py:219
msgid "Couldn't load plugin:" msgid "Couldn't load plugin:"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenu.py:319 #: usr/lib/linuxmint/mintMenu/mintMenu.py:291
msgid "Couldn't initialize plugin" msgid "Couldn't initialize plugin"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenu.py:727 #: usr/lib/linuxmint/mintMenu/mintMenu.py:701
msgid "Advanced MATE Menu" msgid "Advanced MATE Menu"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenu.py:815 #: usr/lib/linuxmint/mintMenu/mintMenu.py:789
msgid "Preferences" msgid "Preferences"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenu.py:818 #: usr/lib/linuxmint/mintMenu/mintMenu.py:792
msgid "Edit menu" msgid "Edit menu"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenu.py:821 #: usr/lib/linuxmint/mintMenu/mintMenu.py:795
msgid "Reload plugins" msgid "Reload plugins"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenu.py:824 #: usr/lib/linuxmint/mintMenu/mintMenu.py:798
msgid "About" msgid "About"
msgstr "" msgstr ""
@ -126,7 +126,7 @@ msgid "Options"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:66 #: 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" msgid "Applications"
msgstr "" msgstr ""
@ -135,8 +135,8 @@ msgid "Theme"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:69 #: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:69
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:200 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:202
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:201 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:203
msgid "Favorites" msgid "Favorites"
msgstr "" msgstr ""
@ -250,27 +250,27 @@ msgid "Toggle Default Items:"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:105 #: 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" msgid "Software Manager"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:106 #: 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" msgid "Package Manager"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:107 #: 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" msgid "Control Center"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:108 #: 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" msgid "Terminal"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:109 #: 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" msgid "Lock Screen"
msgstr "" msgstr ""
@ -279,7 +279,7 @@ msgid "Log Out"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/mintMenuConfig.py:111 #: 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" msgid "Quit"
msgstr "" msgstr ""
@ -345,180 +345,178 @@ msgstr ""
msgid "<not set>" msgid "<not set>"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/recent.py:31 #: usr/lib/linuxmint/mintMenu/plugins/recent.py:32
msgid "Recent documents" msgid "Recently used"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:198 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:200
msgid "Search:" msgid "Search:"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:202 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:204
msgid "All applications" msgid "All applications"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:595 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:597
#, python-format #, python-format
msgid "Search DuckDuckGo for %s" msgid "Search DuckDuckGo for %s"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:602 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:604
#, python-format #, python-format
msgid "Search Wikipedia for %s" msgid "Search Wikipedia for %s"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:618 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:620
#, python-format #, python-format
msgid "Lookup %s in Dictionary" msgid "Lookup %s in Dictionary"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:625 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:627
#, python-format #, python-format
msgid "Search Computer for %s" msgid "Search Computer for %s"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:703 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:705
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:756 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:758
#, python-format #, python-format
msgid "Install package '%s'" msgid "Install package '%s'"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:890 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:892
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:960 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:962
msgid "Add to desktop" msgid "Add to desktop"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:891 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:893
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:961 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:963
msgid "Add to panel" msgid "Add to panel"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:893 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:895
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:942 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:944
msgid "Insert space" msgid "Insert space"
msgstr "" 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:896
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:964 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:945
msgid "Launch when I log in" msgid "Insert separator"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:898 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:898
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:966 #: 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" msgid "Launch"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:899 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:901
msgid "Remove from favorites" msgid "Remove from favorites"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:901 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:903
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:970 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:972
msgid "Edit properties" msgid "Edit properties"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:941 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:943
msgid "Remove" msgid "Remove"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:963 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:965
msgid "Show in my favorites" msgid "Show in my favorites"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:967 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:969
msgid "Uninstall" msgid "Uninstall"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:968 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:970
msgid "Delete from menu" msgid "Delete from menu"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1025 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1027
msgid "Search DuckDuckGo" msgid "Search DuckDuckGo"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1032 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1034
msgid "Search Wikipedia" msgid "Search Wikipedia"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1042 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1044
msgid "Lookup Dictionary" msgid "Lookup Dictionary"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1049 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1051
msgid "Search Computer" msgid "Search Computer"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1059 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1061
msgid "Find Software" msgid "Find Software"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1066 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1068
msgid "Find Tutorials" msgid "Find Tutorials"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1073 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1075
msgid "Find Hardware" msgid "Find Hardware"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1080 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1082
msgid "Find Ideas" msgid "Find Ideas"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1087 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1089
msgid "Find Users" msgid "Find Users"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1547 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1550
msgid "" msgid ""
"Couldn't save favorites. Check if you have write access to ~/.linuxmint/" "Couldn't save favorites. Check if you have write access to ~/.linuxmint/"
"mintMenu" "mintMenu"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1758 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1761
msgid "All" msgid "All"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/applications.py:1758 #: usr/lib/linuxmint/mintMenu/plugins/applications.py:1761
msgid "Show all applications" msgid "Show all applications"
msgstr "" 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" msgid "Browse and install available software"
msgstr "" 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" msgid "Install, remove and upgrade software packages"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:157 #: usr/lib/linuxmint/mintMenu/plugins/system_management.py:174
msgid "Configure your system" msgid "Configure your system"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:167 #: usr/lib/linuxmint/mintMenu/plugins/system_management.py:184
msgid "Use the command line" msgid "Use the command line"
msgstr "" 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 #: 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" msgid "Requires password to unlock"
msgstr "" msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:194
msgid "Logout"
msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/system_management.py:198 #: 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" msgid "Shutdown, restart, suspend or hibernate"
msgstr "" msgstr ""
@ -546,3 +544,9 @@ msgstr ""
#: usr/lib/linuxmint/mintMenu/plugins/places.py:261 #: usr/lib/linuxmint/mintMenu/plugins/places.py:261
msgid "Empty trash" msgid "Empty trash"
msgstr "" 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 ""

View File

@ -19,6 +19,7 @@ from easybuttons import *
from execute import Execute from execute import Execute
from easygsettings import EasyGSettings from easygsettings import EasyGSettings
from easyfiles import * from easyfiles import *
import recentHelper as RecentHelper
gtk = CDLL("libgtk-x11-2.0.so.0") gtk = CDLL("libgtk-x11-2.0.so.0")
@ -168,6 +169,7 @@ class pluginclass( object ):
@print_timing @print_timing
def __init__( self, mintMenuWin, toggleButton, de ): def __init__( self, mintMenuWin, toggleButton, de ):
self.mintMenuWin = mintMenuWin self.mintMenuWin = mintMenuWin
RecentHelper.mintMenuWin = mintMenuWin
self.mainMenus = [ ] self.mainMenus = [ ]
@ -293,7 +295,6 @@ class pluginclass( object ):
self.icon_theme = Gtk.IconTheme.get_default(); self.icon_theme = Gtk.IconTheme.get_default();
self.icon_theme.connect("changed", self.on_icon_theme_changed) self.icon_theme.connect("changed", self.on_icon_theme_changed)
def refresh_apt_cache(self): def refresh_apt_cache(self):
if self.useAPT: if self.useAPT:
os.system("mkdir -p %s/.linuxmint/mintMenu/" % home) os.system("mkdir -p %s/.linuxmint/mintMenu/" % home)
@ -445,6 +446,7 @@ class pluginclass( object ):
self.Todos() self.Todos()
self.buildFavorites() self.buildFavorites()
RecentHelper.buildRecentApps()
self.RebuildPlugin() self.RebuildPlugin()
def GetGSettingsEntries( self ): def GetGSettingsEntries( self ):
@ -1302,6 +1304,7 @@ class pluginclass( object ):
def do_plugin( self ): def do_plugin( self ):
self.Todos() self.Todos()
self.buildFavorites() self.buildFavorites()
RecentHelper.buildRecentApps()
# Scroll button into view # Scroll button into view
def scrollItemIntoView( self, widget, event = None ): def scrollItemIntoView( self, widget, event = None ):
@ -1374,7 +1377,7 @@ class pluginclass( object ):
favButton.connect( "popup-menu", self.favPopup ) favButton.connect( "popup-menu", self.favPopup )
favButton.connect( "button-press-event", self.favPopup ) favButton.connect( "button-press-event", self.favPopup )
favButton.connect( "focus-in-event", self.scrollItemIntoView ) 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() ) self.mintMenuWin.setTooltip( favButton, favButton.getTooltip() )
favButton.type = "location" favButton.type = "location"
@ -1720,7 +1723,7 @@ class pluginclass( object ):
self.mintMenuWin.setTooltip( item["button"], item["button"].getTooltip() ) self.mintMenuWin.setTooltip( item["button"], item["button"].getTooltip() )
item["button"].connect( "button-press-event", self.menuPopup ) item["button"].connect( "button-press-event", self.menuPopup )
item["button"].connect( "focus-in-event", self.scrollItemIntoView ) 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: if self.activeFilter[0] == 0:
item["button"].filterText( self.activeFilter[1] ) item["button"].filterText( self.activeFilter[1] )
else: else:

View File

@ -20,7 +20,7 @@
<object class="GtkNotebook" id="RecentTabs"> <object class="GtkNotebook" id="RecentTabs">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="show_tabs">False</property> <!--<property name="show_tabs">False</property>-->
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow1"> <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -9,6 +9,7 @@ from easygsettings import EasyGSettings
from execute import Execute from execute import Execute
from easyfiles import * from easyfiles import *
from easybuttons import * from easybuttons import *
import recentHelper as RecentHelper
class pluginclass: class pluginclass:
"""This is the main class for the plugin""" """This is the main class for the plugin"""
@ -28,12 +29,17 @@ class pluginclass:
self.window = self.builder.get_object( "window1" ) self.window = self.builder.get_object( "window1" )
#Set 'heading' property for plugin #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 #This should be the first item added to the window in glade
self.content_holder = self.builder.get_object( "eventbox1" ) self.content_holder = self.builder.get_object( "eventbox1" )
self.recentBox = self.builder.get_object("RecentBox") 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" ) self.recentVBox = self.builder.get_object( "vbox1" )
#Specify plugin width #Specify plugin width
@ -49,12 +55,15 @@ class pluginclass:
self.settings.notifyAdd( 'num-recent-docs', self.RegenPlugin ) self.settings.notifyAdd( 'num-recent-docs', self.RegenPlugin )
self.settings.notifyAdd( 'recent-font-size', 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.FileList=[]
self.RecManagerInstance = Gtk.RecentManager.get_default() self.RecManagerInstance = Gtk.RecentManager.get_default()
self.recentManagerId = self.RecManagerInstance.connect("changed", self.DoRecent) self.recentManagerId = self.RecManagerInstance.connect("changed", self.DoRecent)
self.RegenPlugin() self.RegenPlugin()
self.builder.get_object( "RecentTabs" ).set_current_page(1) self.builder.get_object( "RecentTabs" ).set_current_page(0)
#Connect event handlers #Connect event handlers
self.builder.get_object("ClrBtn").connect("clicked", self.clrmenu) self.builder.get_object("ClrBtn").connect("clicked", self.clrmenu)
@ -79,6 +88,8 @@ class pluginclass:
self.recenth = self.settings.get( 'int', 'height' ) self.recenth = self.settings.get( 'int', 'height' )
self.recentw = self.settings.get( 'int', 'width' ) self.recentw = self.settings.get( 'int', 'width' )
self.numentries = self.settings.get( 'int', 'num-recent-docs' ) self.numentries = self.settings.get( 'int', 'num-recent-docs' )
RecentHelper.numentries = self.numentries
self.recentfontsize = self.settings.get( 'int', 'recent-font-size' ) self.recentfontsize = self.settings.get( 'int', 'recent-font-size' )
# Hide vertical dotted separator # Hide vertical dotted separator
@ -88,6 +99,7 @@ class pluginclass:
# Allow plugin to be minimized to the left plugin pane # Allow plugin to be minimized to the left plugin pane
self.sticky = self.settings.get( "bool", "sticky" ) self.sticky = self.settings.get( "bool", "sticky" )
self.minimized = self.settings.get( "bool", "minimized" ) self.minimized = self.settings.get( "bool", "minimized" )
RecentHelper.iconSize = self.appSettings.get( "int", "icon-size")
self.RebuildPlugin() self.RebuildPlugin()
def SetHidden( self, state ): def SetHidden( self, state ):
@ -121,6 +133,9 @@ class pluginclass:
if Name != None: if Name != None:
self.AddRecentBtn( Name, self.IconList[loc] ) self.AddRecentBtn( Name, self.IconList[loc] )
loc = loc + 1 loc = loc + 1
RecentHelper.doRecentApps()
return True return True
def clrmenu(self, *args, **kargs): def clrmenu(self, *args, **kargs):
@ -224,3 +239,4 @@ class pluginclass:
def do_plugin(self): def do_plugin(self):
self.DoRecent() self.DoRecent()

View File

@ -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()