From: Emmanuele Bassi Date: Thu, 25 Sep 2008 13:27:32 +0000 (+0000) Subject: 2008-09-25 Emmanuele Bassi X-Git-Url: http://git.maemo.org/git/?p=clutter-gtk;a=commitdiff_plain;h=fdf79f34c16a44815b45046be616ee2d8fe6d31b 2008-09-25 Emmanuele Bassi * clutter-gtk/gtk-clutter-util.[ch]: Add API for retrieving the various color components out of a GtkWidget style in form of a ClutterColor. * doc/reference/clutter-gtk-sections.txt: Include the newly added API in the generated reference. --- diff --git a/ChangeLog b/ChangeLog index 26c0dc2..0ea6288 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-09-25 Emmanuele Bassi + + * clutter-gtk/gtk-clutter-util.[ch]: Add API for retrieving + the various color components out of a GtkWidget style in form + of a ClutterColor. + + * doc/reference/clutter-gtk-sections.txt: Include the newly + added API in the generated reference. + 2008-09-15 Emmanuele Bassi Bug 1114 - Mouse wheel events ignored in GtkClutterEmbed diff --git a/clutter-gtk/gtk-clutter-util.c b/clutter-gtk/gtk-clutter-util.c index 952058e..6b61ebd 100644 --- a/clutter-gtk/gtk-clutter-util.c +++ b/clutter-gtk/gtk-clutter-util.c @@ -20,9 +20,24 @@ * GTK+ stock items and icon themes. */ +enum +{ + /* base symbols from GtkRcStyle */ + FG_COMPONENT = GTK_RC_FG, + BG_COMPONENT = GTK_RC_BG, + TEXT_COMPONENT = GTK_RC_TEXT, + BASE_COMPONENT = GTK_RC_BASE, + + /* symbols used by GtkStyle */ + LIGHT_COMPONENT, + MID_COMPONENT, + DARK_COMPONENT, + TEXT_AA_COMPONENT +}; + static inline void gtk_clutter_get_component (GtkWidget *widget, - GtkRcFlags component, + gint component, GtkStateType state, ClutterColor *color) { @@ -31,22 +46,38 @@ gtk_clutter_get_component (GtkWidget *widget, switch (component) { - case GTK_RC_FG: + case FG_COMPONENT: gtk_color = style->fg[state]; break; - case GTK_RC_BG: + case BG_COMPONENT: gtk_color = style->bg[state]; break; - case GTK_RC_TEXT: + case TEXT_COMPONENT: gtk_color = style->text[state]; break; - case GTK_RC_BASE: + case BASE_COMPONENT: gtk_color = style->base[state]; break; + case LIGHT_COMPONENT: + gtk_color = style->light[state]; + break; + + case MID_COMPONENT: + gtk_color = style->mid[state]; + break; + + case DARK_COMPONENT: + gtk_color = style->dark[state]; + break; + + case TEXT_AA_COMPONENT: + gtk_color = style->text_aa[state]; + break; + default: g_assert_not_reached (); break; @@ -79,7 +110,7 @@ gtk_clutter_get_fg_color (GtkWidget *widget, state <= GTK_STATE_INSENSITIVE); g_return_if_fail (color != NULL); - gtk_clutter_get_component (widget, GTK_RC_FG, state, color); + gtk_clutter_get_component (widget, FG_COMPONENT, state, color); } /** @@ -103,7 +134,7 @@ gtk_clutter_get_bg_color (GtkWidget *widget, state <= GTK_STATE_INSENSITIVE); g_return_if_fail (color != NULL); - gtk_clutter_get_component (widget, GTK_RC_BG, state, color); + gtk_clutter_get_component (widget, BG_COMPONENT, state, color); } /** @@ -127,7 +158,7 @@ gtk_clutter_get_text_color (GtkWidget *widget, state <= GTK_STATE_INSENSITIVE); g_return_if_fail (color != NULL); - gtk_clutter_get_component (widget, GTK_RC_TEXT, state, color); + gtk_clutter_get_component (widget, TEXT_COMPONENT, state, color); } /** @@ -151,7 +182,103 @@ gtk_clutter_get_base_color (GtkWidget *widget, state <= GTK_STATE_INSENSITIVE); g_return_if_fail (color != NULL); - gtk_clutter_get_component (widget, GTK_RC_BASE, state, color); + gtk_clutter_get_component (widget, BASE_COMPONENT, state, color); +} + +/** + * gtk_clutter_get_light_color: + * @widget: a #GtkWidget + * @state: a state + * @color: return location for a #ClutterColor + * + * Retrieves the light color of @widget for the given @state and copies it + * into @color. + * + * Since: 0.8 + */ +void +gtk_clutter_get_light_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, LIGHT_COMPONENT, state, color); +} + +/** + * gtk_clutter_get_mid_color: + * @widget: a #GtkWidget + * @state: a state + * @color: return location for a #ClutterColor + * + * Retrieves the mid color of @widget for the given @state and copies it + * into @color. + * + * Since: 0.8 + */ +void +gtk_clutter_get_mid_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, MID_COMPONENT, state, color); +} + +/** + * gtk_clutter_get_dark_color: + * @widget: a #GtkWidget + * @state: a state + * @color: return location for a #ClutterColor + * + * Retrieves the dark color of @widget for the given @state and copies it + * into @color. + * + * Since: 0.8 + */ +void +gtk_clutter_get_dark_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, DARK_COMPONENT, state, color); +} + +/** + * gtk_clutter_get_text_aa_color: + * @widget: a #GtkWidget + * @state: a state + * @color: return location for a #ClutterColor + * + * Retrieves the text-aa color of @widget for the given @state and copies it + * into @color. + * + * Since: 0.8 + */ +void +gtk_clutter_get_text_aa_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, TEXT_AA_COMPONENT, state, color); } /** diff --git a/clutter-gtk/gtk-clutter-util.h b/clutter-gtk/gtk-clutter-util.h index 7557426..61473c4 100644 --- a/clutter-gtk/gtk-clutter-util.h +++ b/clutter-gtk/gtk-clutter-util.h @@ -36,9 +36,21 @@ void gtk_clutter_get_bg_color (GtkWidget *widget, void gtk_clutter_get_text_color (GtkWidget *widget, GtkStateType state, ClutterColor *color); +void gtk_clutter_get_text_aa_color (GtkWidget *widget, + GtkStateType state, + ClutterColor *color); void gtk_clutter_get_base_color (GtkWidget *widget, GtkStateType state, ClutterColor *color); +void gtk_clutter_get_light_color (GtkWidget *widget, + GtkStateType state, + ClutterColor *color); +void gtk_clutter_get_dark_color (GtkWidget *widget, + GtkStateType state, + ClutterColor *color); +void gtk_clutter_get_mid_color (GtkWidget *widget, + GtkStateType state, + ClutterColor *color); ClutterActor *gtk_clutter_texture_new_from_pixbuf (GdkPixbuf *pixbuf); ClutterActor *gtk_clutter_texture_new_from_stock (GtkWidget *widget,