From 8257929e88e4309f8ff01ac73a4cd58ce0e8ae7d Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 14 Nov 2023 20:23:37 +0800 Subject: [PATCH] Improve the appearance of window title --- dbx_preference | 38 +++++++++++++++++--------------------- dockbarx/windowbutton.py | 12 +++++++----- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/dbx_preference b/dbx_preference index 59ecadb..2577b35 100755 --- a/dbx_preference +++ b/dbx_preference @@ -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")) @@ -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="%s"%_("Locked list")) @@ -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( diff --git a/dockbarx/windowbutton.py b/dockbarx/windowbutton.py index bf4cd43..555b219 100644 --- a/dockbarx/windowbutton.py +++ b/dockbarx/windowbutton.py @@ -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) @@ -458,10 +458,11 @@ def __update_label(self, arg=None): text = "" + text + "" 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"] @@ -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()