Skip to content

Commit

Permalink
gtk: use predifined css classes instead of custom ones
Browse files Browse the repository at this point in the history
  • Loading branch information
feschber committed Apr 12, 2024
1 parent f0099ee commit 81f65dc
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 36 deletions.
1 change: 1 addition & 0 deletions resources/client_row.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<property name="valign">center</property>
<property name="halign">center</property>
<property name="name">delete-button</property>
<style><class name="error"/></style>
</object>
</child>
</object>
Expand Down
2 changes: 0 additions & 2 deletions resources/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<gresource prefix="/de/feschber/LanMouse">
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">client_row.ui</file>
<file compressed="true">style.css</file>
<file compressed="true">style-dark.css</file>
</gresource>
<gresource prefix="/de/feschber/LanMouse/icons">
<file compressed="true" preprocess="xml-stripblanks">de.feschber.LanMouse.svg</file>
Expand Down
11 changes: 0 additions & 11 deletions resources/style-dark.css

This file was deleted.

11 changes: 0 additions & 11 deletions resources/style.css

This file was deleted.

2 changes: 2 additions & 0 deletions resources/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<property name="valign">center</property>
<property name="visible">false</property>
<property name="name">port-edit-apply</property>
<style><class name="success"/></style>
</object>
</child>
<child>
Expand All @@ -93,6 +94,7 @@
<property name="valign">center</property>
<property name="visible">false</property>
<property name="name">port-edit-cancel</property>
<style><class name="error"/></style>
</object>
</child>
</object>
Expand Down
13 changes: 1 addition & 12 deletions src/frontend/gtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::frontend::gtk::window::Window;

use adw::Application;
use gtk::{
gdk::Display, glib::clone, prelude::*, subclass::prelude::ObjectSubclassIsExt, CssProvider,
gdk::Display, glib::clone, prelude::*, subclass::prelude::ObjectSubclassIsExt,
IconTheme,
};
use gtk::{gio, glib, prelude::ApplicationExt};
Expand Down Expand Up @@ -51,23 +51,12 @@ fn gtk_main() -> glib::ExitCode {
.build();

app.connect_startup(|_| load_icons());
app.connect_startup(|_| load_css());
app.connect_activate(build_ui);

let args: Vec<&'static str> = vec![];
app.run_with_args(&args)
}

fn load_css() {
let provider = CssProvider::new();
provider.load_from_resource("de/feschber/LanMouse/style.css");
gtk::style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display."),
&provider,
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
);
}

fn load_icons() {
let display = &Display::default().expect("Could not connect to a display.");
let icon_theme = IconTheme::for_display(display);
Expand Down

0 comments on commit 81f65dc

Please sign in to comment.