Skip to content

Commit

Permalink
Improve the appearance of window title
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhen committed Nov 14, 2023
1 parent 19dba7c commit 8257929
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
38 changes: 17 additions & 21 deletions dbx_preference
Original file line number Diff line number Diff line change
Expand Up @@ -859,21 +859,6 @@ class PrefDialog():
popup_box.pack_start(self.shape_mask_cb, False, True, 5)


self.preview_size_spinbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
self.preview_size_spinbox.set_border_width(5)
spinlabel = Gtk.Label(label=_("Preview size"))
spinlabel.set_xalign(0)
spinlabel.set_yalign(0.5)
adj = Gtk.Adjustment.new(200, 50, 800, 1, 50, 0)
self.preview_size_spin = Gtk.SpinButton.new(adj, 0.5, 0)
self.preview_size_spinbox.pack_start(spinlabel, False, True, 0)
self.preview_size_spinbox.pack_start(self.preview_size_spin,
False, True, 5)
adj.connect("value_changed", self.__adjustment_changed, "preview_size")
self.preview_size_spinbox.show_all()
self.preview_size_spinbox.set_no_show_all(True)
popup_box.pack_start(self.preview_size_spinbox, False, True, 5)

self.window_title_width_spinbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
self.window_title_width_spinbox.set_border_width(5)
spinlabel = Gtk.Label(label=_("Window title width"))
Expand Down Expand Up @@ -936,6 +921,22 @@ class PrefDialog():
vbox.pack_start(self.preview_keep_cb, False, True, 0)
popup_box.pack_start(vbox, False, True, 5)

self.preview_size_spinbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
self.preview_size_spinbox.set_border_width(5)
spinlabel = Gtk.Label(label=_("Preview size"))
spinlabel.set_xalign(0)
spinlabel.set_yalign(0.5)
adj = Gtk.Adjustment.new(200, 50, 800, 1, 50, 0)
self.preview_size_spin = Gtk.SpinButton.new(adj, 0.5, 0)
self.preview_size_spinbox.pack_start(spinlabel, False, True, 0)
self.preview_size_spinbox.pack_start(self.preview_size_spin,
False, True, 5)
adj.connect("value_changed", self.__adjustment_changed, "preview_size")
self.preview_size_spinbox.show_all()
self.preview_size_spinbox.set_no_show_all(True)
popup_box.pack_start(self.preview_size_spinbox, False, True, 5)


# Locked list
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
label1 = Gtk.Label(label="<b><big>%s</big></b>"%_("Locked list"))
Expand Down Expand Up @@ -1769,14 +1770,9 @@ class PrefDialog():
self.preview_keep_cb.set_active(self.globals.settings["preview_keep"])
self.preview_keep_cb.set_sensitive(self.globals.settings["preview"])
self.preview_size_spin.set_value(self.globals.settings["preview_size"])
self.preview_size_spin.set_sensitive(self.globals.settings["preview"])
self.window_title_width_spin.set_value(
self.globals.settings["window_title_width"])
if self.globals.settings["preview"]:
self.preview_size_spinbox.show()
self.window_title_width_spinbox.hide()
else:
self.preview_size_spinbox.hide()
self.window_title_width_spinbox.show()

# Advanced page stuff
self.ignore_workspace_cb.set_active(
Expand Down
12 changes: 7 additions & 5 deletions dockbarx/windowbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def __init__(self, window, group):
self.close_button.show()

self.label = Gtk.Label()
self.label.set_ellipsize(Pango.EllipsizeMode.END)
self.label.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
self.label.set_halign(Gtk.Align.START)
self.label.set_valign(Gtk.Align.CENTER)

Expand Down Expand Up @@ -458,10 +458,11 @@ def __update_label(self, arg=None):
text = "<span foreground=\"" + color + "\">" + text + "</span>"
self.label.set_text(text)
self.label.set_use_markup(True)
if self.globals.settings["preview"]:
# The label should be 140px wide unless there are more room
# because the preview takes up more.
label_size = 140
self.__set_label_size()

def __set_label_size(self):
if self.preview.get_visible():
label_size = self.globals.settings["preview_size"]
else:
label_size = self.globals.settings["window_title_width"]

Expand Down Expand Up @@ -575,6 +576,7 @@ def set_show_preview(self, show_preview):
self.preview.show()
else:
self.preview.hide()
self.__set_label_size()

def set_preview_image(self):
pixbuf = self.take_preview()
Expand Down

0 comments on commit 8257929

Please sign in to comment.