Moved grid class to mixin

This commit is contained in:
Maxim Stewart 2020-05-08 22:57:22 -05:00
parent 99ba4cd131
commit 06de146b52
5 changed files with 28 additions and 30 deletions

View File

@ -15,7 +15,7 @@ from gi.repository import GLib
# Application imports
from utils import Settings
from signal_classes import Signals, GridSignals
from signal_classes import Signals
class Main:
@ -56,8 +56,7 @@ class Main:
def connectBuilder(self, settings, builder):
# Gets the methods from the classes and sets to handler.
# Then, builder connects to any signals it needs.
classes = [Signals(settings),
GridSignals(settings)]
classes = [Signals(settings)]
handlers = {}
for c in classes:

View File

@ -5,10 +5,11 @@ from datetime import datetime
# Application imports
from mixins import CPUDrawMixin, TaskbarMixin
from mixins import CPUDrawMixin, TaskbarMixin, GridMixin
from utils import FileHandler
class Signals(CPUDrawMixin, TaskbarMixin):
class Signals(CPUDrawMixin, TaskbarMixin, GridMixin):
def __init__(self, settings):
self.settings = settings
self.builder = self.settings.returnBuilder()
@ -45,3 +46,23 @@ class Signals(CPUDrawMixin, TaskbarMixin):
self.good = [0.53, 0.8, 0.15, 1.0]
self.warning = [1.0, 0.66, 0.0, 1.0]
self.danger = [1.0, 0.0, 0.0, 1.0]
# GridMixin Parts
self.filehandler = FileHandler(settings)
self.builder = self.settings.returnBuilder()
self.gridObj = self.builder.get_object("Desktop")
selectDirDialog = self.builder.get_object("selectDirDialog")
filefilter = self.builder.get_object("Folders")
self.currentPath = self.settings.returnSettings()[0]
self.copyCutArry = []
self.selectedFiles = []
self.gridClss = None
self.pasteType = 1 # copy == 1 and cut == 2
# Add filter to allow only folders to be selected
selectDirDialog.add_filter(filefilter)
selectDirDialog.set_filename(self.currentPath)
self.setNewDirectory(selectDirDialog)

View File

@ -1,4 +1,4 @@
from mixins import CPUDrawMixin
from mixins import TaskbarMixin
from signal_classes.GridSignals import GridSignals
from mixins import GridMixin
from signal_classes.Signals import Signals

View File

@ -4,32 +4,9 @@
# Application imports
from widgets import Grid
from utils import Dragging
from utils import FileHandler
class GridSignals:
def __init__(self, settings):
self.settings = settings
self.filehandler = FileHandler(settings)
self.builder = self.settings.returnBuilder()
self.gridObj = self.builder.get_object("Desktop")
selectDirDialog = self.builder.get_object("selectDirDialog")
filefilter = self.builder.get_object("Folders")
self.currentPath = self.settings.returnSettings()[0]
self.copyCutArry = []
self.selectedFiles = []
self.gridClss = None
self.pasteType = 1 # copy == 1 and cut == 2
# Add filter to allow only folders to be selected
selectDirDialog.add_filter(filefilter)
selectDirDialog.set_filename(self.currentPath)
self.setNewDirectory(selectDirDialog)
class GridMixin:
def setNewDirectory(self, widget, data=None):
newPath = widget.get_filename()
self.gridClss = Grid(self.gridObj, self.settings)

View File

@ -1,2 +1,3 @@
from .TaskbarMixin import TaskbarMixin
from .CPUDrawMixin import CPUDrawMixin
from .GridMixin import GridMixin