general: Use stable rust dependencies

This commit is contained in:
Christopher Davis 2021-06-27 15:28:35 -07:00
parent 4ef2b61ecd
commit 73188840ae
6 changed files with 158 additions and 183 deletions

195
Cargo.lock generated
View file

@ -18,13 +18,14 @@ checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
[[package]]
name = "ashpd"
version = "0.1.0"
source = "git+https://github.com/bilelmoussaoui/ashpd#d7ec2103565301b8476d6706ef34090e197b021c"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05092d6c609057712953f07e974752926ec8fcf5feed2782e9ed70a2ea0a2304"
dependencies = [
"enumflags2",
"serde",
"serde_repr",
"strum",
"strum_macros",
"strum 0.19.5",
"strum_macros 0.19.4",
"zbus",
"zvariant",
"zvariant_derive",
@ -87,12 +88,12 @@ checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"
[[package]]
name = "cairo-rs"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d32eecb1e806433cf68063c4548bbdc15cc56d35db19d685ab60909c4c85206"
dependencies = [
"bitflags",
"cairo-sys-rs",
"freetype",
"glib",
"libc",
"thiserror",
@ -100,8 +101,9 @@ dependencies = [
[[package]]
name = "cairo-sys-rs"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c9c3928781e8a017ece15eace05230f04b647457d170d2d9641c94a444ff80"
dependencies = [
"glib-sys",
"libc",
@ -126,15 +128,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cmake"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855"
dependencies = [
"cc",
]
[[package]]
name = "concurrent-queue"
version = "1.2.2"
@ -214,27 +207,6 @@ dependencies = [
"rustc_version",
]
[[package]]
name = "freetype"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bee38378a9e3db1cc693b4f88d166ae375338a0ff75cb8263e1c601d51f35dc6"
dependencies = [
"freetype-sys",
"libc",
]
[[package]]
name = "freetype-sys"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a"
dependencies = [
"cmake",
"libc",
"pkg-config",
]
[[package]]
name = "futures"
version = "0.3.13"
@ -344,8 +316,9 @@ dependencies = [
[[package]]
name = "gdk-pixbuf"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534192cb8f01daeb8fab2c8d4baa8f9aae5b7a39130525779f5c2608e235b10f"
dependencies = [
"gdk-pixbuf-sys",
"gio",
@ -355,8 +328,9 @@ dependencies = [
[[package]]
name = "gdk-pixbuf-sys"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f097c0704201fbc8f69c1762dc58c6947c8bb188b8ed0bc7e65259f1894fe590"
dependencies = [
"gio-sys",
"glib-sys",
@ -368,7 +342,8 @@ dependencies = [
[[package]]
name = "gdk4"
version = "0.1.0"
source = "git+https://github.com/gtk-rs/gtk4-rs#cc63cbb91f94f35e820fe6afb9f9aaa944904999"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c03132f21de5fe15ded4f950328fb44e007037aea7c6bbbc3f082493d5d3c164"
dependencies = [
"bitflags",
"cairo-rs",
@ -383,13 +358,15 @@ dependencies = [
[[package]]
name = "gdk4-sys"
version = "0.1.0"
source = "git+https://github.com/gtk-rs/gtk4-rs#cc63cbb91f94f35e820fe6afb9f9aaa944904999"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3453f8dc11a6167a7269355fcfbd6b96d10625395e87f77199e7dbba9077b58c"
dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
"gio-sys",
"glib-sys",
"gobject-sys",
"graphene-sys",
"libc",
"pango-sys",
"system-deps",
@ -416,8 +393,9 @@ dependencies = [
[[package]]
name = "gio"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86c6823b39d46d22cac2466de261f28d7f049ebc18f7b35296a42c7ed8a88325"
dependencies = [
"bitflags",
"futures-channel",
@ -432,8 +410,9 @@ dependencies = [
[[package]]
name = "gio-sys"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0a41df66e57fcc287c4bcf74fc26b884f31901ea9792ec75607289b456f48fa"
dependencies = [
"glib-sys",
"gobject-sys",
@ -444,8 +423,9 @@ dependencies = [
[[package]]
name = "glib"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0028bbfd270d0778540294abca11141d59cb474da4c1f61ca1e11f579c49247"
dependencies = [
"bitflags",
"futures-channel",
@ -462,12 +442,13 @@ dependencies = [
[[package]]
name = "glib-macros"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9eb7bdf41972a6f6dab5d72c23d22789f400059a43ba0d72b4bb2f8664d946a9"
dependencies = [
"anyhow",
"heck",
"proc-macro-crate",
"proc-macro-crate 1.0.0",
"proc-macro-error",
"proc-macro2",
"quote",
@ -476,8 +457,9 @@ dependencies = [
[[package]]
name = "glib-sys"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c1d60554a212445e2a858e42a0e48cece1bd57b311a19a9468f70376cf554ae"
dependencies = [
"libc",
"system-deps",
@ -507,8 +489,9 @@ dependencies = [
[[package]]
name = "gobject-sys"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa92cae29759dae34ab5921d73fff5ad54b3d794ab842c117e36cafc7994c3f5"
dependencies = [
"glib-sys",
"libc",
@ -517,8 +500,9 @@ dependencies = [
[[package]]
name = "graphene-rs"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1460a39f06e491e6112f27e71e51435c833ba370723224dd1743dfd1f201f19"
dependencies = [
"glib",
"graphene-sys",
@ -527,8 +511,9 @@ dependencies = [
[[package]]
name = "graphene-sys"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7d23fb7a9547e5f072a7e0cd49cd648fedeb786d122b106217511980cbb8962"
dependencies = [
"glib-sys",
"libc",
@ -539,7 +524,8 @@ dependencies = [
[[package]]
name = "gsk4"
version = "0.1.0"
source = "git+https://github.com/gtk-rs/gtk4-rs#cc63cbb91f94f35e820fe6afb9f9aaa944904999"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2699e9ff7ba3ca3582043bfd45ea3af3c45fa461fea75a369bcc6ab77eacde2"
dependencies = [
"bitflags",
"cairo-rs",
@ -554,7 +540,8 @@ dependencies = [
[[package]]
name = "gsk4-sys"
version = "0.1.0"
source = "git+https://github.com/gtk-rs/gtk4-rs#cc63cbb91f94f35e820fe6afb9f9aaa944904999"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27cf692f33ec2f438a89cb57018f57260b73193929da9d37b873e47a7662a7e0"
dependencies = [
"cairo-sys-rs",
"gdk4-sys",
@ -575,7 +562,8 @@ checksum = "1874c48e670519ce192093ac906c08a6dde7cb2d18b28722ef237726a39c3a63"
[[package]]
name = "gtk4"
version = "0.1.0"
source = "git+https://github.com/gtk-rs/gtk4-rs#cc63cbb91f94f35e820fe6afb9f9aaa944904999"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8801459abe49508a914c591d0cf355a6aea9762058334ba6efe63bdf40e479"
dependencies = [
"bitflags",
"cairo-rs",
@ -597,12 +585,13 @@ dependencies = [
[[package]]
name = "gtk4-macros"
version = "0.1.0"
source = "git+https://github.com/gtk-rs/gtk4-rs#cc63cbb91f94f35e820fe6afb9f9aaa944904999"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca4260cbbdad77f91c57b4836ff63c6c51dc79b2feadc83c0869e4d379dcbee5"
dependencies = [
"anyhow",
"heck",
"itertools 0.9.0",
"proc-macro-crate",
"itertools",
"proc-macro-crate 1.0.0",
"proc-macro-error",
"proc-macro2",
"quote",
@ -612,7 +601,8 @@ dependencies = [
[[package]]
name = "gtk4-sys"
version = "0.1.0"
source = "git+https://github.com/gtk-rs/gtk4-rs#cc63cbb91f94f35e820fe6afb9f9aaa944904999"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "580a7215a4d681e068cb1ea93e7293ca0d84b738d9b0c82b630199f21d3c82ef"
dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
@ -663,15 +653,6 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.10.0"
@ -689,16 +670,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libadwaita"
version = "0.1.0"
source = "git+https://gitlab.gnome.org/bilelmoussaoui/libadwaita-rs#f684b2bef4dc154e58a1f333bfee46741e86622e"
version = "0.1.0-alpha"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52d8221b476b16ee55b18bf4209e0fb5457c66375b9af8f8cef91ff930e82da6"
dependencies = [
"bitflags",
"gdk-pixbuf",
"gdk4",
"gio",
"glib",
"gtk4",
"lazy_static",
"libadwaita-sys",
"libc",
"pango",
@ -706,8 +686,9 @@ dependencies = [
[[package]]
name = "libadwaita-sys"
version = "0.1.0"
source = "git+https://gitlab.gnome.org/bilelmoussaoui/libadwaita-rs#f684b2bef4dc154e58a1f333bfee46741e86622e"
version = "0.1.0-alpha"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80594e5894e4145639c75164ee33cf607f42c667318475cb1d5db8132b77eab4"
dependencies = [
"gdk-pixbuf-sys",
"gdk4-sys",
@ -792,8 +773,9 @@ checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
name = "pango"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "415823a4fb9f1789785cd6e2d2413816f2ecff92380382969aaca9c400e13a19"
dependencies = [
"bitflags",
"glib",
@ -804,8 +786,9 @@ dependencies = [
[[package]]
name = "pango-sys"
version = "0.13.0"
source = "git+https://github.com/gtk-rs/gtk-rs#abd4ce6f6122c39e80fec457a29e8ad1aa063b81"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2367099ca5e761546ba1d501955079f097caa186bb53ce0f718dca99ac1942fe"
dependencies = [
"glib-sys",
"gobject-sys",
@ -878,6 +861,16 @@ dependencies = [
"toml",
]
[[package]]
name = "proc-macro-crate"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fdbd1df62156fbc5945f4762632564d7d038153091c3fcf1067f6aef7cff92"
dependencies = [
"thiserror",
"toml",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@ -1043,12 +1036,30 @@ dependencies = [
"winapi",
]
[[package]]
name = "strum"
version = "0.19.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b89a286a7e3b5720b9a477b23253bc50debac207c8d21505f8e70b36792f11b5"
[[package]]
name = "strum"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c"
[[package]]
name = "strum_macros"
version = "0.19.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e61bb0be289045cb80bfce000512e32d09f8337e54c186725da381377ad1f8d5"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "strum_macros"
version = "0.20.1"
@ -1080,10 +1091,10 @@ checksum = "14bd4dc3cd87e19c51f550d1b421c628074b3cf4c6daebc7ccbc8a03b237c751"
dependencies = [
"anyhow",
"heck",
"itertools 0.10.0",
"itertools",
"pkg-config",
"strum",
"strum_macros",
"strum 0.20.0",
"strum_macros 0.20.1",
"thiserror",
"toml",
"version-compare",
@ -1253,7 +1264,7 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87cc141cda72384bef359badf1808e391d3968f9299e8f3c3cbb78dafa1e0930"
dependencies = [
"proc-macro-crate",
"proc-macro-crate 0.1.5",
"proc-macro2",
"quote",
"syn",
@ -1277,7 +1288,7 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaee686340b5bff077d52423d8cc4f0f7cb323fe3f31ef676b8a3a2810bc53c5"
dependencies = [
"proc-macro-crate",
"proc-macro-crate 0.1.5",
"proc-macro2",
"quote",
"syn",

View file

@ -11,34 +11,21 @@ once_cell = "1.5.2"
pretty_env_logger = "0.4.0"
zbus = "1.3.0"
zvariant = "2.3.0"
gdk-pixbuf = "0.14.0"
gio = "0.14.0"
glib = "0.14.0"
cairo-rs = "0.14.0"
ashpd = "0.1.0"
libadwaita = "0.1.0-alpha"
[dependencies.gtk]
git = "https://github.com/gtk-rs/gtk4-rs"
package = "gtk4"
version = "0.1.0"
[dependencies.gdk]
git = "https://github.com/gtk-rs/gtk4-rs"
package = "gdk4"
[dependencies.gdk-pixbuf]
git = "https://github.com/gtk-rs/gtk-rs"
[dependencies.gio]
git = "https://github.com/gtk-rs/gtk-rs"
[dependencies.glib]
git = "https://github.com/gtk-rs/gtk-rs"
[dependencies.cairo]
git = "https://github.com/gtk-rs/gtk-rs"
package = "cairo-rs"
[dependencies.ashpd]
git = "https://github.com/bilelmoussaoui/ashpd"
version = "0.1.0"
[dependencies.gettext-rs]
version = "0.4.4"
features = ["gettext-system"]
[dependencies.libadwaita]
git = "https://gitlab.gnome.org/bilelmoussaoui/libadwaita-rs"

View file

@ -38,22 +38,18 @@ mod imp {
}
// Sets up the basics for the GObject
// The `#[glib::object_subclass] macro implements
// some boilerplate code for the object setup, e.g. get_type()
#[glib::object_subclass]
impl ObjectSubclass for IvApplication {
const NAME: &'static str = "IvApplication";
type Type = super::IvApplication;
type ParentType = gtk::Application;
type Interfaces = ();
type Instance = glib::subclass::simple::InstanceStruct<Self>;
type Class = glib::subclass::simple::ClassStruct<Self>;
// This macro implements some boilerplate code
// for the object setup, e.g. get_type()
glib::object_subclass!();
// Initialize with default values
fn new() -> Self {
let gtk_settings =
gtk::Settings::get_default().expect("Could not get default GTK settings");
gtk::Settings::default().expect("Could not get default GTK settings");
Self { gtk_settings }
}
@ -65,12 +61,12 @@ mod imp {
self.parent_constructed(obj);
// Set up the CSS and force dark theme
let display = gdk::Display::get_default().unwrap();
let display = gdk::Display::default().unwrap();
let provider = gtk::CssProvider::new();
provider.load_from_resource("/org/gnome/ImageViewer/image-viewer.css");
gtk::StyleContext::add_provider_for_display(&display, &provider, 600);
self.gtk_settings
.set_property_gtk_application_prefer_dark_theme(true);
.set_gtk_application_prefer_dark_theme(true);
// Set up the actions
obj.setup_actions();
@ -195,7 +191,7 @@ impl IvApplication {
.version(config::VERSION)
.build();
if let Some(window) = self.get_active_window() {
if let Some(window) = self.active_window() {
dialog.set_modal(true);
dialog.set_transient_for(Some(&window));
}

View file

@ -42,6 +42,6 @@ fn main() {
gio::resources_register(&res);
let app = IvApplication::new();
let ret = app.run(&std::env::args().collect::<Vec<_>>());
let ret = app.run();
std::process::exit(ret);
}

View file

@ -60,15 +60,11 @@ mod imp {
pub popover_menu_model: RefCell<Option<gio::MenuModel>>,
}
#[glib::object_subclass]
impl ObjectSubclass for IvImageView {
const NAME: &'static str = "IvImageView";
type Type = super::IvImageView;
type ParentType = libadwaita::Bin;
type Interfaces = ();
type Instance = subclass::simple::InstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
let connection =
@ -92,7 +88,7 @@ mod imp {
Self::bind_template(klass);
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self::Type>) {
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
@ -101,21 +97,21 @@ mod imp {
fn properties() -> &'static [glib::ParamSpec] {
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
vec![
glib::ParamSpec::boolean(
glib::ParamSpec::new_boolean(
"header-visible",
"Header visible",
"Whether or not the headerbar is visible",
false,
glib::ParamFlags::READWRITE,
),
glib::ParamSpec::object(
glib::ParamSpec::new_object(
"primary-menu-model",
"Primary Menu Model",
"The menu model for the menu button",
gio::MenuModel::static_type(),
glib::ParamFlags::READWRITE,
),
glib::ParamSpec::object(
glib::ParamSpec::new_object(
"popover-menu-model",
"Popover Menu Model",
"The menu model for the menu button",
@ -148,13 +144,8 @@ mod imp {
SIGNALS.as_ref()
}
fn get_property(
&self,
_obj: &Self::Type,
_id: usize,
psec: &glib::ParamSpec,
) -> glib::Value {
match psec.get_name() {
fn property(&self, _obj: &Self::Type, _id: usize, psec: &glib::ParamSpec) -> glib::Value {
match psec.name() {
"header-visible" => self.header_visible.get().to_value(),
"primary-menu-model" => self.menu_model.borrow().to_value(),
"popover-menu-model" => self.popover_menu_model.borrow().to_value(),
@ -169,10 +160,9 @@ mod imp {
value: &glib::Value,
psec: &glib::ParamSpec,
) {
match psec.get_name() {
match psec.name() {
"header-visible" => {
self.header_visible
.set(value.get().unwrap().unwrap_or_default());
self.header_visible.set(value.get::<bool>().unwrap());
}
"primary-menu-model" => {
let model: Option<gio::MenuModel> = value.get().unwrap();
@ -231,9 +221,9 @@ impl IvImageView {
}
fn load_dimensions_from_file(&self, file: &gio::File) -> anyhow::Result<()> {
let pb = file.get_path().context("No path for current file")?;
let pb = file.path().context("No path for current file")?;
let (_, width, height) =
gdk_pixbuf::Pixbuf::get_file_info(&pb.as_path()).context("Could not get file info")?;
gdk_pixbuf::Pixbuf::file_info(&pb.as_path()).context("Could not get file info")?;
log::debug!("Image dimensions: {} x {}", width, height);
let _ = self.emit_by_name("dimensions-loaded", &[&width, &height]);
@ -264,9 +254,9 @@ impl IvImageView {
pub fn print(&self) -> anyhow::Result<()> {
let imp = imp::IvImageView::from_instance(&self);
let file = imp.picture.get_file().context("No file to print")?;
let file = imp.picture.file().context("No file to print")?;
let operation = gtk::PrintOperation::new();
let path = file.get_path().context("No path for current file")?;
let path = file.path().context("No path for current file")?;
let pb = gdk_pixbuf::Pixbuf::from_file(path)?;
let setup = gtk::PageSetup::default();
@ -282,13 +272,13 @@ impl IvImageView {
});
operation.connect_draw_page(clone!(@weak pb => move |_, ctx, _| {
let cr = ctx.get_cairo_context().expect("No cairo context for print context");
let cr = ctx.cairo_context().expect("No cairo context for print context");
cr.set_source_pixbuf(&pb, 0.0, 0.0);
cr.paint();
}));
log::debug!("Running print operation...");
let root = self.get_root().context("Could not get root for widget")?;
let root = self.root().context("Could not get root for widget")?;
let window = root
.downcast_ref::<gtk::Window>()
.context("Could not downcast to GtkWindow")?;
@ -299,8 +289,8 @@ impl IvImageView {
pub fn uri(&self) -> Option<String> {
let imp = imp::IvImageView::from_instance(&self);
let file = imp.picture.get_file()?;
Some(file.get_uri().to_string())
let file = imp.picture.file()?;
Some(file.uri().to_string())
}
pub fn show_popover_at(&self, x: f64, y: f64) {
@ -322,9 +312,9 @@ impl IvImageView {
f: F,
) -> glib::SignalHandlerId {
self.connect_local("dimensions-loaded", true, move |values| {
let view = values[0].get::<Self>().unwrap().unwrap();
let width = values[1].get::<i32>().unwrap().unwrap();
let height = values[2].get::<i32>().unwrap().unwrap();
let view = values[0].get::<Self>().unwrap();
let width = values[1].get::<i32>().unwrap();
let height = values[2].get::<i32>().unwrap();
f(&view, width, height);

View file

@ -40,7 +40,13 @@ mod imp {
//
// For this derive macro, you need to have
// `use gtk::CompositeTemplate` in your code.
#[derive(Debug, CompositeTemplate)]
//
// Because all of our member fields implement the
// `Default` trait, we can use `#[derive(Default)]`.
// If some member fields did not implement default,
// we'd need to have a `new()` function in the
// `impl ObjectSubclass for $TYPE` section.
#[derive(Default, Debug, CompositeTemplate)]
#[template(resource = "/org/gnome/ImageViewer/gtk/window.ui")]
pub struct IvWindow {
// Template children are used with the
@ -58,33 +64,18 @@ mod imp {
pub open_gesture: TemplateChild<gtk::GestureClick>,
}
#[glib::object_subclass]
impl ObjectSubclass for IvWindow {
const NAME: &'static str = "IvWindow";
type Type = super::IvWindow;
type ParentType = libadwaita::ApplicationWindow;
type Interfaces = ();
type Instance = glib::subclass::simple::InstanceStruct<Self>;
type Class = glib::subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
// For the initial value, use this function.
headerbar: TemplateChild::default(),
stack: TemplateChild::default(),
status_page: TemplateChild::default(),
image_view: TemplateChild::default(),
open_gesture: TemplateChild::default(),
}
}
fn class_init(klass: &mut Self::Class) {
// bind_template() is a function generated by the
// CompositeTemplate macro to bind all children at once.
Self::bind_template(klass);
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self::Type>) {
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
@ -104,7 +95,7 @@ mod imp {
// Set help overlay
let builder = gtk::Builder::from_resource("/org/gnome/ImageViewer/gtk/help_overlay.ui");
let help_overlay = builder.get_object("help_overlay").unwrap();
let help_overlay = builder.object("help_overlay").unwrap();
obj.set_help_overlay(Some(&help_overlay));
// For callbacks, you will want to reference the GTK docs on
@ -146,7 +137,7 @@ impl IvWindow {
self,
"toggle-fullscreen",
clone!(@weak self as win => move |_, _| {
win.set_property_fullscreened(!win.get_property_fullscreened());
win.set_fullscreened(!win.is_fullscreened());
})
);
@ -207,7 +198,7 @@ impl IvWindow {
chooser.connect_response(
clone!(@weak self as win, @strong chooser => move |_, resp| {
if resp == gtk::ResponseType::Accept {
if let Some(file) = chooser.get_file() {
if let Some(file) = chooser.file() {
win.set_image_from_file(&file);
}
}
@ -249,12 +240,12 @@ impl IvWindow {
pub fn set_image_from_file(&self, file: &gio::File) {
let imp = imp::IvWindow::from_instance(self);
log::debug!("Loading file: {}", file.get_uri().to_string());
log::debug!("Loading file: {}", file.uri().to_string());
imp.image_view.set_image_from_file(file);
imp.stack.set_visible_child(&*imp.image_view);
if let Some(name) = file.get_basename() {
if let Some(name) = file.basename() {
self.set_title(Some(
name.file_name().expect("Missing name").to_str().unwrap(),
));
@ -294,18 +285,18 @@ impl IvWindow {
let mut final_width = img_width;
let mut final_height = img_height;
let header_height = imp.headerbar.get_height();
let header_height = imp.headerbar.height();
// Ensure the window surface exists
if !self.get_realized() {
if !self.is_realized() {
self.realize();
}
let display = gdk::Display::get_default().unwrap();
let display = gdk::Display::default().unwrap();
let monitor = display
.get_monitor_at_surface(&self.get_native().unwrap().get_surface().unwrap())
.monitor_at_surface(&self.native().unwrap().surface().unwrap())
.unwrap();
let monitor_geometry = monitor.get_geometry();
let monitor_geometry = monitor.geometry();
let monitor_width = monitor_geometry.width;
let monitor_height = monitor_geometry.height;