Using treeview instead of grid
This commit is contained in:
parent
035d485129
commit
8773011925
@ -7,7 +7,6 @@ Need python 3
|
||||
# TODO
|
||||
<ul>
|
||||
<li>Attach copy, cut, and paste signals to the controls menu.</li>
|
||||
<li>Add search functionality to the current directory.</li>
|
||||
<li>Add a settings file to store values.</li>
|
||||
<li>Improve icon detection for Steam.</li>
|
||||
</ul>
|
||||
|
Binary file not shown.
@ -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()
|
||||
|
12
src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.sh
Executable file
12
src/debs/pytop-0-0-1-x64/opt/Pytop/PyTop.sh
Executable file
@ -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 $@;
|
@ -22,23 +22,53 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="submenu">main</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="iconControlsWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="position">right</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="iconRenameInput">
|
||||
<property name="width_request">300</property>
|
||||
<property name="height_request">26</property>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_stock">gtk-edit</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="iconRenameInput">
|
||||
<property name="width_request">300</property>
|
||||
<property name="height_request">26</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_stock">gtk-edit</property>
|
||||
<signal name="key-release-event" handler="updateFile" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-save</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="updateFile" object="iconRenameInput" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -52,12 +82,14 @@
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">65</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="deleteFile" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -65,6 +97,9 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-cut</property>
|
||||
@ -77,19 +112,15 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">65</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
</object>
|
||||
@ -109,6 +140,12 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="upImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-go-up</property>
|
||||
<property name="icon_size">3</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="webDropDown">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -138,35 +175,6 @@
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="selectedDirDialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
<property name="filter">Folders</property>
|
||||
<property name="title" translatable="yes">Directory Chooser</property>
|
||||
<signal name="file-set" handler="setDir" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="popOutBttn">
|
||||
<property name="visible">True</property>
|
||||
@ -176,12 +184,57 @@
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="showWebview" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Up</property>
|
||||
<property name="image">upImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="dirUp" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="selectedDirDialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
<property name="filter">Folders</property>
|
||||
<property name="title" translatable="yes">Directory Chooser</property>
|
||||
<signal name="selection-changed" handler="setIconViewDir" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -193,6 +246,7 @@
|
||||
<object class="GtkProgressBar" id="loadProgress">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="show_text">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -210,38 +264,16 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="Desktop">
|
||||
<object class="GtkTreeView" id="Desktop">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="column_spacing">10</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="show_expanders">False</property>
|
||||
<property name="rubber_banding">True</property>
|
||||
<property name="enable_grid_lines">both</property>
|
||||
<signal name="row-activated" handler="iconLeftClickEventManager" swapped="no"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
@ -262,7 +294,7 @@
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="relative_to">popOutBttn</property>
|
||||
<property name="position">left</property>
|
||||
<property name="position">bottom</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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 = ""
|
||||
|
@ -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()
|
||||
|
12
src/versions/pytop-0.0.1/Pytop/PyTop.sh
Executable file
12
src/versions/pytop-0.0.1/Pytop/PyTop.sh
Executable file
@ -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 $@;
|
@ -22,23 +22,53 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="submenu">main</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="iconControlsWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="position">right</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="iconRenameInput">
|
||||
<property name="width_request">300</property>
|
||||
<property name="height_request">26</property>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_stock">gtk-edit</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="iconRenameInput">
|
||||
<property name="width_request">300</property>
|
||||
<property name="height_request">26</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_stock">gtk-edit</property>
|
||||
<signal name="key-release-event" handler="updateFile" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-save</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="updateFile" object="iconRenameInput" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -52,12 +82,14 @@
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">65</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="deleteFile" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -65,6 +97,9 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-cut</property>
|
||||
@ -77,19 +112,15 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">65</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
</object>
|
||||
@ -109,6 +140,12 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="upImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-go-up</property>
|
||||
<property name="icon_size">3</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="webDropDown">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -138,35 +175,6 @@
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="selectedDirDialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
<property name="filter">Folders</property>
|
||||
<property name="title" translatable="yes">Directory Chooser</property>
|
||||
<signal name="file-set" handler="setDir" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="popOutBttn">
|
||||
<property name="visible">True</property>
|
||||
@ -176,12 +184,57 @@
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="showWebview" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Up</property>
|
||||
<property name="image">upImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="dirUp" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="selectedDirDialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
<property name="filter">Folders</property>
|
||||
<property name="title" translatable="yes">Directory Chooser</property>
|
||||
<signal name="selection-changed" handler="setIconViewDir" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -193,6 +246,7 @@
|
||||
<object class="GtkProgressBar" id="loadProgress">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="show_text">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -210,38 +264,16 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="Desktop">
|
||||
<object class="GtkTreeView" id="Desktop">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="column_spacing">10</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="show_expanders">False</property>
|
||||
<property name="rubber_banding">True</property>
|
||||
<property name="enable_grid_lines">both</property>
|
||||
<signal name="row-activated" handler="iconLeftClickEventManager" swapped="no"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
@ -262,7 +294,7 @@
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="relative_to">popOutBttn</property>
|
||||
<property name="position">left</property>
|
||||
<property name="position">bottom</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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 = ""
|
||||
|
Loading…
Reference in New Issue
Block a user