2017-03-02 14:37:32 +00:00
|
|
|
using Gtk;
|
|
|
|
|
|
|
|
using Dino.Entities;
|
|
|
|
|
2017-03-10 17:07:28 +00:00
|
|
|
namespace Dino.Ui {
|
|
|
|
|
2017-12-03 18:42:15 +00:00
|
|
|
[GtkTemplate (ui = "/im/dino/Dino/conversation_list_titlebar.ui")]
|
2017-03-10 17:07:28 +00:00
|
|
|
public class ConversationListTitlebar : Gtk.HeaderBar {
|
2017-03-02 14:37:32 +00:00
|
|
|
|
|
|
|
public signal void conversation_opened(Conversation conversation);
|
|
|
|
|
2017-03-10 17:07:28 +00:00
|
|
|
[GtkChild] private MenuButton add_button;
|
2017-03-02 14:37:32 +00:00
|
|
|
|
|
|
|
private StreamInteractor stream_interactor;
|
|
|
|
|
2017-05-30 20:47:16 +00:00
|
|
|
public ConversationListTitlebar(StreamInteractor stream_interactor, Window window) {
|
2017-03-02 14:37:32 +00:00
|
|
|
this.stream_interactor = stream_interactor;
|
2017-08-29 19:55:15 +00:00
|
|
|
|
|
|
|
custom_title = new Label("Dino") { visible = true, hexpand = true, xalign = 0 };
|
|
|
|
custom_title.get_style_context().add_class("title");
|
|
|
|
|
2017-05-30 20:47:16 +00:00
|
|
|
create_add_menu(window);
|
2017-03-02 14:37:32 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 18:22:45 +00:00
|
|
|
private void create_add_menu(Window window) {
|
2017-03-02 14:37:32 +00:00
|
|
|
SimpleAction contacts_action = new SimpleAction("add_chat", null);
|
|
|
|
contacts_action.activate.connect(() => {
|
2017-10-28 20:02:32 +00:00
|
|
|
AddChatDialog add_chat_dialog = new AddChatDialog(stream_interactor, stream_interactor.get_accounts());
|
2017-05-09 12:53:26 +00:00
|
|
|
add_chat_dialog.set_transient_for(window);
|
2017-10-28 20:02:32 +00:00
|
|
|
add_chat_dialog.added.connect((conversation) => {
|
2017-06-11 11:59:24 +00:00
|
|
|
conversation_opened(conversation);
|
|
|
|
});
|
2017-05-30 20:47:16 +00:00
|
|
|
add_chat_dialog.present();
|
2017-03-02 14:37:32 +00:00
|
|
|
});
|
2017-05-30 20:47:16 +00:00
|
|
|
GLib.Application.get_default().add_action(contacts_action);
|
2017-03-02 14:37:32 +00:00
|
|
|
|
|
|
|
SimpleAction conference_action = new SimpleAction("add_conference", null);
|
|
|
|
conference_action.activate.connect(() => {
|
2017-10-28 20:02:32 +00:00
|
|
|
AddConferenceDialog add_conference_dialog = new AddConferenceDialog(stream_interactor);
|
2017-05-09 12:53:26 +00:00
|
|
|
add_conference_dialog.set_transient_for(window);
|
2017-03-02 14:37:32 +00:00
|
|
|
add_conference_dialog.conversation_opened.connect((conversation) => conversation_opened(conversation));
|
2017-05-30 20:47:16 +00:00
|
|
|
add_conference_dialog.present();
|
2017-03-02 14:37:32 +00:00
|
|
|
});
|
2017-05-30 20:47:16 +00:00
|
|
|
GLib.Application.get_default().add_action(conference_action);
|
2017-03-02 14:37:32 +00:00
|
|
|
|
2017-12-03 18:42:15 +00:00
|
|
|
Builder builder = new Builder.from_resource("/im/dino/Dino/menu_add.ui");
|
2017-03-02 14:37:32 +00:00
|
|
|
MenuModel menu = builder.get_object("menu_add") as MenuModel;
|
|
|
|
add_button.set_menu_model(menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-09 12:53:26 +00:00
|
|
|
}
|