[gtk+/wip/baedert/drawing: 5/143] switch: Remove gadget
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing: 5/143] switch: Remove gadget
- Date: Fri, 19 May 2017 13:23:49 +0000 (UTC)
commit fdf28989828e801095d9724bbb520d7cd53a7763
Author: Timm Bäder <mail baedert org>
Date: Wed May 3 22:22:49 2017 +0200
switch: Remove gadget
gtk/gtkswitch.c | 97 +++++++++++++++---------------------------------------
1 files changed, 27 insertions(+), 70 deletions(-)
---
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index bf9bede..4a51f3d 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -61,8 +61,6 @@
#include "gtkactionable.h"
#include "a11y/gtkswitchaccessible.h"
#include "gtkactionhelper.h"
-#include "gtkcsscustomgadgetprivate.h"
-#include "gtkcssgadgetprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkcssshadowsvalueprivate.h"
@@ -81,8 +79,6 @@ struct _GtkSwitchPrivate
GtkGesture *pan_gesture;
GtkGesture *multipress_gesture;
- GtkCssGadget *gadget;
-
double handle_pos;
guint tick_id;
GtkProgressTracker tracker;
@@ -317,22 +313,19 @@ gtk_switch_activate (GtkSwitch *sw)
}
static void
-gtk_switch_get_content_size (GtkCssGadget *gadget,
- GtkOrientation orientation,
- gint for_size,
- gint *minimum,
- gint *natural,
- gint *minimum_baseline,
- gint *natural_baseline,
- gpointer unused)
-{
- GtkWidget *widget;
+gtk_switch_measure (GtkWidget *widget,
+ GtkOrientation orientation,
+ int for_size,
+ int *minimum,
+ int *natural,
+ int *minimum_baseline,
+ int *natural_baseline)
+{
GtkSwitch *self;
GtkSwitchPrivate *priv;
gint slider_minimum, slider_natural;
int on_nat, off_nat;
- widget = gtk_css_gadget_get_owner (gadget);
self = GTK_SWITCH (widget);
priv = self->priv;
@@ -358,30 +351,13 @@ gtk_switch_get_content_size (GtkCssGadget *gadget,
}
static void
-gtk_switch_measure (GtkWidget *widget,
- GtkOrientation orientation,
- int for_size,
- int *minimum,
- int *natural,
- int *minimum_baseline,
- int *natural_baseline)
+gtk_switch_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
{
- gtk_css_gadget_get_preferred_size (GTK_SWITCH (widget)->priv->gadget,
- orientation,
- for_size,
- minimum, natural,
- minimum_baseline, natural_baseline);
-}
-
-static void
-gtk_switch_allocate_contents (GtkCssGadget *gadget,
- const GtkAllocation *allocation,
- int baseline,
- GtkAllocation *out_clip,
- gpointer unused)
-{
- GtkSwitch *self = GTK_SWITCH (gtk_css_gadget_get_owner (gadget));
- GtkSwitchPrivate *priv = self->priv;
+ GtkSwitch *self = GTK_SWITCH (widget);
+ GtkSwitchPrivate *priv = gtk_switch_get_instance_private (self);
+ GtkAllocation clip = *allocation;
+ GtkAllocation child_clip;
GtkAllocation child_alloc;
GtkAllocation slider_alloc;
int min;
@@ -392,6 +368,9 @@ gtk_switch_allocate_contents (GtkCssGadget *gadget,
slider_alloc.height = allocation->height;
gtk_widget_size_allocate (priv->slider, &slider_alloc);
+ gtk_widget_get_clip (priv->slider, &child_clip);
+ gdk_rectangle_union (&child_clip, &clip, &clip);
+
/* Center ON label in left half */
gtk_widget_measure (priv->on_label, GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL);
@@ -401,7 +380,8 @@ gtk_switch_allocate_contents (GtkCssGadget *gadget,
child_alloc.y = allocation->y + (allocation->height - min) / 2;
child_alloc.height = min;
gtk_widget_size_allocate (priv->on_label, &child_alloc);
-
+ gtk_widget_get_clip (priv->on_label, &child_clip);
+ gdk_rectangle_union (&child_clip, &clip, &clip);
/* Center OFF label in right half */
gtk_widget_measure (priv->off_label, GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL);
@@ -411,32 +391,20 @@ gtk_switch_allocate_contents (GtkCssGadget *gadget,
child_alloc.y = allocation->y + (allocation->height - min) / 2;
child_alloc.height = min;
gtk_widget_size_allocate (priv->off_label, &child_alloc);
+ gtk_widget_get_clip (priv->off_label, &child_clip);
+ gdk_rectangle_union (&child_clip, &clip, &clip);
if (gtk_widget_get_realized (GTK_WIDGET (self)))
{
- GtkAllocation border_allocation;
- gtk_css_gadget_get_border_allocation (gadget, &border_allocation, NULL);
+ GtkAllocation widget_allocation;
+ gtk_widget_get_allocation (widget, &widget_allocation);
gdk_window_move_resize (priv->event_window,
- border_allocation.x,
- border_allocation.y,
- border_allocation.width,
- border_allocation.height);
+ widget_allocation.x,
+ widget_allocation.y,
+ widget_allocation.width,
+ widget_allocation.height);
}
-}
-
-static void
-gtk_switch_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkSwitchPrivate *priv = GTK_SWITCH (widget)->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);
}
@@ -633,7 +601,6 @@ gtk_switch_dispose (GObject *object)
GtkSwitchPrivate *priv = GTK_SWITCH (object)->priv;
g_clear_object (&priv->action_helper);
- g_clear_object (&priv->gadget);
g_clear_object (&priv->pan_gesture);
g_clear_object (&priv->multipress_gesture);
@@ -785,22 +752,12 @@ gtk_switch_init (GtkSwitch *self)
{
GtkSwitchPrivate *priv;
GtkGesture *gesture;
- GtkCssNode *widget_node;
priv = self->priv = gtk_switch_get_instance_private (self);
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
- widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
- priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
- GTK_WIDGET (self),
- gtk_switch_get_content_size,
- gtk_switch_allocate_contents,
- NULL,
- NULL,
- NULL);
-
priv->slider = g_object_new (GTK_TYPE_BUTTON, "css-name", "slider", NULL);
gtk_widget_set_parent (priv->slider, GTK_WIDGET (self));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]