-#include "gtkscrollingwindow.h"
+#include "gtkscrolledview.h"
/**
- * SECTION:gtkscrollingwindow
+ * SECTION:gtkscrolledview
* @Short_description: Adds scrollbars to its child widget
- * @Title: GtkScrollingWindow
+ * @Title: GtkScrolledView
* @See_also: #GtkScrollable, #GtkViewport, #GtkAdjustment
*
- * #GtkScrollingWindow is a #GtkBin subclass: it's a container that
+ * #GtkScrolledView is a #GtkBin subclass: it's a container that
* accepts a single child widget (a GtkScrollable) and adds an
* optional beveled frame and scrollbars.
*
* The position of the scrollbars is controlled by the scroll
* adjustments. See #GtkAdjustment for the fields in an adjustment.
*
- * #GtkScrollingWindow is a #GtkScrolledWindow subclass that overrides
+ * #GtkScrolledView is a #GtkScrolledWindow subclass that overrides
* the geometry protocol to work as follows:
*
* A scrolled window (GtkScrolledWindow) is about squeezing an overly
* It ignores the natural size of the problem widget, expecting a
* gtk_widget_set_size_request to override (squeeze) it.
*
- * A scrolling window (GtkScrollingWindow) is about sticking
- * scrollbars on a viewport -- a GtkScrollable. Its natural size is
- * the natural size of the viewport, scrollbars and frame (with
- * spacing). Using gtk_widget_set_size_request interferes with the
- * natural sizing (esp. shrinking of expandable viewports).
+ * A scrolled view (GtkScrolledView) is about sticking scrollbars on a
+ * viewport -- a GtkScrollable. Its natural size is the natural size
+ * of the viewport, scrollbars and frame (with spacing). Using
+ * gtk_widget_set_size_request interferes with the natural sizing
+ * (esp. shrinking of expandable viewports).
*/
struct _GtkScrolledWindowPrivate
gint min_content_width;
gint min_content_height;
-
- /* Kinetic scrolling */
- GdkEvent *button_press_event;
- GdkWindow *overshoot_window;
- GdkDevice *drag_device;
- guint kinetic_scrolling : 1;
- guint capture_button_press : 1;
- guint in_drag : 1;
- guint last_button_event_valid : 1;
-
- guint release_timeout_id;
- guint deceleration_id;
-
- gdouble last_button_event_x_root;
- gdouble last_button_event_y_root;
-
- gdouble last_motion_event_x_root;
- gdouble last_motion_event_y_root;
- guint32 last_motion_event_time;
-
- gdouble x_velocity;
- gdouble y_velocity;
-
- gdouble unclamped_hadj_value;
- gdouble unclamped_vadj_value;
};
-static void
-gtk_scrolled_window_update_real_placement (GtkScrolledWindow *scrolled_window)
-{
- GtkScrolledWindowPrivate *priv = scrolled_window->priv;
- GtkSettings *settings;
-
- settings = gtk_widget_get_settings (GTK_WIDGET (scrolled_window));
-
- if (priv->window_placement_set || settings == NULL)
- priv->real_window_placement = priv->window_placement;
- else
- g_object_get (settings,
- "gtk-scrolled-window-placement",
- &priv->real_window_placement,
- NULL);
-}
-
-static void
-gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
-{
- GtkScrolledWindowPrivate *priv;
-
- scrolled_window->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (scrolled_window,
- GTK_TYPE_SCROLLED_WINDOW,
- GtkScrolledWindowPrivate);
-
- gtk_widget_set_has_window (GTK_WIDGET (scrolled_window), FALSE);
- gtk_widget_set_can_focus (GTK_WIDGET (scrolled_window), TRUE);
-
- priv->hscrollbar = NULL;
- priv->vscrollbar = NULL;
- priv->hscrollbar_policy = GTK_POLICY_AUTOMATIC;
- priv->vscrollbar_policy = GTK_POLICY_AUTOMATIC;
- priv->hscrollbar_visible = FALSE;
- priv->vscrollbar_visible = FALSE;
- priv->focus_out = FALSE;
- priv->window_placement = GTK_CORNER_TOP_LEFT;
- gtk_scrolled_window_update_real_placement (scrolled_window);
- priv->min_content_width = -1;
- priv->min_content_height = -1;
-
- gtk_scrolled_window_set_kinetic_scrolling (scrolled_window, TRUE);
- gtk_scrolled_window_set_capture_button_press (scrolled_window, TRUE);
-}
-
-static void gtk_scrolling_window_get_preferred_width (GtkWidget *widget,
+static void gtk_scrolled_view_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_scrolling_window_get_preferred_height (GtkWidget *widget,
+static void gtk_scrolled_view_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_scrolling_window_get_preferred_height_for_width (GtkWidget *layout,
+static void gtk_scrolled_view_get_preferred_height_for_width (GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
-static void gtk_scrolling_window_get_preferred_width_for_height (GtkWidget *layout,
+static void gtk_scrolled_view_get_preferred_width_for_height (GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
-G_DEFINE_TYPE (GtkScrollingWindow, gtk_scrolling_window,
+G_DEFINE_TYPE (GtkScrolledView, gtk_scrolled_view,
GTK_TYPE_SCROLLED_WINDOW)
static void
-gtk_scrolling_window_class_init (GtkScrollingWindowClass *class)
+gtk_scrolled_view_class_init (GtkScrolledViewClass *class)
{
GtkWidgetClass *widget_class = (GtkWidgetClass*) class;
- widget_class->get_preferred_width = gtk_scrolling_window_get_preferred_width;
- widget_class->get_preferred_height = gtk_scrolling_window_get_preferred_height;
- widget_class->get_preferred_height_for_width = gtk_scrolling_window_get_preferred_height_for_width;
- widget_class->get_preferred_width_for_height = gtk_scrolling_window_get_preferred_width_for_height;
+ widget_class->get_preferred_width = gtk_scrolled_view_get_preferred_width;
+ widget_class->get_preferred_height = gtk_scrolled_view_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_scrolled_view_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_scrolled_view_get_preferred_width_for_height;
}
static void
-gtk_scrolling_window_init (GtkScrollingWindow *scrolling_window)
+gtk_scrolled_view_init (GtkScrolledView *scrolled_view)
{
- gtk_scrolled_window_init (GTK_SCROLLED_WINDOW (scrolling_window));
+ g_assert (GTK_SCROLLED_WINDOW (scrolled_view) ->priv != NULL);
}
/**
- * gtk_scrolling_window_new:
+ * gtk_scrolled_view_new:
* @hadjustment: (allow-none): horizontal adjustment
* @vadjustment: (allow-none): vertical adjustment
*
* Returns: a new scrolling window
*/
GtkWidget*
-gtk_scrolling_window_new (GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment)
+gtk_scrolled_view_new (GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment)
{
- GtkWidget *scrolling_window;
+ GtkWidget *scrolled_view;
if (hadjustment)
g_return_val_if_fail (GTK_IS_ADJUSTMENT (hadjustment), NULL);
if (vadjustment)
g_return_val_if_fail (GTK_IS_ADJUSTMENT (vadjustment), NULL);
- scrolling_window = g_object_new (GTK_TYPE_SCROLLING_WINDOW,
- "hadjustment", hadjustment,
- "vadjustment", vadjustment,
- NULL);
+ scrolled_view = g_object_new (GTK_TYPE_SCROLLED_VIEW,
+ "hadjustment", hadjustment,
+ "vadjustment", vadjustment,
+ NULL);
- return scrolling_window;
+ return scrolled_view;
}
-extern gboolean ubuntu_overlay_scrollbar_get_enabled (void);
-
static gint
gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window)
{
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0);
- if (ubuntu_overlay_scrollbar_get_enabled ())
- return 0;
-
class = GTK_SCROLLED_WINDOW_GET_CLASS (scrolled_window);
if (class->scrollbar_spacing >= 0)
}
static void
-gtk_scrolling_window_get_preferred_size (GtkWidget *widget,
+gtk_scrolled_view_get_preferred_size (GtkWidget *widget,
GtkOrientation orientation,
gint *minimum_size,
gint *natural_size)
}
/* Add scrollbar size. */
- if (priv->vscrollbar_policy != GTK_POLICY_NEVER)
+ if ((orientation == GTK_ORIENTATION_VERTICAL
+ && priv->hscrollbar_policy != GTK_POLICY_NEVER) ||
+ (orientation == GTK_ORIENTATION_HORIZONTAL
+ && priv->vscrollbar_policy != GTK_POLICY_NEVER))
{
gint min, nat;
gint space = gtk_scrolled_window_get_scrollbar_spacing (scrolled_window);
}
static void
-gtk_scrolling_window_get_preferred_width (GtkWidget *widget,
+gtk_scrolled_view_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
- gtk_scrolling_window_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_scrolled_view_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_scrolling_window_get_preferred_height (GtkWidget *widget,
+gtk_scrolled_view_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
- gtk_scrolling_window_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_scrolled_view_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_scrolling_window_get_preferred_height_for_width (GtkWidget *widget,
+gtk_scrolled_view_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum_height,
gint *natural_height)
}
static void
-gtk_scrolling_window_get_preferred_width_for_height (GtkWidget *widget,
+gtk_scrolled_view_get_preferred_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width)