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

using Dino.Entities;

namespace Dino.Ui {

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

    StreamInteractor stream_interactor;

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

    public double order { get { return 0; } }
    public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) {
        if (type == Plugins.WidgetType.GTK) {
            return new MenuWidget(stream_interactor) { visible=true };
        }
        return null;
    }
}

class MenuWidget : MenuButton, Plugins.ConversationTitlebarWidget {

    private Conversation? conversation;

    public MenuWidget(StreamInteractor stream_interactor) {
        image = new Image.from_icon_name("open-menu-symbolic", IconSize.MENU);

        Builder builder = new Builder.from_resource("/org/dino-im/menu_conversation.ui");
        MenuModel menu = builder.get_object("menu_conversation") as MenuModel;
        set_menu_model(menu);

        SimpleAction contact_details_action = new SimpleAction("contact_details", null);
        contact_details_action.activate.connect(() => {
            ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation);
            contact_details_dialog.set_transient_for((Window) get_toplevel());
            contact_details_dialog.present();
        });
        GLib.Application.get_default().add_action(contact_details_action);
    }

    public new void set_conversation(Conversation conversation) {
        this.conversation = conversation;
    }
}

}