summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-06-26 10:14:46 +0200
committerStefano Karapetsas <[email protected]>2014-06-26 10:14:46 +0200
commit1d630a530de8cafd7f4dc1a0a225a0fa335893de (patch)
tree0ecef65b3f546d302e62044ee11b01356fe9a46c
parent1d7eccd9994ca9f3ecb7d6f27043b84e6886088b (diff)
downloadmate-desktop-1d630a530de8cafd7f4dc1a0a225a0fa335893de.tar.bz2
mate-desktop-1d630a530de8cafd7f4dc1a0a225a0fa335893de.tar.xz
MateColorButton: Add function to get/set rgba color for GTK3
-rw-r--r--libmate-desktop/mate-colorbutton.c48
-rw-r--r--libmate-desktop/mate-colorbutton.h8
2 files changed, 56 insertions, 0 deletions
diff --git a/libmate-desktop/mate-colorbutton.c b/libmate-desktop/mate-colorbutton.c
index a98da71..e7a36d4 100644
--- a/libmate-desktop/mate-colorbutton.c
+++ b/libmate-desktop/mate-colorbutton.c
@@ -669,6 +669,32 @@ mate_color_button_set_color (MateColorButton *color_button,
g_object_notify (G_OBJECT (color_button), "color");
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+/**
+ * mate_color_button_set_rgba:
+ * @color_button: a #MateColorButton.
+ * @color: A #GdkRGBA to set the current color with.
+ *
+ * Sets the current color to be @color.
+ *
+ * Since: 1.9.1
+ **/
+void
+mate_color_button_set_rgba (MateColorButton *color_button,
+ const GdkRGBA *color)
+{
+ g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (color != NULL);
+
+ color_button->priv->color.red = color->red * 65535;
+ color_button->priv->color.green = color->green * 65535;
+ color_button->priv->color.blue = color->blue * 65535;
+
+ gtk_widget_queue_draw (color_button->priv->draw_area);
+
+ g_object_notify (G_OBJECT (color_button), "color");
+}
+#endif
/**
* mate_color_button_set_alpha:
@@ -712,6 +738,28 @@ mate_color_button_get_color (MateColorButton *color_button,
color->blue = color_button->priv->color.blue;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+/**
+ * mate_color_button_get_rgba:
+ * @color_button: a #MateColorButton.
+ * @color: a #GdkRGBA to fill in with the current color.
+ *
+ * Sets @color to be the current color in the #MateColorButton widget.
+ *
+ * Since: 1.9.1
+ **/
+void
+mate_color_button_get_rgba (MateColorButton *color_button,
+ GdkRGBA *color)
+{
+ g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+
+ color->red = color_button->priv->color.red / 65535.;
+ color->green = color_button->priv->color.green / 65535.;
+ color->blue = color_button->priv->color.blue / 65535.;
+}
+#endif
+
/**
* mate_color_button_get_alpha:
* @color_button: a #MateColorButton.
diff --git a/libmate-desktop/mate-colorbutton.h b/libmate-desktop/mate-colorbutton.h
index 2eeebc1..9bb0686 100644
--- a/libmate-desktop/mate-colorbutton.h
+++ b/libmate-desktop/mate-colorbutton.h
@@ -81,10 +81,18 @@ GtkWidget *mate_color_button_new (void);
GtkWidget *mate_color_button_new_with_color (const GdkColor *color);
void mate_color_button_set_color (MateColorButton *color_button,
const GdkColor *color);
+#if GTK_CHECK_VERSION(3, 0, 0)
+void mate_color_button_set_rgba (MateColorButton *color_button,
+ const GdkRGBA *color);
+#endif
void mate_color_button_set_alpha (MateColorButton *color_button,
guint16 alpha);
void mate_color_button_get_color (MateColorButton *color_button,
GdkColor *color);
+#if GTK_CHECK_VERSION(3, 0, 0)
+void mate_color_button_get_rgba (MateColorButton *color_button,
+ GdkRGBA *color);
+#endif
guint16 mate_color_button_get_alpha (MateColorButton *color_button);
void mate_color_button_set_use_alpha (MateColorButton *color_button,
gboolean use_alpha);