[gtk+/wip/baedert/children] switch: Use a button for the slider
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/children] switch: Use a button for the slider
- Date: Tue, 22 Nov 2016 11:38:23 +0000 (UTC)
commit b7102e89a3cbf79253f076c9ef5c551e39f82d39
Author: Timm Bäder <mail baedert org>
Date: Tue Nov 22 12:39:38 2016 +0100
switch: Use a button for the slider
WIP
gtk/gtkswitch.c | 45 ++++++++-------------------------------------
1 files changed, 8 insertions(+), 37 deletions(-)
---
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index a6d683a..2227454 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -80,7 +80,6 @@ struct _GtkSwitchPrivate
GtkGesture *multipress_gesture;
GtkCssGadget *gadget;
- GtkCssGadget *slider_gadget;
double handle_pos;
guint tick_id;
@@ -92,6 +91,7 @@ struct _GtkSwitchPrivate
GtkWidget *on_label;
GtkWidget *off_label;
+ GtkWidget *slider;
};
enum
@@ -337,11 +337,7 @@ gtk_switch_get_content_size (GtkCssGadget *gadget,
self = GTK_SWITCH (widget);
priv = self->priv;
- gtk_css_gadget_get_preferred_size (priv->slider_gadget,
- orientation,
- -1,
- &slider_minimum, &slider_natural,
- NULL, NULL);
+ gtk_widget_measure (priv->slider, orientation, -1, &slider_minimum, &slider_natural, NULL, NULL);
gtk_widget_measure (priv->on_label, orientation, for_size, NULL, &on_nat, NULL, NULL);
gtk_widget_measure (priv->off_label, orientation, for_size, NULL, &off_nat, NULL, NULL);
@@ -393,11 +389,7 @@ gtk_switch_allocate_contents (GtkCssGadget *gadget,
slider_alloc.y = allocation->y;
slider_alloc.width = allocation->width / 2;
slider_alloc.height = allocation->height;
-
- gtk_css_gadget_allocate (priv->slider_gadget,
- &slider_alloc,
- baseline,
- out_clip);
+ gtk_widget_size_allocate (priv->slider, &slider_alloc);
/* Center ON label in left half */
gtk_widget_measure (priv->on_label, GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL);
@@ -512,18 +504,6 @@ gtk_switch_unmap (GtkWidget *widget)
}
static gboolean
-gtk_switch_snapshot_slider (GtkCssGadget *gadget,
- GtkSnapshot *snapshot,
- int x,
- int y,
- int width,
- int height,
- gpointer data)
-{
- return gtk_widget_has_visible_focus (gtk_css_gadget_get_owner (gadget));
-}
-
-static gboolean
gtk_switch_snapshot_trough (GtkCssGadget *gadget,
GtkSnapshot *snapshot,
int x,
@@ -537,8 +517,7 @@ gtk_switch_snapshot_trough (GtkCssGadget *gadget,
gtk_widget_snapshot_child (widget, priv->on_label, snapshot);
gtk_widget_snapshot_child (widget, priv->off_label, snapshot);
-
- gtk_css_gadget_snapshot (priv->slider_gadget, snapshot);
+ gtk_widget_snapshot_child (widget, priv->slider, snapshot);
return FALSE;
}
@@ -668,7 +647,6 @@ gtk_switch_dispose (GObject *object)
g_clear_object (&priv->action_helper);
g_clear_object (&priv->gadget);
- g_clear_object (&priv->slider_gadget);
g_clear_object (&priv->pan_gesture);
g_clear_object (&priv->multipress_gesture);
@@ -831,17 +809,6 @@ gtk_switch_init (GtkSwitch *self)
NULL,
NULL);
- priv->slider_gadget = gtk_css_custom_gadget_new ("slider",
- GTK_WIDGET (self),
- priv->gadget,
- NULL,
- NULL,
- NULL,
- NULL,
- gtk_switch_snapshot_slider,
- NULL,
- NULL);
-
gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
@@ -879,6 +846,10 @@ gtk_switch_init (GtkSwitch *self)
priv->off_label = gtk_label_new (C_("switch", "OFF"));
gtk_widget_set_parent (priv->off_label, GTK_WIDGET (self));
gtk_widget_show (priv->off_label);
+
+ priv->slider = gtk_button_new ();
+ gtk_widget_set_parent (priv->slider, GTK_WIDGET (self));
+ gtk_widget_show (priv->slider);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]