aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/application.vala33
-rw-r--r--main/src/ui/notifier_freedesktop.vala7
-rw-r--r--main/src/ui/notifier_gnotifications.vala1
-rw-r--r--main/src/ui/settings_dialog.vala30
4 files changed, 25 insertions, 46 deletions
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index 2e785224..d0fde297 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -113,13 +113,17 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
}
private void create_actions() {
- 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 preferences_action = new SimpleAction("preferences", null);
+ preferences_action.activate.connect(show_preferences_window);
+ add_action(preferences_action);
+
+ SimpleAction preferences_account_action = new SimpleAction("preferences-account", VariantType.INT32);
+ preferences_account_action.activate.connect((variant) => {
+ Account? account = db.get_account_by_id(variant.get_int32());
+ if (account == null) return;
+ show_preferences_account_window(account);
+ });
+ add_action(preferences_account_action);
SimpleAction about_action = new SimpleAction("about", null);
about_action.activate.connect(show_about_window);
@@ -233,17 +237,16 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
return Environment.get_variable("GTK_CSD") != "0";
}
- private void show_accounts_window() {
- ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interactor, db);
- dialog.set_transient_for(get_active_window());
- dialog.account_enabled.connect(add_connection);
- dialog.account_disabled.connect(remove_connection);
+ private void show_preferences_window() {
+ Ui.PreferencesWindow dialog = new Ui.PreferencesWindow() { transient_for = window };
+ dialog.model.populate(db, stream_interactor);
dialog.present();
}
- private void show_settings_window() {
- SettingsDialog dialog = new SettingsDialog();
- dialog.set_transient_for(get_active_window());
+ private void show_preferences_account_window(Account account) {
+ Ui.PreferencesWindow dialog = new Ui.PreferencesWindow() { transient_for = window };
+ dialog.model.populate(db, stream_interactor);
+ dialog.accounts_page.account_chosen(account);
dialog.present();
}
diff --git a/main/src/ui/notifier_freedesktop.vala b/main/src/ui/notifier_freedesktop.vala
index a1df5990..0d263dba 100644
--- a/main/src/ui/notifier_freedesktop.vala
+++ b/main/src/ui/notifier_freedesktop.vala
@@ -201,8 +201,13 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object {
HashTable<string, Variant> hash_table = new HashTable<string, Variant>(null, null);
hash_table["desktop-entry"] = new Variant.string(Dino.Application.get_default().get_application_id());
hash_table["category"] = new Variant.string("im.error");
+ string[] actions = new string[] {"default", "Open preferences"};
try {
- yield dbus_notifications.notify("Dino", 0, "im.dino.Dino", summary, body, new string[]{}, hash_table, -1);
+ uint32 notification_id = yield dbus_notifications.notify("Dino", 0, "im.dino.Dino", summary, body, actions, hash_table, -1);
+
+ add_action_listener(notification_id, "default", () => {
+ GLib.Application.get_default().activate_action("preferences-account", new Variant.int32(account.id));
+ });
} catch (Error e) {
warning("Failed showing connection error notification: %s", e.message);
}
diff --git a/main/src/ui/notifier_gnotifications.vala b/main/src/ui/notifier_gnotifications.vala
index 4d36620d..462cdf70 100644
--- a/main/src/ui/notifier_gnotifications.vala
+++ b/main/src/ui/notifier_gnotifications.vala
@@ -102,6 +102,7 @@ namespace Dino.Ui {
public async void notify_connection_error(Account account, ConnectionManager.ConnectionError error) {
Notification notification = new Notification(_("Could not connect to %s").printf(account.bare_jid.domainpart));
+ notification.set_default_action_and_target_value("app.preferences-account", new Variant.int32(account.id));
switch (error.source) {
case ConnectionManager.ConnectionError.Source.SASL:
notification.set_body("Wrong password");
diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala
deleted file mode 100644
index 3635879c..00000000
--- a/main/src/ui/settings_dialog.vala
+++ /dev/null
@@ -1,30 +0,0 @@
-using Gtk;
-
-namespace Dino.Ui {
-
-[GtkTemplate (ui = "/im/dino/Dino/settings_dialog.ui")]
-class SettingsDialog : Adw.PreferencesWindow {
-
- [GtkChild] private unowned Switch typing_switch;
- [GtkChild] private unowned Switch marker_switch;
- [GtkChild] private unowned Switch notification_switch;
- [GtkChild] private unowned Switch emoji_switch;
-
- Dino.Entities.Settings settings = Dino.Application.get_default().settings;
-
- public SettingsDialog() {
- Object();
-
- typing_switch.active = settings.send_typing;
- marker_switch.active = settings.send_marker;
- notification_switch.active = settings.notifications;
- emoji_switch.active = settings.convert_utf8_smileys;
-
- typing_switch.notify["active"].connect(() => { settings.send_typing = typing_switch.active; } );
- marker_switch.notify["active"].connect(() => { settings.send_marker = marker_switch.active; } );
- notification_switch.notify["active"].connect(() => { settings.notifications = notification_switch.active; } );
- emoji_switch.notify["active"].connect(() => { settings.convert_utf8_smileys = emoji_switch.active; });
- }
-}
-
-}