Skip to content

Commit

Permalink
Merge pull request #50 from nwg-piotr/clone
Browse files Browse the repository at this point in the history
Mirror bars to all outputs #48
  • Loading branch information
nwg-piotr authored Apr 13, 2021
2 parents beefe71 + a7b5f6b commit bae8a65
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
7 changes: 5 additions & 2 deletions nwg_panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
configs = {}
editor = None
selector_window = None
outputs = None
outputs = {}

SKELETON_PANEL: dict = {
"name": "",
Expand Down Expand Up @@ -538,7 +538,10 @@ def edit_panel(self, *args):
self.cb_output = builder.get_object("output")
for key in outputs:
self.cb_output.append(key, key)
if self.panel["output"] and self.panel["output"] in outputs:

self.cb_output.append("All", "All")

if self.panel["output"] and (self.panel["output"] in outputs or self.panel["output"] == "All"):
self.cb_output.set_active_id(self.panel["output"])

screen_width, screen_height = None, None
Expand Down
25 changes: 22 additions & 3 deletions nwg_panel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,27 @@ def main():
except Exception as e:
print(e)

# Mirror bars to all outputs #48 (if panel["output"] == "All")
to_remove = []
to_append = []
for panel in panels:
check_key(panel, "output", "")

clones = []
if panel["output"] == "All" and len(common.outputs) > 1:
to_remove.append(panel)
for key in common.outputs.keys():
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:
check_key(panel, "icons", "")
icons_path = ""
Expand All @@ -259,8 +280,6 @@ def main():
elif panel["icons"] == "dark":
icons_path = os.path.join(common.config_dir, "icons_dark")

check_key(panel, "output", "")

# 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")
Expand Down Expand Up @@ -380,7 +399,7 @@ def main():

check_key(panel, "layer", "top")
o = panel["output"] if "output" in panel else "undefined"
print("Display: {}, position: {}, layer: {}, width: {}, height: {}".format(o, panel["position"],
print("Output: {}, position: {}, layer: {}, width: {}, height: {}".format(o, panel["position"],
panel["layer"], panel["width"],
panel["height"]))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def read(f_name):

setup(
name='nwg-panel',
version='0.2.1',
version='0.2.2',
description='GTK3-based panel for sway window manager',
packages=find_packages(),
include_package_data=True,
Expand Down

0 comments on commit bae8a65

Please sign in to comment.