cleanup
This commit is contained in:
parent
a6c5b3b0b4
commit
04b4b88534
3 changed files with 32 additions and 21 deletions
|
|
@ -5,30 +5,36 @@ mod window;
|
|||
use gtk::gdk::Display;
|
||||
use gtk::prelude::*;
|
||||
use gtk4 as gtk;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::StyleContext;
|
||||
|
||||
use window::Window;
|
||||
|
||||
fn main() {
|
||||
let application = gtk::Application::new(
|
||||
Some("com.github.gtk-rs.examples.apps_launcher"),
|
||||
Default::default(),
|
||||
);
|
||||
let app = gtk::Application::new(Some("com.cosmic.app_library"), Default::default());
|
||||
app.connect_startup(|_app| load_css());
|
||||
|
||||
application.connect_activate(|app| {
|
||||
let provider = gtk::CssProvider::new();
|
||||
provider.load_from_data(include_bytes!("style.css"));
|
||||
gtk::StyleContext::add_provider_for_display(
|
||||
&Display::default().expect("Error initializing gtk css provider."),
|
||||
&provider,
|
||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
new_build_ui(app);
|
||||
app.connect_activate(|app| {
|
||||
build_ui(app);
|
||||
});
|
||||
|
||||
application.run();
|
||||
app.run();
|
||||
}
|
||||
|
||||
fn new_build_ui(app: >k::Application) {
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
fn build_ui(app: >k::Application) {
|
||||
// Create a new custom window and show it
|
||||
let window = Window::new(app);
|
||||
window.show();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue