diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py
index aeb3dfe..49d3f9a 100755
--- a/usr/lib/linuxmint/mintMenu/plugins/applications.py
+++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py
@@ -245,6 +245,9 @@ class pluginclass(object):
try:
# GSettings stuff
self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.applications")
+
+ self.migrate_favorites()
+
self.GetGSettingsEntries()
self.settings.connect("changed::icon-size", self.changeIconSize)
self.settings.connect("changed::favicon-size", self.changeFavIconSize)
@@ -264,6 +267,7 @@ class pluginclass(object):
self.settings.connect("changed::enable-internet-search", self.GetGSettingsEntries)
self.settings.connect("changed::search-command", self.GetGSettingsEntries)
self.settings.connect("changed::default-tab", self.GetGSettingsEntries)
+ self.settings.connect("changed::favorite-apps-list", self.favoriteAppsChanged)
except Exception as e:
print(e)
@@ -519,16 +523,6 @@ class pluginclass(object):
def RebuildPlugin(self):
self.content_holder.set_size_request(self.width, self.height)
- def checkMintMenuFolder(self):
- if os.path.exists(os.path.join(os.path.expanduser("~"), ".linuxmint", "mintMenu", "applications")):
- return True
- try:
- os.makedirs(os.path.join(os.path.expanduser("~"), ".linuxmint", "mintMenu", "applications"))
- return True
- except:
- pass
- return False
-
def onShowMenu(self):
if self.favorites:
if self.defaultTab == -1:
@@ -1245,26 +1239,44 @@ class pluginclass(object):
return None
+ def migrate_favorites(self):
+ if self.settings.get_strv("favorite-apps-list") != []:
+ return
+
+ default_path = os.path.join("/usr/linuxmint/mintMenu/applications.list")
+ path = os.path.join(home, ".linuxmint/mintMenu/applications.list")
+
+ if os.path.isdir(path):
+ # dir created by a bug in mint 19.2 beta
+ os.system("rm -rf %s" % path)
+ return
+
+ if not os.path.exists(path):
+ path = default_path
+
+ with open(path) as f:
+ self.settings.set_strv("favorite-apps-list", f.readlines())
+
+ try:
+ os.replace(path, path + ".deprecated_uses_dconf_now")
+ except:
+ # This will fail if it was the default path, ignore it.
+ pass
+
+ def favoriteAppsChanged(self, setting, key):
+ self.buildFavorites()
+
def buildFavorites(self):
try:
- path = os.path.join(home, ".linuxmint/mintMenu/applications.list")
- if os.path.isdir(path):
- # dir created by a bug in mint 19.2 beta
- os.system("rm -rf %s" % path)
- if not os.path.exists(path):
- os.system("mkdir -p ~/.linuxmint/mintMenu")
- os.system("cp /usr/lib/linuxmint/mintMenu/applications.list " + path)
-
- applicationsList = open(path).readlines()
-
- self.favorites = []
+ faves = self.settings.get_strv("favorite-apps-list")
for child in self.favoritesBox:
child.destroy()
position = 0
+ self.favorites = []
- for app in applicationsList:
+ for app in faves:
try:
app = app.strip()
@@ -1296,7 +1308,6 @@ class pluginclass(object):
print("Can't add favorite: %s" % app)
print (e)
- self.favoritesSave()
except Exception as e:
print(e)
@@ -1382,20 +1393,15 @@ class pluginclass(object):
self.favoritesRemove(fav.position)
def favoritesSave(self):
- try:
- self.checkMintMenuFolder()
- with open(os.path.join(home, ".linuxmint/mintMenu/applications.list") , "w") as appListFile:
- for favorite in self.favorites:
- if favorite.type == "location":
- appListFile.write("location:" + favorite.desktopFile + "\n")
- else:
- appListFile.write(favorite.type + "\n")
- except Exception as e:
- msgDlg = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
- _("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu") +
- "\n(" + e.__str__() + ")")
- msgDlg.run()
- msgDlg.destroy()
+ new_faves = []
+
+ for favorite in self.favorites:
+ if favorite.type == "location":
+ new_faves.append("location:" + favorite.desktopFile)
+ else:
+ new_faves.append(favorite.type)
+
+ self.settings.set_strv("favorite-apps-list", new_faves)
def isLocationInFavorites(self, location):
for fav in self.favorites:
diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py
index 82427c0..bef3bdb 100755
--- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py
+++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py
@@ -388,13 +388,6 @@ class ApplicationLauncher(easyButton):
if os.path.exists(self.startupFilePath):
os.remove(self.startupFilePath)
- def addToFavourites(self):
- favouritesDir = os.path.join(os.path.expanduser("~"), ".linuxmint/mintMenu/applications")
- if not os.path.exists(favouritesDir):
- os.makedirs(favouritesDir)
-
- shutil.copyfile(self.desktopFile, self.favouritesFilePath)
-
def removeFromFavourites(self):
if os.path.exists(self.favouritesFilePath):
os.remove(self.favouritesFilePath)
diff --git a/usr/lib/linuxmint/mintMenu/plugins/recent.py b/usr/lib/linuxmint/mintMenu/plugins/recent.py
index d2f90f7..6e2909f 100755
--- a/usr/lib/linuxmint/mintMenu/plugins/recent.py
+++ b/usr/lib/linuxmint/mintMenu/plugins/recent.py
@@ -12,6 +12,8 @@ from gi.repository import Gtk, Gio
import plugins.recentHelper as RecentHelper
from plugins.execute import Execute
+home = os.path.expanduser("~")
+
# i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
locale.bindtextdomain("mintmenu", "/usr/share/linuxmint/locale")
@@ -56,6 +58,9 @@ class pluginclass:
self.icon = 'mate-folder.png'
self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.recent")
+ RecentHelper.settings = self.settings
+
+ self.migrate_recent_apps()
self.settings.connect('changed', self.RegenPlugin)
self.appSettings = Gio.Settings("com.linuxmint.mintmenu.plugins.applications")
@@ -87,6 +92,20 @@ class pluginclass:
def RegenPlugin(self, *args, **kargs):
self.GetGSettingsEntries()
+ def migrate_recent_apps(self):
+ if self.settings.get_strv("recent-apps-list") != []:
+ return
+
+ path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
+ if os.path.exists(path):
+ with open(path) as f:
+ self.settings.set_strv("recent-apps-list", f.readlines())
+
+ try:
+ os.unlink(path)
+ except:
+ pass
+
def GetGSettingsEntries(self):
self.recenth = self.settings.get_int("height")
self.recentw = self.settings.get_int("width")
diff --git a/usr/lib/linuxmint/mintMenu/plugins/recentHelper.py b/usr/lib/linuxmint/mintMenu/plugins/recentHelper.py
index aaa302f..c0fab8d 100644
--- a/usr/lib/linuxmint/mintMenu/plugins/recentHelper.py
+++ b/usr/lib/linuxmint/mintMenu/plugins/recentHelper.py
@@ -10,6 +10,8 @@ from plugins.easybuttons import ApplicationLauncher
home = os.path.expanduser("~")
recentApps = []
+settings = None # set by recent plugin
+
mintMenuWin = None
recentAppBox = None
numentries = 10
@@ -25,21 +27,15 @@ def recentAppsAdd(recentAppsButton):
counter = counter + 1
def recentAppsSave():
- try:
- path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
- with open(path, "w") as recentAppListFile:
- 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")
+ new_recent_apps = []
- except Exception as 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()
+ for recentApp in recentApps:
+ if not hasattr(recentApp, "type") or recentApp.type == "location":
+ new_recent_apps.append("location:" + recentApp.desktopFile)
+ else:
+ new_recent_apps.append(recentApp.type)
+
+ settings.set_strv("recent-apps-list", new_recent_apps)
def recentAppBuildLauncher(location):
try:
@@ -82,13 +78,9 @@ def recentAppBuildLauncher(location):
def buildRecentApps():
del recentApps[:]
try:
- path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
- if not os.path.exists(path):
- recentApplicationsList = []
- else:
- recentApplicationsList = open(path).readlines()
+ recent_apps = settings.get_strv("recent-apps-list")
- for app in recentApplicationsList :
+ for app in recent_apps:
app = app.strip()
if app[0:9] == "location:":
diff --git a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml
index 0aa4b5d..aee257a 100644
--- a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml
+++ b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml
@@ -291,6 +291,12 @@
+
+
+ []
+ List of absolute desktop file paths
+
+