Skip to content

Commit 43414d9

Browse files
committed
Further work on pages infrastructure
1 parent 2f41c87 commit 43414d9

7 files changed

Lines changed: 67 additions & 12 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { GClass, Property, from } from "../gobjectify/gobjectify.js"
55
import { Installation } from "../flatpak.js"
66

77
@GClass()
8-
export class ContentPage extends from(Adw.Bin, {
9-
title: Property.string(),
10-
icon: Property.string(),
8+
export class BasePage extends from(Adw.NavigationPage, {
119
installations: Property.gobject(Gio.ListStore, { flags: "CONSTRUCT_ONLY" }).as<Gio.ListStore<Installation>>(),
10+
sidebar_title: Property.string(),
11+
icon_name: Property.string(),
1212
}) {}

‎src/pages/remotes_page.blp‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Gtk 4.0;
2+
using Adw 1;
3+
4+
template $RemotesPage: $BasePage {
5+
title: _("Manage Remotes");
6+
sidebar_title: _("Remotes");
7+
icon_name: "warehouse:server-pick-symbolic";
8+
9+
child: Adw.ToolbarView {
10+
[top]
11+
Adw.HeaderBar {}
12+
13+
content: Adw.StatusPage {
14+
title: "Hello";
15+
description: _("Hello World");
16+
};
17+
};
18+
}

‎src/pages/remotes_page.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Adw from "gi://Adw?version=1"
2+
3+
import { GClass, Property, from } from "../gobjectify/gobjectify.js"
4+
5+
import { BasePage } from "./base_page.js"
6+
7+
@GClass({ template: "resource:///io/github/flattool/Warehouse/pages/remotes_page.ui" })
8+
export class RemotesPage extends from(BasePage, {
9+
// installations: Property.gobject(Gio.ListStore),
10+
}) {}

‎src/window/main_window.blp‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ template $MainWindow: Adw.ApplicationWindow {
3333
};
3434

3535
content: Adw.ViewStack view_stack {
36-
$ContentPage {
37-
title: _("Page One");
38-
installations: installations;
39-
}
40-
41-
$ContentPage {
42-
title: _("Page Two");
36+
$RemotesPage remotes_page {
4337
installations: installations;
4438
}
4539
};

‎src/window/main_window.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import Gio from "gi://Gio?version=2.0"
44

55
import { GClass, Child, Property, from } from "../gobjectify/gobjectify.js"
66
import { Installation, get_installations } from "../flatpak.js"
7+
import { SidebarRow } from "./sidebar_row.js"
8+
import { BasePage } from "../pages/base_page.js"
79

8-
import { ContentPage } from "../widgets/content_page.js"
10+
import "../pages/remotes_page.js"
911

1012
@GClass({ template: "resource:///io/github/flattool/Warehouse/window/main_window.ui" })
1113
export class MainWindow extends from(Adw.ApplicationWindow, {
@@ -32,7 +34,10 @@ export class MainWindow extends from(Adw.ApplicationWindow, {
3234
const base_list: Gtk.SelectionModel<Adw.ViewStackPage> = this._view_stack.pages
3335
this._sidebar_list.bind_model(
3436
base_list,
35-
(item) => new Gtk.Label({ label: ((item as Adw.ViewStackPage).child as ContentPage).title }),
37+
(item) => new SidebarRow({
38+
icon_name: ((item as Adw.ViewStackPage).child as BasePage).icon_name,
39+
text: ((item as Adw.ViewStackPage).child as BasePage).sidebar_title,
40+
}),
3641
)
3742
}
3843

‎src/window/sidebar_row.blp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Gtk 4.0;
2+
3+
template $SidebarRow: Box {
4+
margin-start: 6;
5+
margin-end: 6;
6+
margin-top: 12;
7+
margin-bottom: 12;
8+
spacing: 12;
9+
10+
Image {
11+
icon-name: bind template.icon_name;
12+
}
13+
14+
Label {
15+
label: bind template.text;
16+
wrap: true;
17+
wrap-mode: word_char;
18+
}
19+
}

‎src/window/sidebar_row.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Gtk from "gi://Gtk?version=4.0"
2+
3+
import { GClass, Property, from } from "../gobjectify/gobjectify.js"
4+
5+
@GClass({ template: "resource:///io/github/flattool/Warehouse/window/sidebar_row.ui" })
6+
export class SidebarRow extends from(Gtk.Box, {
7+
icon_name: Property.string(),
8+
text: Property.string(),
9+
}) {}

0 commit comments

Comments
 (0)