Example #1
0
static void
store_in_global_parent_cache (GtkCssNode                  *node,
                              GtkCssStyle                 *parent,
                              const GtkCssNodeDeclaration *decl,
                              GtkCssStyle                 *style)
{
    GHashTable *cache;

    g_assert (GTK_IS_CSS_STATIC_STYLE (style));

    if (parent == NULL ||
            !may_use_global_parent_cache (node))
        return;

    if (!may_be_stored_in_parent_cache (style))
        return;

    cache = g_object_get_data (G_OBJECT (parent), "gtk-global-cache");
    if (cache == NULL)
    {
        cache = g_hash_table_new_full (gtk_css_node_declaration_hash,
                                       gtk_css_node_declaration_equal,
                                       (GDestroyNotify) gtk_css_node_declaration_unref,
                                       g_object_unref);
        g_object_set_data_full (G_OBJECT (parent), "gtk-global-cache", cache, (GDestroyNotify) g_hash_table_destroy);
    }

    g_hash_table_insert (cache,
                         gtk_css_node_declaration_ref ((GtkCssNodeDeclaration *) decl),
                         g_object_ref (style));
}
Example #2
0
static void
gtk_path_element_copy (GtkPathElement       *dest,
                       const GtkPathElement *src)
{
  memset (dest, 0, sizeof (GtkPathElement));

  dest->decl = gtk_css_node_declaration_ref (src->decl);
  if (src->siblings)
    dest->siblings = gtk_widget_path_ref (src->siblings);
  dest->sibling_index = src->sibling_index;
}
Example #3
0
GtkCssNodeDeclaration *
gtk_css_node_declaration_new (void)
{
    static GtkCssNodeDeclaration empty = {
        1, /* need to own a ref ourselves so the copy-on-write path kicks in when people change things */
        0,
        0,
        0,
        0
    };

    return gtk_css_node_declaration_ref (&empty);
}