diff --git a/nwg_panel/config.py b/nwg_panel/config.py
index 51ac1744..dc1400fb 100644
--- a/nwg_panel/config.py
+++ b/nwg_panel/config.py
@@ -921,6 +921,7 @@ def check_defaults(self):
"controls": "off",
"menu-start": "off",
"width": "auto",
+ "width-as-percentage": False,
"height": 0,
"margin-top": 0,
"margin-bottom": 0,
@@ -1042,6 +1043,9 @@ def edit_panel(self, *args):
adj = Gtk.Adjustment(value=0, lower=0, upper=upper, step_increment=1, page_increment=10, page_size=1)
self.sb_width.configure(adj, 1, 0)
+ self.ckb_width_percentage = builder.get_object("as-percentage")
+ self.ckb_width_percentage.set_active(self.panel["width-as-percentage"])
+
self.ckb_width_auto = builder.get_object("width-auto")
if isinstance(self.panel["width"], int):
self.sb_width.set_value(float(self.panel["width"]))
@@ -1172,6 +1176,8 @@ def update_panel(self):
if val:
self.panel["layer"] = val
+ self.panel["width-as-percentage"] = self.ckb_width_percentage.get_active()
+
val = self.ckb_width_auto.get_active()
if val:
self.panel["width"] = "auto"
diff --git a/nwg_panel/glade/config_panel.glade b/nwg_panel/glade/config_panel.glade
index 6f31480c..b1164eec 100644
--- a/nwg_panel/glade/config_panel.glade
+++ b/nwg_panel/glade/config_panel.glade
@@ -502,7 +502,17 @@
-
+
+
+ 2
+ 7
+
diff --git a/nwg_panel/main.py b/nwg_panel/main.py
index cac970c4..99c6b2b1 100644
--- a/nwg_panel/main.py
+++ b/nwg_panel/main.py
@@ -618,6 +618,7 @@ def main():
# This is to allow width "auto" value. Actually all non-numeric values will be removed.
if "width" in panel and not isinstance(panel["width"], int):
panel.pop("width")
+ panel["width-as-percentage"] = False
if panel["output"] in common.outputs or not panel["output"]:
check_key(panel, "spacing", 6)
@@ -628,6 +629,8 @@ def main():
check_key(panel, "use-sigrt", False)
check_key(panel, "start-hidden", False)
+ check_key(panel, "width-as-percentage", True)
+
window = Gtk.Window()
global panel_windows_hide_show_sigs
if panel["use-sigrt"]:
@@ -649,6 +652,12 @@ def main():
if "output" in panel and panel["output"] and "width" not in panel:
panel["width"] = common.outputs[panel["output"]]["width"]
+ # Width defined as percentage
+ if "width" in panel and panel["width"] > 0 and panel["width-as-percentage"]:
+ if panel["width"] > 100:
+ panel["width"] = 100
+ panel["width"] = int(common.outputs[panel["output"]]["width"] * panel["width"] / 100)
+
check_key(panel, "width", 0)
w = panel["width"]