Moved clock stuff to taskbar mixin

This commit is contained in:
Maxim Stewart 2020-05-08 22:43:25 -05:00
parent 3a04b2c8e8
commit 99ba4cd131
4 changed files with 25 additions and 28 deletions

View File

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

View File

@ -2,13 +2,13 @@
from datetime import datetime from datetime import datetime
# Gtk imports # Gtk imports
from gi.repository import GObject
# Application imports # Application imports
from mixins import CPUDrawMixin, TaskbarMixin from mixins import CPUDrawMixin, TaskbarMixin
class CrossClassSignals(CPUDrawMixin, TaskbarMixin): class Signals(CPUDrawMixin, TaskbarMixin):
def __init__(self, settings): def __init__(self, settings):
self.settings = settings self.settings = settings
self.builder = self.settings.returnBuilder() self.builder = self.settings.returnBuilder()
@ -18,10 +18,8 @@ class CrossClassSignals(CPUDrawMixin, TaskbarMixin):
self.brushSizeProp = self.builder.get_object("brushSizeProp") self.brushSizeProp = self.builder.get_object("brushSizeProp")
self.brushColorProp = self.builder.get_object("brushColorProp") self.brushColorProp = self.builder.get_object("brushColorProp")
# Menu bar setup # Menu bar setup - Note: Must be before setting clock
self.orientation = 1 # 0 = horizontal, 1 = vertical self.orientation = 1 # 0 = horizontal, 1 = vertical
# Must be before setting clock
self.setPagerWidget() self.setPagerWidget()
self.setTasklistWidget() self.setTasklistWidget()
@ -47,23 +45,3 @@ class CrossClassSignals(CPUDrawMixin, TaskbarMixin):
self.good = [0.53, 0.8, 0.15, 1.0] self.good = [0.53, 0.8, 0.15, 1.0]
self.warning = [1.0, 0.66, 0.0, 1.0] self.warning = [1.0, 0.66, 0.0, 1.0]
self.danger = [1.0, 0.0, 0.0, 1.0] self.danger = [1.0, 0.0, 0.0, 1.0]
# Displays Timer
def displayclock(self):
now = datetime.now()
hms = now.strftime("%I:%M %p")
mdy = now.strftime("%m/%d/%Y")
timeStr = hms + "\n" + mdy
self.timeLabel.set_label(timeStr)
return True
# Starting or clock
def startClock(self):
GObject.timeout_add(59000, self.displayclock)
def closePopup(self, widget, data=None):
widget.hide()

View File

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

View File

@ -12,6 +12,7 @@ from gi.repository import Wnck as wnck
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 GLib from gi.repository import GLib
from gi.repository import GObject
# Application imports # Application imports
@ -69,3 +70,21 @@ class TaskbarMixin:
self.builder.get_object('taskBarButtonsVer').add(tasklist) self.builder.get_object('taskBarButtonsVer').add(tasklist)
tasklist.show() tasklist.show()
# Displays Timer
def displayclock(self):
now = datetime.now()
hms = now.strftime("%I:%M %p")
mdy = now.strftime("%m/%d/%Y")
timeStr = hms + "\n" + mdy
self.timeLabel.set_label(timeStr)
return True
# Starting or clock
def startClock(self):
GObject.timeout_add(59000, self.displayclock)
def closePopup(self, widget, data=None):
widget.hide()