cssnode: Split into 3 objects
- GtkCssWidgetNode for style contexts owned by a widget - GtkCssPathNode for style contexts using a GtkWidgetPath - GtkCssTransientNode for nodes created with gtk_style_context_save()/restore()
This commit is contained in:
93
gtk/gtkcsswidgetnode.c
Normal file
93
gtk/gtkcsswidgetnode.c
Normal file
@ -0,0 +1,93 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcsswidgetnodeprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssWidgetNode, gtk_css_widget_node, GTK_TYPE_CSS_NODE)
|
||||
|
||||
static GtkWidgetPath *
|
||||
gtk_css_widget_node_create_widget_path (GtkCssNode *node)
|
||||
{
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
|
||||
if (widget_node->widget == NULL)
|
||||
return gtk_widget_path_new ();
|
||||
|
||||
return _gtk_widget_create_path (widget_node->widget);
|
||||
}
|
||||
|
||||
static const GtkWidgetPath *
|
||||
gtk_css_widget_node_get_widget_path (GtkCssNode *node)
|
||||
{
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
|
||||
if (widget_node->widget == NULL)
|
||||
return NULL;
|
||||
|
||||
return gtk_widget_get_path (widget_node->widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
|
||||
{
|
||||
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
|
||||
|
||||
node_class->create_widget_path = gtk_css_widget_node_create_widget_path;
|
||||
node_class->get_widget_path = gtk_css_widget_node_get_widget_path;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_widget_node_init (GtkCssWidgetNode *cssnode)
|
||||
{
|
||||
}
|
||||
|
||||
GtkCssNode *
|
||||
gtk_css_widget_node_new (GtkWidget *widget)
|
||||
{
|
||||
GtkCssWidgetNode *result;
|
||||
|
||||
gtk_internal_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_CSS_WIDGET_NODE, NULL);
|
||||
result->widget = widget;
|
||||
|
||||
return GTK_CSS_NODE (result);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode *node)
|
||||
{
|
||||
gtk_internal_return_if_fail (GTK_IS_CSS_WIDGET_NODE (node));
|
||||
gtk_internal_return_if_fail (node->widget != NULL);
|
||||
|
||||
node->widget = NULL;
|
||||
/* Contents of this node are now undefined.
|
||||
* So we don't clear the style or anything.
|
||||
*/
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_css_widget_node_get_widget (GtkCssWidgetNode *node)
|
||||
{
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_WIDGET_NODE (node), NULL);
|
||||
|
||||
return node->widget;
|
||||
}
|
Reference in New Issue
Block a user