Skip to content

Commit

Permalink
style: Use AdwApplication to auto load css
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Aug 5, 2021
1 parent a6af75a commit 426a703
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ log = "0.4"
pretty_env_logger = "0.4"
once_cell = "1.5"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
ashpd = { version = "0.2.0-alpha-3", features = ["feature_gtk4"] }
gtk = { package = "gtk4", version = "0.2" }
adw = { package = "libadwaita", version = "0.1.0-alpha" }
adw = { package = "libadwaita", version = "0.1.0-alpha-3" }
gst = { package = "gstreamer", version = "0.17" }
gst-plugin-gif = "0.7.0"
ashpd = { version = "0.2.0-alpha-3", features = ["feature_gtk4"] }
24 changes: 5 additions & 19 deletions src/application.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use adw::subclass::prelude::*;
use gettextrs::gettext;
use gtk::{
gdk, gio,
gio,
glib::{self, clone, WeakRef},
prelude::*,
subclass::prelude::*,
Expand Down Expand Up @@ -28,7 +29,7 @@ mod imp {
impl ObjectSubclass for Application {
const NAME: &'static str = "Application";
type Type = super::Application;
type ParentType = gtk::Application;
type ParentType = adw::Application;
}

impl ObjectImpl for Application {}
Expand All @@ -54,17 +55,17 @@ mod imp {
self.parent_startup(app);
gtk::Window::set_default_icon_name(APP_ID);

app.setup_css();
app.setup_actions();
}
}

impl GtkApplicationImpl for Application {}
impl AdwApplicationImpl for Application {}
}

glib::wrapper! {
pub struct Application(ObjectSubclass<imp::Application>)
@extends gio::Application, gtk::Application,
@extends gio::Application, gtk::Application, adw::Application,
@implements gio::ActionMap, gio::ActionGroup;
}

Expand Down Expand Up @@ -124,21 +125,6 @@ impl Application {
self.set_accels_for_action("win.cancel-delay", &["<Primary>c"]);
}

fn setup_css(&self) {
let provider = gtk::CssProvider::new();
provider.load_from_resource("/io/github/seadve/Kooha/style.css");
if let Some(display) = gdk::Display::default() {
gtk::StyleContext::add_provider_for_display(
&display,
&provider,
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
);

log::info!("is_display_composited: {}", display.is_composited());
log::info!("is_display_rgba: {}", display.is_rgba());
}
}

fn select_saving_location(&self) {
let settings = Settings::new();
let chooser = gtk::FileChooserDialogBuilder::new()
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ fn main() {

gst::init().expect("Unable to start gstreamer");
gtk::init().expect("Unable to start GTK4");
adw::init();

gstgif::plugin_register_static().expect("Failed to register gif plugin");

Expand Down
4 changes: 4 additions & 0 deletions src/widgets/area_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,9 @@ impl AreaSelector {
pub fn select_area(&self) {
self.fullscreen();
self.present();

let display = gdk::Display::default().unwrap();
log::info!("is_display_composited: {}", display.is_composited());
log::info!("is_display_rgba: {}", display.is_rgba());
}
}

0 comments on commit 426a703

Please sign in to comment.