diff --git a/README.md b/README.md index ee3dc3a..57303ad 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Need python 3 # TODO diff --git a/bin/pytop-0-0-1-x64.deb b/bin/pytop-0-0-1-x64.deb index e752683..75e21a3 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/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.py b/src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.py index f427990..ba52412 100755 --- a/src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.py +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 # Gtk Imports -import gi +import gi, faulthandler gi.require_version('Gtk', '3.0') gi.require_version('WebKit2', '4.0') @@ -15,6 +15,7 @@ from utils import Settings, Events gdk.threads_init() class Main: def __init__(self): + faulthandler.enable() webkit.WebView() # Needed for glade file to load... self.builder = gtk.Builder() @@ -27,10 +28,6 @@ class Main: window.show_all() - - - - if __name__ == "__main__": main = Main() gtk.main() diff --git a/src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.sh b/src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.sh new file mode 100755 index 0000000..6cf9f3f --- /dev/null +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +function main() { + # GTK_DEBUG=interactive python3 ./PyTop.py + python3 ./PyTop.py +} +main $@; diff --git a/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/PyTop.glade b/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/PyTop.glade index 9bebfe5..f7d25bb 100644 --- a/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/PyTop.glade +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/PyTop.glade @@ -22,23 +22,53 @@ main + 1 False + right True False vertical - - 300 - 26 + True - True - gtk-edit + False + + + 300 + 26 + True + True + gtk-edit + + + + False + True + 0 + + + + + gtk-save + True + True + True + True + True + + + + False + True + 1 + + False @@ -52,12 +82,14 @@ False - gtk-copy + gtk-delete True True True + 65 True True + False @@ -65,6 +97,9 @@ 0 + + + gtk-cut @@ -77,19 +112,15 @@ False True - 1 + 2 - - - - gtk-delete + gtk-copy True True True - 65 True True @@ -109,6 +140,12 @@ + + True + False + gtk-go-up + 3 + True False @@ -138,35 +175,6 @@ True False - - - True - True - edit-find-symbolic - False - False - - - True - True - 0 - - - - - True - False - select-folder - Folders - Directory Chooser - - - - False - True - 1 - - True @@ -176,12 +184,57 @@ True + + False + True + 0 + + + + + True + True + edit-find-symbolic + False + False + + + True + True + 1 + + + + + True + True + True + Up + upImage + True + + False True 2 + + + True + False + select-folder + Folders + Directory Chooser + + + + False + True + 3 + + False @@ -193,6 +246,7 @@ True False + True False @@ -210,38 +264,16 @@ True False - + True - False - vertical - 10 - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - + True + False + False + True + both + + + @@ -262,7 +294,7 @@ True True popOutBttn - left + bottom True diff --git a/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/stylesheet.css b/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/stylesheet.css index 5a93664..e0240db 100644 --- a/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/stylesheet.css +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/resources/stylesheet.css @@ -11,3 +11,15 @@ notebook > header { background-color: rgba(0, 0, 0, 0.24); border-color: rgba(0, 232, 255, 0.64); } + +box, +iconview { + background-color: rgba(0, 0, 0, 0.2); + background: rgba(0, 0, 0, 0.2); +} + +treeview, +treeview.view { + background: rgba(0, 0, 0, 0.64); + background-color: rgba(0, 0, 0, 0.64); +} diff --git a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Events.py b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Events.py index 4615ba6..988dda0 100644 --- a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Events.py +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Events.py @@ -28,7 +28,15 @@ class Events: def setIconViewDir(self, widget, data=None): newPath = widget.get_filename() - Grid(self.desktop, self.settings, newPath) + self.grid = Grid(self.desktop, self.settings, newPath) + + def dirUp(self, widget, data=None): + newPath = self.grid.returnParentDir() + self.grid = Grid(self.desktop, self.settings, newPath) + + def iconLeftClickEventManager(self, widget, eve, item): + self.grid.iconLeftClickEventManager(widget, eve, item) + def showGridControlMenu(self, widget, data=None): popover = self.builder.get_object("gridControlMenu") diff --git a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py index e750f85..c213e6e 100644 --- a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Grid.py @@ -8,7 +8,7 @@ gi.require_version('Gdk', '3.0') from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GdkPixbuf -from gi.repository import GObject as gobject +from gi.repository import GLib # Python imports import os, threading @@ -18,8 +18,6 @@ from .Icon import Icon from .FileHandler import FileHandler -gdk.threads_init() - def threaded(fn): def wrapper(*args, **kwargs): threading.Thread(target=fn, args=args, kwargs=kwargs).start() @@ -31,27 +29,42 @@ class Grid: self.settings = settings self.filehandler = FileHandler() - self.store = gtk.ListStore(GdkPixbuf.Pixbuf, str) + self.store = gtk.TreeStore(str, GdkPixbuf.Pixbuf) self.usrHome = settings.returnUserHome() self.builder = self.settings.returnBuilder() self.ColumnSize = self.settings.returnColumnSize() self.currentPath = "" self.selectedFile = "" - + self.treeViewCol = None self.desktop.set_model(self.store) - self.desktop.set_pixbuf_column(0) - self.desktop.set_text_column(1) - self.desktop.connect("item-activated", self.iconLeftClickEventManager) - self.desktop.connect("button_press_event", self.iconRightClickEventManager, (self.desktop,)) + + if len(self.desktop.get_columns()) == 0: + self.treeViewCol = gtk.TreeViewColumn("Files") + # Create a column cell to display text + colCellText = gtk.CellRendererText() + # Create a column cell to display an image + colCellImg = gtk.CellRendererPixbuf() + # Add the cells to the column + self.treeViewCol.pack_start(colCellImg, False) + self.treeViewCol.pack_start(colCellText, True) + # Bind the text cell to column 0 of the tree's model + self.treeViewCol.add_attribute(colCellText, "text", 0) + # Bind the image cell to column 1 of the tree's model + self.treeViewCol.add_attribute(colCellImg, "pixbuf", 1) + # Append the columns to the TreeView + self.desktop.append_column(self.treeViewCol) + else: + self.treeViewCol = self.desktop.get_column(0) self.setIconViewDir(newPath) - @threaded + def setIconViewDir(self, path): + # self.treeViewCol.clear() self.store.clear() self.currentPath = path - dirPaths = ['.', '..'] + paths = ['.', '..'] files = [] for f in listdir(path): @@ -62,42 +75,49 @@ class Grid: if isfile(file): files.append(f) else: - dirPaths.append(f) + paths.append(f) - dirPaths.sort() + paths.sort() files.sort() - files = dirPaths + files + files = paths + files self.generateDirectoryGrid(path, files) - def generateDirectoryGrid(self, dirPath, files): + @threaded + def generateDirectoryGrid(self, path, files): fractionTick = 1.0 / 1.0 if len(files) == 0 else len(files) tickCount = 0.0 - row = 0 - col = 0 - x = 0 - y = 0 loadProgress = self.builder.get_object('loadProgress') loadProgress.set_text("Loading...") loadProgress.set_fraction(0.0) - for file in files: - imgBuffer = Icon(self.settings).createIcon(dirPath, file) - gobject.idle_add(self.addToGrid, (imgBuffer, file,)) - tickCount += fractionTick + imgBuffer = self.getImgBuffer(path, file) + GLib.idle_add(self.addToGrid, (imgBuffer, file,)) + # tickCount += fractionTick loadProgress.set_fraction(tickCount) - loadProgress.set_text("Finished...") - def addToGrid(self, args): - self.store.append([args[0], args[1]]) + def getImgBuffer(self, path, file): + return Icon(self.settings).createIcon(path, file) + + def addToGrid(self, args, parent=None): + # NOTE: Converting to pixbuf after retreval to keep Icon.py more universal. + # We can just remove get_pixbuf to get a gtk image. + # We probably need a settings check to chose a set type... + self.store.append(parent, [args[1], args[0].get_pixbuf()]) + + + def iconLeftClickEventManager(self, widget, eve, item): + tree_selection = self.desktop.get_selection() + (model, pathlist) = tree_selection.get_selected_rows() + fileName = None + dir = self.currentPath + for path in pathlist : + tree_iter = model.get_iter(path) + fileName = model.get_value(tree_iter,0) - def iconLeftClickEventManager(self, widget, item): try: - model = widget.get_model() - fileName = model[item][1] - dir = self.currentPath - file = dir + "/" + fileName + file = dir + "/" + fileName if fileName == ".": self.setIconViewDir(dir) @@ -135,6 +155,9 @@ class Grid: print(e) + def returnParentDir(self): + return os.path.abspath(os.path.join(self.currentPath, os.pardir)) + # Passthrough file control events def createFile(arg): pass diff --git a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Icon.py b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Icon.py index a0c22c1..d6a377a 100644 --- a/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Icon.py +++ b/src/debs/pytop-0-0-1-x64/opt/Pytop/utils/Icon.py @@ -57,12 +57,14 @@ class Icon: elif file.lower().endswith(imagesList): thumbnl = self.createIconImageBuffer(fullPathFile, self.viIconWxH) else: - thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0]) - thumbnl = self.createIconImageBuffer(thumbPth, self.systemIconImageWxH) + try: + thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0]) + thumbnl = self.createIconImageBuffer(thumbPth, self.systemIconImageWxH) + except Exception as e: + print(e) + thumbnl = gtk.Image(stock = gtk.STOCK_DIALOG_ERROR) - # NOTE: Returning pixbuf through retreval to keep this file more universaly usable. - # We can just remove get_pixbuf to get a gtk image - return thumbnl.get_pixbuf() + return thumbnl def createIconImageBuffer(self, path, wxh): pixbuf = None @@ -76,7 +78,7 @@ class Icon: except Exception as e: print(e) - return gtk.Image() + return gtk.Image(stock = gtk.STOCK_DIALOG_ERROR) def getSystemThumbnail(self, filename,size): final_filename = "" diff --git a/src/versions/pytop-0.0.1/Pytop/PyTop.py b/src/versions/pytop-0.0.1/Pytop/PyTop.py index f427990..ba52412 100755 --- a/src/versions/pytop-0.0.1/Pytop/PyTop.py +++ b/src/versions/pytop-0.0.1/Pytop/PyTop.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 # Gtk Imports -import gi +import gi, faulthandler gi.require_version('Gtk', '3.0') gi.require_version('WebKit2', '4.0') @@ -15,6 +15,7 @@ from utils import Settings, Events gdk.threads_init() class Main: def __init__(self): + faulthandler.enable() webkit.WebView() # Needed for glade file to load... self.builder = gtk.Builder() @@ -27,10 +28,6 @@ class Main: window.show_all() - - - - if __name__ == "__main__": main = Main() gtk.main() diff --git a/src/versions/pytop-0.0.1/Pytop/PyTop.sh b/src/versions/pytop-0.0.1/Pytop/PyTop.sh new file mode 100755 index 0000000..6cf9f3f --- /dev/null +++ b/src/versions/pytop-0.0.1/Pytop/PyTop.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +function main() { + # GTK_DEBUG=interactive python3 ./PyTop.py + python3 ./PyTop.py +} +main $@; diff --git a/src/versions/pytop-0.0.1/Pytop/resources/PyTop.glade b/src/versions/pytop-0.0.1/Pytop/resources/PyTop.glade index 9bebfe5..f7d25bb 100644 --- a/src/versions/pytop-0.0.1/Pytop/resources/PyTop.glade +++ b/src/versions/pytop-0.0.1/Pytop/resources/PyTop.glade @@ -22,23 +22,53 @@ main + 1 False + right True False vertical - - 300 - 26 + True - True - gtk-edit + False + + + 300 + 26 + True + True + gtk-edit + + + + False + True + 0 + + + + + gtk-save + True + True + True + True + True + + + + False + True + 1 + + False @@ -52,12 +82,14 @@ False - gtk-copy + gtk-delete True True True + 65 True True + False @@ -65,6 +97,9 @@ 0 + + + gtk-cut @@ -77,19 +112,15 @@ False True - 1 + 2 - - - - gtk-delete + gtk-copy True True True - 65 True True @@ -109,6 +140,12 @@ + + True + False + gtk-go-up + 3 + True False @@ -138,35 +175,6 @@ True False - - - True - True - edit-find-symbolic - False - False - - - True - True - 0 - - - - - True - False - select-folder - Folders - Directory Chooser - - - - False - True - 1 - - True @@ -176,12 +184,57 @@ True + + False + True + 0 + + + + + True + True + edit-find-symbolic + False + False + + + True + True + 1 + + + + + True + True + True + Up + upImage + True + + False True 2 + + + True + False + select-folder + Folders + Directory Chooser + + + + False + True + 3 + + False @@ -193,6 +246,7 @@ True False + True False @@ -210,38 +264,16 @@ True False - + True - False - vertical - 10 - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - + True + False + False + True + both + + + @@ -262,7 +294,7 @@ True True popOutBttn - left + bottom True diff --git a/src/versions/pytop-0.0.1/Pytop/resources/stylesheet.css b/src/versions/pytop-0.0.1/Pytop/resources/stylesheet.css index 5a93664..e0240db 100644 --- a/src/versions/pytop-0.0.1/Pytop/resources/stylesheet.css +++ b/src/versions/pytop-0.0.1/Pytop/resources/stylesheet.css @@ -11,3 +11,15 @@ notebook > header { background-color: rgba(0, 0, 0, 0.24); border-color: rgba(0, 232, 255, 0.64); } + +box, +iconview { + background-color: rgba(0, 0, 0, 0.2); + background: rgba(0, 0, 0, 0.2); +} + +treeview, +treeview.view { + background: rgba(0, 0, 0, 0.64); + background-color: rgba(0, 0, 0, 0.64); +} diff --git a/src/versions/pytop-0.0.1/Pytop/utils/Events.py b/src/versions/pytop-0.0.1/Pytop/utils/Events.py index 4615ba6..988dda0 100644 --- a/src/versions/pytop-0.0.1/Pytop/utils/Events.py +++ b/src/versions/pytop-0.0.1/Pytop/utils/Events.py @@ -28,7 +28,15 @@ class Events: def setIconViewDir(self, widget, data=None): newPath = widget.get_filename() - Grid(self.desktop, self.settings, newPath) + self.grid = Grid(self.desktop, self.settings, newPath) + + def dirUp(self, widget, data=None): + newPath = self.grid.returnParentDir() + self.grid = Grid(self.desktop, self.settings, newPath) + + def iconLeftClickEventManager(self, widget, eve, item): + self.grid.iconLeftClickEventManager(widget, eve, item) + def showGridControlMenu(self, widget, data=None): popover = self.builder.get_object("gridControlMenu") diff --git a/src/versions/pytop-0.0.1/Pytop/utils/Grid.py b/src/versions/pytop-0.0.1/Pytop/utils/Grid.py index e750f85..c213e6e 100644 --- a/src/versions/pytop-0.0.1/Pytop/utils/Grid.py +++ b/src/versions/pytop-0.0.1/Pytop/utils/Grid.py @@ -8,7 +8,7 @@ gi.require_version('Gdk', '3.0') from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GdkPixbuf -from gi.repository import GObject as gobject +from gi.repository import GLib # Python imports import os, threading @@ -18,8 +18,6 @@ from .Icon import Icon from .FileHandler import FileHandler -gdk.threads_init() - def threaded(fn): def wrapper(*args, **kwargs): threading.Thread(target=fn, args=args, kwargs=kwargs).start() @@ -31,27 +29,42 @@ class Grid: self.settings = settings self.filehandler = FileHandler() - self.store = gtk.ListStore(GdkPixbuf.Pixbuf, str) + self.store = gtk.TreeStore(str, GdkPixbuf.Pixbuf) self.usrHome = settings.returnUserHome() self.builder = self.settings.returnBuilder() self.ColumnSize = self.settings.returnColumnSize() self.currentPath = "" self.selectedFile = "" - + self.treeViewCol = None self.desktop.set_model(self.store) - self.desktop.set_pixbuf_column(0) - self.desktop.set_text_column(1) - self.desktop.connect("item-activated", self.iconLeftClickEventManager) - self.desktop.connect("button_press_event", self.iconRightClickEventManager, (self.desktop,)) + + if len(self.desktop.get_columns()) == 0: + self.treeViewCol = gtk.TreeViewColumn("Files") + # Create a column cell to display text + colCellText = gtk.CellRendererText() + # Create a column cell to display an image + colCellImg = gtk.CellRendererPixbuf() + # Add the cells to the column + self.treeViewCol.pack_start(colCellImg, False) + self.treeViewCol.pack_start(colCellText, True) + # Bind the text cell to column 0 of the tree's model + self.treeViewCol.add_attribute(colCellText, "text", 0) + # Bind the image cell to column 1 of the tree's model + self.treeViewCol.add_attribute(colCellImg, "pixbuf", 1) + # Append the columns to the TreeView + self.desktop.append_column(self.treeViewCol) + else: + self.treeViewCol = self.desktop.get_column(0) self.setIconViewDir(newPath) - @threaded + def setIconViewDir(self, path): + # self.treeViewCol.clear() self.store.clear() self.currentPath = path - dirPaths = ['.', '..'] + paths = ['.', '..'] files = [] for f in listdir(path): @@ -62,42 +75,49 @@ class Grid: if isfile(file): files.append(f) else: - dirPaths.append(f) + paths.append(f) - dirPaths.sort() + paths.sort() files.sort() - files = dirPaths + files + files = paths + files self.generateDirectoryGrid(path, files) - def generateDirectoryGrid(self, dirPath, files): + @threaded + def generateDirectoryGrid(self, path, files): fractionTick = 1.0 / 1.0 if len(files) == 0 else len(files) tickCount = 0.0 - row = 0 - col = 0 - x = 0 - y = 0 loadProgress = self.builder.get_object('loadProgress') loadProgress.set_text("Loading...") loadProgress.set_fraction(0.0) - for file in files: - imgBuffer = Icon(self.settings).createIcon(dirPath, file) - gobject.idle_add(self.addToGrid, (imgBuffer, file,)) - tickCount += fractionTick + imgBuffer = self.getImgBuffer(path, file) + GLib.idle_add(self.addToGrid, (imgBuffer, file,)) + # tickCount += fractionTick loadProgress.set_fraction(tickCount) - loadProgress.set_text("Finished...") - def addToGrid(self, args): - self.store.append([args[0], args[1]]) + def getImgBuffer(self, path, file): + return Icon(self.settings).createIcon(path, file) + + def addToGrid(self, args, parent=None): + # NOTE: Converting to pixbuf after retreval to keep Icon.py more universal. + # We can just remove get_pixbuf to get a gtk image. + # We probably need a settings check to chose a set type... + self.store.append(parent, [args[1], args[0].get_pixbuf()]) + + + def iconLeftClickEventManager(self, widget, eve, item): + tree_selection = self.desktop.get_selection() + (model, pathlist) = tree_selection.get_selected_rows() + fileName = None + dir = self.currentPath + for path in pathlist : + tree_iter = model.get_iter(path) + fileName = model.get_value(tree_iter,0) - def iconLeftClickEventManager(self, widget, item): try: - model = widget.get_model() - fileName = model[item][1] - dir = self.currentPath - file = dir + "/" + fileName + file = dir + "/" + fileName if fileName == ".": self.setIconViewDir(dir) @@ -135,6 +155,9 @@ class Grid: print(e) + def returnParentDir(self): + return os.path.abspath(os.path.join(self.currentPath, os.pardir)) + # Passthrough file control events def createFile(arg): pass diff --git a/src/versions/pytop-0.0.1/Pytop/utils/Icon.py b/src/versions/pytop-0.0.1/Pytop/utils/Icon.py index a0c22c1..d6a377a 100644 --- a/src/versions/pytop-0.0.1/Pytop/utils/Icon.py +++ b/src/versions/pytop-0.0.1/Pytop/utils/Icon.py @@ -57,12 +57,14 @@ class Icon: elif file.lower().endswith(imagesList): thumbnl = self.createIconImageBuffer(fullPathFile, self.viIconWxH) else: - thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0]) - thumbnl = self.createIconImageBuffer(thumbPth, self.systemIconImageWxH) + try: + thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0]) + thumbnl = self.createIconImageBuffer(thumbPth, self.systemIconImageWxH) + except Exception as e: + print(e) + thumbnl = gtk.Image(stock = gtk.STOCK_DIALOG_ERROR) - # NOTE: Returning pixbuf through retreval to keep this file more universaly usable. - # We can just remove get_pixbuf to get a gtk image - return thumbnl.get_pixbuf() + return thumbnl def createIconImageBuffer(self, path, wxh): pixbuf = None @@ -76,7 +78,7 @@ class Icon: except Exception as e: print(e) - return gtk.Image() + return gtk.Image(stock = gtk.STOCK_DIALOG_ERROR) def getSystemThumbnail(self, filename,size): final_filename = ""