aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_titlebar/occupants_entry.vala
blob: c305bed7adae8b1785436ff4679a892e0a39b532 (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 OccupantsEntry : Plugins.ConversationTitlebarEntry {
    public override string id { get { return "occupants"; } }

    StreamInteractor stream_interactor;
    Window window;

    public OccupantsEntry(StreamInteractor stream_interactor, Window window) {
        this.stream_interactor = stream_interactor;
        this.window = window;
    }

    public override double order { get { return 3; } }
    public override Plugins.ConversationTitlebarWidget get_widget() {
        return new OccupantsWidget(stream_interactor, window) { visible=true };
    }
}

class OccupantsWidget : MenuButton, Plugins.ConversationTitlebarWidget {

    private Conversation? conversation;
    private StreamInteractor stream_interactor;
    private Window window;

    public OccupantsWidget(StreamInteractor stream_interactor, Window window) {

        image = new Image.from_icon_name("system-users-symbolic", IconSize.MENU);

        this.stream_interactor = stream_interactor;
        this.window = window;
        set_use_popover(true);
    }

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

        visible = conversation.type_ == Conversation.Type.GROUPCHAT;
        if (conversation.type_ == Conversation.Type.GROUPCHAT) {
            OccupantMenu.View menu = new OccupantMenu.View(stream_interactor, window, conversation);
            set_popover(menu);
        }
    }
}

}