aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_titlebar/menu_entry.vala
blob: 479a228cb9f6399844d958ce49d904ee5f472d2a (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
using Gtk;

using Dino.Entities;

namespace Dino.Ui {

class MenuEntry : Plugins.ConversationTitlebarEntry, Object {
    public string id { get { return "menu"; } }
    public double order { get { return 0; } }

    StreamInteractor stream_interactor;
    private Conversation? conversation;

    Button button = new Button() { icon_name="view-more-symbolic" };

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

        button.clicked.connect(on_clicked);
    }

    public new void set_conversation(Conversation conversation) {
        button.sensitive = true;
        this.conversation = conversation;
        if (conversation.type_ == Conversation.Type.GROUPCHAT) {
            button.tooltip_text = Util.string_if_tooltips_active("Channel details");
        } else {
            button.tooltip_text = Util.string_if_tooltips_active("Conversation details");
        }
    }

    public new void unset_conversation() {
        button.sensitive = false;
    }

    private void on_clicked() {
        var conversation_details = ConversationDetails.setup_dialog(conversation, stream_interactor, (Window)button.get_root());
        conversation_details.present();
    }

    public Object? get_widget(Plugins.WidgetType type) {
        if (type != Plugins.WidgetType.GTK4) return null;
        return button;
    }
}
}