diff options
author | Teemu Ikonen <tpikonen@mailbox.org> | 2022-09-12 18:06:27 +0300 |
---|---|---|
committer | Marvin W <git@larma.de> | 2023-01-24 19:20:43 +0100 |
commit | e934a76a1139938ae668836b812102cd5d9c9d9f (patch) | |
tree | 5bcd97b7b678181777b23164157a1e53958ff9b5 /main/src/ui | |
parent | 04acab82c98f5d9cdb798ba3baac8d73b097b1df (diff) | |
download | dino-e934a76a1139938ae668836b812102cd5d9c9d9f.tar.gz dino-e934a76a1139938ae668836b812102cd5d9c9d9f.zip |
Add back button to ConversationTitlebar
Add a bool 'back_button_visible' and a signal 'back_pressed' to the
ConversationTitlebar interface.
Also add implementations to both ConversationTitlebarNoCsd and
ConversationTitlebarCsd.
Diffstat (limited to 'main/src/ui')
-rw-r--r-- | main/src/ui/conversation_titlebar/conversation_titlebar.vala | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/main/src/ui/conversation_titlebar/conversation_titlebar.vala b/main/src/ui/conversation_titlebar/conversation_titlebar.vala index 56568ba2..ba0dcfa3 100644 --- a/main/src/ui/conversation_titlebar/conversation_titlebar.vala +++ b/main/src/ui/conversation_titlebar/conversation_titlebar.vala @@ -12,6 +12,9 @@ public interface ConversationTitlebar : Object { public abstract void insert_button(Widget button); public abstract Widget get_widget(); + + public abstract bool back_button_visible{ get; set; } + public signal void back_pressed(); } public class ConversationTitlebarNoCsd : ConversationTitlebar, Object { @@ -31,14 +34,27 @@ public class ConversationTitlebarNoCsd : ConversationTitlebar, Object { } } + public bool back_button_visible { + get { return back_revealer.reveal_child; } + set { back_revealer.reveal_child = value; } + } + private Box widgets_box = new Box(Orientation.HORIZONTAL, 7) { margin_start=15, valign=Align.END }; private Label title_label = new Label("") { ellipsize=EllipsizeMode.END }; private Label subtitle_label = new Label("") { use_markup=true, ellipsize=EllipsizeMode.END, visible=false }; + private Revealer back_revealer; construct { Box content_box = new Box(Orientation.HORIZONTAL, 0) { margin_start=15, margin_end=10, hexpand=true }; main.append(content_box); + back_revealer = new Revealer() { visible = true, transition_type = RevealerTransitionType.SLIDE_RIGHT, transition_duration = 200, can_focus = false, reveal_child = false }; + Button back_button = new Button.from_icon_name("go-previous-symbolic") { visible = true, valign = Align.CENTER, use_underline = true }; + back_button.get_style_context().add_class("image-button"); + back_button.clicked.connect(() => back_pressed()); + back_revealer.set_child(back_button); + content_box.append(back_revealer); + Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER, hexpand=true }; content_box.append(titles_box); @@ -67,10 +83,15 @@ public class ConversationTitlebarCsd : ConversationTitlebar, Object { public new string? title { get { return title_label.label; } set { title_label.label = value; } } public new string? subtitle { get { return subtitle_label.label; } set { subtitle_label.label = value; subtitle_label.visible = (value != null); } } + public bool back_button_visible { + get { return back_revealer.reveal_child; } + set { back_revealer.reveal_child = value; } + } public Adw.HeaderBar header_bar = new Adw.HeaderBar(); private Label title_label = new Label("") { ellipsize=EllipsizeMode.END }; private Label subtitle_label = new Label("") { ellipsize=EllipsizeMode.END, visible=false }; + private Revealer back_revealer; public ConversationTitlebarCsd() { Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER }; @@ -82,6 +103,13 @@ public class ConversationTitlebarCsd : ConversationTitlebar, Object { subtitle_label.add_css_class("dim-label"); titles_box.append(subtitle_label); + back_revealer = new Revealer() { visible = true, transition_type = RevealerTransitionType.SLIDE_RIGHT, transition_duration = 200, can_focus = false, reveal_child = false }; + Button back_button = new Button.from_icon_name("go-previous-symbolic") { visible = true, valign = Align.CENTER, use_underline = true }; + back_button.get_style_context().add_class("image-button"); + back_button.clicked.connect(() => back_pressed()); + back_revealer.set_child(back_button); + header_bar.pack_start(back_revealer); + header_bar.set_title_widget(titles_box); } |