Skip to content

Commit

Permalink
VariantWidget: Leaflet → NavigationView (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Oct 23, 2024
1 parent b3a2cee commit 7c76a4c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
1 change: 1 addition & 0 deletions data/installer.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<issue url="https://github.com/elementary/installer/issues/628">Port Installer to GTK4</issue>
<issue url="https://github.com/elementary/installer/issues/652">Use libxkbregistry</issue>
<issue url="https://github.com/elementary/installer/issues/692">No partitions visible when running without daemon</issue>
<issue url="https://github.com/elementary/installer/issues/745">Double clicking the language in first step leads to empty select list in next step</issue>
<issue url="https://github.com/elementary/installer/issues/775">Installer is not localized</issue>
<issue url="https://github.com/elementary/installer/issues/793">Clicking a partition in the custom install glitches the installer window</issue>
<issue url="https://github.com/elementary/installer/issues/806">Installer doesn't launch from Applications menu in Circe daily</issue>
Expand Down
5 changes: 2 additions & 3 deletions src/Views/KeyboardLayoutView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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 (() => {
Expand Down
6 changes: 2 additions & 4 deletions src/Views/LanguageView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 () {
Expand All @@ -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;
}
Expand Down
41 changes: 24 additions & 17 deletions src/Widgets/VariantWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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;

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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 ();
}

Expand Down

0 comments on commit 7c76a4c

Please sign in to comment.