From e8f82fd328697542d2ee0233635b694827a5cc79 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 15 Sep 2024 20:04:52 +0200 Subject: Code cleanup: Remove broken disable CSD code --- main/CMakeLists.txt | 1 - main/data/conversation_list_titlebar.ui | 46 +++++------- main/data/conversation_list_titlebar_csd.ui | 33 -------- main/data/gresource.xml | 1 - .../ui/add_conversation/add_conference_dialog.vala | 87 ++++++---------------- .../ui/add_conversation/select_contact_dialog.vala | 22 ++---- main/src/ui/application.vala | 8 -- main/src/ui/conversation_list_titlebar.vala | 15 +--- .../conversation_titlebar.vala | 75 +------------------ main/src/ui/main_window.vala | 17 +---- main/src/ui/manage_accounts/dialog.vala | 2 +- main/src/ui/util/helper.vala | 4 - 12 files changed, 55 insertions(+), 256 deletions(-) delete mode 100644 main/data/conversation_list_titlebar_csd.ui (limited to 'main') diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 7e4a246d..2a32d23f 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -66,7 +66,6 @@ set(RESOURCE_LIST conversation_details.ui conversation_item_widget.ui conversation_list_titlebar.ui - conversation_list_titlebar_csd.ui conversation_row.ui conversation_view.ui file_default_widget.ui diff --git a/main/data/conversation_list_titlebar.ui b/main/data/conversation_list_titlebar.ui index 8fd8605b..afe10926 100644 --- a/main/data/conversation_list_titlebar.ui +++ b/main/data/conversation_list_titlebar.ui @@ -1,43 +1,33 @@ - + diff --git a/main/data/conversation_list_titlebar_csd.ui b/main/data/conversation_list_titlebar_csd.ui deleted file mode 100644 index afe10926..00000000 --- a/main/data/conversation_list_titlebar_csd.ui +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - False - - - - False - - - list-add-symbolic - normal - - - - - - - False - - - open-menu-symbolic - normal - - - - - - diff --git a/main/data/gresource.xml b/main/data/gresource.xml index 8717fa85..647f5116 100644 --- a/main/data/gresource.xml +++ b/main/data/gresource.xml @@ -15,7 +15,6 @@ conversation_details.ui conversation_item_widget.ui conversation_list_titlebar.ui - conversation_list_titlebar_csd.ui conversation_row.ui conversation_view.ui dino-conversation-list-placeholder-arrow.svg diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala index eac55ffc..ac721a63 100644 --- a/main/src/ui/add_conversation/add_conference_dialog.vala +++ b/main/src/ui/add_conversation/add_conference_dialog.vala @@ -21,7 +21,7 @@ public class AddConferenceDialog : Gtk.Dialog { private StreamInteractor stream_interactor; public AddConferenceDialog(StreamInteractor stream_interactor) { - Object(use_header_bar : Util.use_csd() ? 1 : 0); + Object(use_header_bar : 1); this.title = _("Join Channel"); this.modal = true; this.default_width = 460; @@ -39,36 +39,30 @@ public class AddConferenceDialog : Gtk.Dialog { } private void show_jid_add_view() { - // Rewire headerbar (if CSD) - if (Util.use_csd()) { - cancel_button.set_label(_("Cancel")); - cancel_button.clicked.disconnect(show_jid_add_view); - cancel_button.clicked.connect(on_cancel); - ok_button.label = _("Next"); - ok_button.sensitive = select_fragment.done; - ok_button.clicked.connect(on_next_button_clicked); - details_fragment.fragment_active = false; - details_fragment.notify["done"].disconnect(set_ok_sensitive_from_details); - select_fragment.notify["done"].connect(set_ok_sensitive_from_select); - } + cancel_button.set_label(_("Cancel")); + cancel_button.clicked.disconnect(show_jid_add_view); + cancel_button.clicked.connect(on_cancel); + ok_button.label = _("Next"); + ok_button.sensitive = select_fragment.done; + ok_button.clicked.connect(on_next_button_clicked); + details_fragment.fragment_active = false; + details_fragment.notify["done"].disconnect(set_ok_sensitive_from_details); + select_fragment.notify["done"].connect(set_ok_sensitive_from_select); stack.transition_type = StackTransitionType.SLIDE_RIGHT; stack.set_visible_child_name("select"); } private void show_conference_details_view() { - // Rewire headerbar (if CSD) - if (Util.use_csd()) { - cancel_button.set_icon_name("go-previous-symbolic"); - cancel_button.clicked.disconnect(on_cancel); - cancel_button.clicked.connect(show_jid_add_view); - ok_button.label = _("Join"); - ok_button.sensitive = details_fragment.done; - ok_button.clicked.disconnect(on_next_button_clicked); - details_fragment.fragment_active = true; - select_fragment.notify["done"].disconnect(set_ok_sensitive_from_select); - details_fragment.notify["done"].connect(set_ok_sensitive_from_details); - } + cancel_button.set_icon_name("go-previous-symbolic"); + cancel_button.clicked.disconnect(on_cancel); + cancel_button.clicked.connect(show_jid_add_view); + ok_button.label = _("Join"); + ok_button.sensitive = details_fragment.done; + ok_button.clicked.disconnect(on_next_button_clicked); + details_fragment.fragment_active = true; + select_fragment.notify["done"].disconnect(set_ok_sensitive_from_select); + details_fragment.notify["done"].connect(set_ok_sensitive_from_details); stack.transition_type = StackTransitionType.SLIDE_LEFT; stack.set_visible_child_name("details"); @@ -79,15 +73,11 @@ public class AddConferenceDialog : Gtk.Dialog { ok_button = new Button() { can_focus=true }; ok_button.add_css_class("suggested-action"); - if (Util.use_csd()) { - HeaderBar header_bar = get_header_bar() as HeaderBar; - header_bar.show_title_buttons = false; + HeaderBar header_bar = get_header_bar() as HeaderBar; + header_bar.show_title_buttons = false; - header_bar.pack_start(cancel_button); - header_bar.pack_end(ok_button); - -// ok_button.has_default = true; - } + header_bar.pack_start(cancel_button); + header_bar.pack_end(ok_button); } private void setup_jid_add_view() { @@ -110,22 +100,6 @@ public class AddConferenceDialog : Gtk.Dialog { Box wrap_box = new Box(Orientation.VERTICAL, 0); wrap_box.append(select_fragment); stack.add_named(wrap_box, "select"); - - if (!Util.use_csd()) { - Box box = new Box(Orientation.HORIZONTAL, 5) { halign=Align.END, margin_bottom=15, margin_start=80, margin_end=80 }; - - Button ok_button = new Button.with_label(_("Next")) { sensitive=false, halign = Align.END, can_focus=true }; - ok_button.add_css_class("suggested-action"); - ok_button.clicked.connect(on_next_button_clicked); - select_fragment.notify["done"].connect(() => { ok_button.sensitive = select_fragment.done; }); - Button cancel_button = new Button.with_label(_("Cancel")) { halign=Align.START }; - cancel_button.clicked.connect(on_cancel); - box.append(cancel_button); - box.append(ok_button); - wrap_box.append(box); - -// ok_button.has_default = true; - } } private void setup_conference_details_view() { @@ -135,21 +109,6 @@ public class AddConferenceDialog : Gtk.Dialog { Box wrap_box = new Box(Orientation.VERTICAL, 0); wrap_box.append(details_fragment); - if (!Util.use_csd()) { - Box box = new Box(Orientation.HORIZONTAL, 5) { halign=Align.END, margin_bottom=15, margin_start=80, margin_end=80 }; - - Button ok_button = new Button.with_label(_("Join")) { halign = Align.END, can_focus=true }; - ok_button.add_css_class("suggested-action"); - details_fragment.notify["done"].connect(() => { ok_button.sensitive = select_fragment.done; }); - details_fragment.ok_button = ok_button; - - Button cancel_button = new Button.with_label(_("Back")) { halign=Align.START }; - cancel_button.clicked.connect(show_jid_add_view); - box.append(cancel_button); - box.append(ok_button); - - wrap_box.append(box); - } stack.add_named(wrap_box, "details"); } diff --git a/main/src/ui/add_conversation/select_contact_dialog.vala b/main/src/ui/add_conversation/select_contact_dialog.vala index fb69257e..c0e5140a 100644 --- a/main/src/ui/add_conversation/select_contact_dialog.vala +++ b/main/src/ui/add_conversation/select_contact_dialog.vala @@ -20,7 +20,7 @@ public class SelectContactDialog : Gtk.Dialog { private Gee.List accounts; public SelectContactDialog(StreamInteractor stream_interactor, Gee.List accounts) { - Object(use_header_bar : Util.use_csd() ? 1 : 0); + Object(use_header_bar : 1); modal = true; this.default_width = 460; this.default_height = 550; @@ -46,22 +46,10 @@ public class SelectContactDialog : Gtk.Dialog { ok_button.sensitive = false; ok_button.visible = true; - if (Util.use_csd()) { - HeaderBar header_bar = get_header_bar() as HeaderBar; - header_bar.show_title_buttons = false; - - header_bar.pack_start(cancel_button); - header_bar.pack_end(ok_button); - } else { - Box box = new Box(Orientation.HORIZONTAL, 5) { halign=Align.END, margin_bottom=15, margin_start=80, margin_end=80 }; - - cancel_button.halign = Align.START; - ok_button.halign = Align.END; - box.append(cancel_button); - box.append(ok_button); - - get_content_area().append(box); - } + HeaderBar header_bar = get_header_bar() as HeaderBar; + header_bar.show_title_buttons = false; + header_bar.pack_start(cancel_button); + header_bar.pack_end(ok_button); cancel_button.clicked.connect(() => { close(); }); ok_button.clicked.connect(() => { diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 9d69c10b..706a61e6 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -233,10 +233,6 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application { add_action(deny_call_action); } - public bool use_csd() { - return Environment.get_variable("GTK_CSD") != "0"; - } - private void show_preferences_window() { Ui.PreferencesWindow dialog = new Ui.PreferencesWindow() { transient_for = window }; dialog.model.populate(db, stream_interactor); @@ -272,10 +268,6 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application { about_window.website = "https://dino.im/"; about_window.copyright = "Copyright © 2016-2023 - Dino Team"; about_window.license_type = License.GPL_3_0; - - if (!use_csd()) { - about_window.set_titlebar(null); - } about_window.present(); } diff --git a/main/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala index 7daab5e5..51dbdcf6 100644 --- a/main/src/ui/conversation_list_titlebar.vala +++ b/main/src/ui/conversation_list_titlebar.vala @@ -4,19 +4,8 @@ using Dino.Entities; namespace Dino.Ui { -[GtkTemplate (ui = "/im/dino/Dino/conversation_list_titlebar.ui")] -public class ConversationListTitlebar : Gtk.Box { - - [GtkChild] private unowned MenuButton add_button; - [GtkChild] private unowned MenuButton menu_button; - - public ConversationListTitlebar() { - create_add_menu(add_button, menu_button); - } -} - -public static Adw.HeaderBar get_conversation_list_titlebar_csd() { - Builder builder = new Builder.from_resource("/im/dino/Dino/conversation_list_titlebar_csd.ui"); +public static Adw.HeaderBar get_conversation_list_titlebar() { + Builder builder = new Builder.from_resource("/im/dino/Dino/conversation_list_titlebar.ui"); MenuButton add_button = (MenuButton) builder.get_object("add_button"); MenuButton menu_button = (MenuButton) builder.get_object("menu_button"); create_add_menu(add_button, menu_button); diff --git a/main/src/ui/conversation_titlebar/conversation_titlebar.vala b/main/src/ui/conversation_titlebar/conversation_titlebar.vala index 980d8d72..326528bd 100644 --- a/main/src/ui/conversation_titlebar/conversation_titlebar.vala +++ b/main/src/ui/conversation_titlebar/conversation_titlebar.vala @@ -6,80 +6,9 @@ using Dino.Entities; namespace Dino.Ui { -public interface ConversationTitlebar : Object { - public abstract string? subtitle { get; set; } - public abstract string? title { get; set; } +public class ConversationTitlebar : Object { - public abstract void insert_button(Widget button); - public abstract Widget get_widget(); - - public abstract bool back_button_visible{ get; set; } public signal void back_pressed(); -} - -public class ConversationTitlebarNoCsd : ConversationTitlebar, Object { - - public Box main = new Box(Orientation.HORIZONTAL, 0); - - public string? title { - get { return title_label.label; } - set { this.title_label.label = value; } - } - - public string? subtitle { - get { return subtitle_label.label; } - set { - this.subtitle_label.label = "" + value + ""; - this.subtitle_label.visible = (value != null); - } - } - - public bool back_button_visible { - get { return back_revealer.reveal_child; } - set { back_revealer.reveal_child = value; } - } - - private Box widgets_box = new Box(Orientation.HORIZONTAL, 7) { margin_start=15, valign=Align.END }; - private Label title_label = new Label("") { ellipsize=EllipsizeMode.END }; - private Label subtitle_label = new Label("") { use_markup=true, ellipsize=EllipsizeMode.END, visible=false }; - private Revealer back_revealer; - - construct { - Box content_box = new Box(Orientation.HORIZONTAL, 0) { margin_start=15, margin_end=10, hexpand=true }; - main.append(content_box); - - back_revealer = new Revealer() { visible = true, transition_type = RevealerTransitionType.SLIDE_RIGHT, transition_duration = 200, can_focus = false, reveal_child = false }; - Button back_button = new Button.from_icon_name("go-previous-symbolic") { visible = true, valign = Align.CENTER, use_underline = true }; - back_button.get_style_context().add_class("image-button"); - back_button.clicked.connect(() => back_pressed()); - back_revealer.set_child(back_button); - content_box.append(back_revealer); - - Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER, hexpand=true }; - content_box.append(titles_box); - - titles_box.append(title_label); - subtitle_label.attributes = new AttrList(); - subtitle_label.add_css_class("dim-label"); - titles_box.append(subtitle_label); - - content_box.append(widgets_box); - } - - public ConversationTitlebarNoCsd() { - main.add_css_class("dino-header-right"); - } - - public void insert_button(Widget button) { - widgets_box.prepend(button); - } - - public Widget get_widget() { - return main; - } -} - -public class ConversationTitlebarCsd : ConversationTitlebar, Object { public new string? title { get { return title_label.label; } set { title_label.label = value; } } public new string? subtitle { get { return subtitle_label.label; } set { subtitle_label.label = value; subtitle_label.visible = (value != null); } } @@ -93,7 +22,7 @@ public class ConversationTitlebarCsd : ConversationTitlebar, Object { private Label subtitle_label = new Label("") { use_markup=true, ellipsize=EllipsizeMode.END, visible=false }; private Revealer back_revealer; - public ConversationTitlebarCsd() { + public ConversationTitlebar() { Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER }; title_label.attributes = new AttrList(); title_label.attributes.insert(Pango.attr_weight_new(Weight.BOLD)); diff --git a/main/src/ui/main_window.vala b/main/src/ui/main_window.vala index ce71d413..e3110336 100644 --- a/main/src/ui/main_window.vala +++ b/main/src/ui/main_window.vala @@ -77,19 +77,10 @@ public class MainWindow : Adw.ApplicationWindow { } private void setup_headerbar() { - if (Util.use_csd()) { - conversation_list_titlebar = get_conversation_list_titlebar_csd(); - conversation_titlebar = new ConversationTitlebarCsd(); - leaflet.bind_property("folded", conversation_list_titlebar, "show-end-title-buttons", BindingFlags.SYNC_CREATE); - leaflet.bind_property("folded", conversation_titlebar.get_widget(), "show-start-title-buttons", BindingFlags.SYNC_CREATE); - } else { - Label title_label = new Label("Dino"); - HeaderBar titlebar = new HeaderBar() { title_widget=title_label, show_title_buttons=true }; - box.prepend(titlebar); - - conversation_list_titlebar = new ConversationListTitlebar(); - conversation_titlebar = new ConversationTitlebarNoCsd(); - } + conversation_list_titlebar = get_conversation_list_titlebar(); + conversation_titlebar = new ConversationTitlebar(); + leaflet.bind_property("folded", conversation_list_titlebar, "show-end-title-buttons", BindingFlags.SYNC_CREATE); + leaflet.bind_property("folded", conversation_titlebar.get_widget(), "show-start-title-buttons", BindingFlags.SYNC_CREATE); left_box.prepend(conversation_list_titlebar); right_box.prepend(conversation_titlebar.get_widget()); leaflet.notify["folded"].connect_after(() => conversation_titlebar.back_button_visible = leaflet.folded); diff --git a/main/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala index a326aeff..b67f3a49 100644 --- a/main/src/ui/manage_accounts/dialog.vala +++ b/main/src/ui/manage_accounts/dialog.vala @@ -69,7 +69,7 @@ public class Dialog : Gtk.Dialog { } public Dialog(StreamInteractor stream_interactor, Database db) { - Object(use_header_bar : Util.use_csd() ? 1 : 0); + Object(use_header_bar : 1); this.db = db; this.stream_interactor = stream_interactor; foreach (Account account in db.get_accounts()) { diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 45b96b94..e12dfe20 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -394,10 +394,6 @@ public void present_window(Window window) { #endif } -public bool use_csd() { - return ((Application) GLib.Application.get_default()).use_csd(); -} - public Widget? widget_if_tooltips_active(Widget w) { return use_tooltips() ? w : null; } -- cgit v1.2.3-70-g09d2