anotherim-desktop/main/src/ui/conversation_list_titlebar.vala

47 lines
1.9 KiB
Vala
Raw Normal View History

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-03-02 14:37:32 +00:00
[GtkTemplate (ui = "/org/dino-im/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;
[GtkChild] public ToggleButton search_button;
2017-03-02 14:37:32 +00:00
private StreamInteractor stream_interactor;
public ConversationListTitlebar(Window application, StreamInteractor stream_interactor) {
2017-03-02 14:37:32 +00:00
this.stream_interactor = stream_interactor;
create_add_menu(application);
}
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(() => {
AddConversation.Chat.Dialog add_chat_dialog = new AddConversation.Chat.Dialog(stream_interactor);
add_chat_dialog.set_transient_for((Window) get_toplevel());
2017-03-02 14:37:32 +00:00
add_chat_dialog.conversation_opened.connect((conversation) => conversation_opened(conversation));
add_chat_dialog.show();
});
window.get_application().add_action(contacts_action);
2017-03-02 14:37:32 +00:00
SimpleAction conference_action = new SimpleAction("add_conference", null);
conference_action.activate.connect(() => {
AddConversation.Conference.Dialog add_conference_dialog = new AddConversation.Conference.Dialog(stream_interactor);
add_conference_dialog.set_transient_for((Window) get_toplevel());
2017-03-02 14:37:32 +00:00
add_conference_dialog.conversation_opened.connect((conversation) => conversation_opened(conversation));
add_conference_dialog.show();
});
window.get_application().add_action(conference_action);
2017-03-02 14:37:32 +00:00
Builder builder = new Builder.from_resource("/org/dino-im/menu_add.ui");
MenuModel menu = builder.get_object("menu_add") as MenuModel;
add_button.set_menu_model(menu);
}
}
2017-03-10 17:07:28 +00:00
}