forked from AuroraMiddleware/gtk
separatortoolitem: Remove gadget
This commit is contained in:
parent
fe6832fcc9
commit
bafa55349f
@ -24,7 +24,6 @@
|
||||
#include "gtktoolbarprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkcsscustomgadgetprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkseparatortoolitem
|
||||
@ -52,7 +51,6 @@
|
||||
|
||||
struct _GtkSeparatorToolItemPrivate
|
||||
{
|
||||
GtkCssGadget *gadget;
|
||||
guint draw : 1;
|
||||
};
|
||||
|
||||
@ -70,32 +68,13 @@ static void gtk_separator_tool_item_get_property (GObject
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_separator_tool_item_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
gint for_size,
|
||||
gint *minimum,
|
||||
gint *natural,
|
||||
gint *minimum_baseline,
|
||||
gint *natural_baseline);
|
||||
static void gtk_separator_tool_item_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_separator_tool_item_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
static void gtk_separator_tool_item_add (GtkContainer *container,
|
||||
GtkWidget *child);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkSeparatorToolItem, gtk_separator_tool_item, GTK_TYPE_TOOL_ITEM)
|
||||
|
||||
static void
|
||||
gtk_separator_tool_item_finalize (GObject *object)
|
||||
{
|
||||
GtkSeparatorToolItem *item = GTK_SEPARATOR_TOOL_ITEM (object);
|
||||
|
||||
g_clear_object (&item->priv->gadget);
|
||||
|
||||
G_OBJECT_CLASS (gtk_separator_tool_item_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
|
||||
{
|
||||
@ -111,11 +90,8 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
|
||||
|
||||
object_class->set_property = gtk_separator_tool_item_set_property;
|
||||
object_class->get_property = gtk_separator_tool_item_get_property;
|
||||
object_class->finalize = gtk_separator_tool_item_finalize;
|
||||
|
||||
widget_class->measure = gtk_separator_tool_item_measure;
|
||||
widget_class->size_allocate = gtk_separator_tool_item_size_allocate;
|
||||
widget_class->snapshot = gtk_separator_tool_item_snapshot;
|
||||
|
||||
toolitem_class->create_menu_proxy = gtk_separator_tool_item_create_menu_proxy;
|
||||
|
||||
@ -137,20 +113,12 @@ gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item)
|
||||
{
|
||||
GtkSeparatorToolItemPrivate *priv;
|
||||
GtkWidget *widget;
|
||||
GtkCssNode *widget_node;
|
||||
|
||||
widget = GTK_WIDGET (separator_item);
|
||||
priv = separator_item->priv = gtk_separator_tool_item_get_instance_private (separator_item);
|
||||
priv->draw = TRUE;
|
||||
|
||||
gtk_widget_set_has_window (widget, FALSE);
|
||||
|
||||
widget_node = gtk_widget_get_css_node (widget);
|
||||
separator_item->priv->gadget =
|
||||
gtk_css_custom_gadget_new_for_node (widget_node,
|
||||
widget,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -209,46 +177,12 @@ gtk_separator_tool_item_get_property (GObject *object,
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void
|
||||
gtk_separator_tool_item_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
gint for_size,
|
||||
gint *minimum,
|
||||
gint *natural,
|
||||
gint *minimum_baseline,
|
||||
gint *natural_baseline)
|
||||
{
|
||||
gtk_css_gadget_get_preferred_size (GTK_SEPARATOR_TOOL_ITEM (widget)->priv->gadget,
|
||||
orientation,
|
||||
for_size,
|
||||
minimum, natural,
|
||||
minimum_baseline, natural_baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_separator_tool_item_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
||||
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
||||
GtkAllocation clip;
|
||||
|
||||
gtk_widget_set_allocation (widget, allocation);
|
||||
|
||||
gtk_css_gadget_allocate (priv->gadget,
|
||||
allocation,
|
||||
gtk_widget_get_allocated_baseline (widget),
|
||||
&clip);
|
||||
|
||||
gtk_widget_set_clip (widget, &clip);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_separator_tool_item_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
if (GTK_SEPARATOR_TOOL_ITEM (widget)->priv->draw)
|
||||
gtk_css_gadget_snapshot (GTK_SEPARATOR_TOOL_ITEM (widget)->priv->gadget, snapshot);
|
||||
gtk_widget_set_clip (widget, allocation);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -313,11 +247,11 @@ gtk_separator_tool_item_set_draw (GtkSeparatorToolItem *item,
|
||||
{
|
||||
item->priv->draw = draw;
|
||||
if (draw)
|
||||
gtk_css_gadget_remove_class (item->priv->gadget, "invisible");
|
||||
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
|
||||
"invisible");
|
||||
else
|
||||
gtk_css_gadget_add_class (item->priv->gadget, "invisible");
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (item));
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
|
||||
"invisible");
|
||||
|
||||
g_object_notify (G_OBJECT (item), "draw");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user