From 42cb76282ea199726145cd2888d670557d3a44cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bellegarde?= Date: Mon, 21 Aug 2023 11:22:36 +0200 Subject: [PATCH] client: Ensure accounts dialog fits on small display devices - Replace ellipsizing by wrapping - Switch to vertical boxing if not enough space - Fix welcome dialog --- .../accounts/accounts-editor-edit-pane.vala | 3 +- .../accounts/accounts-editor-list-pane.vala | 3 +- src/client/accounts/accounts-editor-row.vala | 73 ++++++++++++++++--- src/client/accounts/accounts-editor.vala | 8 ++ ui/accounts_editor.ui | 2 - ui/accounts_editor_edit_pane.ui | 44 +++++------ ui/accounts_editor_list_pane.ui | 8 +- ui/geary.css | 26 ++----- 8 files changed, 106 insertions(+), 61 deletions(-) diff --git a/src/client/accounts/accounts-editor-edit-pane.vala b/src/client/accounts/accounts-editor-edit-pane.vala index cdecb7ac..9d5156de 100644 --- a/src/client/accounts/accounts-editor-edit-pane.vala +++ b/src/client/accounts/accounts-editor-edit-pane.vala @@ -389,7 +389,8 @@ private class Accounts.MailboxRow : AccountRow { public MailboxRow(Geary.AccountInformation account, Geary.RFC822.MailboxAddress mailbox) { var label = new Gtk.Label(""); - label.ellipsize = Pango.EllipsizeMode.END; + label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR); + label.set_line_wrap(true); base(account, "", label); this.mailbox = mailbox; enable_drag(); diff --git a/src/client/accounts/accounts-editor-list-pane.vala b/src/client/accounts/accounts-editor-list-pane.vala index b0bee989..f1ea439b 100644 --- a/src/client/accounts/accounts-editor-list-pane.vala +++ b/src/client/accounts/accounts-editor-list-pane.vala @@ -276,7 +276,8 @@ private class Accounts.AccountListRow : AccountRow { this.value.add(this.unavailable_icon); this.value.add(this.service_label); - this.service_label.set_ellipsize(Pango.EllipsizeMode.END); + this.service_label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR); + this.service_label.set_line_wrap(true); this.service_label.show(); this.account.changed.connect(on_account_changed); diff --git a/src/client/accounts/accounts-editor-row.vala b/src/client/accounts/accounts-editor-row.vala index 70223d71..d342ec3b 100644 --- a/src/client/accounts/accounts-editor-row.vala +++ b/src/client/accounts/accounts-editor-row.vala @@ -14,7 +14,10 @@ internal class Accounts.EditorRow : Gtk.ListBoxRow { }; - protected Gtk.Grid layout { get; private set; default = new Gtk.Grid(); } + protected Gtk.Box layout { + get; + private set; + default = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5); } private Gtk.Container drag_handle; private bool drag_picked_up = false; @@ -26,13 +29,10 @@ internal class Accounts.EditorRow : Gtk.ListBoxRow { public EditorRow() { + get_style_context().add_class("geary-settings"); get_style_context().add_class("geary-labelled-row"); - this.layout.orientation = Gtk.Orientation.HORIZONTAL; - this.layout.show(); - add(this.layout); - // We'd like to add the drag handle only when needed, but // GNOME/gtk#1495 prevents us from doing so. Gtk.EventBox drag_box = new Gtk.EventBox(); @@ -48,9 +48,25 @@ internal class Accounts.EditorRow : Gtk.ListBoxRow { this.drag_handle.hide(); // Translators: Tooltip for dragging list items this.drag_handle.set_tooltip_text(_("Drag to move this item")); - this.layout.add(drag_handle); + var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5); + box.add(drag_handle); + box.add(this.layout); + box.show(); + add(box); + + this.layout.show(); this.show(); + + this.size_allocate.connect((allocation) => { + if (allocation.width < 500) { + if (this.layout.orientation == Gtk.Orientation.HORIZONTAL) { + this.layout.orientation = Gtk.Orientation.VERTICAL; + } + } else if (this.layout.orientation == Gtk.Orientation.VERTICAL) { + this.layout.orientation = Gtk.Orientation.HORIZONTAL; + } + }); } public virtual void activated(PaneType pane) { @@ -216,8 +232,10 @@ internal class Accounts.LabelledEditorRow : EditorRow { public LabelledEditorRow(string label, V value) { this.label.halign = Gtk.Align.START; this.label.valign = Gtk.Align.CENTER; + this.label.hexpand = true; this.label.set_text(label); - this.label.set_ellipsize(Pango.EllipsizeMode.END); + this.label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR); + this.label.set_line_wrap(true); this.label.show(); this.layout.add(this.label); @@ -228,10 +246,15 @@ internal class Accounts.LabelledEditorRow : EditorRow { Gtk.Entry? entry = value as Gtk.Entry; if (entry != null) { expand_label = false; - entry.xalign = 1; entry.hexpand = true; } + Gtk.Label? vlabel = value as Gtk.Label; + if (vlabel != null) { + vlabel.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR); + vlabel.set_line_wrap(true); + } + widget.halign = Gtk.Align.START; widget.valign = Gtk.Align.CENTER; widget.show(); this.layout.add(widget); @@ -499,6 +522,7 @@ internal class Accounts.TlsComboBox : Gtk.ComboBox { set_id_column(0); Gtk.CellRendererText text_renderer = new Gtk.CellRendererText(); + text_renderer.ellipsize = Pango.EllipsizeMode.END; pack_start(text_renderer, true); add_attribute(text_renderer, "text", 2); @@ -510,7 +534,7 @@ internal class Accounts.TlsComboBox : Gtk.ComboBox { } -internal class Accounts.OutgoingAuthComboBox : Gtk.ComboBoxText { +internal class Accounts.OutgoingAuthComboBox : Gtk.ComboBox { public string label { get; private set; } @@ -535,29 +559,54 @@ internal class Accounts.OutgoingAuthComboBox : Gtk.ComboBoxText { // account this.label = _("Login"); - append( + Gtk.ListStore store = new Gtk.ListStore( + 2, typeof(string), typeof(string) + ); + Gtk.TreeIter iter; + + store.append(out iter); + store.set( + iter, + 0, Geary.Credentials.Requirement.NONE.to_value(), + 1, // Translators: ComboBox value for source of SMTP // authentication credentials (none) when adding a new // account _("No login needed") ); - append( + store.append(out iter); + store.set( + iter, + 0, Geary.Credentials.Requirement.USE_INCOMING.to_value(), + 1, // Translators: ComboBox value for source of SMTP // authentication credentials (use IMAP) when adding a new // account _("Use same login as receiving") ); - append( + store.append(out iter); + store.set( + iter, + 0, Geary.Credentials.Requirement.CUSTOM.to_value(), + 1, // Translators: ComboBox value for source of SMTP // authentication credentials (custom) when adding a new // account _("Use a different login") ); + + this.model = store; + set_id_column(0); + + Gtk.CellRendererText text_renderer = new Gtk.CellRendererText(); + text_renderer.ellipsize = Pango.EllipsizeMode.END; + pack_start(text_renderer, true); + add_attribute(text_renderer, "text", 1); } } diff --git a/src/client/accounts/accounts-editor.vala b/src/client/accounts/accounts-editor.vala index 4a7e4d36..65a6d493 100644 --- a/src/client/accounts/accounts-editor.vala +++ b/src/client/accounts/accounts-editor.vala @@ -78,6 +78,14 @@ public class Accounts.Editor : Gtk.Dialog { push(this.editor_list_pane); update_command_actions(); + + if (this.accounts.size > 1) { + this.default_height = 650; + this.default_width = 800; + } else { + // Welcome dialog + this.default_width = 600; + } } public override bool key_press_event(Gdk.EventKey event) { diff --git a/ui/accounts_editor.ui b/ui/accounts_editor.ui index 179bf778..717b0918 100644 --- a/ui/accounts_editor.ui +++ b/ui/accounts_editor.ui @@ -4,8 +4,6 @@