Using treeview instead of grid
This commit is contained in:
parent
035d485129
commit
8773011925
@ -7,7 +7,6 @@ Need python 3
|
|||||||
# TODO
|
# TODO
|
||||||
<ul>
|
<ul>
|
||||||
<li>Attach copy, cut, and paste signals to the controls menu.</li>
|
<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>Add a settings file to store values.</li>
|
||||||
<li>Improve icon detection for Steam.</li>
|
<li>Improve icon detection for Steam.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# Gtk Imports
|
# Gtk Imports
|
||||||
import gi
|
import gi, faulthandler
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
gi.require_version('WebKit2', '4.0')
|
gi.require_version('WebKit2', '4.0')
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ from utils import Settings, Events
|
|||||||
gdk.threads_init()
|
gdk.threads_init()
|
||||||
class Main:
|
class Main:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
faulthandler.enable()
|
||||||
webkit.WebView() # Needed for glade file to load...
|
webkit.WebView() # Needed for glade file to load...
|
||||||
|
|
||||||
self.builder = gtk.Builder()
|
self.builder = gtk.Builder()
|
||||||
@ -27,10 +28,6 @@ class Main:
|
|||||||
window.show_all()
|
window.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main = Main()
|
main = Main()
|
||||||
gtk.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,16 +22,22 @@
|
|||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="submenu">main</property>
|
<property name="submenu">main</property>
|
||||||
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkPopover" id="iconControlsWindow">
|
<object class="GtkPopover" id="iconControlsWindow">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="position">right</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="iconRenameInput">
|
<object class="GtkEntry" id="iconRenameInput">
|
||||||
<property name="width_request">300</property>
|
<property name="width_request">300</property>
|
||||||
@ -39,6 +45,30 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="primary_icon_stock">gtk-edit</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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -52,12 +82,14 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label">gtk-copy</property>
|
<property name="label">gtk-delete</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
|
<property name="margin_left">65</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="always_show_image">True</property>
|
<property name="always_show_image">True</property>
|
||||||
|
<signal name="clicked" handler="deleteFile" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -65,6 +97,9 @@
|
|||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label">gtk-cut</property>
|
<property name="label">gtk-cut</property>
|
||||||
@ -77,19 +112,15 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label">gtk-delete</property>
|
<property name="label">gtk-copy</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="margin_left">65</property>
|
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="always_show_image">True</property>
|
<property name="always_show_image">True</property>
|
||||||
</object>
|
</object>
|
||||||
@ -109,6 +140,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</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">
|
<object class="GtkImage" id="webDropDown">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@ -138,35 +175,6 @@
|
|||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</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>
|
<child>
|
||||||
<object class="GtkButton" id="popOutBttn">
|
<object class="GtkButton" id="popOutBttn">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -176,12 +184,57 @@
|
|||||||
<property name="always_show_image">True</property>
|
<property name="always_show_image">True</property>
|
||||||
<signal name="clicked" handler="showWebview" swapped="no"/>
|
<signal name="clicked" handler="showWebview" swapped="no"/>
|
||||||
</object>
|
</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>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -193,6 +246,7 @@
|
|||||||
<object class="GtkProgressBar" id="loadProgress">
|
<object class="GtkProgressBar" id="loadProgress">
|
||||||
<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_text">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -210,38 +264,16 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="Desktop">
|
<object class="GtkTreeView" id="Desktop">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="headers_visible">False</property>
|
||||||
<property name="row_spacing">10</property>
|
<property name="show_expanders">False</property>
|
||||||
<property name="column_spacing">10</property>
|
<property name="rubber_banding">True</property>
|
||||||
<child>
|
<property name="enable_grid_lines">both</property>
|
||||||
<placeholder/>
|
<signal name="row-activated" handler="iconLeftClickEventManager" swapped="no"/>
|
||||||
</child>
|
<child internal-child="selection">
|
||||||
<child>
|
<object class="GtkTreeSelection"/>
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@ -262,7 +294,7 @@
|
|||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="vexpand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="relative_to">popOutBttn</property>
|
<property name="relative_to">popOutBttn</property>
|
||||||
<property name="position">left</property>
|
<property name="position">bottom</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -11,3 +11,15 @@ notebook > header {
|
|||||||
background-color: rgba(0, 0, 0, 0.24);
|
background-color: rgba(0, 0, 0, 0.24);
|
||||||
border-color: rgba(0, 232, 255, 0.64);
|
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):
|
def setIconViewDir(self, widget, data=None):
|
||||||
newPath = widget.get_filename()
|
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):
|
def showGridControlMenu(self, widget, data=None):
|
||||||
popover = self.builder.get_object("gridControlMenu")
|
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 Gtk as gtk
|
||||||
from gi.repository import Gdk as gdk
|
from gi.repository import Gdk as gdk
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
from gi.repository import GObject as gobject
|
from gi.repository import GLib
|
||||||
|
|
||||||
# Python imports
|
# Python imports
|
||||||
import os, threading
|
import os, threading
|
||||||
@ -18,8 +18,6 @@ from .Icon import Icon
|
|||||||
from .FileHandler import FileHandler
|
from .FileHandler import FileHandler
|
||||||
|
|
||||||
|
|
||||||
gdk.threads_init()
|
|
||||||
|
|
||||||
def threaded(fn):
|
def threaded(fn):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||||
@ -31,27 +29,42 @@ class Grid:
|
|||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.filehandler = FileHandler()
|
self.filehandler = FileHandler()
|
||||||
|
|
||||||
self.store = gtk.ListStore(GdkPixbuf.Pixbuf, str)
|
self.store = gtk.TreeStore(str, GdkPixbuf.Pixbuf)
|
||||||
self.usrHome = settings.returnUserHome()
|
self.usrHome = settings.returnUserHome()
|
||||||
self.builder = self.settings.returnBuilder()
|
self.builder = self.settings.returnBuilder()
|
||||||
self.ColumnSize = self.settings.returnColumnSize()
|
self.ColumnSize = self.settings.returnColumnSize()
|
||||||
self.currentPath = ""
|
self.currentPath = ""
|
||||||
self.selectedFile = ""
|
self.selectedFile = ""
|
||||||
|
self.treeViewCol = None
|
||||||
self.desktop.set_model(self.store)
|
self.desktop.set_model(self.store)
|
||||||
self.desktop.set_pixbuf_column(0)
|
|
||||||
self.desktop.set_text_column(1)
|
if len(self.desktop.get_columns()) == 0:
|
||||||
self.desktop.connect("item-activated", self.iconLeftClickEventManager)
|
self.treeViewCol = gtk.TreeViewColumn("Files")
|
||||||
self.desktop.connect("button_press_event", self.iconRightClickEventManager, (self.desktop,))
|
# 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)
|
self.setIconViewDir(newPath)
|
||||||
|
|
||||||
@threaded
|
|
||||||
def setIconViewDir(self, path):
|
def setIconViewDir(self, path):
|
||||||
|
# self.treeViewCol.clear()
|
||||||
self.store.clear()
|
self.store.clear()
|
||||||
|
|
||||||
self.currentPath = path
|
self.currentPath = path
|
||||||
dirPaths = ['.', '..']
|
paths = ['.', '..']
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
for f in listdir(path):
|
for f in listdir(path):
|
||||||
@ -62,41 +75,48 @@ class Grid:
|
|||||||
if isfile(file):
|
if isfile(file):
|
||||||
files.append(f)
|
files.append(f)
|
||||||
else:
|
else:
|
||||||
dirPaths.append(f)
|
paths.append(f)
|
||||||
|
|
||||||
dirPaths.sort()
|
paths.sort()
|
||||||
files.sort()
|
files.sort()
|
||||||
files = dirPaths + files
|
files = paths + files
|
||||||
self.generateDirectoryGrid(path, 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)
|
fractionTick = 1.0 / 1.0 if len(files) == 0 else len(files)
|
||||||
tickCount = 0.0
|
tickCount = 0.0
|
||||||
row = 0
|
|
||||||
col = 0
|
|
||||||
x = 0
|
|
||||||
y = 0
|
|
||||||
|
|
||||||
loadProgress = self.builder.get_object('loadProgress')
|
loadProgress = self.builder.get_object('loadProgress')
|
||||||
loadProgress.set_text("Loading...")
|
loadProgress.set_text("Loading...")
|
||||||
loadProgress.set_fraction(0.0)
|
loadProgress.set_fraction(0.0)
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
imgBuffer = Icon(self.settings).createIcon(dirPath, file)
|
imgBuffer = self.getImgBuffer(path, file)
|
||||||
gobject.idle_add(self.addToGrid, (imgBuffer, file,))
|
GLib.idle_add(self.addToGrid, (imgBuffer, file,))
|
||||||
tickCount += fractionTick
|
# tickCount += fractionTick
|
||||||
loadProgress.set_fraction(tickCount)
|
loadProgress.set_fraction(tickCount)
|
||||||
|
|
||||||
loadProgress.set_text("Finished...")
|
loadProgress.set_text("Finished...")
|
||||||
|
|
||||||
def addToGrid(self, args):
|
def getImgBuffer(self, path, file):
|
||||||
self.store.append([args[0], args[1]])
|
return Icon(self.settings).createIcon(path, file)
|
||||||
|
|
||||||
def iconLeftClickEventManager(self, widget, item):
|
def addToGrid(self, args, parent=None):
|
||||||
try:
|
# NOTE: Converting to pixbuf after retreval to keep Icon.py more universal.
|
||||||
model = widget.get_model()
|
# We can just remove get_pixbuf to get a gtk image.
|
||||||
fileName = model[item][1]
|
# 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
|
dir = self.currentPath
|
||||||
|
for path in pathlist :
|
||||||
|
tree_iter = model.get_iter(path)
|
||||||
|
fileName = model.get_value(tree_iter,0)
|
||||||
|
|
||||||
|
try:
|
||||||
file = dir + "/" + fileName
|
file = dir + "/" + fileName
|
||||||
|
|
||||||
if fileName == ".":
|
if fileName == ".":
|
||||||
@ -135,6 +155,9 @@ class Grid:
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
|
def returnParentDir(self):
|
||||||
|
return os.path.abspath(os.path.join(self.currentPath, os.pardir))
|
||||||
|
|
||||||
# Passthrough file control events
|
# Passthrough file control events
|
||||||
def createFile(arg):
|
def createFile(arg):
|
||||||
pass
|
pass
|
||||||
|
@ -57,12 +57,14 @@ class Icon:
|
|||||||
elif file.lower().endswith(imagesList):
|
elif file.lower().endswith(imagesList):
|
||||||
thumbnl = self.createIconImageBuffer(fullPathFile, self.viIconWxH)
|
thumbnl = self.createIconImageBuffer(fullPathFile, self.viIconWxH)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0])
|
thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0])
|
||||||
thumbnl = self.createIconImageBuffer(thumbPth, self.systemIconImageWxH)
|
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.
|
return thumbnl
|
||||||
# We can just remove get_pixbuf to get a gtk image
|
|
||||||
return thumbnl.get_pixbuf()
|
|
||||||
|
|
||||||
def createIconImageBuffer(self, path, wxh):
|
def createIconImageBuffer(self, path, wxh):
|
||||||
pixbuf = None
|
pixbuf = None
|
||||||
@ -76,7 +78,7 @@ class Icon:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
return gtk.Image()
|
return gtk.Image(stock = gtk.STOCK_DIALOG_ERROR)
|
||||||
|
|
||||||
def getSystemThumbnail(self, filename,size):
|
def getSystemThumbnail(self, filename,size):
|
||||||
final_filename = ""
|
final_filename = ""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# Gtk Imports
|
# Gtk Imports
|
||||||
import gi
|
import gi, faulthandler
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
gi.require_version('WebKit2', '4.0')
|
gi.require_version('WebKit2', '4.0')
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ from utils import Settings, Events
|
|||||||
gdk.threads_init()
|
gdk.threads_init()
|
||||||
class Main:
|
class Main:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
faulthandler.enable()
|
||||||
webkit.WebView() # Needed for glade file to load...
|
webkit.WebView() # Needed for glade file to load...
|
||||||
|
|
||||||
self.builder = gtk.Builder()
|
self.builder = gtk.Builder()
|
||||||
@ -27,10 +28,6 @@ class Main:
|
|||||||
window.show_all()
|
window.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main = Main()
|
main = Main()
|
||||||
gtk.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,16 +22,22 @@
|
|||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="submenu">main</property>
|
<property name="submenu">main</property>
|
||||||
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkPopover" id="iconControlsWindow">
|
<object class="GtkPopover" id="iconControlsWindow">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="position">right</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="iconRenameInput">
|
<object class="GtkEntry" id="iconRenameInput">
|
||||||
<property name="width_request">300</property>
|
<property name="width_request">300</property>
|
||||||
@ -39,6 +45,30 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="primary_icon_stock">gtk-edit</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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -52,12 +82,14 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label">gtk-copy</property>
|
<property name="label">gtk-delete</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
|
<property name="margin_left">65</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="always_show_image">True</property>
|
<property name="always_show_image">True</property>
|
||||||
|
<signal name="clicked" handler="deleteFile" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -65,6 +97,9 @@
|
|||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label">gtk-cut</property>
|
<property name="label">gtk-cut</property>
|
||||||
@ -77,19 +112,15 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label">gtk-delete</property>
|
<property name="label">gtk-copy</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="margin_left">65</property>
|
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="always_show_image">True</property>
|
<property name="always_show_image">True</property>
|
||||||
</object>
|
</object>
|
||||||
@ -109,6 +140,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</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">
|
<object class="GtkImage" id="webDropDown">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@ -138,35 +175,6 @@
|
|||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</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>
|
<child>
|
||||||
<object class="GtkButton" id="popOutBttn">
|
<object class="GtkButton" id="popOutBttn">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -176,12 +184,57 @@
|
|||||||
<property name="always_show_image">True</property>
|
<property name="always_show_image">True</property>
|
||||||
<signal name="clicked" handler="showWebview" swapped="no"/>
|
<signal name="clicked" handler="showWebview" swapped="no"/>
|
||||||
</object>
|
</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>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -193,6 +246,7 @@
|
|||||||
<object class="GtkProgressBar" id="loadProgress">
|
<object class="GtkProgressBar" id="loadProgress">
|
||||||
<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_text">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -210,38 +264,16 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="Desktop">
|
<object class="GtkTreeView" id="Desktop">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="headers_visible">False</property>
|
||||||
<property name="row_spacing">10</property>
|
<property name="show_expanders">False</property>
|
||||||
<property name="column_spacing">10</property>
|
<property name="rubber_banding">True</property>
|
||||||
<child>
|
<property name="enable_grid_lines">both</property>
|
||||||
<placeholder/>
|
<signal name="row-activated" handler="iconLeftClickEventManager" swapped="no"/>
|
||||||
</child>
|
<child internal-child="selection">
|
||||||
<child>
|
<object class="GtkTreeSelection"/>
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@ -262,7 +294,7 @@
|
|||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="vexpand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="relative_to">popOutBttn</property>
|
<property name="relative_to">popOutBttn</property>
|
||||||
<property name="position">left</property>
|
<property name="position">bottom</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -11,3 +11,15 @@ notebook > header {
|
|||||||
background-color: rgba(0, 0, 0, 0.24);
|
background-color: rgba(0, 0, 0, 0.24);
|
||||||
border-color: rgba(0, 232, 255, 0.64);
|
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):
|
def setIconViewDir(self, widget, data=None):
|
||||||
newPath = widget.get_filename()
|
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):
|
def showGridControlMenu(self, widget, data=None):
|
||||||
popover = self.builder.get_object("gridControlMenu")
|
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 Gtk as gtk
|
||||||
from gi.repository import Gdk as gdk
|
from gi.repository import Gdk as gdk
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
from gi.repository import GObject as gobject
|
from gi.repository import GLib
|
||||||
|
|
||||||
# Python imports
|
# Python imports
|
||||||
import os, threading
|
import os, threading
|
||||||
@ -18,8 +18,6 @@ from .Icon import Icon
|
|||||||
from .FileHandler import FileHandler
|
from .FileHandler import FileHandler
|
||||||
|
|
||||||
|
|
||||||
gdk.threads_init()
|
|
||||||
|
|
||||||
def threaded(fn):
|
def threaded(fn):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||||
@ -31,27 +29,42 @@ class Grid:
|
|||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.filehandler = FileHandler()
|
self.filehandler = FileHandler()
|
||||||
|
|
||||||
self.store = gtk.ListStore(GdkPixbuf.Pixbuf, str)
|
self.store = gtk.TreeStore(str, GdkPixbuf.Pixbuf)
|
||||||
self.usrHome = settings.returnUserHome()
|
self.usrHome = settings.returnUserHome()
|
||||||
self.builder = self.settings.returnBuilder()
|
self.builder = self.settings.returnBuilder()
|
||||||
self.ColumnSize = self.settings.returnColumnSize()
|
self.ColumnSize = self.settings.returnColumnSize()
|
||||||
self.currentPath = ""
|
self.currentPath = ""
|
||||||
self.selectedFile = ""
|
self.selectedFile = ""
|
||||||
|
self.treeViewCol = None
|
||||||
self.desktop.set_model(self.store)
|
self.desktop.set_model(self.store)
|
||||||
self.desktop.set_pixbuf_column(0)
|
|
||||||
self.desktop.set_text_column(1)
|
if len(self.desktop.get_columns()) == 0:
|
||||||
self.desktop.connect("item-activated", self.iconLeftClickEventManager)
|
self.treeViewCol = gtk.TreeViewColumn("Files")
|
||||||
self.desktop.connect("button_press_event", self.iconRightClickEventManager, (self.desktop,))
|
# 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)
|
self.setIconViewDir(newPath)
|
||||||
|
|
||||||
@threaded
|
|
||||||
def setIconViewDir(self, path):
|
def setIconViewDir(self, path):
|
||||||
|
# self.treeViewCol.clear()
|
||||||
self.store.clear()
|
self.store.clear()
|
||||||
|
|
||||||
self.currentPath = path
|
self.currentPath = path
|
||||||
dirPaths = ['.', '..']
|
paths = ['.', '..']
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
for f in listdir(path):
|
for f in listdir(path):
|
||||||
@ -62,41 +75,48 @@ class Grid:
|
|||||||
if isfile(file):
|
if isfile(file):
|
||||||
files.append(f)
|
files.append(f)
|
||||||
else:
|
else:
|
||||||
dirPaths.append(f)
|
paths.append(f)
|
||||||
|
|
||||||
dirPaths.sort()
|
paths.sort()
|
||||||
files.sort()
|
files.sort()
|
||||||
files = dirPaths + files
|
files = paths + files
|
||||||
self.generateDirectoryGrid(path, 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)
|
fractionTick = 1.0 / 1.0 if len(files) == 0 else len(files)
|
||||||
tickCount = 0.0
|
tickCount = 0.0
|
||||||
row = 0
|
|
||||||
col = 0
|
|
||||||
x = 0
|
|
||||||
y = 0
|
|
||||||
|
|
||||||
loadProgress = self.builder.get_object('loadProgress')
|
loadProgress = self.builder.get_object('loadProgress')
|
||||||
loadProgress.set_text("Loading...")
|
loadProgress.set_text("Loading...")
|
||||||
loadProgress.set_fraction(0.0)
|
loadProgress.set_fraction(0.0)
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
imgBuffer = Icon(self.settings).createIcon(dirPath, file)
|
imgBuffer = self.getImgBuffer(path, file)
|
||||||
gobject.idle_add(self.addToGrid, (imgBuffer, file,))
|
GLib.idle_add(self.addToGrid, (imgBuffer, file,))
|
||||||
tickCount += fractionTick
|
# tickCount += fractionTick
|
||||||
loadProgress.set_fraction(tickCount)
|
loadProgress.set_fraction(tickCount)
|
||||||
|
|
||||||
loadProgress.set_text("Finished...")
|
loadProgress.set_text("Finished...")
|
||||||
|
|
||||||
def addToGrid(self, args):
|
def getImgBuffer(self, path, file):
|
||||||
self.store.append([args[0], args[1]])
|
return Icon(self.settings).createIcon(path, file)
|
||||||
|
|
||||||
def iconLeftClickEventManager(self, widget, item):
|
def addToGrid(self, args, parent=None):
|
||||||
try:
|
# NOTE: Converting to pixbuf after retreval to keep Icon.py more universal.
|
||||||
model = widget.get_model()
|
# We can just remove get_pixbuf to get a gtk image.
|
||||||
fileName = model[item][1]
|
# 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
|
dir = self.currentPath
|
||||||
|
for path in pathlist :
|
||||||
|
tree_iter = model.get_iter(path)
|
||||||
|
fileName = model.get_value(tree_iter,0)
|
||||||
|
|
||||||
|
try:
|
||||||
file = dir + "/" + fileName
|
file = dir + "/" + fileName
|
||||||
|
|
||||||
if fileName == ".":
|
if fileName == ".":
|
||||||
@ -135,6 +155,9 @@ class Grid:
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
|
def returnParentDir(self):
|
||||||
|
return os.path.abspath(os.path.join(self.currentPath, os.pardir))
|
||||||
|
|
||||||
# Passthrough file control events
|
# Passthrough file control events
|
||||||
def createFile(arg):
|
def createFile(arg):
|
||||||
pass
|
pass
|
||||||
|
@ -57,12 +57,14 @@ class Icon:
|
|||||||
elif file.lower().endswith(imagesList):
|
elif file.lower().endswith(imagesList):
|
||||||
thumbnl = self.createIconImageBuffer(fullPathFile, self.viIconWxH)
|
thumbnl = self.createIconImageBuffer(fullPathFile, self.viIconWxH)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0])
|
thumbPth = self.getSystemThumbnail(fullPathFile, self.systemIconImageWxH[0])
|
||||||
thumbnl = self.createIconImageBuffer(thumbPth, self.systemIconImageWxH)
|
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.
|
return thumbnl
|
||||||
# We can just remove get_pixbuf to get a gtk image
|
|
||||||
return thumbnl.get_pixbuf()
|
|
||||||
|
|
||||||
def createIconImageBuffer(self, path, wxh):
|
def createIconImageBuffer(self, path, wxh):
|
||||||
pixbuf = None
|
pixbuf = None
|
||||||
@ -76,7 +78,7 @@ class Icon:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
return gtk.Image()
|
return gtk.Image(stock = gtk.STOCK_DIALOG_ERROR)
|
||||||
|
|
||||||
def getSystemThumbnail(self, filename,size):
|
def getSystemThumbnail(self, filename,size):
|
||||||
final_filename = ""
|
final_filename = ""
|
||||||
|
Loading…
Reference in New Issue
Block a user