aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_titlebar/view.vala
blob: 9706b5160a677c60269cee2e0128d71b43147c5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Gtk;
using Gee;
using Pango;

using Dino.Entities;

namespace Dino.Ui {

public class ConversationTitlebar : Gtk.Box {

    public string? title {
        get { return title_label.label; }
        set { this.title_label.label = value; }
    }

    public string? subtitle {
        get { return subtitle_label.label; }
        set {
            this.subtitle_label.label = "<span size='small'>" + value + "</span>";
            this.subtitle_label.visible = (value != null);
        }
    }

    private StreamInteractor stream_interactor;

    private Box content_box = new Box(Orientation.HORIZONTAL, 0) { margin=5, margin_start=15, margin_end=5, hexpand=true, visible=true };
    private Label title_label = new Label("") { visible=true };
    private Label subtitle_label = new Label("") { use_markup=true, ellipsize=EllipsizeMode.END, visible=false };
    public GlobalSearchButton search_button = new GlobalSearchButton() { visible = true };

    construct {
        this.add(content_box);

        Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER, hexpand=true, visible=true };
        content_box.add(titles_box);

        titles_box.add(title_label);
        subtitle_label.attributes = new AttrList();
        subtitle_label.get_style_context().add_class("dim-label");
        titles_box.add(subtitle_label);

        Box placeholder_box = new Box(Orientation.VERTICAL, 0) { visible=true };
        placeholder_box.add(new Label("") { xalign=0, visible=true });
        placeholder_box.add(new Label("<span size='small'> </span>") { use_markup=true, xalign=0, visible=true });
        content_box.add(placeholder_box);
    }

    public ConversationTitlebar(StreamInteractor stream_interactor) {
        this.stream_interactor = stream_interactor;

        this.get_style_context().add_class("dino-header-right");
        hexpand = true;
        search_button.set_image(new Gtk.Image.from_icon_name("system-search-symbolic", Gtk.IconSize.MENU) { visible = true });

        Application app = GLib.Application.get_default() as Application;
        foreach(var e in app.plugin_registry.conversation_titlebar_entries) {
            Plugins.ConversationTitlebarWidget widget = e.get_widget(Plugins.WidgetType.GTK);
            if (widget != null) {
                Button gtk_widget = (Gtk.Button)widget;
                gtk_widget.relief = ReliefStyle.NONE;
                content_box.add(gtk_widget);
            }
        }
    }
}

}