[librsvg] rsvg_state_get_stop_color(): New helper function to expose state->stop_color to Rust



commit 5c0a332f1af1db35a8e77d2232043268612f0613
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon May 29 19:11:21 2017 -0500

    rsvg_state_get_stop_color(): New helper function to expose state->stop_color to Rust

 rsvg-styles.c           |    9 +++++++++
 rsvg-styles.h           |    3 +++
 rust/src/drawing_ctx.rs |   14 ++++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 5469e8a..e4bbf8c 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -1703,3 +1703,12 @@ gboolean rsvg_state_get_cond_true (RsvgState *state)
 {
     return state->cond_true;
 }
+
+RsvgCssColorSpec *rsvg_state_get_stop_color (RsvgState *state)
+{
+    if (state->has_stop_color) {
+        return &state->stop_color;
+    } else {
+        return NULL;
+    }
+}
diff --git a/rsvg-styles.h b/rsvg-styles.h
index b2b792e..6dfab49 100644
--- a/rsvg-styles.h
+++ b/rsvg-styles.h
@@ -250,6 +250,9 @@ gboolean rsvg_state_has_overflow (RsvgState *state);
 G_GNUC_INTERNAL
 gboolean rsvg_state_get_cond_true (RsvgState *state);
 
+G_GNUC_INTERNAL
+RsvgCssColorSpec *rsvg_state_get_stop_color (RsvgState *state);
+
 G_END_DECLS
 
 #endif                          /* RSVG_STYLES_H */
diff --git a/rust/src/drawing_ctx.rs b/rust/src/drawing_ctx.rs
index 77ebd96..5c6d40a 100644
--- a/rust/src/drawing_ctx.rs
+++ b/rust/src/drawing_ctx.rs
@@ -6,6 +6,7 @@ extern crate libc;
 
 use self::glib::translate::*;
 
+use color::*;
 use node::RsvgNode;
 use node::NodeType;
 use path_builder::RsvgPathBuilder;
@@ -62,6 +63,7 @@ extern "C" {
     fn rsvg_state_is_overflow (state: *const RsvgState) -> glib_sys::gboolean;
     fn rsvg_state_has_overflow (state: *const RsvgState) -> glib_sys::gboolean;
     fn rsvg_state_get_cond_true (state: *const RsvgState) -> glib_sys::gboolean;
+    fn rsvg_state_get_stop_color (state: *const RsvgState) -> *const ColorSpec;
 
     fn rsvg_state_push (draw_ctx: *const RsvgDrawingCtx);
     fn rsvg_state_pop (draw_ctx: *const RsvgDrawingCtx);
@@ -232,3 +234,15 @@ pub fn state_pop (draw_ctx: *const RsvgDrawingCtx) {
         rsvg_state_pop (draw_ctx);
     }
 }
+
+pub fn state_get_stop_color (state: *const RsvgState) -> Option<ColorSpec> {
+    unsafe {
+        let spec_ptr = rsvg_state_get_stop_color (state);
+
+        if spec_ptr.is_null () {
+            None
+        } else {
+            Some (*spec_ptr)
+        }
+    }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]