From 7c76a4c676aeaec27908eab4a75b8ed1cc37f8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Oct 2024 14:46:02 -0700 Subject: [PATCH] =?UTF-8?q?VariantWidget:=20Leaflet=20=E2=86=92=20Navigati?= =?UTF-8?q?onView=20(#846)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/installer.metainfo.xml.in | 1 + src/Views/KeyboardLayoutView.vala | 5 ++-- src/Views/LanguageView.vala | 6 ++--- src/Widgets/VariantWidget.vala | 41 ++++++++++++++++++------------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/data/installer.metainfo.xml.in b/data/installer.metainfo.xml.in index 102ae8cdb..366e4d62c 100644 --- a/data/installer.metainfo.xml.in +++ b/data/installer.metainfo.xml.in @@ -74,6 +74,7 @@ Port Installer to GTK4 Use libxkbregistry No partitions visible when running without daemon + Double clicking the language in first step leads to empty select list in next step Installer is not localized Clicking a partition in the custom install glitches the installer window Installer doesn't launch from Applications menu in Circe daily diff --git a/src/Views/KeyboardLayoutView.vala b/src/Views/KeyboardLayoutView.vala index dc68a6e0e..bf1521c59 100644 --- a/src/Views/KeyboardLayoutView.vala +++ b/src/Views/KeyboardLayoutView.vala @@ -27,12 +27,11 @@ public class KeyboardLayoutView : AbstractInstallerView { valign = Gtk.Align.END }; - input_variant_widget = new VariantWidget (); + input_variant_widget = new VariantWidget (_("Input Language")); title = _("Select Keyboard Layout"); var title_label = new Gtk.Label (title) { - mnemonic_widget = input_variant_widget.main_listbox, valign = Gtk.Align.START }; @@ -107,7 +106,7 @@ public class KeyboardLayoutView : AbstractInstallerView { input_variant_widget.variant_listbox.select_row (input_variant_widget.variant_listbox.get_row_at_index (0)); - input_variant_widget.show_variants (_("Input Language"), layout.display_name); + input_variant_widget.show_variants (layout.display_name); }); input_variant_widget.variant_listbox.row_selected.connect (() => { diff --git a/src/Views/LanguageView.vala b/src/Views/LanguageView.vala index a353d5ae5..07f50cfb2 100644 --- a/src/Views/LanguageView.vala +++ b/src/Views/LanguageView.vala @@ -64,7 +64,7 @@ public class Installer.LanguageView : AbstractInstallerView { } }); - lang_variant_widget = new VariantWidget (); + lang_variant_widget = new VariantWidget (_("Languages")); lang_variant_widget.variant_listbox.set_sort_func ((Gtk.ListBoxSortFunc) CountryRow.compare); @@ -254,7 +254,7 @@ public class Installer.LanguageView : AbstractInstallerView { Environment.set_variable ("LANGUAGE", lang_code, true); Intl.textdomain (Build.GETTEXT_PACKAGE); - lang_variant_widget.show_variants (_("Languages"), lang_entry.name); + lang_variant_widget.show_variants (lang_entry.name); } private bool timeout () { @@ -275,8 +275,6 @@ public class Installer.LanguageView : AbstractInstallerView { select_stack.add_child (select_label); select_stack.set_visible_child (select_label); - lang_variant_widget.main_listbox.update_property (Gtk.AccessibleProperty.LABEL, label_text, -1); - select_number++; return GLib.Source.CONTINUE; } diff --git a/src/Widgets/VariantWidget.vala b/src/Widgets/VariantWidget.vala index 889c7fb60..b73da25b5 100644 --- a/src/Widgets/VariantWidget.vala +++ b/src/Widgets/VariantWidget.vala @@ -4,15 +4,20 @@ */ public class VariantWidget : Gtk.Frame { + public string main_title { get; construct; } + public Gtk.ListBox main_listbox { get; private set; } public Gtk.ListBox variant_listbox { get; private set; } public signal void going_to_main (); - private Gtk.Button back_button; private Gtk.Box variant_box; - private Gtk.Label variant_title; - private Adw.Leaflet leaflet; + private Adw.NavigationView navigation_view; + private Adw.NavigationPage variant_page; + + public VariantWidget (string main_title) { + Object (main_title: main_title); + } construct { main_listbox = new Gtk.ListBox (); @@ -22,6 +27,8 @@ public class VariantWidget : Gtk.Frame { hscrollbar_policy = NEVER }; + var main_page = new Adw.NavigationPage (main_scrolled, main_title); + variant_listbox = new Gtk.ListBox (); variant_listbox.activate_on_single_click = false; @@ -31,7 +38,7 @@ public class VariantWidget : Gtk.Frame { vexpand = true }; - back_button = new Gtk.Button () { + var back_button = new Gtk.Button.with_label (main_page.title) { halign = START, margin_top = 6, margin_end = 6, @@ -40,7 +47,7 @@ public class VariantWidget : Gtk.Frame { }; back_button.add_css_class (Granite.STYLE_CLASS_BACK_BUTTON); - variant_title = new Gtk.Label ("") { + var variant_title = new Gtk.Label ("") { hexpand = true, justify = CENTER, margin_end = 6, @@ -62,26 +69,26 @@ public class VariantWidget : Gtk.Frame { variant_box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); variant_box.append (variant_scrolled); - leaflet = new Adw.Leaflet () { - can_navigate_back = true, - can_unfold = false - }; - leaflet.append (main_scrolled); - leaflet.append (variant_box); + variant_page = new Adw.NavigationPage (variant_box, ""); + + navigation_view = new Adw.NavigationView (); + navigation_view.add (main_page); - child = leaflet; + child = navigation_view; vexpand = true; back_button.clicked.connect (() => { going_to_main (); - leaflet.navigate (BACK); + navigation_view.pop (); }); + + variant_page.bind_property ("title", variant_title, "label"); } - public void show_variants (string back_button_label, string variant_title_label) { - back_button.label = back_button_label; - variant_title.label = variant_title_label; - leaflet.visible_child = variant_box; + public void show_variants (string variant_title_label) { + variant_page.title = variant_title_label; + navigation_view.push (variant_page); + variant_listbox.get_selected_row ().grab_focus (); }