]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwidget.c
Rename gtkcolorswatchaccessible.h
[~andy/gtk] / gtk / gtkwidget.c
index 9141a707f786cfc1e9ad8479d06b05a31e2b9806..c04bfb95268639bb13ca8908c265faad007dbcfa 100644 (file)
  * 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
 {
@@ -3675,6 +3675,7 @@ gtk_widget_init (GtkWidget *widget)
   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
@@ -8705,12 +8706,8 @@ gtk_widget_peek_pango_context (GtkWidget *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.
  **/
@@ -8738,18 +8735,21 @@ static void
 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
@@ -8818,11 +8818,10 @@ gtk_widget_create_pango_context (GtkWidget *widget)
  * 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
  **/
@@ -10136,11 +10135,32 @@ static void
 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);
 }
@@ -13991,7 +14011,7 @@ gtk_widget_get_style_context (GtkWidget *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)