diff --git a/Cargo.lock b/Cargo.lock index f3a90b4..d59fb29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -471,23 +471,22 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cairo-rs" -version = "0.18.5" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" +checksum = "bc1c415b7088381c53c575420899c34c9e6312df5ac5defd05614210e9fd6e1b" dependencies = [ "bitflags 2.4.1", "cairo-sys-rs", "glib", "libc", - "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.18.2" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +checksum = "75b6a5fefce2eadb8333e3c604ac964ba6573ec4f28bdd17f67032c4a2831831" dependencies = [ "glib-sys", "libc", @@ -1015,22 +1014,21 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.18.5" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" +checksum = "c311c47800051b87de1335e8792774d7cec551c91a0a3d109ab21d76b36f208f" dependencies = [ "gdk-pixbuf-sys", "gio", "glib", "libc", - "once_cell", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +checksum = "3dcbd04c1b2c4834cc008b4828bc917d062483b88d26effde6342e5622028f96" dependencies = [ "gio-sys", "glib-sys", @@ -1041,9 +1039,9 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edb019ad581f8ecf8ea8e4baa6df7c483a95b5a59be3140be6a9c3b0c632af6" +checksum = "6771942f85a2beaa220c64739395e4401b9fab4a52aba9b503fa1e6ed4d4d806" dependencies = [ "cairo-rs", "gdk-pixbuf", @@ -1056,9 +1054,9 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbab43f332a3cf1df9974da690b5bb0e26720ed09a228178ce52175372dcfef0" +checksum = "1eb95854fab65072023a7814434f003db571d6e45c287c0b0c540c1c78bdf6ae" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -1129,9 +1127,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gio" -version = "0.18.4" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" +checksum = "b3d1aaa2d926710a27f3b35822806b1513b393b71174dd2601c9d02fdab0cb82" dependencies = [ "futures-channel", "futures-core", @@ -1140,7 +1138,6 @@ dependencies = [ "gio-sys", "glib", "libc", - "once_cell", "pin-project-lite", "smallvec", "thiserror", @@ -1148,22 +1145,22 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +checksum = "bcf8e1d9219bb294636753d307b030c1e8a032062cba74f493c431a5c8b81ce4" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", - "winapi", + "windows-sys 0.52.0", ] [[package]] name = "glib" -version = "0.18.5" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" +checksum = "170ee82b9b44b3b5fd1cf4971d6cf0eadec38303bb84c7bcc4e6b95a18934e71" dependencies = [ "bitflags 2.4.1", "futures-channel", @@ -1177,20 +1174,18 @@ dependencies = [ "gobject-sys", "libc", "memchr", - "once_cell", "smallvec", "thiserror", ] [[package]] name = "glib-macros" -version = "0.18.5" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" +checksum = "2ff52fff7e4d1bb8598ae744e9bb90c8c76271712483c3f0ce931bee9814de85" dependencies = [ "heck", - "proc-macro-crate 2.0.1", - "proc-macro-error", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.46", @@ -1198,9 +1193,9 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +checksum = "630f097773d7c7a0bb3258df4e8157b47dc98bbfa0e60ad9ab56174813feced4" dependencies = [ "libc", "system-deps", @@ -1220,9 +1215,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +checksum = "c85e2b1080b9418dd0c58b498da3a5c826030343e0ef07bde6a955d28de54979" dependencies = [ "glib-sys", "libc", @@ -1231,9 +1226,9 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2228cda1505613a7a956cca69076892cfbda84fc2b7a62b94a41a272c0c401" +checksum = "147827e4f506f8073ac3ec5b28cc2255bdf3abc30f5b4e101a80506eebe11d2c" dependencies = [ "glib", "graphene-sys", @@ -1242,9 +1237,9 @@ dependencies = [ [[package]] name = "graphene-sys" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4144cee8fc8788f2a9b73dc5f1d4e1189d1f95305c4cb7bd9c1af1cfa31f59" +checksum = "236ed66cc9b18d8adf233716f75de803d0bf6fc806f60d14d948974a12e240d0" dependencies = [ "glib-sys", "libc", @@ -1254,9 +1249,9 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d958e351d2f210309b32d081c832d7de0aca0b077aa10d88336c6379bd01f7e" +checksum = "0e8ce8dee0fd87a11002214b1204ff18c9272fbd530408f0884a0f9b25dc31de" dependencies = [ "cairo-rs", "gdk4", @@ -1269,9 +1264,9 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bd9e3effea989f020e8f1ff3fa3b8c63ba93d43b899c11a118868853a56d55" +checksum = "2660a652da5b662d43924df19ba40d73f015ed427329ef51d2b1360a4e0dc0e4" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -1285,9 +1280,9 @@ dependencies = [ [[package]] name = "gtk4" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeb51aa3e9728575a053e1f43543cd9992ac2477e1b186ad824fd4adfb70842" +checksum = "7d26ffa3ec6316ccaa1df62d3e7f5bae1637c0acbb43f250fabef38319f73c64" dependencies = [ "cairo-rs", "field-offset", @@ -1306,12 +1301,12 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d57ec49cf9b657f69a05bca8027cff0a8dfd0c49e812be026fc7311f2163832f" +checksum = "c8b86439e9896f6f3f47c3d8077c5c8205174078760afdabd9098a8e9e937d97" dependencies = [ "anyhow", - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.1.0", "proc-macro-error", "proc-macro2", "quote", @@ -1320,9 +1315,9 @@ dependencies = [ [[package]] name = "gtk4-sys" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54d8c4aa23638ce9faa2caf7e2a27d4a1295af2155c8e8d28c4d4eeca7a65eb8" +checksum = "2abc0a6d356d59a3806021829ce6ed3e70bba3509b41a535fedcb09fae13fbc0" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -1610,9 +1605,9 @@ dependencies = [ [[package]] name = "libadwaita" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe7e70c06507ed10a16cda707f358fbe60fe0dc237498f78c686ade92fd979c" +checksum = "91b4990248b9e1ec5e72094a2ccaea70ec3809f88f6fd52192f2af306b87c5d9" dependencies = [ "gdk-pixbuf", "gdk4", @@ -1626,9 +1621,9 @@ dependencies = [ [[package]] name = "libadwaita-sys" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e10aaa38de1d53374f90deeb4535209adc40cc5dba37f9704724169bceec69a" +checksum = "23a748e4e92be1265cd9e93d569c0b5dfc7814107985aa6743d670ab281ea1a8" dependencies = [ "gdk4-sys", "gio-sys", @@ -2084,22 +2079,21 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pango" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" +checksum = "78d7f779b957728c74fd1a060dfa6d89a0bea792ebc50cc2da80e4e87282d69e" dependencies = [ "gio", "glib", "libc", - "once_cell", "pango-sys", ] [[package]] name = "pango-sys" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +checksum = "f52ef6a881c19fbfe3b1484df5cad411acaaba29dbec843941c3110d19f340ea" dependencies = [ "glib-sys", "gobject-sys", @@ -2177,9 +2171,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "polling" @@ -2229,12 +2223,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", + "toml_edit 0.21.1", ] [[package]] @@ -2678,9 +2671,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -2704,9 +2697,9 @@ dependencies = [ [[package]] name = "sourceview5" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88c5f976a113e947bc5ec67758b2960c0db4ca76f80fb410d7cd86cd456d9ee5" +checksum = "9f0bf70f2f1ac4624af22056f9c4cf58dccff73dafc7207b46fbd3df7b57410f" dependencies = [ "futures-channel", "futures-core", @@ -2722,9 +2715,9 @@ dependencies = [ [[package]] name = "sourceview5-sys" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29637cccd56075a37ba72c0cc8b8d599dbc1d857e30dadea97eaacbc29b7fd46" +checksum = "eac236ad7ce6dad2b819ced8b68b5a1cf4d968aa301cb9a7692470eb21f657be" dependencies = [ "gdk-pixbuf-sys", "gdk4-sys", @@ -2981,9 +2974,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -3012,6 +3005,17 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" diff --git a/Cargo.toml b/Cargo.toml index c9d39ff..cf3b23a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,12 @@ members = [ [dependencies] ntfy-daemon = { path = "./ntfy-daemon" } gettext-rs = { version = "0.7", features = ["gettext-system"] } -gtk = { version = "0.7", package = "gtk4", features = ["gnome_45"] } -gsv = { package = "sourceview5", version = "0.7" } +gtk = { version = "0.8", package = "gtk4", features = ["gnome_45"] } +gsv = { package = "sourceview5", version = "0.8" } once_cell = "1.14" tracing = "0.1.37" tracing-subscriber = "0.3" -adw = { version = "0.5", package = "libadwaita", features = ["v1_4"] } +adw = { version = "0.6", package = "libadwaita", features = ["v1_5"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" capnp = "0.18.0" diff --git a/README.md b/README.md index df9ae27..a5ec575 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,6 @@ https://ntfy.sh client application to receive everyday's notifications. The code is split between the GUI and the underlying ntfy-daemon. +## How to run +Use gnome-builder to clone and run the project. Note: after clicking the "run" +button a terminal may appear at the bottom: run the command "notify" in it. diff --git a/build-aux/com.ranfdev.Notify.Devel.json b/build-aux/com.ranfdev.Notify.Devel.json index 7eadf58..e5f7422 100644 --- a/build-aux/com.ranfdev.Notify.Devel.json +++ b/build-aux/com.ranfdev.Notify.Devel.json @@ -1,7 +1,7 @@ { "id": "com.ranfdev.Notify.Devel", "runtime": "org.gnome.Platform", - "runtime-version": "45", + "runtime-version": "master", "sdk": "org.gnome.Sdk", "sdk-extensions": [ "org.freedesktop.Sdk.Extension.rust-stable", diff --git a/data/resources/ui/subscription_info_dialog.blp b/data/resources/ui/subscription_info_dialog.blp index 823574a..f45e06f 100644 --- a/data/resources/ui/subscription_info_dialog.blp +++ b/data/resources/ui/subscription_info_dialog.blp @@ -1,10 +1,8 @@ using Gtk 4.0; using Adw 1; -template $SubscriptionInfoDialog : Adw.Window { - modal: true; +template $SubscriptionInfoDialog : Adw.Dialog { title: "Subscription Info"; - width-request: 240; Adw.ToolbarView { [top] Adw.HeaderBar {} diff --git a/data/resources/ui/window.blp b/data/resources/ui/window.blp index c80bf6e..95b4f0e 100644 --- a/data/resources/ui/window.blp +++ b/data/resources/ui/window.blp @@ -41,7 +41,7 @@ menu subscription_menu { } template $NotifyWindow : Adw.ApplicationWindow { - width-request: 240; + width-request: 360; height-request: 360; Adw.Breakpoint { condition ("max-width: 640sp") diff --git a/src/widgets/add_subscription_dialog.rs b/src/widgets/add_subscription_dialog.rs index 518e3c6..d6c9f70 100644 --- a/src/widgets/add_subscription_dialog.rs +++ b/src/widgets/add_subscription_dialog.rs @@ -3,11 +3,11 @@ use std::cell::RefCell; use adw::prelude::*; use adw::subclass::prelude::*; -use glib::once_cell::sync::Lazy; use glib::subclass::Signal; use gtk::gio; use gtk::glib; use ntfy_daemon::models; +use once_cell::sync::Lazy; #[derive(Default, Debug, Clone)] pub struct Widgets { @@ -28,14 +28,13 @@ mod imp { impl ObjectSubclass for AddSubscriptionDialog { const NAME: &'static str = "AddSubscriptionDialog"; type Type = super::AddSubscriptionDialog; - type ParentType = adw::Window; + type ParentType = adw::Dialog; fn class_init(klass: &mut Self::Class) { klass.add_binding_action( gtk::gdk::Key::Escape, gtk::gdk::ModifierType::empty(), "window.close", - None, ); klass.install_action("default.activate", None, |this, _, _| { this.emit_subscribe_request(); @@ -51,13 +50,12 @@ mod imp { } } impl WidgetImpl for AddSubscriptionDialog {} - impl WindowImpl for AddSubscriptionDialog {} - impl AdwWindowImpl for AddSubscriptionDialog {} + impl AdwDialogImpl for AddSubscriptionDialog {} } glib::wrapper! { pub struct AddSubscriptionDialog(ObjectSubclass) - @extends gtk::Widget, gtk::Window, adw::Window, + @extends gtk::Widget, adw::Dialog, @implements gio::ActionMap, gio::ActionGroup, gtk::Root; } @@ -75,72 +73,67 @@ impl AddSubscriptionDialog { fn build_ui(&self) { let imp = self.imp(); let obj = self.clone(); - obj.set_title(Some("Subscribe To Topic")); - obj.set_modal(true); - obj.set_default_width(360); + obj.set_title("Subscribe To Topic"); relm4_macros::view! { toolbar_view = adw::ToolbarView { add_top_bar: &adw::HeaderBar::new(), #[wrap(Some)] - set_content = &adw::Clamp { - #[wrap(Some)] - set_child = >k::Box { - set_orientation: gtk::Orientation::Vertical, - set_spacing: 12, - set_margin_end: 12, - set_margin_start: 12, - set_margin_top: 12, - set_margin_bottom: 12, - append = >k::Label { - add_css_class: "dim-label", - set_label: "Topics may not be password-protected, so choose a name that's not easy to guess. \ - Once subscribed, you can PUT/POST notifications.", - set_wrap: true, - set_xalign: 0.0, - set_wrap_mode: gtk::pango::WrapMode::WordChar - }, - append = >k::ListBox { - add_css_class: "boxed-list", - append: topic_entry = &adw::EntryRow { - set_title: "Topic", - set_activates_default: true, - add_suffix = >k::Button { - set_icon_name: "dice3-symbolic", - set_tooltip_text: Some("Generate name"), - set_valign: gtk::Align::Center, - add_css_class: "flat", - connect_clicked[topic_entry] => move |_| { - use rand::distributions::Alphanumeric; - use rand::{thread_rng, Rng}; - let mut rng = thread_rng(); - let chars: String = (0..10).map(|_| rng.sample(Alphanumeric) as char).collect(); - topic_entry.set_text(&chars); - } - } - }, - append: server_expander = &adw::ExpanderRow { - set_title: "Custom server...", - set_enable_expansion: imp.init_custom_server.get().is_some(), - set_expanded: imp.init_custom_server.get().is_some(), - set_show_enable_switch: true, - add_row: server_entry = &adw::EntryRow { - set_title: "Server", - set_text: imp.init_custom_server.get().map(|x| x.as_str()).unwrap_or(""), + set_content = >k::Box { + set_orientation: gtk::Orientation::Vertical, + set_spacing: 12, + set_margin_end: 12, + set_margin_start: 12, + set_margin_top: 12, + set_margin_bottom: 12, + append = >k::Label { + add_css_class: "dim-label", + set_label: "Topics may not be password-protected, so choose a name that's not easy to guess. \ + Once subscribed, you can PUT/POST notifications.", + set_wrap: true, + set_xalign: 0.0, + set_wrap_mode: gtk::pango::WrapMode::WordChar + }, + append = >k::ListBox { + add_css_class: "boxed-list", + append: topic_entry = &adw::EntryRow { + set_title: "Topic", + set_activates_default: true, + add_suffix = >k::Button { + set_icon_name: "dice3-symbolic", + set_tooltip_text: Some("Generate name"), + set_valign: gtk::Align::Center, + add_css_class: "flat", + connect_clicked[topic_entry] => move |_| { + use rand::distributions::Alphanumeric; + use rand::{thread_rng, Rng}; + let mut rng = thread_rng(); + let chars: String = (0..10).map(|_| rng.sample(Alphanumeric) as char).collect(); + topic_entry.set_text(&chars); } } }, - append: sub_btn = >k::Button { - set_label: "Subscribe", - add_css_class: "suggested-action", - add_css_class: "pill", - set_halign: gtk::Align::Center, - set_sensitive: false, - connect_clicked[obj] => move |_| { - obj.emit_subscribe_request(); + append: server_expander = &adw::ExpanderRow { + set_title: "Custom server...", + set_enable_expansion: imp.init_custom_server.get().is_some(), + set_expanded: imp.init_custom_server.get().is_some(), + set_show_enable_switch: true, + add_row: server_entry = &adw::EntryRow { + set_title: "Server", + set_text: imp.init_custom_server.get().map(|x| x.as_str()).unwrap_or(""), } } }, + append: sub_btn = >k::Button { + set_label: "Subscribe", + add_css_class: "suggested-action", + add_css_class: "pill", + set_halign: gtk::Align::Center, + set_sensitive: false, + connect_clicked[obj] => move |_| { + obj.emit_subscribe_request(); + } + } }, }, } @@ -175,7 +168,8 @@ impl AddSubscriptionDialog { sub_btn, }); - obj.set_content(Some(&toolbar_view)); + obj.set_content_width(480); + obj.set_child(Some(&toolbar_view)); } pub fn subscription(&self) -> Result> { let w = { self.imp().widgets.borrow().clone() }; diff --git a/src/widgets/subscription_info_dialog.rs b/src/widgets/subscription_info_dialog.rs index fa46779..c4dc5d3 100644 --- a/src/widgets/subscription_info_dialog.rs +++ b/src/widgets/subscription_info_dialog.rs @@ -26,7 +26,7 @@ mod imp { impl ObjectSubclass for SubscriptionInfoDialog { const NAME: &'static str = "SubscriptionInfoDialog"; type Type = super::SubscriptionInfoDialog; - type ParentType = adw::Window; + type ParentType = adw::Dialog; fn class_init(klass: &mut Self::Class) { klass.bind_template(); @@ -34,7 +34,6 @@ mod imp { gtk::gdk::Key::Escape, gtk::gdk::ModifierType::empty(), "window.close", - None, ); } @@ -73,13 +72,12 @@ mod imp { } } impl WidgetImpl for SubscriptionInfoDialog {} - impl WindowImpl for SubscriptionInfoDialog {} - impl AdwWindowImpl for SubscriptionInfoDialog {} + impl AdwDialogImpl for SubscriptionInfoDialog {} } glib::wrapper! { pub struct SubscriptionInfoDialog(ObjectSubclass) - @extends gtk::Widget, gtk::Window, adw::Window, + @extends gtk::Widget, adw::Dialog, @implements gio::ActionMap, gio::ActionGroup, gtk::Root; } diff --git a/src/widgets/window.rs b/src/widgets/window.rs index d45ace0..f912028 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -21,7 +21,7 @@ pub trait SpawnWithToast { ); } -impl> SpawnWithToast for W { +impl> SpawnWithToast for W { fn spawn_with_near_toast( &self, f: impl Future> + 'static, @@ -125,8 +125,7 @@ mod imp { let this = self.obj().clone(); let dialog = AddSubscriptionDialog::new(this.selected_subscription().map(|x| x.server())); - dialog.set_transient_for(Some(&self.obj().clone())); - dialog.present(); + dialog.present(&self.obj().clone()); let dc = dialog.clone(); dialog.connect_local("subscribe-request", true, move |_| { @@ -272,8 +271,7 @@ impl NotifyWindow { } fn show_subscription_info(&self) { let sub = SubscriptionInfoDialog::new(self.selected_subscription().unwrap()); - sub.set_transient_for(Some(self)); - sub.present(); + sub.present(self); } fn connect_items_changed(&self) { let this = self.clone(); @@ -448,7 +446,7 @@ impl NotifyWindow { chip } - fn build_subscription_row(sub: &Subscription) -> impl glib::IsA { + fn build_subscription_row(sub: &Subscription) -> impl IsA { let b = gtk::Box::builder().spacing(4).build(); let label = gtk::Label::builder()