Skip to content

Commit 75c59df

Browse files
committed
update to libadwaita 1.5
1 parent fe3ae28 commit 75c59df

File tree

9 files changed

+145
-150
lines changed

9 files changed

+145
-150
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ members = [
1515
[dependencies]
1616
ntfy-daemon = { path = "./ntfy-daemon" }
1717
gettext-rs = { version = "0.7", features = ["gettext-system"] }
18-
gtk = { version = "0.7", package = "gtk4", features = ["gnome_45"] }
19-
gsv = { package = "sourceview5", version = "0.7" }
18+
gtk = { version = "0.8", package = "gtk4", features = ["gnome_45"] }
19+
gsv = { package = "sourceview5", version = "0.8" }
2020
once_cell = "1.14"
2121
tracing = "0.1.37"
2222
tracing-subscriber = "0.3"
23-
adw = { version = "0.5", package = "libadwaita", features = ["v1_4"] }
23+
adw = { version = "0.6", package = "libadwaita", features = ["v1_5"] }
2424
serde = { version = "1.0", features = ["derive"] }
2525
serde_json = "1.0"
2626
capnp = "0.18.0"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ https://ntfy.sh client application to receive everyday's notifications.
1818

1919
The code is split between the GUI and the underlying ntfy-daemon.
2020

21+
## How to run
22+
Use gnome-builder to clone and run the project. Note: after clicking the "run"
23+
button a terminal may appear at the bottom: run the command "notify" in it.

build-aux/com.ranfdev.Notify.Devel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "com.ranfdev.Notify.Devel",
33
"runtime": "org.gnome.Platform",
4-
"runtime-version": "45",
4+
"runtime-version": "master",
55
"sdk": "org.gnome.Sdk",
66
"sdk-extensions": [
77
"org.freedesktop.Sdk.Extension.rust-stable",

data/resources/ui/subscription_info_dialog.blp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using Gtk 4.0;
22
using Adw 1;
33

4-
template $SubscriptionInfoDialog : Adw.Window {
5-
modal: true;
4+
template $SubscriptionInfoDialog : Adw.Dialog {
65
title: "Subscription Info";
7-
width-request: 240;
86
Adw.ToolbarView {
97
[top]
108
Adw.HeaderBar {}

data/resources/ui/window.blp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ menu subscription_menu {
4141
}
4242

4343
template $NotifyWindow : Adw.ApplicationWindow {
44-
width-request: 240;
44+
width-request: 360;
4545
height-request: 360;
4646
Adw.Breakpoint {
4747
condition ("max-width: 640sp")

src/widgets/add_subscription_dialog.rs

Lines changed: 56 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use std::cell::RefCell;
33

44
use adw::prelude::*;
55
use adw::subclass::prelude::*;
6-
use glib::once_cell::sync::Lazy;
76
use glib::subclass::Signal;
87
use gtk::gio;
98
use gtk::glib;
109
use ntfy_daemon::models;
10+
use once_cell::sync::Lazy;
1111

1212
#[derive(Default, Debug, Clone)]
1313
pub struct Widgets {
@@ -28,14 +28,13 @@ mod imp {
2828
impl ObjectSubclass for AddSubscriptionDialog {
2929
const NAME: &'static str = "AddSubscriptionDialog";
3030
type Type = super::AddSubscriptionDialog;
31-
type ParentType = adw::Window;
31+
type ParentType = adw::Dialog;
3232

3333
fn class_init(klass: &mut Self::Class) {
3434
klass.add_binding_action(
3535
gtk::gdk::Key::Escape,
3636
gtk::gdk::ModifierType::empty(),
3737
"window.close",
38-
None,
3938
);
4039
klass.install_action("default.activate", None, |this, _, _| {
4140
this.emit_subscribe_request();
@@ -51,13 +50,12 @@ mod imp {
5150
}
5251
}
5352
impl WidgetImpl for AddSubscriptionDialog {}
54-
impl WindowImpl for AddSubscriptionDialog {}
55-
impl AdwWindowImpl for AddSubscriptionDialog {}
53+
impl AdwDialogImpl for AddSubscriptionDialog {}
5654
}
5755

5856
glib::wrapper! {
5957
pub struct AddSubscriptionDialog(ObjectSubclass<imp::AddSubscriptionDialog>)
60-
@extends gtk::Widget, gtk::Window, adw::Window,
58+
@extends gtk::Widget, adw::Dialog,
6159
@implements gio::ActionMap, gio::ActionGroup, gtk::Root;
6260
}
6361

@@ -75,72 +73,67 @@ impl AddSubscriptionDialog {
7573
fn build_ui(&self) {
7674
let imp = self.imp();
7775
let obj = self.clone();
78-
obj.set_title(Some("Subscribe To Topic"));
79-
obj.set_modal(true);
80-
obj.set_default_width(360);
76+
obj.set_title("Subscribe To Topic");
8177

8278
relm4_macros::view! {
8379
toolbar_view = adw::ToolbarView {
8480
add_top_bar: &adw::HeaderBar::new(),
8581
#[wrap(Some)]
86-
set_content = &adw::Clamp {
87-
#[wrap(Some)]
88-
set_child = &gtk::Box {
89-
set_orientation: gtk::Orientation::Vertical,
90-
set_spacing: 12,
91-
set_margin_end: 12,
92-
set_margin_start: 12,
93-
set_margin_top: 12,
94-
set_margin_bottom: 12,
95-
append = &gtk::Label {
96-
add_css_class: "dim-label",
97-
set_label: "Topics may not be password-protected, so choose a name that's not easy to guess. \
98-
Once subscribed, you can PUT/POST notifications.",
99-
set_wrap: true,
100-
set_xalign: 0.0,
101-
set_wrap_mode: gtk::pango::WrapMode::WordChar
102-
},
103-
append = &gtk::ListBox {
104-
add_css_class: "boxed-list",
105-
append: topic_entry = &adw::EntryRow {
106-
set_title: "Topic",
107-
set_activates_default: true,
108-
add_suffix = &gtk::Button {
109-
set_icon_name: "dice3-symbolic",
110-
set_tooltip_text: Some("Generate name"),
111-
set_valign: gtk::Align::Center,
112-
add_css_class: "flat",
113-
connect_clicked[topic_entry] => move |_| {
114-
use rand::distributions::Alphanumeric;
115-
use rand::{thread_rng, Rng};
116-
let mut rng = thread_rng();
117-
let chars: String = (0..10).map(|_| rng.sample(Alphanumeric) as char).collect();
118-
topic_entry.set_text(&chars);
119-
}
120-
}
121-
},
122-
append: server_expander = &adw::ExpanderRow {
123-
set_title: "Custom server...",
124-
set_enable_expansion: imp.init_custom_server.get().is_some(),
125-
set_expanded: imp.init_custom_server.get().is_some(),
126-
set_show_enable_switch: true,
127-
add_row: server_entry = &adw::EntryRow {
128-
set_title: "Server",
129-
set_text: imp.init_custom_server.get().map(|x| x.as_str()).unwrap_or(""),
82+
set_content = &gtk::Box {
83+
set_orientation: gtk::Orientation::Vertical,
84+
set_spacing: 12,
85+
set_margin_end: 12,
86+
set_margin_start: 12,
87+
set_margin_top: 12,
88+
set_margin_bottom: 12,
89+
append = &gtk::Label {
90+
add_css_class: "dim-label",
91+
set_label: "Topics may not be password-protected, so choose a name that's not easy to guess. \
92+
Once subscribed, you can PUT/POST notifications.",
93+
set_wrap: true,
94+
set_xalign: 0.0,
95+
set_wrap_mode: gtk::pango::WrapMode::WordChar
96+
},
97+
append = &gtk::ListBox {
98+
add_css_class: "boxed-list",
99+
append: topic_entry = &adw::EntryRow {
100+
set_title: "Topic",
101+
set_activates_default: true,
102+
add_suffix = &gtk::Button {
103+
set_icon_name: "dice3-symbolic",
104+
set_tooltip_text: Some("Generate name"),
105+
set_valign: gtk::Align::Center,
106+
add_css_class: "flat",
107+
connect_clicked[topic_entry] => move |_| {
108+
use rand::distributions::Alphanumeric;
109+
use rand::{thread_rng, Rng};
110+
let mut rng = thread_rng();
111+
let chars: String = (0..10).map(|_| rng.sample(Alphanumeric) as char).collect();
112+
topic_entry.set_text(&chars);
130113
}
131114
}
132115
},
133-
append: sub_btn = &gtk::Button {
134-
set_label: "Subscribe",
135-
add_css_class: "suggested-action",
136-
add_css_class: "pill",
137-
set_halign: gtk::Align::Center,
138-
set_sensitive: false,
139-
connect_clicked[obj] => move |_| {
140-
obj.emit_subscribe_request();
116+
append: server_expander = &adw::ExpanderRow {
117+
set_title: "Custom server...",
118+
set_enable_expansion: imp.init_custom_server.get().is_some(),
119+
set_expanded: imp.init_custom_server.get().is_some(),
120+
set_show_enable_switch: true,
121+
add_row: server_entry = &adw::EntryRow {
122+
set_title: "Server",
123+
set_text: imp.init_custom_server.get().map(|x| x.as_str()).unwrap_or(""),
141124
}
142125
}
143126
},
127+
append: sub_btn = &gtk::Button {
128+
set_label: "Subscribe",
129+
add_css_class: "suggested-action",
130+
add_css_class: "pill",
131+
set_halign: gtk::Align::Center,
132+
set_sensitive: false,
133+
connect_clicked[obj] => move |_| {
134+
obj.emit_subscribe_request();
135+
}
136+
}
144137
},
145138
},
146139
}
@@ -175,7 +168,8 @@ impl AddSubscriptionDialog {
175168
sub_btn,
176169
});
177170

178-
obj.set_content(Some(&toolbar_view));
171+
obj.set_content_width(480);
172+
obj.set_child(Some(&toolbar_view));
179173
}
180174
pub fn subscription(&self) -> Result<models::Subscription, Vec<ntfy_daemon::Error>> {
181175
let w = { self.imp().widgets.borrow().clone() };

src/widgets/subscription_info_dialog.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ mod imp {
2626
impl ObjectSubclass for SubscriptionInfoDialog {
2727
const NAME: &'static str = "SubscriptionInfoDialog";
2828
type Type = super::SubscriptionInfoDialog;
29-
type ParentType = adw::Window;
29+
type ParentType = adw::Dialog;
3030

3131
fn class_init(klass: &mut Self::Class) {
3232
klass.bind_template();
3333
klass.add_binding_action(
3434
gtk::gdk::Key::Escape,
3535
gtk::gdk::ModifierType::empty(),
3636
"window.close",
37-
None,
3837
);
3938
}
4039

@@ -73,13 +72,12 @@ mod imp {
7372
}
7473
}
7574
impl WidgetImpl for SubscriptionInfoDialog {}
76-
impl WindowImpl for SubscriptionInfoDialog {}
77-
impl AdwWindowImpl for SubscriptionInfoDialog {}
75+
impl AdwDialogImpl for SubscriptionInfoDialog {}
7876
}
7977

8078
glib::wrapper! {
8179
pub struct SubscriptionInfoDialog(ObjectSubclass<imp::SubscriptionInfoDialog>)
82-
@extends gtk::Widget, gtk::Window, adw::Window,
80+
@extends gtk::Widget, adw::Dialog,
8381
@implements gio::ActionMap, gio::ActionGroup, gtk::Root;
8482
}
8583

src/widgets/window.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait SpawnWithToast {
2121
);
2222
}
2323

24-
impl<W: glib::IsA<gtk::Widget>> SpawnWithToast for W {
24+
impl<W: IsA<gtk::Widget>> SpawnWithToast for W {
2525
fn spawn_with_near_toast<T, R: std::fmt::Display>(
2626
&self,
2727
f: impl Future<Output = Result<T, R>> + 'static,
@@ -125,8 +125,7 @@ mod imp {
125125
let this = self.obj().clone();
126126
let dialog =
127127
AddSubscriptionDialog::new(this.selected_subscription().map(|x| x.server()));
128-
dialog.set_transient_for(Some(&self.obj().clone()));
129-
dialog.present();
128+
dialog.present(&self.obj().clone());
130129

131130
let dc = dialog.clone();
132131
dialog.connect_local("subscribe-request", true, move |_| {
@@ -272,8 +271,7 @@ impl NotifyWindow {
272271
}
273272
fn show_subscription_info(&self) {
274273
let sub = SubscriptionInfoDialog::new(self.selected_subscription().unwrap());
275-
sub.set_transient_for(Some(self));
276-
sub.present();
274+
sub.present(self);
277275
}
278276
fn connect_items_changed(&self) {
279277
let this = self.clone();
@@ -448,7 +446,7 @@ impl NotifyWindow {
448446
chip
449447
}
450448

451-
fn build_subscription_row(sub: &Subscription) -> impl glib::IsA<gtk::Widget> {
449+
fn build_subscription_row(sub: &Subscription) -> impl IsA<gtk::Widget> {
452450
let b = gtk::Box::builder().spacing(4).build();
453451

454452
let label = gtk::Label::builder()

0 commit comments

Comments
 (0)