[gtk+/wip/cosimoc/range-gadget: 47/62] range: use new GtkCssGadget API instead of rolling our own
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cosimoc/range-gadget: 47/62] range: use new GtkCssGadget API instead of rolling our own
- Date: Mon, 29 Feb 2016 00:08:11 +0000 (UTC)
commit 5ea363bb1f00ad56c6a53926147b6e25177a7311
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Feb 24 14:29:52 2016 -0800
range: use new GtkCssGadget API instead of rolling our own
gtk/gtkrange.c | 44 ++++++++++----------------------------------
1 files changed, 10 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 2b482c4..6856fa6 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1211,30 +1211,6 @@ gtk_range_get_min_slider_size (GtkRange *range)
return range->priv->min_slider_size;
}
-/* Returns the gadget rect in widget coordinates */
-static void
-measure_one_gadget_alloc (GtkRange *range,
- GtkCssGadget *gadget,
- gboolean use_content,
- GtkAllocation *allocation_out)
-{
- GtkAllocation widget_alloc;
-
- g_assert (allocation_out != NULL);
-
- gtk_widget_get_allocation (GTK_WIDGET (range), &widget_alloc);
-
- if (use_content)
- gtk_css_gadget_get_content_allocation (gadget,
- allocation_out, NULL);
- else
- gtk_css_gadget_get_margin_allocation (gadget,
- allocation_out, NULL);
-
- allocation_out->x -= widget_alloc.x;
- allocation_out->y -= widget_alloc.y;
-}
-
static void
measure_one_gadget (GtkCssGadget *gadget,
int *width_out,
@@ -1273,7 +1249,7 @@ gtk_range_get_range_rect (GtkRange *range,
priv = range->priv;
- measure_one_gadget_alloc (range, priv->contents_gadget, FALSE, range_rect);
+ gtk_css_gadget_get_margin_box (priv->contents_gadget, range_rect);
}
/**
@@ -1303,7 +1279,7 @@ gtk_range_get_slider_range (GtkRange *range,
priv = range->priv;
- measure_one_gadget_alloc (range, priv->slider_gadget, FALSE, &slider_alloc);
+ gtk_css_gadget_get_margin_box (priv->slider_gadget, &slider_alloc);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
@@ -2493,8 +2469,8 @@ coord_to_value (GtkRange *range,
gint slider_length;
GtkAllocation slider_alloc, trough_alloc;
- measure_one_gadget_alloc (range, priv->slider_gadget, FALSE, &slider_alloc);
- measure_one_gadget_alloc (range, priv->trough_gadget, TRUE, &trough_alloc);
+ gtk_css_gadget_get_margin_box (priv->slider_gadget, &slider_alloc);
+ gtk_css_gadget_get_content_box (priv->trough_gadget, &trough_alloc);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
@@ -2536,7 +2512,7 @@ gtk_range_key_press (GtkWidget *widget,
device = gdk_event_get_device ((GdkEvent *) event);
device = gdk_device_get_associated_device (device);
- measure_one_gadget_alloc (range, priv->slider_gadget, FALSE, &slider_alloc);
+ gtk_css_gadget_get_margin_box (priv->slider_gadget, &slider_alloc);
if (gtk_gesture_is_active (priv->drag_gesture) &&
device == gtk_gesture_get_device (priv->drag_gesture) &&
@@ -2573,7 +2549,7 @@ gtk_range_long_press_gesture_pressed (GtkGestureLongPress *gesture,
GtkAllocation slider_alloc;
gtk_range_update_mouse_location (range);
- measure_one_gadget_alloc (range, priv->slider_gadget, FALSE, &slider_alloc);
+ gtk_css_gadget_get_margin_box (priv->slider_gadget, &slider_alloc);
if (priv->mouse_location == MOUSE_SLIDER && !priv->zoom)
{
@@ -2627,7 +2603,7 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
priv->mouse_y = y;
gtk_range_update_mouse_location (range);
- measure_one_gadget_alloc (range, priv->slider_gadget, FALSE, &slider_alloc);
+ gtk_css_gadget_get_margin_box (priv->slider_gadget, &slider_alloc);
g_object_get (gtk_widget_get_settings (widget),
"gtk-primary-button-warps-slider", &primary_warps,
@@ -2804,8 +2780,8 @@ update_slider_position (GtkRange *range,
gint i;
GtkAllocation slider_alloc, trough_alloc;
- measure_one_gadget_alloc (range, priv->slider_gadget, FALSE, &slider_alloc);
- measure_one_gadget_alloc (range, priv->trough_gadget, FALSE, &trough_alloc);
+ gtk_css_gadget_get_margin_box (priv->slider_gadget, &slider_alloc);
+ gtk_css_gadget_get_margin_box (priv->trough_gadget, &trough_alloc);
if (priv->zoom)
{
@@ -3452,7 +3428,7 @@ gtk_range_compute_slider_position (GtkRange *range,
int slider_width, slider_height;
measure_one_gadget (priv->slider_gadget, &slider_width, &slider_height);
- measure_one_gadget_alloc (range, priv->trough_gadget, TRUE, &trough_content_alloc);
+ gtk_css_gadget_get_content_box (priv->trough_gadget, &trough_content_alloc);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]