Compare commits
3 Commits
css-variab
...
wip/style-
Author | SHA1 | Date | |
---|---|---|---|
|
cbf6545ef2 | ||
|
8c17c90a82 | ||
|
8d2671d00e |
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -2834,13 +2834,15 @@ get_icon_width (GtkEntry *entry,
|
||||
GtkStyleContext *context;
|
||||
GtkBorder padding;
|
||||
gint width;
|
||||
GtkStateFlags state;
|
||||
|
||||
if (!icon_info)
|
||||
return 0;
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
|
||||
state = gtk_style_context_get_state (context);
|
||||
gtk_entry_prepare_context_for_icon (entry, context, icon_pos);
|
||||
gtk_style_context_get_padding (context, 0, &padding);
|
||||
gtk_style_context_get_padding (context, state, &padding);
|
||||
|
||||
_gtk_icon_helper_get_size (icon_info->icon_helper, context,
|
||||
&width, NULL);
|
||||
@@ -3406,19 +3408,17 @@ _gtk_entry_get_borders (GtkEntry *entry,
|
||||
GtkWidget *widget = GTK_WIDGET (entry);
|
||||
GtkBorder padding, border;
|
||||
GtkStyleContext *context;
|
||||
GtkStateFlags state;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
state = gtk_style_context_get_state (context);
|
||||
gtk_style_context_get_padding (context, state, &padding);
|
||||
gtk_style_context_get_border (context, state, &border);
|
||||
|
||||
gtk_style_context_get_padding (context, 0, &padding);
|
||||
gtk_style_context_get_border (context, 0, &border);
|
||||
|
||||
if (border_out != NULL)
|
||||
{
|
||||
border_out->top = padding.top + border.top;
|
||||
border_out->bottom = padding.bottom + border.bottom;
|
||||
border_out->left = padding.left + border.left;
|
||||
border_out->right = padding.right + border.right;
|
||||
}
|
||||
border_out->top = padding.top + border.top;
|
||||
border_out->bottom = padding.bottom + border.bottom;
|
||||
border_out->left = padding.left + border.left;
|
||||
border_out->right = padding.right + border.right;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3770,6 +3770,7 @@ draw_icon (GtkWidget *widget,
|
||||
gint x, y, width, height, pix_width, pix_height;
|
||||
GtkStyleContext *context;
|
||||
GtkBorder padding;
|
||||
GtkStateFlags state;
|
||||
|
||||
if (!icon_info)
|
||||
return;
|
||||
@@ -3789,7 +3790,8 @@ draw_icon (GtkWidget *widget,
|
||||
gtk_entry_prepare_context_for_icon (entry, context, icon_pos);
|
||||
_gtk_icon_helper_get_size (icon_info->icon_helper, context,
|
||||
&pix_width, &pix_height);
|
||||
gtk_style_context_get_padding (context, 0, &padding);
|
||||
state = gtk_style_context_get_state (context);
|
||||
gtk_style_context_get_padding (context, state, &padding);
|
||||
|
||||
x = MAX (0, padding.left);
|
||||
y = MAX (0, (height - pix_height) / 2);
|
||||
@@ -3866,6 +3868,7 @@ get_progress_area (GtkWidget *widget,
|
||||
GtkStyleContext *context;
|
||||
GtkBorder margin, border, entry_borders;
|
||||
gint frame_width, text_area_width, text_area_height;
|
||||
GtkStateFlags state;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
_gtk_entry_get_borders (entry, &entry_borders);
|
||||
@@ -3881,13 +3884,15 @@ get_progress_area (GtkWidget *widget,
|
||||
*width = text_area_width + entry_borders.left + entry_borders.right;
|
||||
*height = text_area_height + entry_borders.top + entry_borders.bottom;
|
||||
|
||||
state = gtk_style_context_get_state (context);
|
||||
|
||||
/* if the text area got resized by a subclass, subtract the left/right
|
||||
* border width, so that the progress bar won't extend over the resized
|
||||
* text area.
|
||||
*/
|
||||
if (frame_width > *width)
|
||||
{
|
||||
gtk_style_context_get_border (context, 0, &border);
|
||||
gtk_style_context_get_border (context, state, &border);
|
||||
if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
*x = (frame_width - *width) + border.left;
|
||||
@@ -3900,7 +3905,7 @@ get_progress_area (GtkWidget *widget,
|
||||
}
|
||||
|
||||
gtk_entry_prepare_context_for_progress (entry, context);
|
||||
gtk_style_context_get_margin (context, 0, &margin);
|
||||
gtk_style_context_get_margin (context, state, &margin);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
@@ -9932,9 +9937,11 @@ gtk_entry_drag_motion (GtkWidget *widget,
|
||||
gint new_position, old_position;
|
||||
gint sel1, sel2;
|
||||
GtkBorder padding;
|
||||
GtkStateFlags state;
|
||||
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get_padding (style_context, 0, &padding);
|
||||
state = gtk_style_context_get_state (style_context);
|
||||
gtk_style_context_get_padding (style_context, state, &padding);
|
||||
x -= padding.left;
|
||||
y -= padding.top;
|
||||
|
||||
@@ -10007,11 +10014,13 @@ gtk_entry_drag_data_received (GtkWidget *widget,
|
||||
GtkStyleContext *style_context;
|
||||
GtkBorder padding;
|
||||
gchar *str;
|
||||
GtkStateFlags state;
|
||||
|
||||
str = (gchar *) gtk_selection_data_get_text (selection_data);
|
||||
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get_padding (style_context, 0, &padding);
|
||||
state = gtk_style_context_get_state (style_context);
|
||||
gtk_style_context_get_padding (style_context, state, &padding);
|
||||
x -= padding.left;
|
||||
y -= padding.top;
|
||||
|
||||
|
@@ -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:
|
||||
|
@@ -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 ();
|
||||
|
@@ -8857,16 +8857,9 @@ gtk_widget_unset_state_flags (GtkWidget *widget,
|
||||
GtkStateFlags
|
||||
gtk_widget_get_state_flags (GtkWidget *widget)
|
||||
{
|
||||
GtkStateFlags flags;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
|
||||
|
||||
flags = widget->priv->state_flags;
|
||||
|
||||
if (gtk_widget_has_focus (widget))
|
||||
flags |= GTK_STATE_FLAG_FOCUSED;
|
||||
|
||||
return flags;
|
||||
return widget->priv->state_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user