Add separators and back button to non csd header
This commit is contained in:
parent
84a669b52d
commit
bb41fb9ce6
|
@ -10,6 +10,10 @@ public interface ConversationTitlebar : Widget {
|
|||
public abstract string? subtitle { get; set; }
|
||||
public abstract string? title { get; set; }
|
||||
|
||||
public abstract bool back_button { get; set; }
|
||||
|
||||
public signal void back_pressed();
|
||||
|
||||
public abstract void insert_entry(Plugins.ConversationTitlebarEntry entry);
|
||||
}
|
||||
|
||||
|
@ -28,6 +32,12 @@ public class ConversationTitlebarNoCsd : ConversationTitlebar, Gtk.Box {
|
|||
}
|
||||
}
|
||||
|
||||
private Revealer back_revealer;
|
||||
public bool back_button {
|
||||
get { return back_revealer.reveal_child; }
|
||||
set { back_revealer.reveal_child = value; }
|
||||
}
|
||||
|
||||
private Box widgets_box = new Box(Orientation.HORIZONTAL, 0) { margin_start=15, valign=Align.END, visible=true };
|
||||
private Label title_label = new Label("") { ellipsize=EllipsizeMode.END, visible=true };
|
||||
private Label subtitle_label = new Label("") { use_markup=true, ellipsize=EllipsizeMode.END, visible=false };
|
||||
|
@ -36,6 +46,13 @@ public class ConversationTitlebarNoCsd : ConversationTitlebar, Gtk.Box {
|
|||
Box content_box = new Box(Orientation.HORIZONTAL, 0) { margin=5, margin_start=15, margin_end=10, hexpand=true, visible=true };
|
||||
this.add(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, relief = ReliefStyle.NONE };
|
||||
back_button.get_style_context().add_class("image-button");
|
||||
back_button.clicked.connect(() => back_pressed());
|
||||
back_revealer.add(back_button);
|
||||
content_box.add(back_revealer);
|
||||
|
||||
Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER, hexpand=true, visible=true };
|
||||
content_box.add(titles_box);
|
||||
|
||||
|
@ -70,7 +87,6 @@ public class ConversationTitlebarCsd : ConversationTitlebar, Gtk.HeaderBar {
|
|||
get { return back_revealer.reveal_child; }
|
||||
set { back_revealer.reveal_child = value; }
|
||||
}
|
||||
public signal void back_pressed();
|
||||
|
||||
public ConversationTitlebarCsd() {
|
||||
this.get_style_context().add_class("dino-right");
|
||||
|
|
|
@ -50,6 +50,12 @@ public class MainWindow : Gtk.Window {
|
|||
setup_headerbar();
|
||||
setup_stack();
|
||||
|
||||
if (!Util.use_csd()) {
|
||||
box.add(headerbar_paned);
|
||||
box.add(new Separator(Orientation.VERTICAL) { visible = true });
|
||||
}
|
||||
box.add(paned);
|
||||
|
||||
paned.bind_property("transition-type", headerbar_paned, "transition-type", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
|
||||
paned.bind_property("mode-transition-duration", headerbar_paned, "mode-transition-duration", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
|
||||
paned.bind_property("child-transition-duration", headerbar_paned, "child-transition-duration", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
|
||||
|
@ -62,7 +68,6 @@ public class MainWindow : Gtk.Window {
|
|||
Builder builder = new Builder.from_resource("/im/dino/Dino/unified_main_content.ui");
|
||||
paned = (Hdy.Leaflet) builder.get_object("paned");
|
||||
paned.notify["folded"].connect_after(() => update_headerbar());
|
||||
box.add(paned);
|
||||
left_stack = (Stack) builder.get_object("left_stack");
|
||||
right_stack = (Stack) builder.get_object("right_stack");
|
||||
conversation_view = (ConversationView) builder.get_object("conversation_view");
|
||||
|
@ -76,8 +81,7 @@ public class MainWindow : Gtk.Window {
|
|||
}
|
||||
|
||||
private void update_headerbar() {
|
||||
if (!Util.use_csd()) return;
|
||||
conversation_titlebar_csd.back_button = paned.folded;
|
||||
conversation_titlebar.back_button = paned.folded;
|
||||
}
|
||||
|
||||
private void show_list_pane() {
|
||||
|
@ -119,11 +123,14 @@ public class MainWindow : Gtk.Window {
|
|||
headerbar_paned.add_with_properties(conversation_list_titlebar, "name", "list-pane");
|
||||
conversation_list_group.add_widget(conversation_list_titlebar);
|
||||
|
||||
Separator sep = new Separator(Orientation.HORIZONTAL) { visible = true };
|
||||
sep.get_style_context().add_class("sidebar");
|
||||
headerbar_paned.add(sep);
|
||||
|
||||
conversation_titlebar = new ConversationTitlebarNoCsd() { visible=true };
|
||||
conversation_titlebar.back_pressed.connect(() => show_list_pane());
|
||||
headerbar_paned.add_with_properties(conversation_titlebar, "name", "view-pane");
|
||||
conversation_view_group.add_widget(conversation_titlebar);
|
||||
|
||||
box.add(headerbar_paned);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue