summaryrefslogtreecommitdiff
path: root/clutter-gtk/gtk-clutter-util.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@openedhand.com>2008-04-17 15:41:00 +0000
committerEmmanuele Bassi <ebassi@openedhand.com>2008-04-17 15:41:00 +0000
commit7e3bf4204b8c90aa075a3ef8c18faf39d24300a2 (patch)
treea102a54c994a4b563da889b06f2b18e184661f6d /clutter-gtk/gtk-clutter-util.c
parentf37accefda8f3556a6c3d26caeb597c6dbde117c (diff)
downloadclutter-gtk-7e3bf4204b8c90aa075a3ef8c18faf39d24300a2.tar.gz
2008-04-17 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-gtk/gtk-clutter-util.[ch]: Add utility functions to ClutterGtk to be able to retrieve the ClutterColor equivalent of the various style color components of a GtkWidget. * clutter-gtk/Makefile.am: Add gtk-clutter-util.[ch] to the build. * doc/reference/clutter-gtk-docs.sgml: Add the new section in the documentation. * examples/gtk-clutter-events.c (create_colors): Test the newly added color retrieval API.
Diffstat (limited to 'clutter-gtk/gtk-clutter-util.c')
-rw-r--r--clutter-gtk/gtk-clutter-util.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/clutter-gtk/gtk-clutter-util.c b/clutter-gtk/gtk-clutter-util.c
new file mode 100644
index 0000000..5ebd74b
--- /dev/null
+++ b/clutter-gtk/gtk-clutter-util.c
@@ -0,0 +1,146 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+#include <clutter/clutter.h>
+
+#include "gtk-clutter-util.h"
+
+/**
+ * SECTION:gtk-clutter-util
+ * @short_description: Utility functions for integrating Clutter in GTK+
+ *
+ * FIXME
+ *
+ */
+
+static inline void
+gtk_clutter_get_component (GtkWidget *widget,
+ GtkRcFlags component,
+ GtkStateType state,
+ ClutterColor *color)
+{
+ GtkStyle *style = gtk_widget_get_style (widget);
+ GdkColor gtk_color = { 0, };
+
+ switch (component)
+ {
+ case GTK_RC_FG:
+ gtk_color = style->fg[state];
+ break;
+
+ case GTK_RC_BG:
+ gtk_color = style->bg[state];
+ break;
+
+ case GTK_RC_TEXT:
+ gtk_color = style->text[state];
+ break;
+
+ case GTK_RC_BASE:
+ gtk_color = style->base[state];
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ color->red = (guint8) ((gtk_color.red / 65535.0) * 255);
+ color->green = (guint8) ((gtk_color.green / 65535.0) * 255);
+ color->blue = (guint8) ((gtk_color.blue / 65535.0) * 255);
+}
+
+/**
+ * gtk_clutter_get_fg_color:
+ * @widget:
+ * @state:
+ * @color:
+ *
+ * FIXME
+ *
+ * Since: 0.8
+ */
+void
+gtk_clutter_get_fg_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (state >= GTK_STATE_NORMAL &&
+ state <= GTK_STATE_INSENSITIVE);
+ g_return_if_fail (color != NULL);
+
+ gtk_clutter_get_component (widget, GTK_RC_FG, state, color);
+}
+
+/**
+ * gtk_clutter_get_bg_color:
+ * @widget:
+ * @state:
+ * @color:
+ *
+ * FIXME
+ *
+ * Since: 0.8
+ */
+void
+gtk_clutter_get_bg_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (state >= GTK_STATE_NORMAL &&
+ state <= GTK_STATE_INSENSITIVE);
+ g_return_if_fail (color != NULL);
+
+ gtk_clutter_get_component (widget, GTK_RC_BG, state, color);
+}
+
+/**
+ * gtk_clutter_get_text_color:
+ * @widget:
+ * @state:
+ * @color:
+ *
+ * FIXME
+ *
+ * Since: 0.8
+ */
+void
+gtk_clutter_get_text_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (state >= GTK_STATE_NORMAL &&
+ state <= GTK_STATE_INSENSITIVE);
+ g_return_if_fail (color != NULL);
+
+ gtk_clutter_get_component (widget, GTK_RC_TEXT, state, color);
+}
+
+/**
+ * gtk_clutter_get_base_color:
+ * @widget:
+ * @state:
+ * @color:
+ *
+ * FIXME
+ *
+ * Since: 0.8
+ */
+void
+gtk_clutter_get_base_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (state >= GTK_STATE_NORMAL &&
+ state <= GTK_STATE_INSENSITIVE);
+ g_return_if_fail (color != NULL);
+
+ gtk_clutter_get_component (widget, GTK_RC_BASE, state, color);
+}
+