Skip to content

Commit

Permalink
Merge pull request #47 from nwg-piotr/workspaces
Browse files Browse the repository at this point in the history
Workspaces: mark non-empty, mark autotiling, show active con parent layout #42
  • Loading branch information
nwg-piotr authored Mar 27, 2021
2 parents 7e033dc + efbb966 commit 9056837
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 41 deletions.
50 changes: 48 additions & 2 deletions nwg_panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@
},
"sway-workspaces": {
"numbers": ["1", "2", "3", "4", "5", "6", "7", "8"],
"show-icon": True,
"image-size": 16,
"show-name": True,
"name-length": 40
"name-length": 40,
"mark-autotiling": True,
"mark-content": True,
"show-layout": True
},
"clock": {
"format": "%a, %d. %b %H:%M:%S",
Expand Down Expand Up @@ -1029,8 +1034,13 @@ def edit_sway_workspaces(self, *args):
settings = self.panel["sway-workspaces"]
defaults = {
"numbers": [1, 2, 3, 4, 5, 6, 7, 8],
"show-icon": True,
"image-size": 16,
"show-name": True,
"name-length": 40
"name-length": 40,
"mark-autotiling": True,
"mark-content": True,
"show-layout": True
}
for key in defaults:
check_key(settings, key, defaults[key])
Expand All @@ -1046,15 +1056,33 @@ def edit_sway_workspaces(self, *args):
self.eb_workspaces_menu.set_text(text.strip())
self.eb_workspaces_menu.connect("changed", validate_workspaces)

self.ws_show_icon = builder.get_object("show-icon")
self.ws_show_icon.set_active(settings["show-icon"])

self.ws_show_name = builder.get_object("show-name")
self.ws_show_name.set_active(settings["show-name"])

self.ws_image_size = builder.get_object("image-size")
self.ws_image_size.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=8, upper=129, step_increment=1, page_increment=10, page_size=1)
self.ws_image_size.configure(adj, 1, 0)
self.ws_image_size.set_value(settings["image-size"])

self.ws_name_length = builder.get_object("name-length")
self.ws_name_length.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=1, upper=256, step_increment=1, page_increment=10, page_size=1)
self.ws_name_length.configure(adj, 1, 0)
self.ws_name_length.set_value(settings["name-length"])

self.ws_mark_autotiling = builder.get_object("mark-autotiling")
self.ws_mark_autotiling.set_active(settings["mark-autotiling"])

self.ws_mark_content = builder.get_object("mark-content")
self.ws_mark_content.set_active(settings["mark-content"])

self.ws_show_layout = builder.get_object("show-layout")
self.ws_show_layout.set_active(settings["show-layout"])

for item in self.scrolled_window.get_children():
item.destroy()
self.scrolled_window.add(grid)
Expand All @@ -1066,12 +1094,30 @@ def update_sway_workspaces(self):
if val:
settings["numbers"] = val.split()

val = self.ws_show_icon.get_active()
if val is not None:
settings["show-icon"] = val

val = self.ws_show_name.get_active()
if val is not None:
settings["show-name"] = val

settings["image-size"] = int(self.ws_image_size.get_value())

settings["name-length"] = int(self.ws_name_length.get_value())

val = self.ws_mark_autotiling.get_active()
if val is not None:
settings["mark-autotiling"] = val

val = self.ws_mark_content.get_active()
if val is not None:
settings["mark-content"] = val

val = self.ws_show_layout.get_active()
if val is not None:
settings["show-layout"] = val

save_json(self.config, self.file)

def edit_scratchpad(self, *args):
Expand Down
93 changes: 88 additions & 5 deletions nwg_panel/glade/config_sway_workspaces.glade
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<!-- n-columns=3 n-rows=4 -->
<!-- n-columns=3 n-rows=7 -->
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -57,6 +57,32 @@ of workspaces to show</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show-name">
<property name="label" translatable="yes">Show window name</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show-icon">
<property name="label" translatable="yes">Show focused window icon</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</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>
Expand All @@ -66,7 +92,7 @@ of workspaces to show</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
Expand All @@ -76,22 +102,79 @@ of workspaces to show</property>
</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">start</property>
<property name="label" translatable="yes">Icon size</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show-name">
<property name="label" translatable="yes">Show focused window</property>
<object class="GtkSpinButton" id="image-size">
<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="GtkCheckButton" id="mark-content">
<property name="label" translatable="yes">Mark non-empty WS</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="mark-autotiling">
<property name="label" translatable="yes">Mark-autotiling</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show-layout">
<property name="label" translatable="yes">Show layout</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
Expand Down
2 changes: 1 addition & 1 deletion nwg_panel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def instantiate_content(panel, container, content_list, icons_path=""):
if item == "sway-workspaces":
if sway:
if "sway-workspaces" in panel:
workspaces = SwayWorkspaces(panel["sway-workspaces"], common.i3)
workspaces = SwayWorkspaces(panel["sway-workspaces"], common.i3, icons_path=icons_path)
container.pack_start(workspaces, False, False, panel["items-padding"])
common.workspaces_list.append(workspaces)
else:
Expand Down
16 changes: 14 additions & 2 deletions nwg_panel/modules/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i
self.bri_scale = None
self.vol_scale = None

self.connect("show", self.refresh)
self.src_tag = 0

self.connect("show", self.on_window_show)

check_key(settings, "output-switcher", False)
self.sinks = []
Expand All @@ -285,6 +287,7 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i
eb.set_above_child(False)
if settings["leave-closes"]:
self.connect("leave_notify_event", self.on_window_exit)
self.connect("enter_notify_event", self.on_window_enter)

outer_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
eb.add(outer_vbox)
Expand Down Expand Up @@ -523,7 +526,16 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i
Gdk.threads_add_timeout(GLib.PRIORITY_LOW, 500, self.refresh)

def on_window_exit(self, w, e):
self.hide()
self.src_tag = GLib.timeout_add_seconds(1, self.hide)

def on_window_enter(self, *args):
if self.src_tag > 0:
GLib.Source.remove(self.src_tag)
self.src_tag = 0

def on_window_show(self, *args):
self.src_tag = 0
self.refresh

def switch_menu_box(self, widget, event):
if self.menu_box.get_visible():
Expand Down
Loading

0 comments on commit 9056837

Please sign in to comment.