diff --git a/README.md b/README.md
index e85bdfd..62cb8bd 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,4 @@ Added task bar.
- Detect window title changes
- Set taskbar menu option based on window options.
-- Attach copy, cut, and paste signals to the controls menu.
-- Add a settings file to store values.
diff --git a/bin/pytop-0-0-1-x64.deb b/bin/pytop-0-0-1-x64.deb
index 169c265..d64625a 100644
Binary files a/bin/pytop-0-0-1-x64.deb and b/bin/pytop-0-0-1-x64.deb differ
diff --git a/src/Pytop/signal_classes/GridSignals.py b/src/Pytop/signal_classes/GridSignals.py
index 74034d1..1062118 100644
--- a/src/Pytop/signal_classes/GridSignals.py
+++ b/src/Pytop/signal_classes/GridSignals.py
@@ -18,7 +18,7 @@ class GridSignals:
selectDirDialog = self.builder.get_object("selectDirDialog")
filefilter = self.builder.get_object("Folders")
- self.currentPath = self.settings.returnDesktopPath()
+ self.currentPath = self.settings.returnSettings()[0]
self.copyCutArry = []
self.selectedFiles = []
self.gridClss = None
@@ -27,6 +27,7 @@ class GridSignals:
# Add filter to allow only folders to be selected
selectDirDialog.add_filter(filefilter)
selectDirDialog.set_filename(self.currentPath)
+ print(selectDirDialog.get_filename())
self.setNewDirectory(selectDirDialog)
@@ -35,6 +36,9 @@ class GridSignals:
self.gridClss = Grid(self.gridObj, self.settings)
self.gridClss.setNewDirectory(newPath)
+ if not "~/Desktop/" in newPath:
+ self.settings.saveSettings(newPath)
+
# File control events
def create(self, wdget):
diff --git a/src/Pytop/utils/Settings.py b/src/Pytop/utils/Settings.py
index b8e4067..2d92eef 100644
--- a/src/Pytop/utils/Settings.py
+++ b/src/Pytop/utils/Settings.py
@@ -7,7 +7,7 @@ from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
# Python imports
-import os
+import os, json
# Application imports
@@ -52,6 +52,12 @@ class Settings:
self.MPV_WH = " -geometry 50%:50% ";
self.GTK_ORIENTATION = 1 # HORIZONTAL (0) VERTICAL (1)
+ configFolder = os.path.expanduser('~') + "/.config/pytop/"
+ self.configFile = configFolder + "settings.ini"
+
+ if os.path.isdir(configFolder) == False:
+ os.mkdir(configFolder)
+
if os.path.isdir(self.TRASHFOLDER) == False:
os.mkdir(TRASHFILESFOLDER)
os.mkdir(TRASHINFOFOLDER)
@@ -62,6 +68,10 @@ class Settings:
if os.path.isdir(self.TRASHINFOFOLDER) == False:
os.mkdir(TRASHINFOFOLDER)
+ if os.path.isfile(self.configFile) == False:
+ open(self.configFile, 'a').close()
+ self.saveSettings(self.desktopPath)
+
def attachBuilder(self, builder):
self.builder = builder
@@ -102,6 +112,36 @@ class Settings:
return monitors
+ def saveSettings(self, startPath):
+ data = {}
+ data['pytop_settings'] = []
+
+ data['pytop_settings'].append({
+ 'startPath' : startPath
+ })
+
+ with open(self.configFile, 'w') as outfile:
+ json.dump(data, outfile)
+
+
+ def returnSettings(self):
+ returnData = []
+
+ with open(self.configFile) as infile:
+ try:
+ data = json.load(infile)
+ for obj in data['pytop_settings']:
+ returnData = [obj['startPath']]
+ except Exception as e:
+ returnData = ['~/Desktop/']
+
+
+ if returnData[0] == '':
+ returnData[0] = '~/Desktop/'
+
+ return returnData
+
+
def returnBuilder(self): return self.builder
def returnUserHome(self): return self.usrHome
def returnDesktopPath(self): return self.usrHome + "/Desktop"
diff --git a/src/Pytop/widgets/Grid.py b/src/Pytop/widgets/Grid.py
index f56a4cb..6e81166 100644
--- a/src/Pytop/widgets/Grid.py
+++ b/src/Pytop/widgets/Grid.py
@@ -48,7 +48,6 @@ class Grid:
self.grid.connect("item-activated", self.iconDblLeftClick)
self.grid.connect("button_release_event", self.iconSingleClick, (self.grid,))
- # @threaded
def setNewDirectory(self, path):
self.store.clear()
self.currentPath = path
@@ -131,9 +130,11 @@ class Grid:
parentDir = os.path.abspath(os.path.join(dir, os.pardir))
self.currentPath = parentDir
self.setNewDirectory(parentDir)
+ self.settings.saveSettings(parentDir)
elif isdir(file):
self.currentPath = file
self.setNewDirectory(self.currentPath)
+ self.settings.saveSettings(self.currentPath)
elif isfile(file):
self.fileHandler.openFile(file)
except Exception as e: