[librsvg: 20/38] Handle::get_property() - Implement
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 20/38] Handle::get_property() - Implement
- Date: Fri, 25 Jan 2019 19:39:03 +0000 (UTC)
commit 8945e7c8c7d115f0f152f58a51d6eedba0716167
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Jan 22 19:14:14 2019 -0600
Handle::get_property() - Implement
rsvg_internals/src/c_api.rs | 37 +++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/rsvg_internals/src/c_api.rs b/rsvg_internals/src/c_api.rs
index 8345ff7e..aac1dc0f 100644
--- a/rsvg_internals/src/c_api.rs
+++ b/rsvg_internals/src/c_api.rs
@@ -6,7 +6,7 @@ use glib::subclass;
use glib::subclass::object::ObjectClassSubclassExt;
use glib::subclass::prelude::*;
use glib::translate::*;
-use glib::{ParamFlags, ParamSpec};
+use glib::{ParamFlags, ParamSpec, ToValue};
use glib_sys;
use gobject_sys;
@@ -187,13 +187,34 @@ impl ObjectImpl for Handle {
}
fn get_property(&self, _obj: &glib::Object, id: usize) -> Result<glib::Value, ()> {
- // let prop = &PROPERTIES[id];
- //
- // match *prop {
- // subclass::Property("name", ..) => Ok(self.name.borrow().to_value()),
- // _ => unimplemented!(),
- // }
- unimplemented!();
+ let prop = &PROPERTIES[id];
+
+ match *prop {
+ subclass::Property("flags", ..) => Ok(self.load_flags.get().to_flags().to_value()),
+ subclass::Property("dpi-x", ..) => Ok(self.dpi.get().x().to_value()),
+ subclass::Property("dpi-y", ..) => Ok(self.dpi.get().y().to_value()),
+
+ subclass::Property("base-uri", ..) => Ok(self
+ .base_url
+ .borrow()
+ .as_ref()
+ .map(|url| url.as_str())
+ .to_value()),
+
+ subclass::Property("width", ..) => Ok(self.get_dimensions_no_error().width.to_value()),
+ subclass::Property("height", ..) => {
+ Ok(self.get_dimensions_no_error().height.to_value())
+ }
+
+ subclass::Property("em", ..) => Ok(self.get_dimensions_no_error().em.to_value()),
+ subclass::Property("ex", ..) => Ok(self.get_dimensions_no_error().ex.to_value()),
+
+ subclass::Property("title", ..) => Ok("".to_value()), // deprecated
+ subclass::Property("desc", ..) => Ok("".to_value()), // deprecated
+ subclass::Property("metadata", ..) => Ok("".to_value()), // deprecated
+
+ _ => unreachable!("invalid property id={} for RsvgHandle", id),
+ }
}
fn constructed(&self, obj: &glib::Object) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]