Example #1
0
void
gtk_css_node_print (GtkCssNode                *cssnode,
                    GtkStyleContextPrintFlags  flags,
                    GString                   *string,
                    guint                      indent)
{
  gboolean need_newline = FALSE;

  g_string_append_printf (string, "%*s", indent, "");

  if (!cssnode->visible)
    g_string_append_c (string, '[');

  gtk_css_node_declaration_print (cssnode->decl, string);

  if (!cssnode->visible)
    g_string_append_c (string, ']');

  g_string_append_c (string, '\n');

  if (flags & GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE)
    need_newline = gtk_css_style_print (gtk_css_node_get_style (cssnode), string, indent + 2, TRUE);

  if (flags & GTK_STYLE_CONTEXT_PRINT_RECURSE)
    {
      GtkCssNode *node;

      if (need_newline && gtk_css_node_get_first_child (cssnode))
        g_string_append_c (string, '\n');

      for (node = gtk_css_node_get_first_child (cssnode); node; node = gtk_css_node_get_next_sibling (node))
        gtk_css_node_print (node, flags, string, indent + 2);
    }
}
Example #2
0
static void
gtk_css_node_propagate_pending_changes (GtkCssNode *cssnode,
                                        gboolean    style_changed)
{
  GtkCssChange change, child_change;
  GtkCssNode *child;

  change = _gtk_css_change_for_child (cssnode->pending_changes);
  if (style_changed)
    change |= GTK_CSS_CHANGE_PARENT_STYLE;

  if (!cssnode->needs_propagation && change == 0)
    return;

  for (child = gtk_css_node_get_first_child (cssnode);
       child;
       child = gtk_css_node_get_next_sibling (child))
    {
      child_change = child->pending_changes;
      gtk_css_node_invalidate (child, change);
      if (child->visible)
        change |= _gtk_css_change_for_sibling (child_change);
    }

  cssnode->needs_propagation = FALSE;
}
Example #3
0
void
gtk_css_node_validate_internal (GtkCssNode *cssnode,
                                gint64      timestamp)
{
  GtkCssNode *child;

  if (!cssnode->invalid)
    return;

  gtk_css_node_ensure_style (cssnode, timestamp);

  /* need to set to FALSE then to TRUE here to make it chain up */
  gtk_css_node_set_invalid (cssnode, FALSE);
  if (!gtk_css_style_is_static (cssnode->style))
    gtk_css_node_set_invalid (cssnode, TRUE);

  GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode);

  for (child = gtk_css_node_get_first_child (cssnode);
       child;
       child = gtk_css_node_get_next_sibling (child))
    {
      if (child->visible)
        gtk_css_node_validate_internal (child, timestamp);
    }
}
Example #4
0
static void
gtk_check_menu_item_direction_changed (GtkWidget        *widget,
                                       GtkTextDirection  previous_dir)
{
  GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (widget);
  GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
  GtkCssNode *widget_node, *node;

  widget_node = gtk_widget_get_css_node (widget);

  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
    {
      gtk_css_node_remove_class (priv->indicator_node, g_quark_from_static_string (GTK_STYLE_CLASS_LEFT));
      gtk_css_node_add_class (priv->indicator_node, g_quark_from_static_string (GTK_STYLE_CLASS_RIGHT));

      node = gtk_css_node_get_last_child (widget_node);
      if (node != priv->indicator_node)
        gtk_css_node_insert_after (widget_node, priv->indicator_node, node);
    }
  else
    {
      gtk_css_node_add_class (priv->indicator_node, g_quark_from_static_string (GTK_STYLE_CLASS_LEFT));
      gtk_css_node_remove_class (priv->indicator_node, g_quark_from_static_string (GTK_STYLE_CLASS_RIGHT));

      node = gtk_css_node_get_first_child (widget_node);
      if (node != priv->indicator_node)
        gtk_css_node_insert_before (widget_node, priv->indicator_node, node);
    }

  GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->direction_changed (widget, previous_dir);
}
Example #5
0
void
gtk_css_node_validate_internal (GtkCssNode *cssnode,
                                gint64      timestamp)
{
    GtkCssNode *child;

    /* If you run your application with
     *   GTK_DEBUG=no-css-cache
     * every invalidation will purge the cache and completely query
     * everything anew form the cache. This is slow (in particular
     * when animating), but useful for figuring out bugs.
     *
     * We achieve that by pretending that everything that could have
     * changed has and so we of course totally need to redo everything.
     *
     * Note that this also completely revalidates child widgets all
     * the time.
     */
#ifdef G_ENABLE_DEBUG
    if (GTK_DEBUG_CHECK (NO_CSS_CACHE))
        cssnode->pending_changes |= GTK_CSS_CHANGE_ANY;
#endif

    if (!cssnode->invalid)
        return;

    gtk_css_node_ensure_style (cssnode, timestamp);

    /* need to set to FALSE then to TRUE here to make it chain up */
    gtk_css_node_set_invalid (cssnode, FALSE);
    if (!gtk_css_style_is_static (cssnode->style))
        gtk_css_node_set_invalid (cssnode, TRUE);

    GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode);

    for (child = gtk_css_node_get_first_child (cssnode);
            child;
            child = gtk_css_node_get_next_sibling (child))
    {
        if (child->visible)
            gtk_css_node_validate_internal (child, timestamp);
    }
}