basic MenuStart integration
This commit is contained in:
@@ -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,29 @@ SKELETON_PANEL: dict = {
|
||||
"custom-items": [{"name": "Panel settings", "icon": "nwg-panel", "cmd": "nwg-panel-config"}],
|
||||
"menu": {"name": "unnamed", "icon": "", "items": []}
|
||||
},
|
||||
"menu-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",
|
||||
"horizontal-align": "left",
|
||||
"height": 0,
|
||||
"icon-size-large": 32,
|
||||
"icon-size-small": 16,
|
||||
"lang": "",
|
||||
"margin-bottom": 0,
|
||||
"margin-left": 0,
|
||||
"margin-right": 0,
|
||||
"margin-top": 0,
|
||||
"output": "",
|
||||
"padding": 2,
|
||||
"styling": "",
|
||||
"terminal": "alacritty",
|
||||
"vertical-align": "",
|
||||
"width": 0
|
||||
},
|
||||
"sway-taskbar": {
|
||||
"workspace-menu": ["1", "2", "3", "4", "5", "6", "7", "8"],
|
||||
"name-max-len": 20,
|
||||
@@ -508,7 +532,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 +588,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 +703,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
|
||||
|
@@ -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>
|
||||
|
@@ -323,6 +323,38 @@ 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",
|
||||
"horizontal-align": "left",
|
||||
"height": 0,
|
||||
"icon-size-large": 32,
|
||||
"icon-size-small": 16,
|
||||
"lang": "",
|
||||
"margin-bottom": 0,
|
||||
"margin-left": 0,
|
||||
"margin-right": 0,
|
||||
"margin-top": 0,
|
||||
"output": panel["output"],
|
||||
"padding": 2,
|
||||
"styling": "",
|
||||
"terminal": "alacritty",
|
||||
"vertical-align": panel["position"],
|
||||
"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)
|
||||
@@ -333,8 +365,6 @@ def main():
|
||||
check_key(panel, "modules-center", [])
|
||||
check_key(panel, "modules-right", [])
|
||||
|
||||
check_key(panel, "menu-start", False)
|
||||
|
||||
# This is to allow the "auto" value. Actually all non-numeric values will be removed.
|
||||
if "homogeneous" in panel and not isinstance(panel["homogeneous"], bool):
|
||||
panel.pop("homogeneous")
|
||||
@@ -364,16 +394,8 @@ def main():
|
||||
common.controls_list.append(cc)
|
||||
left_box.pack_start(cc, False, False, 0)
|
||||
|
||||
if panel["menu-start"]:
|
||||
settings = {
|
||||
"output": panel["output"],
|
||||
"position": panel["position"],
|
||||
"alignment": "left",
|
||||
"margin-left": 0,
|
||||
"margin-bottom": 0,
|
||||
"autohide": True
|
||||
}
|
||||
ms = MenuStart(settings, icons_path=icons_path)
|
||||
if panel["menu-start"] == "left":
|
||||
ms = MenuStart(panel["menu-start-settings"], icons_path=icons_path)
|
||||
left_box.pack_start(ms, False, False, 0)
|
||||
|
||||
instantiate_content(panel, left_box, panel["modules-left"], icons_path=icons_path)
|
||||
@@ -391,6 +413,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:
|
||||
|
@@ -23,38 +23,53 @@ class MenuStart(Gtk.Button):
|
||||
|
||||
self.connect("clicked", self.on_click)
|
||||
|
||||
check_key(settings, "css-name", "")
|
||||
if settings["css-name"]:
|
||||
self.set_property("name", settings["css-name"])
|
||||
|
||||
self.show()
|
||||
|
||||
def on_click(self, button):
|
||||
cmd = "nwg-panel-plugin-menu"
|
||||
"""settings = {
|
||||
"output": panel["output"],
|
||||
"position": panel["position"],
|
||||
"alignment": "left",
|
||||
"margin-left": 6,
|
||||
"margin-bottom": 6
|
||||
}"""
|
||||
if self.settings["output"]:
|
||||
cmd += " -o {}".format(self.settings["output"])
|
||||
|
||||
if self.settings["position"]:
|
||||
cmd += " -va {}".format(self.settings["position"])
|
||||
|
||||
if self.settings["alignment"]:
|
||||
cmd += " -ha {}".format(self.settings["alignment"])
|
||||
|
||||
if self.settings["margin-left"]:
|
||||
cmd += " -ml {}".format(self.settings["margin-left"])
|
||||
|
||||
if self.settings["margin-bottom"]:
|
||||
cmd += " -mb {}".format(self.settings["margin-bottom"])
|
||||
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.settings["horizontal-align"] != "left":
|
||||
cmd += " -ha {}".format(self.settings["horizontal-align"])
|
||||
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["lang"]:
|
||||
cmd += " -lang {}".format(self.settings["lang"])
|
||||
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.settings["output"]:
|
||||
cmd += " -o {}".format(self.settings["output"])
|
||||
if self.settings["padding"] != 2:
|
||||
cmd += " -padding {}".format(self.settings["padding"])
|
||||
if self.settings["styling"]:
|
||||
cmd += " -s {}".format(self.settings["styling"])
|
||||
if self.settings["terminal"] != "alacritty":
|
||||
cmd += " -term {}".format(self.settings["terminal"])
|
||||
if self.settings["vertical-align"] != "bottom":
|
||||
cmd += " -va {}".format(self.settings["vertical-align"])
|
||||
if self.settings["width"] > 0:
|
||||
cmd += " -width {}".format(self.settings["width"])
|
||||
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
|
Reference in New Issue
Block a user