Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pango markup for sway workspace labels #203

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions nwg_panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,18 +1909,12 @@ def edit_sway_workspaces(self, *args):
self.ws_custom_labels = builder.get_object("custom-labels")
self.ws_custom_labels.set_tooltip_text(voc["custom-labels-tooltip"])
labels = settings["custom-labels"]
text = ""
for item in labels:
text += str(item) + " "
self.ws_custom_labels.set_text(text.strip())
self.ws_custom_labels.get_buffer().set_text('\n'.join(labels))

self.ws_focused_labels = builder.get_object("focused-labels")
self.ws_focused_labels.set_tooltip_text(voc["custom-labels-tooltip"])
labels = settings["focused-labels"]
text = ""
for item in labels:
text += str(item) + " "
self.ws_focused_labels.set_text(text.strip())
self.ws_focused_labels.get_buffer().set_text('\n'.join(labels))

self.ws_show_icon = builder.get_object("show-icon")
self.ws_show_icon.set_label(voc["show-focused-window-icon"])
Expand Down Expand Up @@ -1969,11 +1963,13 @@ def update_sway_workspaces(self):
if val:
settings["numbers"] = val.split()

val = self.ws_custom_labels.get_text()
settings["custom-labels"] = val.split()
buffer = self.ws_custom_labels.get_buffer()
val = buffer.get_text(*buffer.get_bounds(), False)
settings["custom-labels"] = val.splitlines()

val = self.ws_focused_labels.get_text()
settings["focused-labels"] = val.split()
buffer = self.ws_focused_labels.get_buffer()
val = buffer.get_text(*buffer.get_bounds(), False)
settings["focused-labels"] = val.splitlines()

val = self.ws_show_icon.get_active()
if val is not None:
Expand Down
24 changes: 22 additions & 2 deletions nwg_panel/glade/config_sway_workspaces.glade
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,39 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="custom-labels">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<property name="propagate-natural-width">True</property>
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkTextView" id="custom-labels">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="monospace">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="focused-labels">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<property name="propagate-natural-width">True</property>
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkTextView" id="focused-labels">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="monospace">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
Expand Down
9 changes: 5 additions & 4 deletions nwg_panel/modules/sway_workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def build_box(self):
ws_num = -1
if self.i3.get_tree().find_focused():
ws_num, win_name, win_id, non_empty, win_layout, numbers = self.find_details()

if len(self.settings["custom-labels"]) == 1:
self.settings["custom-labels"] *= len(self.settings["numbers"])
elif len(self.settings["custom-labels"]) != len(self.settings["numbers"]):
self.settings["custom-labels"] = []

if len(self.settings["focused-labels"]) == 1:
self.settings["focused-labels"] *= len(self.settings["numbers"])
elif len(self.settings["focused-labels"]) != len(self.settings["numbers"]):
Expand Down Expand Up @@ -103,6 +103,7 @@ def build_number(self, num, label):
lbl = Gtk.Label("{}{}".format(autotiling, label))
else:
lbl = Gtk.Label("{}".format(label))
lbl.set_use_markup(True)
if self.settings["angle"] != 0.0:
lbl.set_angle(self.settings["angle"])
self.name_label.set_angle(self.settings["angle"])
Expand Down Expand Up @@ -163,8 +164,8 @@ def refresh(self):
else:
if text.endswith("."):
text = text[0:-1]
lbl.set_text(text)

lbl.set_markup(text)

if num == str(ws_num):
self.ws_num2box[num].set_property("name", "task-box-focused")
Expand Down