From 161e4c19862be0ea6572f7701d37acc1c16b8147 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 20 Feb 2019 23:08:30 +0100 Subject: [PATCH] Add non-CSD alternative for more windows --- main/data/settings_dialog.ui | 2 +- main/src/ui/application.vala | 4 ++++ main/src/ui/contact_details/dialog.vala | 6 ++++-- main/src/ui/manage_accounts/dialog.vala | 2 +- main/src/ui/settings_dialog.vala | 2 +- main/src/ui/util/helper.vala | 2 +- plugins/omemo/src/contact_details_dialog.vala | 6 ++++-- plugins/omemo/src/manage_key_dialog.vala | 2 +- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui index 0fec0e1e..c76f347e 100644 --- a/main/data/settings_dialog.ui +++ b/main/data/settings_dialog.ui @@ -4,7 +4,7 @@ True - Preferences + Settings True True diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index e63caff8..132705cf 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -134,6 +134,10 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { set_accels_for_action("app.add_conference", new string[]{"G"}); } + public bool use_csd() { + 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()); diff --git a/main/src/ui/contact_details/dialog.vala b/main/src/ui/contact_details/dialog.vala index fd3b4751..8cbd8c54 100644 --- a/main/src/ui/contact_details/dialog.vala +++ b/main/src/ui/contact_details/dialog.vala @@ -30,12 +30,14 @@ public class Dialog : Gtk.Dialog { } public Dialog(StreamInteractor stream_interactor, Conversation conversation) { - Object(use_header_bar : 1); + Object(use_header_bar : Util.use_csd() ? 1 : 0); this.stream_interactor = stream_interactor; this.conversation = conversation; title = conversation.type_ == Conversation.Type.GROUPCHAT ? _("Conference Details") : _("Contact Details"); - (get_header_bar() as HeaderBar).set_subtitle(Util.get_conversation_display_name(stream_interactor, conversation)); + if (Util.use_csd()) { + (get_header_bar() as HeaderBar).set_subtitle(Util.get_conversation_display_name(stream_interactor, conversation)); + } setup_top(); contact_details.add.connect(add_entry); diff --git a/main/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala index 07656f3a..bcc0f017 100644 --- a/main/src/ui/manage_accounts/dialog.vala +++ b/main/src/ui/manage_accounts/dialog.vala @@ -78,7 +78,7 @@ public class Dialog : Gtk.Dialog { } public Dialog(StreamInteractor stream_interactor, Database db) { - Object(use_header_bar : 1); + Object(use_header_bar : Util.use_csd() ? 1 : 0); this.db = db; this.stream_interactor = stream_interactor; foreach (Account account in db.get_accounts()) { diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala index e40b2993..68c711dc 100644 --- a/main/src/ui/settings_dialog.vala +++ b/main/src/ui/settings_dialog.vala @@ -13,7 +13,7 @@ class SettingsDialog : Dialog { Dino.Entities.Settings settings = Dino.Application.get_default().settings; public SettingsDialog() { - Object(use_header_bar : 1); + Object(use_header_bar : Util.use_csd() ? 1 : 0); typing_checkbutton.active = settings.send_typing; marker_checkbutton.active = settings.send_marker; diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 5feda242..de05d753 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -265,7 +265,7 @@ public int get_only_emoji_count(string markup_text) { } public bool use_csd() { - return Environment.get_variable("GTK_CSD") != "0"; + return (GLib.Application.get_default() as Application).use_csd(); } } diff --git a/plugins/omemo/src/contact_details_dialog.vala b/plugins/omemo/src/contact_details_dialog.vala index 62d755d9..6899acf6 100644 --- a/plugins/omemo/src/contact_details_dialog.vala +++ b/plugins/omemo/src/contact_details_dialog.vala @@ -31,12 +31,14 @@ public class ContactDetailsDialog : Gtk.Dialog { [GtkChild] private Popover qrcode_popover; public ContactDetailsDialog(Plugin plugin, Account account, Jid jid) { - Object(use_header_bar : 1); + Object(use_header_bar : Environment.get_variable("GTK_CSD") != "0" ? 1 : 0); this.plugin = plugin; this.account = account; this.jid = jid; - (get_header_bar() as HeaderBar).set_subtitle(jid.bare_jid.to_string()); + if (Environment.get_variable("GTK_CSD") != "0") { + (get_header_bar() as HeaderBar).set_subtitle(jid.bare_jid.to_string()); + } int identity_id = plugin.db.identity.get_id(account.id); if (identity_id < 0) return; diff --git a/plugins/omemo/src/manage_key_dialog.vala b/plugins/omemo/src/manage_key_dialog.vala index 1d109a28..87d43de8 100644 --- a/plugins/omemo/src/manage_key_dialog.vala +++ b/plugins/omemo/src/manage_key_dialog.vala @@ -29,7 +29,7 @@ public class ManageKeyDialog : Gtk.Dialog { private int current_response; public ManageKeyDialog(Row device, Database db) { - Object(use_header_bar : 1); + Object(use_header_bar : Environment.get_variable("GTK_CSD") != "0" ? 1 : 0); this.device = device; this.db = db;