2017-03-11 22:52:12 +00:00
|
|
|
using Gtk;
|
|
|
|
|
|
|
|
using Dino.Entities;
|
|
|
|
using Dino.Ui;
|
|
|
|
|
2017-05-04 20:05:48 +00:00
|
|
|
public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
2017-03-11 22:52:12 +00:00
|
|
|
private Notifications notifications;
|
2017-03-17 22:21:23 +00:00
|
|
|
private UnifiedWindow window;
|
2017-03-11 22:52:12 +00:00
|
|
|
|
2017-05-04 20:05:48 +00:00
|
|
|
public Database db { get; set; }
|
2017-08-21 15:16:25 +00:00
|
|
|
public Dino.Entities.Settings settings { get; set; }
|
2017-05-04 20:05:48 +00:00
|
|
|
public StreamInteractor stream_interaction { get; set; }
|
|
|
|
public Plugins.Registry plugin_registry { get; set; default = new Plugins.Registry(); }
|
|
|
|
public SearchPathGenerator? search_path_generator { get; set; }
|
|
|
|
|
2017-03-12 12:19:04 +00:00
|
|
|
public Application() throws Error {
|
2017-08-17 09:38:41 +00:00
|
|
|
Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN);
|
2017-05-04 20:05:48 +00:00
|
|
|
init();
|
2017-03-11 22:52:12 +00:00
|
|
|
Notify.init("dino");
|
2017-03-12 12:19:04 +00:00
|
|
|
Environment.set_application_name("Dino");
|
2017-04-04 17:55:24 +00:00
|
|
|
Gtk.Window.set_default_icon_name("dino");
|
2017-08-17 19:24:01 +00:00
|
|
|
IconTheme.get_default().add_resource_path("/im/dino/icons");
|
2017-03-11 22:52:12 +00:00
|
|
|
|
2017-03-20 21:12:20 +00:00
|
|
|
activate.connect(() => {
|
2017-08-17 09:38:41 +00:00
|
|
|
if (window == null) {
|
|
|
|
create_set_app_menu();
|
|
|
|
window = new UnifiedWindow(this, stream_interaction);
|
|
|
|
notifications = new Notifications(stream_interaction, window);
|
|
|
|
notifications.start();
|
|
|
|
notifications.conversation_selected.connect(window.on_conversation_selected);
|
|
|
|
}
|
2017-05-30 20:47:16 +00:00
|
|
|
window.present();
|
2017-03-20 21:12:20 +00:00
|
|
|
});
|
2017-03-11 22:52:12 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 09:38:41 +00:00
|
|
|
public void handle_uri(string jid, string query, Gee.Map<string, string> options) {
|
|
|
|
switch (query) {
|
|
|
|
case "message":
|
|
|
|
// TODO
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-11 22:52:12 +00:00
|
|
|
private void show_accounts_window() {
|
|
|
|
ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db);
|
|
|
|
dialog.set_transient_for(window);
|
|
|
|
dialog.account_enabled.connect(add_connection);
|
|
|
|
dialog.account_disabled.connect(remove_connection);
|
2017-05-30 20:47:16 +00:00
|
|
|
dialog.present();
|
2017-03-11 22:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void show_settings_window() {
|
|
|
|
SettingsDialog dialog = new SettingsDialog();
|
|
|
|
dialog.set_transient_for(window);
|
2017-05-30 20:47:16 +00:00
|
|
|
dialog.present();
|
2017-03-11 22:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void create_set_app_menu() {
|
|
|
|
SimpleAction accounts_action = new SimpleAction("accounts", null);
|
|
|
|
accounts_action.activate.connect(show_accounts_window);
|
|
|
|
add_action(accounts_action);
|
|
|
|
|
|
|
|
SimpleAction settings_action = new SimpleAction("settings", null);
|
|
|
|
settings_action.activate.connect(show_settings_window);
|
|
|
|
add_action(settings_action);
|
|
|
|
|
|
|
|
SimpleAction quit_action = new SimpleAction("quit", null);
|
|
|
|
quit_action.activate.connect(quit);
|
|
|
|
add_action(quit_action);
|
|
|
|
add_accelerator("<Ctrl>Q", "app.quit", null);
|
|
|
|
|
2017-08-17 19:24:01 +00:00
|
|
|
Builder builder = new Builder.from_resource("/im/dino/menu_app.ui");
|
2017-03-11 22:52:12 +00:00
|
|
|
MenuModel menu = builder.get_object("menu_app") as MenuModel;
|
|
|
|
|
|
|
|
set_app_menu(menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|