Merge pull request #52 from nwg-piotr/menu

MenuStart plugin integration
This commit is contained in:
Piotr Miller
2021-05-05 02:01:22 +02:00
committed by GitHub
11 changed files with 3755 additions and 105 deletions

View File

@@ -2,4 +2,5 @@
python3 setup.py install --optimize=1
cp nwg-panel.svg /usr/share/pixmaps/
cp nwg-shell.svg /usr/share/pixmaps/
cp nwg-panel-config.desktop /usr/share/applications/

2645
nwg-shell.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -9,7 +9,7 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib
from nwg_panel.tools import get_config_dir, load_json, save_json, load_string, list_outputs, check_key, list_configs, \
local_dir, create_pixbuf, update_image, is_command, check_commands
local_dir, create_pixbuf, update_image, is_command, check_commands, cmd2string
from nwg_panel.__about__ import __version__
@@ -29,6 +29,7 @@ SKELETON_PANEL: dict = {
"layer": "bottom",
"position": "top",
"controls": "off",
"menu-start": "off",
"width": "auto",
"height": 0,
"margin-top": 0,
@@ -54,6 +55,25 @@ SKELETON_PANEL: dict = {
"custom-items": [{"name": "Panel settings", "icon": "nwg-panel", "cmd": "nwg-panel-config"}],
"menu": {"name": "unnamed", "icon": "", "items": []}
},
"menu-start-settings": {
"cmd-lock": "swaylock -f -c 000000",
"cmd-logout": "swaymsg exit",
"cmd-restart": "systemctl reboot",
"cmd-shutdown": "systemctl -i poweroff",
"autohide": True,
"file-manager": "thunar",
"height": 0,
"icon-size-large": 32,
"icon-size-small": 16,
"icon-size-button": 16,
"margin-bottom": 0,
"margin-left": 0,
"margin-right": 0,
"margin-top": 0,
"padding": 2,
"terminal": "alacritty",
"width": 0
},
"sway-taskbar": {
"workspace-menu": ["1", "2", "3", "4", "5", "6", "7", "8"],
"name-max-len": 20,
@@ -114,6 +134,7 @@ class PanelSelector(Gtk.Window):
self.to_delete = []
self.connect("key-release-event", handle_keyboard)
self.connect('destroy', Gtk.main_quit)
self.plugin_menu_start = is_command("nwg-menu")
self.outer_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
self.add(self.outer_box)
@@ -127,10 +148,12 @@ class PanelSelector(Gtk.Window):
ver = __version__
except:
ver = ""
label.set_text("nwg-panel {}".format(ver))
label.set_markup('nwg-panel {} <a href="https://github.com/nwg-piotr/nwg-panel">GitHub</a>'.format(ver))
ivbox.pack_start(label, True, False, 0)
label = Gtk.Label()
label.set_markup('see on <a href="https://github.com/nwg-piotr/nwg-panel">GitHub</a>')
status = cmd2string("nwg-menu -v") if self.plugin_menu_start else "not installed"
label.set_markup('MenuStart plugin: {} <a href="https://github.com/nwg-piotr/nwg-menu">GitHub</a>'.format(status))
ivbox.pack_start(label, True, False, 0)
self.scrolled_window = Gtk.ScrolledWindow()
@@ -321,7 +344,7 @@ class PanelSelector(Gtk.Window):
def on_edit_button(self, button, file, panel_idx):
global editor
editor = EditorWrapper(self, file, panel_idx)
editor = EditorWrapper(self, file, panel_idx, self.plugin_menu_start)
editor.edit_panel()
def move_up(self, btn, panels, panel):
@@ -345,7 +368,7 @@ class PanelSelector(Gtk.Window):
idx = config.index(panel)
save_json(config, file)
global editor
editor = EditorWrapper(self, file, idx)
editor = EditorWrapper(self, file, idx, self.plugin_menu_start)
editor.set_panel()
editor.edit_panel()
@@ -387,7 +410,7 @@ def update_icon(gtk_entry, icons):
class EditorWrapper(object):
def __init__(self, parent, file, panel_idx):
def __init__(self, parent, file, panel_idx, plugin_menu_start):
self.file = file
self.panel_idx = panel_idx
self.config = {}
@@ -424,6 +447,13 @@ class EditorWrapper(object):
btn = builder.get_object("btn-controls")
btn.connect("clicked", self.controls_menu)
btn = builder.get_object("btn-menu-start")
if plugin_menu_start:
btn.connect("clicked", self.edit_menu_start)
else:
btn.set_sensitive(False)
btn.set_tooltip_text("Plugin not found")
btn = builder.get_object("btn-clock")
btn.connect("clicked", self.edit_clock)
@@ -508,7 +538,8 @@ class EditorWrapper(object):
"output": "",
"layer": "bottom",
"position": "top",
"controls": False,
"controls": "off",
"menu-start": "off",
"width": "auto",
"height": 0,
"margin-top": 0,
@@ -563,6 +594,17 @@ class EditorWrapper(object):
else:
self.cb_controls.set_active_id("off")
self.cb_menu = builder.get_object("menu")
if not self.panel["menu-start"]:
self.cb_menu.set_active_id("off")
else:
if self.panel["menu-start"] == "right":
self.cb_menu.set_active_id("right")
elif self.panel["menu-start"] == "left":
self.cb_menu.set_active_id("left")
else:
self.cb_menu.set_active_id("off")
self.cb_layer = builder.get_object("layer")
self.cb_layer.set_active_id(self.panel["layer"])
@@ -667,6 +709,13 @@ class EditorWrapper(object):
else:
self.panel["controls"] = "off"
val = self.cb_menu.get_active_id()
if val:
if val in ["left", "right"]:
self.panel["menu-start"] = val
else:
self.panel["menu-start"] = "off"
val = self.cb_layer.get_active_id()
if val:
self.panel["layer"] = val
@@ -741,6 +790,8 @@ class EditorWrapper(object):
save_json(self.config, self.file)
elif self.edited == "controls":
self.update_controls()
elif self.edited == "menu-start":
self.update_menu_start()
elif self.edited == "custom-items":
save_json(self.config, self.file)
elif self.edited == "user-menu":
@@ -1123,6 +1174,165 @@ class EditorWrapper(object):
save_json(self.config, self.file)
def edit_menu_start(self, *args):
self.load_panel()
self.edited = "menu-start"
check_key(self.panel, "menu-start-settings", {})
settings = self.panel["menu-start-settings"]
defaults = {
"cmd-lock": "swaylock -f -c 000000",
"cmd-logout": "swaymsg exit",
"cmd-restart": "systemctl reboot",
"cmd-shutdown": "systemctl -i poweroff",
"autohide": True,
"file-manager": "thunar",
"height": 0,
"icon-size-large": 32,
"icon-size-small": 16,
"icon-size-button": 16,
"margin-bottom": 0,
"margin-left": 0,
"margin-right": 0,
"margin-top": 0,
"padding": 2,
"terminal": "alacritty",
"width": 0
}
for key in defaults:
check_key(settings, key, defaults[key])
builder = Gtk.Builder.new_from_file(os.path.join(dir_name, "glade/config_menu_start.glade"))
grid = builder.get_object("grid")
self.ms_window_width = builder.get_object("width")
self.ms_window_width.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=1921, step_increment=1, page_increment=10, page_size=1)
self.ms_window_width.configure(adj, 1, 0)
self.ms_window_width.set_value(settings["width"])
self.ms_window_height = builder.get_object("height")
self.ms_window_height.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=2161, step_increment=1, page_increment=10, page_size=1)
self.ms_window_height.configure(adj, 1, 0)
self.ms_window_height.set_value(settings["height"])
self.ms_icon_size_large = builder.get_object("icon-size-large")
self.ms_icon_size_large.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=16, upper=129, step_increment=1, page_increment=10, page_size=1)
self.ms_icon_size_large.configure(adj, 1, 0)
self.ms_icon_size_large.set_value(settings["icon-size-large"])
self.ms_icon_size_small = builder.get_object("icon-size-small")
self.ms_icon_size_small.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=16, upper=129, step_increment=1, page_increment=10, page_size=1)
self.ms_icon_size_small.configure(adj, 1, 0)
self.ms_icon_size_small.set_value(settings["icon-size-small"])
self.ms_icon_size_button = builder.get_object("icon-size-button")
self.ms_icon_size_button.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=8, upper=129, step_increment=1, page_increment=10, page_size=1)
self.ms_icon_size_button.configure(adj, 1, 0)
self.ms_icon_size_button.set_value(settings["icon-size-button"])
self.ms_padding = builder.get_object("padding")
self.ms_padding.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=100, step_increment=1, page_increment=10, page_size=1)
self.ms_padding.configure(adj, 1, 0)
self.ms_padding.set_value(settings["padding"])
self.ms_margin_bottom = builder.get_object("margin-bottom")
self.ms_margin_bottom.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=400, step_increment=1, page_increment=10, page_size=1)
self.ms_margin_bottom.configure(adj, 1, 0)
self.ms_margin_bottom.set_value(settings["margin-bottom"])
self.ms_margin_left = builder.get_object("margin-left")
self.ms_margin_left.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=400, step_increment=1, page_increment=10, page_size=1)
self.ms_margin_left.configure(adj, 1, 0)
self.ms_margin_left.set_value(settings["margin-left"])
self.ms_margin_top = builder.get_object("margin-top")
self.ms_margin_top.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=400, step_increment=1, page_increment=10, page_size=1)
self.ms_margin_top.configure(adj, 1, 0)
self.ms_margin_top.set_value(settings["margin-top"])
self.ms_margin_right = builder.get_object("margin-right")
self.ms_margin_right.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=400, step_increment=1, page_increment=10, page_size=1)
self.ms_margin_right.configure(adj, 1, 0)
self.ms_margin_right.set_value(settings["margin-right"])
self.ms_cmd_lock = builder.get_object("cmd-lock")
self.ms_cmd_lock.set_text(settings["cmd-lock"])
self.ms_cmd_logout = builder.get_object("cmd-logout")
self.ms_cmd_logout.set_text(settings["cmd-logout"])
self.ms_cmd_restart = builder.get_object("cmd-restart")
self.ms_cmd_restart.set_text(settings["cmd-restart"])
self.ms_cmd_shutdown = builder.get_object("cmd-shutdown")
self.ms_cmd_shutdown.set_text(settings["cmd-shutdown"])
self.ms_file_manager = builder.get_object("file-manager")
self.ms_file_manager.set_text(settings["file-manager"])
self.ms_terminal = builder.get_object("terminal")
self.ms_terminal.set_text(settings["terminal"])
self.ms_autohide = builder.get_object("autohide")
self.ms_autohide.set_active(settings["autohide"])
for item in self.scrolled_window.get_children():
item.destroy()
self.scrolled_window.add(grid)
def update_menu_start(self):
settings = self.panel["menu-start-settings"]
settings["width"] = int(self.ms_window_width.get_value())
settings["height"] = int(self.ms_window_height.get_value())
settings["icon-size-large"] = int(self.ms_icon_size_large.get_value())
settings["icon-size-small"] = int(self.ms_icon_size_small.get_value())
settings["icon-size-button"] = int(self.ms_icon_size_button.get_value())
settings["padding"] = int(self.ms_padding.get_value())
settings["margin-bottom"] = int(self.ms_margin_bottom.get_value())
settings["margin-left"] = int(self.ms_margin_left.get_value())
settings["margin-top"] = int(self.ms_margin_top.get_value())
settings["margin-right"] = int(self.ms_margin_right.get_value())
val = self.ms_cmd_lock.get_text()
if val:
settings["cmd-lock"] = val
val = self.ms_cmd_logout.get_text()
if val:
settings["cmd-logout"] = val
val = self.ms_cmd_restart.get_text()
if val:
settings["cmd-restart"] = val
val = self.ms_cmd_shutdown.get_text()
if val:
settings["cmd-shutdown"] = val
val = self.ms_file_manager.get_text()
if val:
settings["file-manager"] = val
val = self.ms_terminal.get_text()
if val:
settings["terminal"] = val
val = self.ms_autohide.get_active()
if val is not None:
settings["autohide"] = val
save_json(self.config, self.file)
def edit_scratchpad(self, *args):
self.load_panel()
self.edited = "scratchpad"

View File

@@ -86,6 +86,19 @@
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn-menu-start">
<property name="label" translatable="yes">Menu Start</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-clock">
<property name="label" translatable="yes">Clock</property>
@@ -96,7 +109,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
@@ -109,7 +122,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
<child>
@@ -122,7 +135,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">8</property>
</packing>
</child>
<child>
@@ -135,7 +148,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
<property name="position">9</property>
</packing>
</child>
<child>
@@ -148,7 +161,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
<property name="position">10</property>
</packing>
</child>
<child>
@@ -161,7 +174,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
<property name="position">11</property>
</packing>
</child>
<child>
@@ -174,7 +187,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">11</property>
<property name="position">12</property>
</packing>
</child>
</object>

View File

@@ -0,0 +1,474 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<!-- n-columns=3 n-rows=18 -->
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-spacing">10</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">start</property>
<property name="label" translatable="yes">Plugins::MenuStart</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Window width</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">start</property>
<property name="label" translatable="yes">Window height</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="margin-left">
<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="GtkSpinButton" 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">8</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="margin-right">
<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="GtkSpinButton" 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">6</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="padding">
<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="GtkSpinButton" id="icon-size-small">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="icon-size-large">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" 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">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" 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">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Lock screen command</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Logout command</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">start</property>
<property name="label" translatable="yes">Restart command</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">start</property>
<property name="label" translatable="yes">Shutdown command</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">start</property>
<property name="label" translatable="yes">File manager name</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">14</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Terminal emulator name</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="file-manager">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">30</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">14</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="terminal">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">30</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Right margin</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">start</property>
<property name="label" translatable="yes">Top margin</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">start</property>
<property name="label" translatable="yes">Left margin</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">start</property>
<property name="label" translatable="yes">Bottom margin</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">start</property>
<property name="label" translatable="yes">Vertical item padding</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">start</property>
<property name="label" translatable="yes">Small icon size</property>
</object>
<packing>
<property name="left-attach">0</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">start</property>
<property name="label" translatable="yes">Large icon size</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="cmd-shutdown">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">30</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">13</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="cmd-restart">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">30</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="cmd-logout">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">30</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="cmd-lock">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">30</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="autohide">
<property name="label" translatable="yes">Close window when left</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</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">start</property>
<property name="label" translatable="yes">Menu button icon size</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">17</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="icon-size-button">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">17</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Leave 0 for auto-detection</property>
<property name="halign">start</property>
<property name="stock">gtk-about</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Leave 0 for auto-detection</property>
<property name="halign">start</property>
<property name="stock">gtk-about</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">2</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>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<!-- n-columns=2 n-rows=14 -->
<!-- n-columns=2 n-rows=15 -->
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -108,14 +108,80 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spacing">
<object class="GtkComboBoxText" id="controls">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">4</property>
<property name="can-focus">False</property>
<items>
<item id="right" translatable="yes">on the rigth</item>
<item id="left" translatable="yes">on the left</item>
<item id="off" translatable="yes">off</item>
</items>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</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">start</property>
<property name="label" translatable="yes">Controls</property>
</object>
<packing>
<property name="left-attach">0</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">start</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="css-name">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">20</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">14</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Icon set</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">13</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>
@@ -125,6 +191,29 @@
<property name="halign">start</property>
<property name="label" translatable="yes">Spacing</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spacing">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="width-chars">4</property>
</object>
<packing>
<property name="left-attach">1</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">start</property>
<property name="label" translatable="yes">Vertical padding</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
@@ -138,7 +227,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
@@ -146,7 +235,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Vertical padding</property>
<property name="label" translatable="yes">Horizontal padding</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -161,7 +250,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -169,7 +258,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Horizontal padding</property>
<property name="label" translatable="yes">Bottom margin</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -184,7 +273,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -192,7 +281,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Bottom margin</property>
<property name="label" translatable="yes">Top margin</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -207,7 +296,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -215,7 +304,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Top margin</property>
<property name="label" translatable="yes">Height</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -231,7 +320,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -239,7 +328,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Height</property>
<property name="label" translatable="yes">Width</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -279,7 +368,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -287,7 +376,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Width</property>
<property name="label" translatable="yes">Menu Start</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -295,80 +384,18 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Controls</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="controls">
<object class="GtkComboBoxText" id="menu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<items>
<item id="right" translatable="yes">to the rigth</item>
<item id="left" translatable="yes">to the left</item>
<item id="left" translatable="yes">on the left</item>
<item id="right" translatable="yes">on the rigth</item>
<item id="off" translatable="yes">off</item>
</items>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</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">12</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Icon set</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">start</property>
<property name="label" translatable="yes">CSS name</property>
</object>
<packing>
<property name="left-attach">0</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>
<property name="width-chars">20</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">13</property>
<property name="top-attach">5</property>
</packing>
</child>
</object>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="0 0 16 16"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"
sodipodi:docname="nwg-shell.svg"
inkscape:export-filename="/home/sgs/Bilder/nwg-10-sgs.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<metadata
id="metadata1634">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1906"
inkscape:window-height="996"
id="namedview1632"
showgrid="false"
inkscape:zoom="26.375"
inkscape:cx="12.341232"
inkscape:cy="12"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:document-rotation="0" />
<defs
id="defs2">
<rect
x="280.6113"
y="505.7515"
width="82.542252"
height="34.655735"
id="rect1407" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-85.333325)">
<text
xml:space="preserve"
id="text1405"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect1407);fill:#000000;fill-opacity:1;stroke:none;" />
<path
style="fill:#444444;fill-opacity:1;stroke:none;stroke-width:0.182697;stroke-linecap:round;stroke-linejoin:bevel"
d="m 12.884496,94.45832 c -0.09575,2.555873 -1.20362,3.663688 -3.759496,3.759381 v 2.615619 h 3.9075 L 15.5,98.427225 V 94.45832 Z"
id="path863" />
<path
style="fill:#444444;fill-opacity:1;stroke:none;stroke-width:0.182697;stroke-linecap:round;stroke-linejoin:bevel"
d="M 6.875,88.44895 7.4339006,92.752249 3.1155109,92.208321 V 94.45832 H 0.5 v 3.968912 l 2.4675,2.406088 H 6.875 V 98.217818 C 4.3191304,98.12206 3.2113087,97.014193 3.1156218,94.45832 L 7.446264,93.857499 6.875,98.217701 h 2.25 L 8.5118163,93.857499 12.884496,94.45832 v -2.25 H 15.5 v -3.968908 l -2.4675,-2.40609 H 9.125 v 2.615504 c 2.555869,0.09574 3.663691,1.203618 3.759378,3.759494 L 8.4994531,92.752249 9.125,88.448949 Z"
id="path861"
sodipodi:nodetypes="ccccccccccccccccccccccccc" />
<path
style="fill:#444444;fill-opacity:1;stroke:none;stroke-width:0.182697;stroke-linecap:round;stroke-linejoin:bevel"
d="M 2.9675,85.833323 0.5,88.239413 v 3.968908 H 3.1155109 C 3.211257,89.652452 4.319124,88.544631 6.875,88.44895 v -2.615627 z"
id="rect1723" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="0 0 16 16"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"
sodipodi:docname="nwg-shell.svg"
inkscape:export-filename="/home/sgs/Bilder/nwg-10-sgs.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<metadata
id="metadata1634">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1906"
inkscape:window-height="996"
id="namedview1632"
showgrid="false"
inkscape:zoom="26.375"
inkscape:cx="12.341232"
inkscape:cy="12"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:document-rotation="0" />
<defs
id="defs2">
<rect
x="280.6113"
y="505.7515"
width="82.542252"
height="34.655735"
id="rect1407" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-85.333325)">
<text
xml:space="preserve"
id="text1405"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect1407);fill:#000000;fill-opacity:1;stroke:none;" />
<path
style="fill:#eeeeee;fill-opacity:1;stroke:none;stroke-width:0.182697;stroke-linecap:round;stroke-linejoin:bevel"
d="m 12.884496,94.45832 c -0.09575,2.555873 -1.20362,3.663688 -3.759496,3.759381 v 2.615619 h 3.9075 L 15.5,98.427225 V 94.45832 Z"
id="path863" />
<path
style="fill:#eeeeee;fill-opacity:1;stroke:none;stroke-width:0.182697;stroke-linecap:round;stroke-linejoin:bevel"
d="M 6.875,88.44895 7.4339006,92.752249 3.1155109,92.208321 V 94.45832 H 0.5 v 3.968912 l 2.4675,2.406088 H 6.875 V 98.217818 C 4.3191304,98.12206 3.2113087,97.014193 3.1156218,94.45832 L 7.446264,93.857499 6.875,98.217701 h 2.25 L 8.5118163,93.857499 12.884496,94.45832 v -2.25 H 15.5 v -3.968908 l -2.4675,-2.40609 H 9.125 v 2.615504 c 2.555869,0.09574 3.663691,1.203618 3.759378,3.759494 L 8.4994531,92.752249 9.125,88.448949 Z"
id="path861"
sodipodi:nodetypes="ccccccccccccccccccccccccc" />
<path
style="fill:#eeeeee;fill-opacity:1;stroke:none;stroke-width:0.182697;stroke-linecap:round;stroke-linejoin:bevel"
d="M 2.9675,85.833323 0.5,88.239413 v 3.968908 H 3.1155109 C 3.211257,89.652452 4.319124,88.544631 6.875,88.44895 v -2.615627 z"
id="rect1723" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -36,6 +36,8 @@ from nwg_panel.modules.playerctl import Playerctl
from nwg_panel.modules.cpu_avg import CpuAvg
from nwg_panel.modules.scratchpad import Scratchpad
from nwg_panel.modules.menu_start import MenuStart
dir_name = os.path.dirname(__file__)
from nwg_panel import common
@@ -73,13 +75,13 @@ def check_tree():
if len(common.i3.get_outputs()) != common.outputs_num:
print("Number of outputs changed")
restart()
for item in common.taskbars_list:
item.refresh(tree)
for item in common.scratchpads_list:
item.refresh(tree)
for item in common.workspaces_list:
item.refresh()
@@ -264,12 +266,12 @@ def main():
clone = panel.copy()
clone["output"] = key
clones.append(clone)
to_append = to_append + clones
for item in to_remove:
panels.remove(item)
panels = panels + to_append
for panel in panels:
@@ -321,6 +323,34 @@ def main():
controls_settings = panel["controls-settings"]
check_key(controls_settings, "show-values", False)
check_key(panel, "menu-start", "off")
if panel["menu-start"]:
check_key(panel, "menu-start-settings", {})
defaults = {
"cmd-lock": "swaylock -f -c 000000",
"cmd-logout": "swaymsg exit",
"cmd-restart": "systemctl reboot",
"cmd-shutdown": "systemctl -i poweroff",
"autohide": True,
"file-manager": "thunar",
"height": 0,
"icon-size-large": 32,
"icon-size-small": 16,
"icon-size-button": 16,
"margin-bottom": 0,
"margin-left": 0,
"margin-right": 0,
"margin-top": 0,
"padding": 2,
"terminal": "alacritty",
"width": 0
}
for key in defaults:
check_key(panel["menu-start-settings"], key, defaults[key])
if panel["menu-start"] != "off":
panel["menu-start-settings"]["horizontal-align"] = panel["menu-start"]
Gtk.Widget.set_size_request(window, w, h)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
@@ -360,6 +390,10 @@ def main():
common.controls_list.append(cc)
left_box.pack_start(cc, False, False, 0)
if panel["menu-start"] == "left":
ms = MenuStart(panel, icons_path=icons_path)
left_box.pack_start(ms, False, False, 0)
instantiate_content(panel, left_box, panel["modules-left"], icons_path=icons_path)
center_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=panel["spacing"])
@@ -375,6 +409,10 @@ def main():
check_key(panel, "modules-right", [])
instantiate_content(panel, right_box, panel["modules-right"], icons_path=icons_path)
if panel["menu-start"] == "right":
ms = MenuStart(panel["menu-start-settings"], icons_path=icons_path)
right_box.pack_end(ms, False, False, 0)
if panel["controls"] and panel["controls"] == "right":
monitor = None
try:
@@ -400,8 +438,8 @@ def main():
check_key(panel, "layer", "top")
o = panel["output"] if "output" in panel else "undefined"
print("Output: {}, position: {}, layer: {}, width: {}, height: {}".format(o, panel["position"],
panel["layer"], panel["width"],
panel["height"]))
panel["layer"], panel["width"],
panel["height"]))
if monitor:
GtkLayerShell.set_monitor(window, monitor)

View File

@@ -0,0 +1,72 @@
#!/usr/bin/env python3
from gi.repository import Gtk
import subprocess
from nwg_panel.tools import check_key, update_image
class MenuStart(Gtk.Button):
def __init__(self, panel, icons_path=""):
Gtk.Button.__init__(self)
self.set_always_show_image(True)
self.panel = panel
check_key(panel, "menu-start-settings", {})
self.settings = panel["menu-start-settings"]
self.set_property("name", "button-start")
check_key(self.settings, "icon-size-button", 16)
image = Gtk.Image()
update_image(image, "nwg-shell", self.settings["icon-size-button"], icons_path)
self.set_image(image)
self.connect("clicked", self.on_click)
self.show()
def on_click(self, button):
cmd = "nwg-menu"
if self.settings["cmd-lock"] != "swaylock -f -c 000000":
cmd += " -cmd-lock '{}'".format(self.settings["cmd-lock"])
if self.settings["cmd-logout"] != "swaymsg exit":
cmd += " -cmd-logout '{}'".format(self.settings["cmd-logout"])
if self.settings["cmd-restart"] != "systemctl reboot":
cmd += " -cmd-restart '{}'".format(self.settings["cmd-restart"])
if self.settings["cmd-shutdown"] != "systemctl -i poweroff":
cmd += " -cmd-shutdown '{}'".format(self.settings["cmd-shutdown"])
if self.settings["autohide"]:
cmd += " -d"
if self.settings["file-manager"] != "thunar":
cmd += " -fm {}".format(self.settings["file-manager"])
if self.panel["menu-start"] == "right":
cmd += " -ha {}".format(self.panel["menu-start"])
if self.settings["height"] > 0:
cmd += " -height {}".format(self.settings["height"])
if self.settings["icon-size-large"] != 32:
cmd += " -isl {}".format(self.settings["icon-size-large"])
if self.settings["icon-size-small"] != 16:
cmd += " -iss {}".format(self.settings["icon-size-small"])
if self.settings["margin-bottom"] > 0:
cmd += " -mb {}".format(self.settings["margin-bottom"])
if self.settings["margin-left"] > 0:
cmd += " -ml {}".format(self.settings["margin-left"])
if self.settings["margin-right"] > 0:
cmd += " -mr {}".format(self.settings["margin-right"])
if self.settings["margin-top"] > 0:
cmd += " -mt {}".format(self.settings["margin-top"])
if self.panel["output"]:
cmd += " -o {}".format(self.panel["output"])
if self.settings["padding"] != 2:
cmd += " -padding {}".format(self.settings["padding"])
if self.settings["terminal"] != "alacritty":
cmd += " -term {}".format(self.settings["terminal"])
if self.panel["position"] != "bottom":
cmd += " -va {}".format(self.panel["position"])
if self.settings["width"] > 0:
cmd += " -width {}".format(self.settings["width"])
print("Executing '{}'".format(cmd))
subprocess.Popen('exec {}'.format(cmd), shell=True)

View File

@@ -8,7 +8,7 @@ def read(f_name):
setup(
name='nwg-panel',
version='0.2.3',
version='0.3.1',
description='GTK3-based panel for sway window manager',
packages=find_packages(),
include_package_data=True,