add RT signal handler #164
This commit is contained in:
@@ -13,6 +13,7 @@ taskbars_list = []
|
||||
scratchpads_list = []
|
||||
workspaces_list = []
|
||||
controls_list = []
|
||||
executors_list = []
|
||||
tray_list = []
|
||||
config_dir = ""
|
||||
dwl_data_file = None
|
||||
|
@@ -2232,7 +2232,9 @@ class EditorWrapper(object):
|
||||
"icon-placement": "left",
|
||||
"icon-size": 16,
|
||||
"interval": 1,
|
||||
"angle": 0.0
|
||||
"angle": 0.0,
|
||||
"sigrt": signal.SIGRTMIN+1,
|
||||
"use-sigrt": False
|
||||
}
|
||||
for key in defaults:
|
||||
check_key(settings, key, defaults[key])
|
||||
@@ -2289,6 +2291,15 @@ class EditorWrapper(object):
|
||||
self.executor_angle = builder.get_object("angle")
|
||||
self.executor_angle.set_active_id(str(settings["angle"]))
|
||||
|
||||
self.executor_sigrt = builder.get_object("sigrt")
|
||||
self.executor_sigrt.set_numeric(True)
|
||||
adj = Gtk.Adjustment(value=0, lower=signal.SIGRTMIN+1, upper=signal.SIGRTMAX+1, step_increment=1, page_increment=1, page_size=1)
|
||||
self.executor_sigrt.configure(adj, 1, 0)
|
||||
self.executor_sigrt.set_value(settings["sigrt"])
|
||||
|
||||
self.executor_use_sigrt = builder.get_object("use-sigrt")
|
||||
self.executor_use_sigrt.set_active(settings["use-sigrt"])
|
||||
|
||||
self.executor_remove = builder.get_object("remove")
|
||||
|
||||
self.executor_save_to_db_btn = builder.get_object("save-to-database")
|
||||
@@ -2342,6 +2353,9 @@ class EditorWrapper(object):
|
||||
except:
|
||||
settings["angle"] = 0.0
|
||||
|
||||
settings["sigrt"] = int(self.executor_sigrt.get_value())
|
||||
settings["use-sigrt"] = self.executor_use_sigrt.get_active()
|
||||
|
||||
self.panel[config_key] = settings
|
||||
else:
|
||||
# delete from panel
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkFrame" id="frame">
|
||||
@@ -8,7 +8,7 @@
|
||||
<property name="label-xalign">0.5</property>
|
||||
<property name="shadow-type">out</property>
|
||||
<child>
|
||||
<!-- n-columns=3 n-rows=16 -->
|
||||
<!-- n-columns=3 n-rows=17 -->
|
||||
<object class="GtkGrid" id="grid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
@@ -202,6 +202,7 @@
|
||||
an icon name / path and a label
|
||||
in 1 or 2 lines of text. See Wiki
|
||||
for details.</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="icon-name">help-about</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -238,6 +239,7 @@ for details.</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="tooltip-text" translatable="yes">Attention! Renaming an existing
|
||||
executor will create a new one.</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="icon-name">dialog-warning</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -361,18 +363,6 @@ executor will create a new one.</property>
|
||||
<property name="top-attach">11</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="save-to-database">
|
||||
<property name="label" translatable="yes">Save to database</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">15</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="angle">
|
||||
<property name="visible">True</property>
|
||||
@@ -388,19 +378,6 @@ executor will create a new one.</property>
|
||||
<property name="top-attach">14</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="remove">
|
||||
<property name="label" translatable="yes">Remove executor</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">15</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
@@ -414,7 +391,78 @@ executor will create a new one.</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkButton" id="save-to-database">
|
||||
<property name="label" translatable="yes">Save to database</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">16</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="remove">
|
||||
<property name="label" translatable="yes">Remove executor</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">16</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">Refresh on signal :</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">15</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="sigrt">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="secondary-icon-tooltip-text" translatable="yes">Signal number in range SIRTMIN+1 - SIGRTMAX</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">15</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="use-sigrt">
|
||||
<property name="label" translatable="yes">use signal</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">2</property>
|
||||
<property name="top-attach">15</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="tooltip-text" translatable="yes">Executor refresh interval in seconds. Set 0 for no auto-refresh.</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="icon-name">help-about</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">2</property>
|
||||
<property name="top-attach">13</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
|
@@ -97,6 +97,9 @@ def signal_handler(sig, frame):
|
||||
|
||||
def rt_sig_handler(sig, frame):
|
||||
print("{} RT signal received".format(sig))
|
||||
for executor in common.executors_list:
|
||||
if executor.use_sigrt and executor.sigrt == sig:
|
||||
print("Refreshing {} on signal {}".format(executor.name, sig))
|
||||
|
||||
|
||||
def restart():
|
||||
@@ -203,8 +206,9 @@ def instantiate_content(panel, container, content_list, icons_path=""):
|
||||
|
||||
if "executor-" in item:
|
||||
if item in panel:
|
||||
executor = Executor(panel[item], icons_path)
|
||||
executor = Executor(panel[item], icons_path, item)
|
||||
container.pack_start(executor, False, False, panel["items-padding"])
|
||||
common.executors_list.append(executor)
|
||||
else:
|
||||
print("'{}' not defined in this panel instance".format(item))
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
import subprocess
|
||||
import threading
|
||||
import signal
|
||||
|
||||
import gi
|
||||
from gi.repository import GLib
|
||||
@@ -15,8 +16,10 @@ from gi.repository import Gtk, Gdk, GdkPixbuf
|
||||
|
||||
|
||||
class Executor(Gtk.EventBox):
|
||||
def __init__(self, settings, icons_path):
|
||||
def __init__(self, settings, icons_path, executor_name):
|
||||
self.name = executor_name
|
||||
self.settings = settings
|
||||
print("executor name:", self.name)
|
||||
self.icons_path = icons_path
|
||||
Gtk.EventBox.__init__(self)
|
||||
self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
|
||||
@@ -38,9 +41,15 @@ class Executor(Gtk.EventBox):
|
||||
check_key(settings, "on-scroll-up", "")
|
||||
check_key(settings, "on-scroll-down", "")
|
||||
check_key(settings, "angle", 0.0)
|
||||
check_key(settings, "sigrt", signal.SIGRTMIN + 1)
|
||||
check_key(settings, "use-sigrt", False)
|
||||
|
||||
self.label.set_angle(settings["angle"])
|
||||
|
||||
# refresh signal in range SIGRTMIN+1 - SIGRTMAX
|
||||
self.sigrt = settings["sigrt"]
|
||||
self.use_sigrt = settings["use-sigrt"]
|
||||
|
||||
if settings["angle"] != 0.0:
|
||||
self.box.set_orientation(Gtk.Orientation.VERTICAL)
|
||||
|
||||
|
Reference in New Issue
Block a user