#include "gtkcontainer.h"
#include "gtkaccelmapprivate.h"
#include "gtkclipboard.h"
+#include "gtkcssstylepropertyprivate.h"
#include "gtkiconfactory.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkbuilderprivate.h"
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
-#include "gtksymboliccolor.h"
#include "gtkcssprovider.h"
#include "gtkmodifierstyle.h"
#include "gtkversion.h"
* all flags will be set on children (think prelight or active), but we
* might want to not do this for some.
*/
-#define GTK_STATE_FLAGS_DONT_PROPAGATE (GTK_STATE_FLAG_FOCUSED)
+#define GTK_STATE_FLAGS_DONT_PROPAGATE (GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL)
#define GTK_STATE_FLAGS_DO_PROPAGATE (~GTK_STATE_FLAGS_DONT_PROPAGATE)
#define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
-#define GTK_STATE_FLAGS_BITS 7
+#define GTK_STATE_FLAGS_BITS 9
struct _GtkWidgetPrivate
{
param_types);
cairo_restore (cr);
+
+ va_end (args_copy);
}
static void
* button press events for buttons 4 and 5 when the wheel is turned.
*
* To receive this signal, the #GdkWindow associated to the widget needs
- * to enable the #GDK_BUTTON_PRESS_MASK mask.
+ * to enable the #GDK_SCROLL_MASK mask.
*
* This signal will be sent to the grab widget if there is one.
*
priv->double_buffered = TRUE;
priv->redraw_on_alloc = TRUE;
priv->alloc_needed = TRUE;
+ priv->state_flags = GTK_STATE_FLAG_DIR_LTR;
/* this will be set to TRUE if the widget gets a child or if the
* expand flag is set on the widget, but until one of those happen
if (widget->priv->context)
{
+ const GtkBitmask *changes = _gtk_style_context_get_changes (widget->priv->context);
+
if (gtk_widget_get_realized (widget) &&
gtk_widget_get_has_window (widget) &&
!gtk_widget_get_app_paintable (widget))
gtk_style_context_set_background (widget->priv->context,
widget->priv->window);
- }
- if (widget->priv->anchored)
- gtk_widget_queue_resize (widget);
+ if (widget->priv->anchored)
+ {
+ if (changes && _gtk_css_style_property_changes_affect_size (changes))
+ gtk_widget_queue_resize (widget);
+ else
+ gtk_widget_queue_draw (widget);
+ }
+ }
+ else
+ {
+ if (widget->priv->anchored)
+ gtk_widget_queue_resize (widget);
+ }
}
static gboolean
data.operation = operation;
gtk_widget_propagate_state (widget, &data);
-
- gtk_widget_queue_resize (widget);
}
}
* by gtk_widget_create_pango_context(), this context is owned by
* the widget (it can be used until the screen for the widget changes
* or the widget is removed from its toplevel), and will be updated to
- * match any changes to the widget's attributes.
- *
- * If you create and keep a #PangoLayout using this context, you must
- * deal with changes to the context by calling pango_layout_context_changed()
- * on the layout in response to the #GtkWidget::style-updated and
- * #GtkWidget::direction-changed signals for the widget.
+ * match any changes to the widget's attributes. This can be tracked
+ * by using the #GtkWidget::screen-changed signal on the widget.
*
* Return value: (transfer none): the #PangoContext for the widget.
**/
update_pango_context (GtkWidget *widget,
PangoContext *context)
{
- const PangoFontDescription *font_desc;
+ PangoFontDescription *font_desc;
GtkStyleContext *style_context;
style_context = gtk_widget_get_style_context (widget);
-
- font_desc = gtk_style_context_get_font (style_context,
- gtk_widget_get_state_flags (widget));
+ gtk_style_context_get (style_context,
+ gtk_widget_get_state_flags (widget),
+ "font", &font_desc,
+ NULL);
pango_context_set_font_description (context, font_desc);
pango_context_set_base_dir (context,
gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
+
+ pango_font_description_free (font_desc);
}
static void
* font description, and base direction for drawing text for
* this widget.
*
- * If you keep a #PangoLayout created in this way around, in order to
- * notify the layout of changes to the base direction or font of this
- * widget, you must call pango_layout_context_changed() in response to
- * the #GtkWidget::style-updated and #GtkWidget::direction-changed signals
- * for the widget.
+ * If you keep a #PangoLayout created in this way around, you need
+ * to re-create it when the widget #PangoContext is replaced.
+ * This can be tracked by using the #GtkWidget::screen-changed signal
+ * on the widget.
*
* Return value: (transfer full): the new #PangoLayout
**/
gtk_widget_emit_direction_changed (GtkWidget *widget,
GtkTextDirection old_dir)
{
+ GtkTextDirection direction;
+ GtkStateFlags state;
+
gtk_widget_update_pango_context (widget);
- if (widget->priv->context)
- gtk_style_context_set_direction (widget->priv->context,
- gtk_widget_get_direction (widget));
+ direction = gtk_widget_get_direction (widget);
+ state = widget->priv->state_flags;
+ state &= GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL;
+
+ switch (direction)
+ {
+ case GTK_TEXT_DIR_LTR:
+ state |= GTK_STATE_FLAG_DIR_LTR;
+ break;
+
+ case GTK_TEXT_DIR_RTL:
+ state |= GTK_STATE_FLAG_DIR_RTL;
+ break;
+
+ case GTK_TEXT_DIR_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ gtk_widget_set_state_flags (widget, state, TRUE);
g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
}
*/
widget->priv->style_update_pending = TRUE;
}
-
- if (widget->priv->anchored)
- gtk_widget_queue_resize (widget);
}
/**
priv->context = gtk_style_context_new ();
- gtk_style_context_set_direction (priv->context, gtk_widget_get_direction (widget));
+ gtk_style_context_set_state (priv->context, priv->state_flags);
screen = gtk_widget_get_screen (widget);
if (screen)