Moved CPU drawing to mixin
This commit is contained in:
parent
88d836ac06
commit
3a04b2c8e8
@ -15,7 +15,7 @@ from gi.repository import GLib
|
||||
|
||||
# Application imports
|
||||
from utils import Settings
|
||||
from signal_classes import CrossClassSignals, GridSignals, TaskbarSignals, DrawSignals
|
||||
from signal_classes import CrossClassSignals, GridSignals
|
||||
|
||||
|
||||
class Main:
|
||||
@ -57,9 +57,7 @@ class Main:
|
||||
# Gets the methods from the classes and sets to handler.
|
||||
# Then, builder connects to any signals it needs.
|
||||
classes = [CrossClassSignals(settings),
|
||||
GridSignals(settings),
|
||||
TaskbarSignals(settings),
|
||||
DrawSignals(settings)]
|
||||
GridSignals(settings)]
|
||||
|
||||
handlers = {}
|
||||
for c in classes:
|
||||
|
@ -5,16 +5,51 @@ from datetime import datetime
|
||||
from gi.repository import GObject
|
||||
|
||||
# Application imports
|
||||
from mixins import CPUDrawMixin, TaskbarMixin
|
||||
|
||||
|
||||
class CrossClassSignals:
|
||||
class CrossClassSignals(CPUDrawMixin, TaskbarMixin):
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
self.builder = self.settings.returnBuilder()
|
||||
self.timeLabel = self.builder.get_object("timeLabel")
|
||||
self.settings = settings
|
||||
self.builder = self.settings.returnBuilder()
|
||||
|
||||
self.timeLabel = self.builder.get_object("timeLabel")
|
||||
self.drawArea = self.builder.get_object("drawArea")
|
||||
self.brushSizeProp = self.builder.get_object("brushSizeProp")
|
||||
self.brushColorProp = self.builder.get_object("brushColorProp")
|
||||
|
||||
# Menu bar setup
|
||||
self.orientation = 1 # 0 = horizontal, 1 = vertical
|
||||
|
||||
# Must be before setting clock
|
||||
self.setPagerWidget()
|
||||
self.setTasklistWidget()
|
||||
|
||||
# Must be after pager and task list inits
|
||||
self.displayclock()
|
||||
self.startClock()
|
||||
|
||||
# CPUDrawMixin Parts
|
||||
self.cpu_percents = []
|
||||
self.doDrawBackground = False
|
||||
self.isDrawing = False
|
||||
self.surface = None
|
||||
self.aw = None # Draw area width
|
||||
self.ah = None # Draw area height
|
||||
self.xStep = None # For x-axis 60 sec steps
|
||||
self.yStep = None # For y-axis %s
|
||||
|
||||
rgba = self.brushColorProp.get_rgba()
|
||||
self.brushColorVal = [rgba.red, rgba.green, rgba.blue, rgba.alpha]
|
||||
self.brushSizeVal = self.brushSizeProp.get_value()
|
||||
self.updateSpeed = 100 # 1 sec = 1000ms
|
||||
|
||||
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]
|
||||
|
||||
|
||||
|
||||
|
||||
# Displays Timer
|
||||
def displayclock(self):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from signal_classes.CrossClassSignals import CrossClassSignals
|
||||
from signal_classes.DrawSignals import DrawSignals
|
||||
from mixins import CPUDrawMixin
|
||||
from mixins import TaskbarMixin
|
||||
from signal_classes.GridSignals import GridSignals
|
||||
from signal_classes.TaskbarSignals import TaskbarSignals
|
||||
from signal_classes.CrossClassSignals import CrossClassSignals
|
||||
|
@ -14,49 +14,14 @@ from gi.repository import GLib
|
||||
|
||||
|
||||
|
||||
class DrawSignals:
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
self.builder = self.settings.returnBuilder()
|
||||
|
||||
self.drawArea = self.builder.get_object("drawArea")
|
||||
self.brushSizeProp = self.builder.get_object("brushSizeProp")
|
||||
self.brushColorProp = self.builder.get_object("brushColorProp")
|
||||
self.messageWidget = self.builder.get_object("messageWidget")
|
||||
self.messageLabel = self.builder.get_object("messageLabel")
|
||||
|
||||
self.cpu_percents = []
|
||||
self.doDrawBackground = False
|
||||
self.isDrawing = False
|
||||
self.surface = None
|
||||
self.aw = None # Draw area width
|
||||
self.ah = None # Draw area height
|
||||
self.xStep = None # For x-axis 60 sec steps
|
||||
self.yStep = None # For y-axis %s
|
||||
|
||||
rgba = self.brushColorProp.get_rgba()
|
||||
self.brushColorVal = [rgba.red, rgba.green, rgba.blue, rgba.alpha]
|
||||
self.brushSizeVal = self.brushSizeProp.get_value()
|
||||
self.updateSpeed = 100 # 1 sec = 1000ms
|
||||
|
||||
self.success = "#88cc27"
|
||||
self.warning = "#ffa800"
|
||||
self.error = "#ff0000"
|
||||
|
||||
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]
|
||||
|
||||
# Note: y-axis on draw area goes from top to bottom when increasing.
|
||||
# Need to do the math such that you subtract from max height to start from bottom to go up
|
||||
# self.linePoints.append([1 * xStep, ah - (23 * yStep)]) # 23%
|
||||
# self.linePoints.append([2 * xStep, ah - (60 * yStep)]) # 60%
|
||||
# self.drawPointLine()
|
||||
# del self.linePoints[0:1]
|
||||
# self.linePoints.append([3 * xStep, ah - (44 * yStep)]) # 44%
|
||||
|
||||
|
||||
|
||||
class CPUDrawMixin:
|
||||
# Note: y-axis on draw area goes from top to bottom when increasing.
|
||||
# Need to do the math such that you subtract from max height to start from bottom to go up
|
||||
# self.linePoints.append([1 * xStep, ah - (23 * yStep)]) # 23%
|
||||
# self.linePoints.append([2 * xStep, ah - (60 * yStep)]) # 60%
|
||||
# self.drawPointLine()
|
||||
# del self.linePoints[0:1]
|
||||
# self.linePoints.append([3 * xStep, ah - (44 * yStep)]) # 44%
|
||||
def updateCPUPoints(self):
|
||||
# Clears screen when enough points exist and unshifts the
|
||||
# first point to keep fixed range
|
@ -23,15 +23,7 @@ class MouseButton:
|
||||
RIGHT_BUTTON = 3
|
||||
|
||||
|
||||
class TaskbarSignals:
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
self.builder = self.settings.returnBuilder()
|
||||
self.orientation = 1 # 0 = horizontal, 1 = vertical
|
||||
|
||||
self.setPagerWidget()
|
||||
self.setTasklistWidget()
|
||||
|
||||
class TaskbarMixin:
|
||||
def toggleCalPopover(self, widget, eve):
|
||||
calendarPopup = self.builder.get_object('calendarPopup')
|
||||
if (calendarPopup.get_visible() == False):
|
2
src/Pytop/signal_classes/mixins/__init__.py
Normal file
2
src/Pytop/signal_classes/mixins/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .TaskbarMixin import TaskbarMixin
|
||||
from .CPUDrawMixin import CPUDrawMixin
|
Loading…
Reference in New Issue
Block a user