libcosmic/examples/app_library/main.rs

47 lines
1,020 B
Rust
Raw Normal View History

2021-12-30 16:54:35 -05:00
use gtk4::gdk::Display;
use gtk4::prelude::*;
2021-12-30 17:53:06 -05:00
use gtk4::CssProvider;
2021-12-03 13:47:53 -05:00
use gtk4::StyleContext;
2022-01-14 17:53:11 -05:00
use window::AppLibraryWindow;
2022-01-14 17:53:11 -05:00
mod app_grid;
mod app_group;
mod grid_item;
2022-01-14 17:53:11 -05:00
mod group_grid;
mod utils;
mod window;
fn main() {
2021-12-30 16:54:35 -05:00
let app = gtk4::Application::new(Some("com.cosmic.app_library"), Default::default());
2022-01-14 17:53:11 -05:00
app.connect_startup(|_app| {
load_css();
});
2022-01-14 17:53:11 -05:00
app.connect_activate(|app| {
build_ui(app);
});
2021-12-03 13:47:53 -05:00
app.run();
}
fn load_css() {
// Load the css file and add it to the provider
let provider = CssProvider::new();
provider.load_from_data(include_bytes!("style.css"));
// Add the provider to the default screen
StyleContext::add_provider_for_display(
&Display::default().expect("Error initializing GTK CSS provider."),
&provider,
2021-12-30 16:54:35 -05:00
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
2021-12-03 13:47:53 -05:00
);
}
2021-12-30 16:54:35 -05:00
fn build_ui(app: &gtk4::Application) {
// Create a new custom window and show it
2022-01-14 17:53:11 -05:00
let window = AppLibraryWindow::new(app);
2022-01-14 18:24:31 -05:00
window.show();
}