summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2018-07-07 18:33:43 +0200
committerTimm Bäder <mail@baedert.org>2018-07-08 09:41:15 +0200
commit6e47d0bf4a689bb1f1f2a4022aed4183ac122914 (patch)
treeede86961f7a3216155f34b3fea14d329247a8fa1
parent50b79ae0ab0cd3fe0517ac3e93e54152e2fa7520 (diff)
downloadgtk+-6e47d0bf4a689bb1f1f2a4022aed4183ac122914.tar.gz
GtkSeparatorToolItem: Remove draw flag
We can as well query the current value of the flag using gtk_style_context_has_class.
-rw-r--r--gtk/gtkseparatortoolitem.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/gtk/gtkseparatortoolitem.c b/gtk/gtkseparatortoolitem.c
index a557adb2b6..3cdc517c19 100644
--- a/gtk/gtkseparatortoolitem.c
+++ b/gtk/gtkseparatortoolitem.c
@@ -49,11 +49,6 @@
#define MENU_ID "gtk-separator-tool-item-menu-id"
-typedef struct
-{
- guint draw : 1;
-} GtkSeparatorToolItemPrivate;
-
enum {
PROP_0,
PROP_DRAW
@@ -71,7 +66,7 @@ static void gtk_separator_tool_item_get_property (GObject
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)
+G_DEFINE_TYPE (GtkSeparatorToolItem, gtk_separator_tool_item, GTK_TYPE_TOOL_ITEM)
static void
gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
@@ -107,11 +102,9 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
static void
gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item)
{
- GtkSeparatorToolItemPrivate *priv = gtk_separator_tool_item_get_instance_private (separator_item);
GtkWidget *widget;
widget = GTK_WIDGET (separator_item);
- priv->draw = TRUE;
gtk_widget_set_has_surface (widget, FALSE);
}
@@ -203,11 +196,13 @@ gtk_separator_tool_item_new (void)
gboolean
gtk_separator_tool_item_get_draw (GtkSeparatorToolItem *item)
{
- GtkSeparatorToolItemPrivate *priv = gtk_separator_tool_item_get_instance_private (item);
+ GtkStyleContext *context;
g_return_val_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (item), FALSE);
- return priv->draw;
+ context = gtk_widget_get_style_context (GTK_WIDGET (item));
+
+ return !gtk_style_context_has_class (context, "invisible");
}
/**
@@ -223,22 +218,19 @@ void
gtk_separator_tool_item_set_draw (GtkSeparatorToolItem *item,
gboolean draw)
{
- GtkSeparatorToolItemPrivate *priv = gtk_separator_tool_item_get_instance_private (item);
-
g_return_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (item));
- draw = draw != FALSE;
+ draw = !!draw;
- if (draw != priv->draw)
- {
- priv->draw = draw;
- if (draw)
- gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
- "invisible");
- else
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
- "invisible");
-
- g_object_notify (G_OBJECT (item), "draw");
- }
+ if (draw == gtk_separator_tool_item_get_draw (item))
+ return;
+
+ if (draw)
+ gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
+ "invisible");
+ else
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (item)),
+ "invisible");
+
+ g_object_notify (G_OBJECT (item), "draw");
}