summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSoren Berg <glimmer07@gmail.com>2009-07-23 16:41:13 +0000
committerglimmer07 <glimmer07@users.sourceforge.net>2009-07-23 16:41:13 +0000
commit3924d56a36693270a4e543f076c653f9ceaec355 (patch)
treee230d54c8e406ae427ed6371d699cf662c950753 /src
parentExperimental pause updating scheme. (diff)
downloadinkscape-3924d56a36693270a4e543f076c653f9ceaec355.tar.gz
inkscape-3924d56a36693270a4e543f076c653f9ceaec355.zip
Added set_color function.
(bzr r8254.1.21)
Diffstat (limited to 'src')
-rw-r--r--src/extension/dbus/document-interface.cpp24
-rw-r--r--src/extension/dbus/document-interface.h4
-rw-r--r--src/extension/dbus/document-interface.xml34
3 files changed, 61 insertions, 1 deletions
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)
{
@@ -675,6 +675,28 @@ document_interface_merge_css (DocumentInterface *object, gchar *shape,
}
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
@@ -179,6 +179,10 @@ 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 @@
<doc:seealso><doc:ref type="interface" to="Style Strings">Style Strings</doc:ref></doc:seealso>
</doc:doc>
</method>
+
+ <method name="set_color">
+ <arg type="s" name="shape" direction="in" >
+ <doc:doc>
+ <doc:summary>Any object, or 'document' to apply to document style.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="i" name="red" direction="in" >
+ <doc:doc>
+ <doc:summary>The red component.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="i" name="green" direction="in" >
+ <doc:doc>
+ <doc:summary>The green component.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="i" name="blue" direction="in" >
+ <doc:doc>
+ <doc:summary>The blue component.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="b" name="fill" direction="in" >
+ <doc:doc>
+ <doc:summary>True to change fill color, false for stroke color.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Modifies the fill or stroke color of an object (or the document style) based on RGB values.</doc:para>
+ <doc:para>Red green and blue must be between 0-255 inclusive.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
<method name="move_to_layer">
<arg type="s" name="objectname" direction="in" >