Skip to content

Commit c41723d

Browse files
committed
Add widget stack in tab, add InputPage
1 parent 6411ea8 commit c41723d

File tree

8 files changed

+138
-41
lines changed

8 files changed

+138
-41
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.blp]
2+
indent_style = space
3+
indent_size = 2

Cargo.lock

Lines changed: 26 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data/resources/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
blueprints = custom_target('blueprints',
22
input: files(
33
'ui/window.blp',
4-
'ui/shortcuts.blp'
4+
'ui/shortcuts.blp',
5+
'ui/input_page.blp'
56
),
67
output: '.',
78
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],

data/resources/resources.gresource.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<!-- see https://gtk-rs.org/gtk4-rs/git/docs/gtk4/struct.Application.html#automatic-resources -->
55
<file compressed="true" preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">ui/shortcuts.ui</file>
66
<file compressed="true" preprocess="xml-stripblanks">ui/window.ui</file>
7+
<file compressed="true" preprocess="xml-stripblanks">ui/input_page.ui</file>
78
</gresource>
89
</gresources>

data/resources/ui/input_page.blp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Gtk 4.0;
2+
using Adw 1;
3+
4+
template InputPage: Gtk.Box {
5+
margin-top: 8;
6+
margin-bottom: 8;
7+
margin-start: 8;
8+
margin-end: 8;
9+
orientation: vertical;
10+
valign: center;
11+
Gtk.Label label {
12+
styles ["title-2"]
13+
label: "Text";
14+
xalign: 0.0;
15+
margin-top: 8;
16+
margin-bottom: 8;
17+
margin-start: 8;
18+
margin-end: 8;
19+
wrap: true;
20+
}
21+
Gtk.Entry entry {
22+
margin-bottom: 8;
23+
margin-start: 8;
24+
margin-end: 8;
25+
}
26+
}

src/input_page.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
use gtk::glib;
2+
use gtk::prelude::*;
3+
use gtk::subclass::prelude::*;
4+
use glib::subclass::prelude::*;
5+
use gtk::CompositeTemplate;
6+
use gtk::TemplateChild;
7+
8+
mod imp {
9+
pub use super::*;
10+
#[derive(CompositeTemplate, Default)]
11+
#[template(resource = "/com/ranfdev/Geopard/ui/input_page.ui")]
12+
pub struct InputPage {
13+
#[template_child]
14+
pub label: TemplateChild<gtk::Label>,
15+
#[template_child]
16+
pub entry: TemplateChild<gtk::Entry>,
17+
}
18+
19+
20+
#[glib::object_subclass]
21+
impl ObjectSubclass for InputPage {
22+
// `NAME` needs to match `class` attribute of template
23+
const NAME: &'static str = "InputPage";
24+
type Type = super::InputPage;
25+
type ParentType = gtk::Box;
26+
27+
fn class_init(klass: &mut Self::Class) {
28+
klass.bind_template();
29+
}
30+
31+
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
32+
obj.init_template();
33+
}
34+
}
35+
36+
impl ObjectImpl for InputPage {}
37+
impl WidgetImpl for InputPage {}
38+
impl BoxImpl for InputPage {}
39+
}
40+
41+
glib::wrapper! {
42+
pub struct InputPage(ObjectSubclass<imp::InputPage>)
43+
@extends gtk::Box, gtk::Widget;
44+
}
45+
46+
impl InputPage {
47+
pub fn new() -> Self {
48+
glib::Object::new(&[]).unwrap()
49+
}
50+
}

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod gemini;
1717
mod macros;
1818
mod tab;
1919
mod window;
20+
mod input_page;
2021

2122
use gtk::prelude::*;
2223

0 commit comments

Comments
 (0)