From f74e68b487b57f7cf05a567aba02ff561b5aa557 Mon Sep 17 00:00:00 2001 From: glimmer07 Date: Thu, 23 Jul 2009 16:41:13 +0000 Subject: [PATCH] Added set_color function. --- src/extension/dbus/document-interface.cpp | 24 +++++++++++++++- src/extension/dbus/document-interface.h | 4 +++ src/extension/dbus/document-interface.xml | 34 +++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 76eeec509..53674790a 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -76,7 +76,7 @@ get_object_by_name (SPDesktop *desk, gchar *name, GError **error) } gboolean -dbus_check_string (gchar *string, GError ** error, gchar * errorstr) +dbus_check_string (gchar *string, GError ** error, const gchar * errorstr) { if (string == NULL) { @@ -674,6 +674,28 @@ document_interface_merge_css (DocumentInterface *object, gchar *shape, return TRUE; } +gboolean +document_interface_set_color (DocumentInterface *object, gchar *shape, + int r, int g, int b, gboolean fill, GError **error) +{ + gchar style[15]; + if (r<0 || r>255 || g<0 || g>255 || b<0 || b>255) + { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Given (%d,%d,%d). All values must be between 0-255 inclusive.", r, g, b); + return FALSE; + } + + if (fill) + snprintf(style, 15, "fill:#%.2x%.2x%.2x", r, g, b); + else + snprintf(style, 15, "stroke:#%.2x%.2x%.2x", r, g, b); + + if (strcmp(shape, "document") == 0) + return document_interface_document_merge_css (object, style, error); + + return document_interface_merge_css (object, shape, style, error); +} + gboolean document_interface_move_to_layer (DocumentInterface *object, gchar *shape, gchar *layerstr, GError **error) diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h index ff0452a14..413673862 100644 --- a/src/extension/dbus/document-interface.h +++ b/src/extension/dbus/document-interface.h @@ -178,6 +178,10 @@ gboolean document_interface_merge_css (DocumentInterface *object, gchar *shape, gchar *stylestring, GError **error); +gboolean +document_interface_set_color (DocumentInterface *object, gchar *shape, + int r, int g, int b, gboolean fill, GError **error); + gboolean document_interface_move_to_layer (DocumentInterface *object, gchar *shape, gchar *layerstr, GError **error); diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml index 7c16c6d1e..3ccae9556 100644 --- a/src/extension/dbus/document-interface.xml +++ b/src/extension/dbus/document-interface.xml @@ -665,6 +665,40 @@ Style Strings + + + + + Any object, or 'document' to apply to document style. + + + + + The red component. + + + + + The green component. + + + + + The blue component. + + + + + True to change fill color, false for stroke color. + + + + + Modifies the fill or stroke color of an object (or the document style) based on RGB values. + Red green and blue must be between 0-255 inclusive. + + + -- 2.30.2