Reverted to Iconview and added guards against segfault
This commit is contained in:
parent
8773011925
commit
7a03a3dc6a
Binary file not shown.
@ -28,6 +28,10 @@ class Main:
|
||||
window.show_all()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main = Main()
|
||||
gtk.main()
|
||||
|
@ -28,16 +28,11 @@
|
||||
</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="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="iconRenameInput">
|
||||
<property name="width_request">300</property>
|
||||
@ -45,30 +40,6 @@
|
||||
<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>
|
||||
@ -82,14 +53,12 @@
|
||||
<property name="can_focus">False</property>
|
||||
<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>
|
||||
<signal name="clicked" handler="deleteFile" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -97,9 +66,6 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-cut</property>
|
||||
@ -112,15 +78,19 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<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>
|
||||
</object>
|
||||
@ -140,12 +110,6 @@
|
||||
</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>
|
||||
@ -191,7 +155,22 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry1">
|
||||
<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="setIconViewDir" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searDir">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||
@ -201,40 +180,9 @@
|
||||
<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>
|
||||
@ -246,7 +194,6 @@
|
||||
<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>
|
||||
@ -264,17 +211,10 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="Desktop">
|
||||
<object class="GtkIconView" id="Desktop">
|
||||
<property name="visible">True</property>
|
||||
<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>
|
||||
<property name="margin">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -20,6 +20,17 @@ iconview {
|
||||
|
||||
treeview,
|
||||
treeview.view {
|
||||
background: rgba(0, 0, 0, 0.64);
|
||||
background-color: rgba(0, 0, 0, 0.64);
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
cell {
|
||||
margin: 0em;
|
||||
padding: 0em;
|
||||
/* float: left; */
|
||||
}
|
||||
|
||||
cell:focus {
|
||||
outline-style: solid;
|
||||
outline-color: rgba(0, 232, 255, 0.64);
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
|
||||
# Gtk Imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk as gtk
|
||||
|
||||
# Python imports
|
||||
from .Grid import Grid
|
||||
@ -25,18 +28,9 @@ class Events:
|
||||
self.grid = None
|
||||
self.setIconViewDir(selectedDirDialog)
|
||||
|
||||
|
||||
def setIconViewDir(self, widget, data=None):
|
||||
newPath = widget.get_filename()
|
||||
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)
|
||||
|
||||
Grid(self.desktop, self.settings, newPath)
|
||||
|
||||
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 GLib
|
||||
from gi.repository import GObject as gobject
|
||||
|
||||
# Python imports
|
||||
import os, threading
|
||||
@ -18,6 +18,8 @@ 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()
|
||||
@ -29,42 +31,27 @@ class Grid:
|
||||
self.settings = settings
|
||||
self.filehandler = FileHandler()
|
||||
|
||||
self.store = gtk.TreeStore(str, GdkPixbuf.Pixbuf)
|
||||
self.store = gtk.ListStore(GdkPixbuf.Pixbuf, str)
|
||||
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)
|
||||
|
||||
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.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,))
|
||||
|
||||
self.setIconViewDir(newPath)
|
||||
|
||||
|
||||
@threaded
|
||||
def setIconViewDir(self, path):
|
||||
# self.treeViewCol.clear()
|
||||
self.store.clear()
|
||||
|
||||
self.currentPath = path
|
||||
paths = ['.', '..']
|
||||
dirPaths = ['.', '..']
|
||||
files = []
|
||||
|
||||
for f in listdir(path):
|
||||
@ -75,48 +62,41 @@ class Grid:
|
||||
if isfile(file):
|
||||
files.append(f)
|
||||
else:
|
||||
paths.append(f)
|
||||
dirPaths.append(f)
|
||||
|
||||
paths.sort()
|
||||
dirPaths.sort()
|
||||
files.sort()
|
||||
files = paths + files
|
||||
files = dirPaths + files
|
||||
self.generateDirectoryGrid(path, files)
|
||||
|
||||
@threaded
|
||||
def generateDirectoryGrid(self, path, files):
|
||||
def generateDirectoryGrid(self, dirPath, 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 = self.getImgBuffer(path, file)
|
||||
GLib.idle_add(self.addToGrid, (imgBuffer, file,))
|
||||
imgBuffer = Icon(self.settings).createIcon(dirPath, file)
|
||||
gobject.idle_add(self.addToGrid, (imgBuffer, file,))
|
||||
# tickCount += fractionTick
|
||||
loadProgress.set_fraction(tickCount)
|
||||
# loadProgress.set_fraction(tickCount)
|
||||
|
||||
loadProgress.set_text("Finished...")
|
||||
|
||||
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 addToGrid(self, args):
|
||||
self.store.append([args[0], args[1]])
|
||||
|
||||
def iconLeftClickEventManager(self, widget, item):
|
||||
try:
|
||||
model = widget.get_model()
|
||||
fileName = model[item][1]
|
||||
dir = self.currentPath
|
||||
file = dir + "/" + fileName
|
||||
|
||||
if fileName == ".":
|
||||
@ -155,9 +135,6 @@ 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
|
||||
|
@ -64,7 +64,9 @@ class Icon:
|
||||
print(e)
|
||||
thumbnl = gtk.Image(stock = gtk.STOCK_DIALOG_ERROR)
|
||||
|
||||
return thumbnl
|
||||
# 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()
|
||||
|
||||
def createIconImageBuffer(self, path, wxh):
|
||||
pixbuf = None
|
||||
@ -73,6 +75,7 @@ class Icon:
|
||||
filename = path,
|
||||
width = wxh[0],
|
||||
height = wxh[1],
|
||||
# preserve_aspect_ratio = False)
|
||||
preserve_aspect_ratio = True)
|
||||
return gtk.Image.new_from_pixbuf(pixbuf)
|
||||
except Exception as e:
|
||||
|
@ -44,6 +44,13 @@ class Settings:
|
||||
if visual != None and screen.is_composited():
|
||||
window.set_visual(visual)
|
||||
|
||||
# bind css file
|
||||
cssProvider = gtk.CssProvider()
|
||||
cssProvider.load_from_path('resources/stylesheet.css')
|
||||
screen = gdk.Screen.get_default()
|
||||
styleContext = gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
window.set_app_paintable(True)
|
||||
window.connect("draw", self.area_draw)
|
||||
monitors = self.getMonitorData(screen)
|
||||
|
@ -28,6 +28,10 @@ class Main:
|
||||
window.show_all()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main = Main()
|
||||
gtk.main()
|
||||
|
@ -28,16 +28,11 @@
|
||||
</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="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="iconRenameInput">
|
||||
<property name="width_request">300</property>
|
||||
@ -45,30 +40,6 @@
|
||||
<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>
|
||||
@ -82,14 +53,12 @@
|
||||
<property name="can_focus">False</property>
|
||||
<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>
|
||||
<signal name="clicked" handler="deleteFile" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -97,9 +66,6 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-cut</property>
|
||||
@ -112,15 +78,19 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<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>
|
||||
</object>
|
||||
@ -140,12 +110,6 @@
|
||||
</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>
|
||||
@ -191,7 +155,22 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry1">
|
||||
<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="setIconViewDir" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searDir">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||
@ -201,40 +180,9 @@
|
||||
<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>
|
||||
@ -246,7 +194,6 @@
|
||||
<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>
|
||||
@ -264,17 +211,10 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="Desktop">
|
||||
<object class="GtkIconView" id="Desktop">
|
||||
<property name="visible">True</property>
|
||||
<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>
|
||||
<property name="margin">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -20,6 +20,17 @@ iconview {
|
||||
|
||||
treeview,
|
||||
treeview.view {
|
||||
background: rgba(0, 0, 0, 0.64);
|
||||
background-color: rgba(0, 0, 0, 0.64);
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
cell {
|
||||
margin: 0em;
|
||||
padding: 0em;
|
||||
/* float: left; */
|
||||
}
|
||||
|
||||
cell:focus {
|
||||
outline-style: solid;
|
||||
outline-color: rgba(0, 232, 255, 0.64);
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
|
||||
# Gtk Imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk as gtk
|
||||
|
||||
# Python imports
|
||||
from .Grid import Grid
|
||||
@ -25,18 +28,9 @@ class Events:
|
||||
self.grid = None
|
||||
self.setIconViewDir(selectedDirDialog)
|
||||
|
||||
|
||||
def setIconViewDir(self, widget, data=None):
|
||||
newPath = widget.get_filename()
|
||||
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)
|
||||
|
||||
Grid(self.desktop, self.settings, newPath)
|
||||
|
||||
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 GLib
|
||||
from gi.repository import GObject as gobject
|
||||
|
||||
# Python imports
|
||||
import os, threading
|
||||
@ -18,6 +18,8 @@ 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()
|
||||
@ -29,42 +31,27 @@ class Grid:
|
||||
self.settings = settings
|
||||
self.filehandler = FileHandler()
|
||||
|
||||
self.store = gtk.TreeStore(str, GdkPixbuf.Pixbuf)
|
||||
self.store = gtk.ListStore(GdkPixbuf.Pixbuf, str)
|
||||
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)
|
||||
|
||||
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.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,))
|
||||
|
||||
self.setIconViewDir(newPath)
|
||||
|
||||
|
||||
@threaded
|
||||
def setIconViewDir(self, path):
|
||||
# self.treeViewCol.clear()
|
||||
self.store.clear()
|
||||
|
||||
self.currentPath = path
|
||||
paths = ['.', '..']
|
||||
dirPaths = ['.', '..']
|
||||
files = []
|
||||
|
||||
for f in listdir(path):
|
||||
@ -75,48 +62,41 @@ class Grid:
|
||||
if isfile(file):
|
||||
files.append(f)
|
||||
else:
|
||||
paths.append(f)
|
||||
dirPaths.append(f)
|
||||
|
||||
paths.sort()
|
||||
dirPaths.sort()
|
||||
files.sort()
|
||||
files = paths + files
|
||||
files = dirPaths + files
|
||||
self.generateDirectoryGrid(path, files)
|
||||
|
||||
@threaded
|
||||
def generateDirectoryGrid(self, path, files):
|
||||
def generateDirectoryGrid(self, dirPath, 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 = self.getImgBuffer(path, file)
|
||||
GLib.idle_add(self.addToGrid, (imgBuffer, file,))
|
||||
imgBuffer = Icon(self.settings).createIcon(dirPath, file)
|
||||
gobject.idle_add(self.addToGrid, (imgBuffer, file,))
|
||||
# tickCount += fractionTick
|
||||
loadProgress.set_fraction(tickCount)
|
||||
# loadProgress.set_fraction(tickCount)
|
||||
|
||||
loadProgress.set_text("Finished...")
|
||||
|
||||
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 addToGrid(self, args):
|
||||
self.store.append([args[0], args[1]])
|
||||
|
||||
def iconLeftClickEventManager(self, widget, item):
|
||||
try:
|
||||
model = widget.get_model()
|
||||
fileName = model[item][1]
|
||||
dir = self.currentPath
|
||||
file = dir + "/" + fileName
|
||||
|
||||
if fileName == ".":
|
||||
@ -155,9 +135,6 @@ 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
|
||||
|
@ -64,7 +64,9 @@ class Icon:
|
||||
print(e)
|
||||
thumbnl = gtk.Image(stock = gtk.STOCK_DIALOG_ERROR)
|
||||
|
||||
return thumbnl
|
||||
# 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()
|
||||
|
||||
def createIconImageBuffer(self, path, wxh):
|
||||
pixbuf = None
|
||||
@ -73,6 +75,7 @@ class Icon:
|
||||
filename = path,
|
||||
width = wxh[0],
|
||||
height = wxh[1],
|
||||
# preserve_aspect_ratio = False)
|
||||
preserve_aspect_ratio = True)
|
||||
return gtk.Image.new_from_pixbuf(pixbuf)
|
||||
except Exception as e:
|
||||
|
@ -44,6 +44,13 @@ class Settings:
|
||||
if visual != None and screen.is_composited():
|
||||
window.set_visual(visual)
|
||||
|
||||
# bind css file
|
||||
cssProvider = gtk.CssProvider()
|
||||
cssProvider.load_from_path('resources/stylesheet.css')
|
||||
screen = gdk.Screen.get_default()
|
||||
styleContext = gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
window.set_app_paintable(True)
|
||||
window.connect("draw", self.area_draw)
|
||||
monitors = self.getMonitorData(screen)
|
||||
|
Loading…
Reference in New Issue
Block a user