GtkScrolledWindow: Rename a private field

touch_mode -> use_indicators, more to the point.
This commit is contained in:
Matthias Clasen 2015-01-09 20:26:07 -05:00
parent a834078804
commit 1c6eca04db

View File

@ -195,9 +195,9 @@ struct _GtkScrolledWindowPrivate
guint vscrollbar_policy : 2; guint vscrollbar_policy : 2;
guint hscrollbar_visible : 1; guint hscrollbar_visible : 1;
guint vscrollbar_visible : 1; guint vscrollbar_visible : 1;
guint focus_out : 1; /* Flag used by ::move-focus-out implementation */ guint focus_out : 1; /* used by ::move-focus-out implementation */
guint overlay_scrolling : 1; guint overlay_scrolling : 1;
guint touch_mode : 1; guint use_indicators : 1;
gint min_content_width; gint min_content_width;
gint min_content_height; gint min_content_height;
@ -2359,7 +2359,7 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget,
gtk_style_context_restore (context); gtk_style_context_restore (context);
} }
if (priv->vscrollbar_visible && !priv->touch_mode) if (priv->vscrollbar_visible && !priv->use_indicators)
{ {
gboolean is_rtl; gboolean is_rtl;
@ -2376,7 +2376,7 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget,
allocation->width = MAX (1, allocation->width - (sb_width + sb_spacing)); allocation->width = MAX (1, allocation->width - (sb_width + sb_spacing));
} }
if (priv->hscrollbar_visible && !priv->touch_mode) if (priv->hscrollbar_visible && !priv->use_indicators)
{ {
if (priv->window_placement == GTK_CORNER_BOTTOM_LEFT || if (priv->window_placement == GTK_CORNER_BOTTOM_LEFT ||
@ -2560,25 +2560,27 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
/* Does the content width fit the allocation with minus a possible scrollbar ? */ /* Does the content width fit the allocation with minus a possible scrollbar ? */
priv->hscrollbar_visible = priv->hscrollbar_visible =
child_scroll_width > allocation->width - child_scroll_width > allocation->width -
(priv->vscrollbar_visible && !priv->touch_mode ? sb_width + sb_spacing : 0); (priv->vscrollbar_visible && !priv->use_indicators ? sb_width + sb_spacing : 0);
/* Now that we've guessed the hscrollbar, does the content height fit /* Now that we've guessed the hscrollbar, does the content height fit
* the possible new allocation height ? */ * the possible new allocation height ?
*/
priv->vscrollbar_visible = priv->vscrollbar_visible =
child_scroll_height > allocation->height - child_scroll_height > allocation->height -
(priv->hscrollbar_visible && !priv->touch_mode ? sb_height + sb_spacing : 0); (priv->hscrollbar_visible && !priv->use_indicators ? sb_height + sb_spacing : 0);
/* Now that we've guessed the vscrollbar, does the content width fit /* Now that we've guessed the vscrollbar, does the content width fit
* the possible new allocation width ? */ * the possible new allocation width ?
*/
priv->hscrollbar_visible = priv->hscrollbar_visible =
child_scroll_width > allocation->width - child_scroll_width > allocation->width -
(priv->vscrollbar_visible && !priv->touch_mode ? sb_width + sb_spacing : 0); (priv->vscrollbar_visible && !priv->use_indicators ? sb_width + sb_spacing : 0);
} }
else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */ else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
{ {
priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy); priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy);
priv->vscrollbar_visible = child_scroll_height > allocation->height - priv->vscrollbar_visible = child_scroll_height > allocation->height -
(priv->hscrollbar_visible && !priv->touch_mode ? sb_height + sb_spacing : 0); (priv->hscrollbar_visible && !priv->use_indicators ? sb_height + sb_spacing : 0);
} }
} }
else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */ else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
@ -2588,7 +2590,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC) if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
priv->hscrollbar_visible = priv->hscrollbar_visible =
child_scroll_width > allocation->width - child_scroll_width > allocation->width -
(priv->vscrollbar_visible && !priv->touch_mode ? 0 : sb_width + sb_spacing); (priv->vscrollbar_visible && !priv->use_indicators ? 0 : sb_width + sb_spacing);
else else
priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy); priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy);
} }
@ -2621,25 +2623,27 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
/* Does the content height fit the allocation with minus a possible scrollbar ? */ /* Does the content height fit the allocation with minus a possible scrollbar ? */
priv->vscrollbar_visible = priv->vscrollbar_visible =
child_scroll_height > allocation->height - child_scroll_height > allocation->height -
(priv->hscrollbar_visible && !priv->touch_mode ? sb_height + sb_spacing : 0); (priv->hscrollbar_visible && !priv->use_indicators ? sb_height + sb_spacing : 0);
/* Now that we've guessed the vscrollbar, does the content width fit /* Now that we've guessed the vscrollbar, does the content width fit
* the possible new allocation width ? */ * the possible new allocation width ?
*/
priv->hscrollbar_visible = priv->hscrollbar_visible =
child_scroll_width > allocation->width - child_scroll_width > allocation->width -
(priv->vscrollbar_visible && !priv->touch_mode ? sb_width + sb_spacing : 0); (priv->vscrollbar_visible && !priv->use_indicators ? sb_width + sb_spacing : 0);
/* Now that we've guessed the hscrollbar, does the content height fit /* Now that we've guessed the hscrollbar, does the content height fit
* the possible new allocation height ? */ * the possible new allocation height ?
*/
priv->vscrollbar_visible = priv->vscrollbar_visible =
child_scroll_height > allocation->height - child_scroll_height > allocation->height -
(priv->hscrollbar_visible && !priv->touch_mode ? sb_height + sb_spacing : 0); (priv->hscrollbar_visible && !priv->use_indicators ? sb_height + sb_spacing : 0);
} }
else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */ else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
{ {
priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy); priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy);
priv->hscrollbar_visible = child_scroll_width > allocation->width - priv->hscrollbar_visible = child_scroll_width > allocation->width -
(priv->vscrollbar_visible && !priv->touch_mode ? sb_width + sb_spacing : 0); (priv->vscrollbar_visible && !priv->use_indicators ? sb_width + sb_spacing : 0);
} }
} }
else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */ else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
@ -2649,7 +2653,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC) if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
priv->vscrollbar_visible = priv->vscrollbar_visible =
child_scroll_height > allocation->height - child_scroll_height > allocation->height -
(priv->hscrollbar_visible && !priv->touch_mode ? sb_height + sb_spacing : 0); (priv->hscrollbar_visible && !priv->use_indicators ? sb_height + sb_spacing : 0);
else else
priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy); priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy);
} }
@ -2714,14 +2718,14 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
if (priv->window_placement == GTK_CORNER_TOP_LEFT || if (priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_TOP_RIGHT) priv->window_placement == GTK_CORNER_TOP_RIGHT)
{ {
if (priv->touch_mode) if (priv->use_indicators)
child_allocation.y = relative_allocation.y + relative_allocation.height - sb_height; child_allocation.y = relative_allocation.y + relative_allocation.height - sb_height;
else else
child_allocation.y = relative_allocation.y + relative_allocation.height + sb_spacing; child_allocation.y = relative_allocation.y + relative_allocation.height + sb_spacing;
} }
else else
{ {
if (priv->touch_mode) if (priv->use_indicators)
child_allocation.y = relative_allocation.y; child_allocation.y = relative_allocation.y;
else else
child_allocation.y = relative_allocation.y - sb_spacing - sb_height; child_allocation.y = relative_allocation.y - sb_spacing - sb_height;
@ -2768,14 +2772,14 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
(priv->window_placement == GTK_CORNER_TOP_LEFT || (priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_BOTTOM_LEFT))) priv->window_placement == GTK_CORNER_BOTTOM_LEFT)))
{ {
if (priv->touch_mode) if (priv->use_indicators)
child_allocation.x = relative_allocation.x + relative_allocation.width - sb_width; child_allocation.x = relative_allocation.x + relative_allocation.width - sb_width;
else else
child_allocation.x = relative_allocation.x + relative_allocation.width + sb_spacing; child_allocation.x = relative_allocation.x + relative_allocation.width + sb_spacing;
} }
else else
{ {
if (priv->touch_mode) if (priv->use_indicators)
child_allocation.x = relative_allocation.x; child_allocation.x = relative_allocation.x;
else else
child_allocation.x = relative_allocation.x - sb_spacing - sb_width; child_allocation.x = relative_allocation.x - sb_spacing - sb_width;
@ -3479,7 +3483,7 @@ gtk_scrolled_window_get_preferred_size (GtkWidget *widget,
} }
} }
if (policy_may_be_visible (priv->hscrollbar_policy) && !priv->touch_mode) if (policy_may_be_visible (priv->hscrollbar_policy) && !priv->use_indicators)
{ {
minimum_req.width = MAX (minimum_req.width, hscrollbar_requisition.width); minimum_req.width = MAX (minimum_req.width, hscrollbar_requisition.width);
natural_req.width = MAX (natural_req.width, hscrollbar_requisition.width); natural_req.width = MAX (natural_req.width, hscrollbar_requisition.width);
@ -3487,7 +3491,7 @@ gtk_scrolled_window_get_preferred_size (GtkWidget *widget,
extra_height = scrollbar_spacing + hscrollbar_requisition.height; extra_height = scrollbar_spacing + hscrollbar_requisition.height;
} }
if (policy_may_be_visible (priv->vscrollbar_policy) && !priv->touch_mode) if (policy_may_be_visible (priv->vscrollbar_policy) && !priv->use_indicators)
{ {
minimum_req.height = MAX (minimum_req.height, vscrollbar_requisition.height); minimum_req.height = MAX (minimum_req.height, vscrollbar_requisition.height);
natural_req.height = MAX (natural_req.height, vscrollbar_requisition.height); natural_req.height = MAX (natural_req.height, vscrollbar_requisition.height);
@ -3657,7 +3661,7 @@ create_indicator_window (GtkScrolledWindow *scrolled_window,
gdk_window_set_background_rgba (window, &transparent); gdk_window_set_background_rgba (window, &transparent);
if (scrolled_window->priv->touch_mode) if (scrolled_window->priv->use_indicators)
gtk_widget_set_parent_window (child, window); gtk_widget_set_parent_window (child, window);
return window; return window;
@ -3932,33 +3936,33 @@ device_manager_has_mouse (GdkDeviceManager *dm)
} }
static void static void
gtk_scrolled_window_update_touch_mode (GtkScrolledWindow *scrolled_window) gtk_scrolled_window_update_use_indicators (GtkScrolledWindow *scrolled_window)
{ {
GtkScrolledWindowPrivate *priv = scrolled_window->priv; GtkScrolledWindowPrivate *priv = scrolled_window->priv;
gboolean touch_mode; gboolean use_indicators;
const gchar *env_overlay_scrolling; const gchar *env_overlay_scrolling;
const gchar *env_test_touchscreen; const gchar *env_test_touchscreen;
env_overlay_scrolling = g_getenv ("GTK_OVERLAY_SCROLLING"); env_overlay_scrolling = g_getenv ("GTK_OVERLAY_SCROLLING");
env_test_touchscreen = g_getenv ("GTK_TEST_TOUCHSCREEN"); env_test_touchscreen = g_getenv ("GTK_TEST_TOUCHSCREEN");
if (!priv->overlay_scrolling || g_strcmp0 (env_overlay_scrolling, "0") == 0) if (!priv->overlay_scrolling || g_strcmp0 (env_overlay_scrolling, "0") == 0)
touch_mode = FALSE; use_indicators = FALSE;
else if ((gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || else if ((gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 ||
env_test_touchscreen != NULL || env_test_touchscreen != NULL ||
g_strcmp0 (env_overlay_scrolling, "1") == 0) g_strcmp0 (env_overlay_scrolling, "1") == 0)
touch_mode = TRUE; use_indicators = TRUE;
else else
{ {
GdkDeviceManager *dm; GdkDeviceManager *dm;
dm = gdk_display_get_device_manager (gtk_widget_get_display (GTK_WIDGET (scrolled_window))); dm = gdk_display_get_device_manager (gtk_widget_get_display (GTK_WIDGET (scrolled_window)));
touch_mode = !device_manager_has_mouse (dm); use_indicators = !device_manager_has_mouse (dm);
} }
if (priv->touch_mode != touch_mode) if (priv->use_indicators != use_indicators)
{ {
priv->touch_mode = touch_mode; priv->use_indicators = use_indicators;
if (priv->touch_mode) if (priv->use_indicators)
{ {
setup_indicator (scrolled_window, &priv->hindicator, priv->hscrollbar); setup_indicator (scrolled_window, &priv->hindicator, priv->hscrollbar);
setup_indicator (scrolled_window, &priv->vindicator, priv->vscrollbar); setup_indicator (scrolled_window, &priv->vindicator, priv->vscrollbar);
@ -3978,7 +3982,7 @@ gtk_scrolled_window_device_added (GdkDeviceManager *dm,
GdkDevice *device, GdkDevice *device,
GtkScrolledWindow *scrolled_window) GtkScrolledWindow *scrolled_window)
{ {
gtk_scrolled_window_update_touch_mode (scrolled_window); gtk_scrolled_window_update_use_indicators (scrolled_window);
} }
static void static void
@ -3990,7 +3994,7 @@ gtk_scrolled_window_device_removed (GdkDeviceManager *dm,
* before the device is removed from the list. * before the device is removed from the list.
*/ */
g_object_set_data (G_OBJECT (device), "removed", GINT_TO_POINTER (1)); g_object_set_data (G_OBJECT (device), "removed", GINT_TO_POINTER (1));
gtk_scrolled_window_update_touch_mode (scrolled_window); gtk_scrolled_window_update_use_indicators (scrolled_window);
} }
static void static void
@ -4031,7 +4035,7 @@ gtk_scrolled_window_realize (GtkWidget *widget)
priv->hindicator.scrollbar = priv->hscrollbar; priv->hindicator.scrollbar = priv->hscrollbar;
priv->vindicator.scrollbar = priv->vscrollbar; priv->vindicator.scrollbar = priv->vscrollbar;
gtk_scrolled_window_update_touch_mode (scrolled_window); gtk_scrolled_window_update_use_indicators (scrolled_window);
dm = gdk_display_get_device_manager (gtk_widget_get_display (widget)); dm = gdk_display_get_device_manager (gtk_widget_get_display (widget));
g_signal_connect (dm, "device-added", g_signal_connect (dm, "device-added",
@ -4208,7 +4212,7 @@ gtk_scrolled_window_set_overlay_scrolling (GtkScrolledWindow *scrolled_window,
priv->overlay_scrolling = overlay_scrolling; priv->overlay_scrolling = overlay_scrolling;
if (gtk_widget_get_realized (GTK_WIDGET (scrolled_window))) if (gtk_widget_get_realized (GTK_WIDGET (scrolled_window)))
gtk_scrolled_window_update_touch_mode (scrolled_window); gtk_scrolled_window_update_use_indicators (scrolled_window);
g_object_notify (G_OBJECT (scrolled_window), "overlay-scrolling"); g_object_notify (G_OBJECT (scrolled_window), "overlay-scrolling");
} }