[gtk+/wip/style-changes] wip state changes
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/style-changes] wip state changes
- Date: Tue, 25 Nov 2014 03:41:00 +0000 (UTC)
commit cbf6545ef260c104fe3f7569452341cb4b8d0bcf
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Nov 24 19:40:25 2014 -0800
wip state changes
gtk/deprecated/gtkstyle.c | 57 +++++++++++++++++++++++++-------------------
gtk/gtkcellarea.c | 4 +-
gtk/gtknotebook.c | 17 +++++--------
gtk/gtkstylecontext.c | 2 +
gtk/gtkwindow.c | 3 +-
5 files changed, 45 insertions(+), 38 deletions(-)
---
diff --git a/gtk/deprecated/gtkstyle.c b/gtk/deprecated/gtkstyle.c
index 2c3bde6..c271982 100644
--- a/gtk/deprecated/gtkstyle.c
+++ b/gtk/deprecated/gtkstyle.c
@@ -616,11 +616,13 @@ static gboolean
set_color_from_context (GtkStyle *style,
GtkStateType state,
GtkStyleContext *context,
- GtkStateFlags flags,
GtkRcFlags prop)
{
GdkRGBA *color = NULL;
GdkColor *dest = { 0 }; /* Shut up gcc */
+ GtkStateFlags flags;
+
+ flags = gtk_style_context_get_state (context);
switch (prop)
{
@@ -674,26 +676,6 @@ set_color (GtkStyle *style,
GtkStateType state,
GtkRcFlags prop)
{
- GtkStateFlags flags;
-
- switch (state)
- {
- case GTK_STATE_ACTIVE:
- flags = GTK_STATE_FLAG_ACTIVE;
- break;
- case GTK_STATE_PRELIGHT:
- flags = GTK_STATE_FLAG_PRELIGHT;
- break;
- case GTK_STATE_SELECTED:
- flags = GTK_STATE_FLAG_SELECTED;
- break;
- case GTK_STATE_INSENSITIVE:
- flags = GTK_STATE_FLAG_INSENSITIVE;
- break;
- default:
- flags = 0;
- }
-
/* Try to fill in the values from the associated GtkStyleContext.
* Since fully-transparent black is a very common default (e.g. for
* background-color properties), and we must store the result in a GdkColor
@@ -701,11 +683,11 @@ set_color (GtkStyle *style,
* we give themes a fallback style class they can style, before using the
* hardcoded default values.
*/
- if (!set_color_from_context (style, state, context, flags, prop))
+ if (!set_color_from_context (style, state, context, prop))
{
gtk_style_context_save (context);
gtk_style_context_add_class (context, "gtkstyle-fallback");
- set_color_from_context (style, state, context, flags, prop);
+ set_color_from_context (style, state, context, prop);
gtk_style_context_restore (context);
}
}
@@ -715,6 +697,7 @@ gtk_style_update_from_context (GtkStyle *style)
{
GtkStylePrivate *priv;
GtkStateType state;
+ GtkStateFlags flags;
GtkBorder padding;
gint i;
@@ -722,6 +705,27 @@ gtk_style_update_from_context (GtkStyle *style)
for (state = GTK_STATE_NORMAL; state <= GTK_STATE_INSENSITIVE; state++)
{
+ switch (state)
+ {
+ case GTK_STATE_ACTIVE:
+ flags = GTK_STATE_FLAG_ACTIVE;
+ break;
+ case GTK_STATE_PRELIGHT:
+ flags = GTK_STATE_FLAG_PRELIGHT;
+ break;
+ case GTK_STATE_SELECTED:
+ flags = GTK_STATE_FLAG_SELECTED;
+ break;
+ case GTK_STATE_INSENSITIVE:
+ flags = GTK_STATE_FLAG_INSENSITIVE;
+ break;
+ default:
+ flags = 0;
+ }
+
+ gtk_style_context_save (priv->context);
+ gtk_style_context_set_state (priv->context, flags);
+
if (gtk_style_context_has_class (priv->context, "entry"))
{
gtk_style_context_save (priv->context);
@@ -744,15 +748,18 @@ gtk_style_update_from_context (GtkStyle *style)
set_color (style, priv->context, state, GTK_RC_BG);
set_color (style, priv->context, state, GTK_RC_FG);
}
+
+ gtk_style_context_restore (priv->context);
}
if (style->font_desc)
pango_font_description_free (style->font_desc);
- gtk_style_context_get (priv->context, 0,
+ flags = gtk_style_context_get_state (priv->context);
+ gtk_style_context_get (priv->context, flags,
"font", &style->font_desc,
NULL);
- gtk_style_context_get_padding (priv->context, 0, &padding);
+ gtk_style_context_get_padding (priv->context, flags, &padding);
style->xthickness = padding.left;
style->ythickness = padding.top;
diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c
index eb82de3..1ce312a 100644
--- a/gtk/gtkcellarea.c
+++ b/gtk/gtkcellarea.c
@@ -3561,7 +3561,7 @@ gtk_cell_area_inner_cell_area (GtkCellArea *area,
g_return_if_fail (inner_area != NULL);
context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
+ state = gtk_style_context_get_state (context);
gtk_style_context_get_padding (context, state, &border);
*inner_area = *cell_area;
@@ -3611,7 +3611,7 @@ gtk_cell_area_request_renderer (GtkCellArea *area,
g_return_if_fail (natural_size != NULL);
context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
+ state = gtk_style_context_get_state (context);
gtk_style_context_get_padding (context, state, &border);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index acb90e5..916ef58 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -2240,15 +2240,17 @@ get_padding_and_border (GtkNotebook *notebook,
GtkBorder *border)
{
GtkStyleContext *context;
+ GtkStateFlags state;
context = gtk_widget_get_style_context (GTK_WIDGET (notebook));
- gtk_style_context_get_padding (context, 0, border);
+ state = gtk_style_context_get_state (context);
+ gtk_style_context_get_padding (context, state, border);
if (notebook->priv->show_border || notebook->priv->show_tabs)
{
GtkBorder tmp;
- gtk_style_context_get_border (context, 0, &tmp);
+ gtk_style_context_get_border (context, state, &tmp);
border->top += tmp.top;
border->right += tmp.right;
border->bottom += tmp.bottom;
@@ -6247,7 +6249,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
if (page != priv->cur_page)
{
- GtkBorder active_padding, normal_padding, padding;
+ GtkBorder padding = {};
/* The active tab is by definition at least the same height as the inactive one.
* The padding we're building is the offset between the two tab states,
@@ -6259,16 +6261,11 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
gtk_style_context_save (context);
notebook_tab_prepare_style_context (notebook, page, context, TRUE);
- gtk_style_context_get_padding (context, GTK_STATE_FLAG_ACTIVE, &active_padding);
- gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &normal_padding);
+ /* gtk_style_context_get_padding (context, GTK_STATE_FLAG_ACTIVE, &active_padding); */
+ /* gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &normal_padding); */
gtk_style_context_restore (context);
- padding.top = MAX (0, active_padding.top - normal_padding.top);
- padding.right = MAX (0, active_padding.right - normal_padding.right);
- padding.bottom = MAX (0, active_padding.bottom - normal_padding.bottom);
- padding.left = MAX (0, active_padding.left - normal_padding.left);
-
switch (tab_pos)
{
case GTK_POS_TOP:
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 37f330d..5b2d8df 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -745,6 +745,8 @@ style_values_lookup_for_state (GtkStyleContext *context,
if (gtk_css_node_declaration_get_state (context->priv->info->decl) == state)
return g_object_ref (style_values_lookup (context));
+ g_warning ("State does not match current state");
+
decl = gtk_css_node_declaration_ref (context->priv->info->decl);
gtk_css_node_declaration_set_state (&decl, state);
values = _gtk_css_computed_values_new ();
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c01a47e..62a7caa 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6431,13 +6431,14 @@ get_shadow_width (GtkWidget *widget,
else
s = state | GTK_STATE_FLAG_BACKDROP;
+ gtk_style_context_set_state (context, s);
+
/* Always sum border + padding */
gtk_style_context_get_border (context, s, &border);
gtk_style_context_get_padding (context, s, &d);
sum_borders (&d, &border);
/* Calculate the size of the drop shadows ... */
- gtk_style_context_set_state (context, s);
shadows = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BOX_SHADOW);
_gtk_css_shadows_value_get_extents (shadows, &border);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]