basic forms
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
/.idea
|
||||
/venv
|
||||
/nwgg-panel.egg-info/
|
||||
/nwg-panel.egg-info/
|
||||
/build/
|
||||
/dist/
|
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import gi
|
||||
@@ -13,6 +12,7 @@ from nwg_panel.tools import get_config_dir, load_json, list_outputs, check_key,
|
||||
config_dir = get_config_dir()
|
||||
configs = {}
|
||||
editor = None
|
||||
selector_window = None
|
||||
outputs = list_outputs()
|
||||
|
||||
|
||||
@@ -22,14 +22,10 @@ def handle_keyboard(window, event):
|
||||
|
||||
|
||||
class PanelSelector(Gtk.Window):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
super(PanelSelector, self).__init__()
|
||||
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
||||
self.set_transient_for(parent)
|
||||
self.set_modal(True)
|
||||
self.set_keep_above(True)
|
||||
self.connect("key-release-event", handle_keyboard)
|
||||
self.connect('destroy', self.release_parent, parent)
|
||||
self.connect('destroy', Gtk.main_quit)
|
||||
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
|
||||
@@ -71,9 +67,8 @@ class PanelSelector(Gtk.Window):
|
||||
|
||||
panel_idx = 0
|
||||
for panel in panels:
|
||||
check_key(panel, "name", "")
|
||||
check_key(panel, "output", "")
|
||||
check_key(panel, "position", "")
|
||||
for item in ["name", "output", "position"]:
|
||||
check_key(panel, item, "")
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_text('"{}"'.format(panel["name"]))
|
||||
@@ -100,93 +95,181 @@ class PanelSelector(Gtk.Window):
|
||||
|
||||
self.show_all()
|
||||
|
||||
def on_button_clicked(self, button, file, panel):
|
||||
editor.set_values(file, panel)
|
||||
self.close()
|
||||
|
||||
def release_parent(self, w, parent):
|
||||
parent.set_sensitive(True)
|
||||
def on_button_clicked(self, button, file, panel_idx):
|
||||
global editor
|
||||
editor = EditorWrapper(self)
|
||||
editor.set_panel(file, panel_idx)
|
||||
editor.edit_panel()
|
||||
|
||||
|
||||
class PanelEditor(object):
|
||||
def __init__(self):
|
||||
self.config = None
|
||||
class EditorWrapper(object):
|
||||
def __init__(self, parent):
|
||||
self.file = ""
|
||||
self.config = {}
|
||||
self.panel = {}
|
||||
builder = Gtk.Builder()
|
||||
builder.add_from_file("glade/panel_edit.glade")
|
||||
self.lb_panel_desc = builder.get_object("label-desc")
|
||||
self.eb_name = builder.get_object("name")
|
||||
builder.add_from_file("glade/config_main.glade")
|
||||
|
||||
self.cb_output = builder.get_object("output")
|
||||
for key in outputs:
|
||||
self.cb_output.append(key, key)
|
||||
|
||||
self.cb_position = builder.get_object("position")
|
||||
self.cb_layer = builder.get_object("layer")
|
||||
|
||||
self.eb_width = builder.get_object("width")
|
||||
self.eb_height = builder.get_object("height")
|
||||
self.eb_margin_top = builder.get_object("margin-top")
|
||||
self.eb_margin_bottom = builder.get_object("margin-bottom")
|
||||
self.eb_padding_horizontal = builder.get_object("padding-horizontal")
|
||||
self.eb_padding_vertical = builder.get_object("padding-vertical")
|
||||
self.eb_spacing = builder.get_object("spacing")
|
||||
self.eb_items_padding = builder.get_object("items-padding")
|
||||
|
||||
self.cb_icons = builder.get_object("icons")
|
||||
|
||||
self.eb_css_name = builder.get_object("css-name")
|
||||
|
||||
self.window = builder.get_object("panel_edit_win")
|
||||
self.window.connect('destroy', Gtk.main_quit)
|
||||
self.window = builder.get_object("main-window")
|
||||
self.window.set_transient_for(parent)
|
||||
self.window.set_keep_above(True)
|
||||
self.window.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
||||
self.window.connect('destroy', self.release_parent, parent)
|
||||
self.window.connect("key-release-event", handle_keyboard)
|
||||
self.window.set_sensitive(False)
|
||||
self.window.connect("show", self.lock_parent, parent)
|
||||
|
||||
self.scrolled_window = builder.get_object("scrolled-window")
|
||||
btn_cancel = builder.get_object("btn-cancel")
|
||||
btn_cancel.connect("clicked", self.quit)
|
||||
|
||||
self.set_panel()
|
||||
self.edit_panel()
|
||||
|
||||
self.window.show_all()
|
||||
|
||||
def set_values(self, file, panel_num):
|
||||
print(file, panel_num)
|
||||
self.config = load_json(file)
|
||||
self.panel = self.config[panel_num]
|
||||
check_key(self.panel, "name", "")
|
||||
check_key(self.panel, "output", "")
|
||||
check_key(self.panel, "position", "")
|
||||
|
||||
check_key(self.panel, "width", "auto")
|
||||
check_key(self.panel, "height", 0)
|
||||
check_key(self.panel, "margin-top", 0)
|
||||
check_key(self.panel, "margin-bottom", 0)
|
||||
check_key(self.panel, "padding-horizontal", 0)
|
||||
check_key(self.panel, "padding-vertical", 0)
|
||||
check_key(self.panel, "spacing", 0)
|
||||
check_key(self.panel, "items-padding", 0)
|
||||
check_key(self.panel, "icons", "")
|
||||
check_key(self.panel, "css-name", "")
|
||||
|
||||
self.lb_panel_desc.set_text("Panel #{} in {}".format(panel_num, file))
|
||||
self.eb_name.set_text(self.panel["name"])
|
||||
|
||||
self.cb_position.set_active_id(self.panel["position"])
|
||||
self.cb_layer.set_active_id(self.panel["layer"])
|
||||
|
||||
self.eb_width.set_text(str(self.panel["width"]))
|
||||
self.eb_height.set_text(str(self.panel["height"]))
|
||||
self.eb_margin_top.set_text(str(self.panel["margin-top"]))
|
||||
self.eb_margin_bottom.set_text(str(self.panel["margin-bottom"]))
|
||||
self.eb_padding_horizontal.set_text(str(self.panel["padding-horizontal"]))
|
||||
self.eb_padding_vertical.set_text(str(self.panel["padding-vertical"]))
|
||||
self.eb_spacing.set_text(str(self.panel["spacing"]))
|
||||
self.eb_items_padding.set_text(str(self.panel["items-padding"]))
|
||||
|
||||
if self.panel["icons"]:
|
||||
self.cb_icons.set_active_id(self.panel["icons"])
|
||||
def quit(self, btn):
|
||||
selector_window.show_all()
|
||||
self.window.close()
|
||||
|
||||
def set_panel(self, file="", panel_num=0):
|
||||
self.file = file
|
||||
if file:
|
||||
self.config = load_json(file)
|
||||
self.panel = self.config[panel_num]
|
||||
else:
|
||||
self.cb_icons.set_active_id("gtk")
|
||||
|
||||
self.panel = {}
|
||||
defaults = {
|
||||
"name": "",
|
||||
"output": "",
|
||||
"layer": "",
|
||||
"position": "",
|
||||
"width": "auto",
|
||||
"height": 0,
|
||||
"margin-top": 0,
|
||||
"margin-bottom": 0,
|
||||
"padding-horizontal": 0,
|
||||
"padding-vertical": 0,
|
||||
"spacing": 0,
|
||||
"items-padding": 0,
|
||||
"icons": "",
|
||||
"css-name": ""
|
||||
}
|
||||
for key in defaults:
|
||||
check_key(self.panel, key, defaults[key])
|
||||
|
||||
def edit_panel(self):
|
||||
builder = Gtk.Builder.new_from_file("glade/config_panel.glade")
|
||||
grid = builder.get_object("grid")
|
||||
|
||||
eb_name = builder.get_object("name")
|
||||
eb_name.set_text(self.panel["name"])
|
||||
|
||||
cb_output = builder.get_object("output")
|
||||
for key in outputs:
|
||||
cb_output.append(key, key)
|
||||
if self.panel["output"] and self.panel["output"] in outputs:
|
||||
self.cb_output.set_active_id(self.panel["output"])
|
||||
cb_output.set_active_id(self.panel["output"])
|
||||
|
||||
screen_width, screen_height = None, None
|
||||
if cb_output.get_active_id() and cb_output.get_active_id() in outputs:
|
||||
screen_width = outputs[cb_output.get_active_id()]["width"]
|
||||
screen_height = outputs[cb_output.get_active_id()]["height"]
|
||||
|
||||
cb_position = builder.get_object("position")
|
||||
cb_position.set_active_id(self.panel["position"])
|
||||
|
||||
cb_layer = builder.get_object("layer")
|
||||
cb_layer.set_active_id(self.panel["layer"])
|
||||
|
||||
sb_width = builder.get_object("width")
|
||||
sb_width.set_numeric(True)
|
||||
upper = float(screen_width + 1) if screen_width is not None else 8193
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=upper, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_width.configure(adj, 1, 0)
|
||||
|
||||
self.eb_css_name.set_text(str(self.panel["css-name"]))
|
||||
ckb_width_auto = builder.get_object("width-auto")
|
||||
if isinstance(self.panel["width"], int):
|
||||
sb_width.set_value(float(self.panel["width"]))
|
||||
else:
|
||||
ckb_width_auto.set_active(True)
|
||||
sb_width.set_sensitive(False)
|
||||
ckb_width_auto.connect("toggled", self.on_auto_toggle, sb_width, cb_output)
|
||||
|
||||
sb_height = builder.get_object("height")
|
||||
sb_height.set_numeric(True)
|
||||
upper = float(screen_height + 1) if screen_height is not None else 4602
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=upper, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_height.configure(adj, 1, 0)
|
||||
sb_height.set_value(float(self.panel["height"]))
|
||||
|
||||
sb_margin_top = builder.get_object("margin-top")
|
||||
sb_margin_top.set_numeric(True)
|
||||
upper = float(screen_height + 1) if screen_height is not None else 4602
|
||||
if sb_height.get_value():
|
||||
upper = upper - sb_height.get_value()
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=upper, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_margin_top.configure(adj, 1, 0)
|
||||
sb_margin_top.set_value(float(self.panel["margin-top"]))
|
||||
|
||||
sb_margin_bottom = builder.get_object("margin-bottom")
|
||||
sb_margin_bottom.set_numeric(True)
|
||||
upper = float(screen_height + 1) if screen_height is not None else 4602
|
||||
if sb_height.get_value():
|
||||
upper = upper - sb_height.get_value()
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=upper, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_margin_bottom.configure(adj, 1, 0)
|
||||
sb_margin_bottom.set_value(float(self.panel["margin-bottom"]))
|
||||
|
||||
sb_padding_horizontal = builder.get_object("padding-horizontal")
|
||||
sb_padding_horizontal.set_numeric(True)
|
||||
upper = float(screen_width / 3 + 1) if screen_width is not None else 640
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=upper, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_padding_horizontal.configure(adj, 1, 0)
|
||||
sb_padding_horizontal.set_value(float(self.panel["padding-horizontal"]))
|
||||
|
||||
sb_padding_vertical = builder.get_object("padding-vertical")
|
||||
sb_padding_vertical.set_numeric(True)
|
||||
upper = float(screen_height / 3 + 1) if screen_height is not None else 360
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=upper, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_padding_vertical.configure(adj, 1, 0)
|
||||
sb_padding_vertical.set_value(float(self.panel["padding-vertical"]))
|
||||
|
||||
sb_spacing = builder.get_object("spacing")
|
||||
sb_spacing.set_numeric(True)
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=201, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_spacing.configure(adj, 1, 0)
|
||||
sb_spacing.set_value(float(self.panel["spacing"]))
|
||||
|
||||
sb_items_padding = builder.get_object("items-padding")
|
||||
sb_items_padding.set_numeric(True)
|
||||
adj = Gtk.Adjustment(value=0, lower=0, upper=201, step_increment=1, page_increment=10, page_size=1)
|
||||
sb_items_padding.configure(adj, 1, 0)
|
||||
sb_items_padding.set_value(float(self.panel["items-padding"]))
|
||||
|
||||
cb_icons = builder.get_object("icons")
|
||||
cb_icons.set_active_id(self.panel["icons"])
|
||||
|
||||
eb_css_name = builder.get_object("css-name")
|
||||
eb_css_name.set_text(self.panel["css-name"])
|
||||
|
||||
for item in self.scrolled_window.get_children():
|
||||
item.destroy()
|
||||
self.scrolled_window.add(grid)
|
||||
|
||||
def on_auto_toggle(self, checkbutton, sb_width, cb_output):
|
||||
if not checkbutton.get_active():
|
||||
o_name = cb_output.get_active_id()
|
||||
sb_width.set_sensitive(True)
|
||||
if o_name in outputs:
|
||||
sb_width.set_value(float(outputs[o_name]["width"]))
|
||||
else:
|
||||
sb_width.set_sensitive(False)
|
||||
|
||||
def lock_parent(self, w, parent):
|
||||
parent.hide()
|
||||
|
||||
def release_parent(self, w, parent):
|
||||
parent.show()
|
||||
|
||||
|
||||
def main():
|
||||
@@ -195,9 +278,8 @@ def main():
|
||||
|
||||
GLib.set_prgname('nwg-panel-config')
|
||||
|
||||
global editor
|
||||
editor = PanelEditor()
|
||||
selector = PanelSelector(editor.window)
|
||||
global selector_window
|
||||
selector_window = PanelSelector()
|
||||
|
||||
Gtk.main()
|
||||
|
||||
|
234
nwg_panel/glade/config_main.glade
Normal file
234
nwg_panel/glade/config_main.glade
Normal file
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkWindow" id="main-window">
|
||||
<property name="can-focus">False</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="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">7</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-panel">
|
||||
<property name="label" translatable="yes">Panel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="has-focus">True</property>
|
||||
<property name="is-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-modules-left">
|
||||
<property name="label" translatable="yes">Modules left</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-modules-center">
|
||||
<property name="label" translatable="yes">Modules center</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-modules-right">
|
||||
<property name="label" translatable="yes">Modules right</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-contols">
|
||||
<property name="label" translatable="yes">Controls</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-clock">
|
||||
<property name="label" translatable="yes">Clock</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-playerctl">
|
||||
<property name="label" translatable="yes">Playerctl</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-sway-taskbar">
|
||||
<property name="label" translatable="yes">Sway Taskbar</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-sway-workspaces">
|
||||
<property name="label" translatable="yes">Sway Workspaces</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolled-window">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="propagate-natural-width">True</property>
|
||||
<property name="propagate-natural-height">True</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">20</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-apply</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn-cancel">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -1,432 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkWindow" id="panel_edit_win">
|
||||
<property name="can-focus">False</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>
|
||||
<!-- n-columns=3 n-rows=15 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="row-spacing">4</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<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">name:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</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">output:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</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">position:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</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">layer:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="output">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="position">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<items>
|
||||
<item id="top" translatable="yes">top</item>
|
||||
<item id="bottom" translatable="yes">bottom</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="layer">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<items>
|
||||
<item id="top" translatable="yes">top</item>
|
||||
<item id="bottom" translatable="yes">bottom</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">4</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">width:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">5</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">height:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">6</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">margin-top:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">7</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">margin-bottom:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">8</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">padding-horizontal:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">9</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">padding-vertical:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="width">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="height">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="margin-top">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="margin-bottom">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="padding-horizontal">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="padding-vertical">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="max-width-chars">24</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</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">spacing:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">11</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">items-padding:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">12</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">icons:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">13</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">css-name:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">14</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="spacing">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">11</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="items-padding">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">12</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="icons">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<items>
|
||||
<item id="light" translatable="yes">custom light</item>
|
||||
<item id="dark" translatable="yes">custom dark</item>
|
||||
<item id="gtk" translatable="yes">GTK</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">13</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="css-name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">14</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label-desc">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Select panel</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
<property name="width">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">11</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -5,6 +5,11 @@ import signal
|
||||
import gi
|
||||
import argparse
|
||||
|
||||
try:
|
||||
from .__about__ import __version__
|
||||
except ImportError:
|
||||
__version__ = "unknown"
|
||||
|
||||
gi.require_version('Gtk', '3.0')
|
||||
try:
|
||||
gi.require_version('GtkLayerShell', '0.1')
|
||||
@@ -39,13 +44,6 @@ if common.sway:
|
||||
from nwg_panel.modules.sway_taskbar import SwayTaskbar
|
||||
from nwg_panel.modules.sway_workspaces import SwayWorkspaces
|
||||
|
||||
try:
|
||||
from pyalsa import alsamixer
|
||||
|
||||
common.dependencies["pyalsa"] = True
|
||||
except:
|
||||
print("pylsa module not found, will try amixer")
|
||||
|
||||
restart_cmd = ""
|
||||
|
||||
|
||||
@@ -173,10 +171,23 @@ def main():
|
||||
action="store_true",
|
||||
help="restore default config files")
|
||||
|
||||
parser.add_argument("-v",
|
||||
"--version",
|
||||
action="version",
|
||||
version="%(prog)s {}".format(__version__),
|
||||
help="display version information")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
from pyalsa import alsamixer
|
||||
common.dependencies["pyalsa"] = True
|
||||
except:
|
||||
print("pylsa module not found, will try amixer")
|
||||
|
||||
global restart_cmd
|
||||
restart_cmd = "nwg-panel -c {} -s {}".format(args.config, args.style)
|
||||
|
||||
|
||||
# Try and kill already running instance if any
|
||||
pid_file = os.path.join(temp_dir(), "nwg-panel.pid")
|
||||
if os.path.isfile(pid_file):
|
||||
@@ -188,6 +199,10 @@ def main():
|
||||
pass
|
||||
save_string(str(os.getpid()), pid_file)
|
||||
|
||||
cmd_file = os.path.join(local_dir(), "args")
|
||||
cmd = "-c {} -s {}".format(args.config, args.style)
|
||||
save_string(cmd, cmd_file)
|
||||
|
||||
common.app_dirs = get_app_dirs()
|
||||
|
||||
common.dependencies["upower"] = is_command("upower")
|
||||
|
@@ -79,6 +79,15 @@ def get_icon(app_name):
|
||||
return line.split("=")[1]
|
||||
|
||||
|
||||
def local_dir():
|
||||
local_dir = os.path.join(os.path.join(os.getenv("HOME"), ".local/share/nwg-panel"))
|
||||
if not os.path.isdir(local_dir):
|
||||
print("Creating '{}'".format(local_dir))
|
||||
os.mkdir(local_dir)
|
||||
|
||||
return local_dir
|
||||
|
||||
|
||||
def get_config_dir():
|
||||
"""
|
||||
Determine config dir path, create if not found, then create sub-dirs
|
||||
@@ -258,7 +267,7 @@ def get_volume():
|
||||
switch = element.get_switch()
|
||||
del mixer
|
||||
else:
|
||||
result = cmd2string(nwg_panel.common.commands["set_volume_alt"])
|
||||
result = cmd2string(nwg_panel.common.commands["get_volume_alt"])
|
||||
if result:
|
||||
lines = result.splitlines()
|
||||
for line in lines:
|
||||
|
Reference in New Issue
Block a user