libcosmic/examples/app_library/main.rs

46 lines
1,013 B
Rust
Raw Normal View History

2021-12-02 17:25:33 -05:00
mod app_group;
mod grid_item;
2021-12-06 10:56:45 -05:00
mod utils;
mod window;
use gtk::gdk::Display;
use gtk::prelude::*;
use gtk4 as gtk;
2021-12-03 13:47:53 -05:00
use gtk4::CssProvider;
use gtk4::StyleContext;
use window::Window;
fn main() {
2021-12-03 13:47:53 -05:00
let app = gtk::Application::new(Some("com.cosmic.app_library"), Default::default());
app.connect_startup(|app| {
load_css();
build_ui(&app);
});
// 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,
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
);
}
2021-12-03 13:47:53 -05:00
fn build_ui(app: &gtk::Application) {
// Create a new custom window and show it
let window = Window::new(app);
window.show();
}