diff options
author | venomade <venomade@venomade.com> | 2024-05-08 19:50:28 +0100 |
---|---|---|
committer | venomade <venomade@venomade.com> | 2024-05-08 19:50:28 +0100 |
commit | d1cb531ae9ad4427861bc60ad5430d75a69ff197 (patch) | |
tree | e946497573a592e5e429bd4ff503515eb9bc6a37 | |
parent | 68c483e8c599af1b29c5decf74d6ed43bcd89ef1 (diff) |
Remove LibAdwaita dependency
Remove LibAdwaita dependency to allow theming across platforms Remove Preferences and Toast as they are libadwaita components Remove now unneeded comments
-rw-r--r-- | Cargo.lock | 33 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | src/ui/mod.rs | 69 |
4 files changed, 7 insertions, 98 deletions
diff --git a/Cargo.lock b/Cargo.lock index 2ec0e08..2107d2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -408,38 +408,6 @@ dependencies = [ ] [[package]] -name = "libadwaita" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b4990248b9e1ec5e72094a2ccaea70ec3809f88f6fd52192f2af306b87c5d9" -dependencies = [ - "gdk-pixbuf", - "gdk4", - "gio", - "glib", - "gtk4", - "libadwaita-sys", - "libc", - "pango", -] - -[[package]] -name = "libadwaita-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a748e4e92be1265cd9e93d569c0b5dfc7814107985aa6743d670ab281ea1a8" -dependencies = [ - "gdk4-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "gtk4-sys", - "libc", - "pango-sys", - "system-deps", -] - -[[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -465,7 +433,6 @@ name = "number_of_the_day" version = "0.1.0" dependencies = [ "gtk4", - "libadwaita", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3b3cdf9..5bdd004 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -adw = { version = "0.6.0", package = "libadwaita", features = ["v1_4"] } gtk = { version = "0.8.0", package = "gtk4", features = ["v4_12"] } diff --git a/src/main.rs b/src/main.rs index 18613be..6cd96f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ mod notd; mod ui; -use adw::Application; +use gtk::Application; use gtk::glib; use gtk::prelude::*; use ui::{build_ui, load_css}; diff --git a/src/ui/mod.rs b/src/ui/mod.rs index c8201c1..263eb11 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,13 +1,9 @@ use super::notd; -use adw::{ - prelude::*, AboutWindow, ActionRow, Application, HeaderBar, PreferencesGroup, PreferencesPage, - PreferencesWindow, Toast, ToastOverlay, -}; use gtk::{ gdk::Display, gio::{ActionEntry, Menu, MenuItem}, prelude::*, - Align, ApplicationWindow, Box, Entry, EntryBuffer, Label, MenuButton, Orientation, + AboutDialog, Align, Application, ApplicationWindow, Box, Entry, EntryBuffer, HeaderBar, Label, MenuButton, Orientation, }; pub fn build_ui(app: &Application) { @@ -19,22 +15,6 @@ pub fn build_ui(app: &Application) { .use_markup(true) .build(); - let toast_overlay = ToastOverlay::new(); - - let current_date = notd::current_datetime(); - - let date_toast = Toast::builder() - .title(format!( - // TODO: Follow System Time Formatting - "Today's Date: {}/{}/{}", - current_date.day_of_month(), - current_date.month(), - current_date.year() - )) - .build(); - - date_toast.set_timeout(2); - let name_buffer = EntryBuffer::new(Some("Name")); let name_entry = Entry::with_buffer(&name_buffer); @@ -59,8 +39,6 @@ pub fn build_ui(app: &Application) { gtk_box.append(&subtitle_label); gtk_box.append(&number_label); - toast_overlay.set_child(Some(>k_box)); - name_entry.connect_changed(move |_| { let name = name_buffer.text(); let pnum = notd::personal_number_of_the_day(&name); @@ -77,13 +55,10 @@ pub fn build_ui(app: &Application) { titlebar.set_opacity(1.0); - let preferences_menu = MenuItem::new(Some("Preferences"), Some("win.preferences")); let about_menu = MenuItem::new(Some("About"), Some("win.about")); let menu = Menu::new(); - // TODO Work on Preferences - // menu.append_item(&preferences_menu); menu.append_item(&about_menu); let menu_button = MenuButton::builder() @@ -101,37 +76,26 @@ pub fn build_ui(app: &Application) { }) .build(); - let action_preferences = ActionEntry::builder("preferences") - .activate(|window: &ApplicationWindow, _, _| { - show_preferences(&window); - }) - .build(); - let window = ApplicationWindow::builder() .application(app) .title("Number of the Day") - .child(&toast_overlay) + .child(>k_box) .titlebar(&titlebar) .width_request(300) .height_request(400) .build(); - window.add_action_entries([action_about, action_preferences]); - - window.connect_show(move |_| { - toast_overlay.add_toast(date_toast.clone()); - }); + window.add_action_entries([action_about]); window.present(); } fn show_about(window: &ApplicationWindow) { - let about = AboutWindow::builder() + let about = AboutDialog::builder() .transient_for(window) - .application_name("Number of the Day") - .developer_name("Venomade") + .program_name("Number of the Day") + .authors(["Venomade"]) .version("0.0.1") - .developers(vec!["Venomade"]) .copyright("© 2024 Venomade") .license_type(gtk::License::Gpl30) .comments("Shows a number of the day, general or personal") @@ -141,27 +105,6 @@ fn show_about(window: &ApplicationWindow) { about.present(); } -fn show_preferences(window: &ApplicationWindow) { - let preferences_group = PreferencesGroup::builder().title("Preferences").build(); - - let action_row = ActionRow::builder().title("Action Row").build(); - - let preferences_page = PreferencesPage::builder() - .description("Bungus Bungus") - .title("Bungus") - .build(); - - let preferences = PreferencesWindow::builder() - .transient_for(window) - .display(&Display::default().expect("Could not get display")) - .content(&preferences_page) - .build(); - - preferences.set_visible_page(&preferences_page); - - preferences.present(); -} - pub fn load_css() { let provider = gtk::CssProvider::new(); provider.load_from_string(include_str!("ui.css")); |