2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
* Copyright (C) 2001 Red Hat, Inc.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
2008-11-06 23:52:30 +00:00
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2008-11-06 23:52:30 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
#include "gtkscrollbar.h"
|
2017-05-25 15:34:23 +00:00
|
|
|
|
#include "gtkrange.h"
|
2012-03-03 18:41:55 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkadjustment.h"
|
2016-02-23 06:00:57 +00:00
|
|
|
|
#include "gtkorientable.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2020-04-08 11:43:28 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2019-07-15 05:48:46 +00:00
|
|
|
|
#include "gtkboxlayout.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2010-10-22 20:41:55 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-03-01 13:19:09 +00:00
|
|
|
|
* GtkScrollbar:
|
2010-10-22 20:41:55 +00:00
|
|
|
|
*
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* The `GtkScrollbar` widget is a horizontal or vertical scrollbar.
|
|
|
|
|
*
|
|
|
|
|
* ![An example GtkScrollbar](scrollbar.png)
|
2010-10-22 20:41:55 +00:00
|
|
|
|
*
|
2017-03-20 23:54:57 +00:00
|
|
|
|
* Its position and movement are controlled by the adjustment that is passed to
|
2021-05-27 00:18:23 +00:00
|
|
|
|
* or created by [ctor@Gtk.Scrollbar.new]. See [class@Gtk.Adjustment] for more
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* details. The [property@Gtk.Adjustment:value] field sets the position of the
|
|
|
|
|
* thumb and must be between [property@Gtk.Adjustment:lower] and
|
|
|
|
|
* [property@Gtk.Adjustment:upper] - [property@Gtk.Adjustment:page-size].
|
|
|
|
|
* The [property@Gtk.Adjustment:page-size] represents the size of the visible
|
|
|
|
|
* scrollable area.
|
|
|
|
|
*
|
|
|
|
|
* The fields [property@Gtk.Adjustment:step-increment] and
|
|
|
|
|
* [property@Gtk.Adjustment:page-increment] fields are added to or subtracted
|
|
|
|
|
* from the [property@Gtk.Adjustment:value] when the user asks to move by a step
|
|
|
|
|
* (using e.g. the cursor arrow keys) or by a page (using e.g. the Page Down/Up
|
|
|
|
|
* keys).
|
2015-11-04 04:11:52 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
2021-02-28 01:05:28 +00:00
|
|
|
|
* ```
|
2017-10-07 23:10:10 +00:00
|
|
|
|
* scrollbar
|
2019-07-15 05:48:46 +00:00
|
|
|
|
* ╰── range[.fine-tune]
|
|
|
|
|
* ╰── trough
|
|
|
|
|
* ╰── slider
|
2021-02-28 01:05:28 +00:00
|
|
|
|
* ```
|
2015-11-04 04:11:52 +00:00
|
|
|
|
*
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* `GtkScrollbar` has a main CSS node with name scrollbar and a subnode for its
|
|
|
|
|
* contents. The main node gets the .horizontal or .vertical style classes applied,
|
|
|
|
|
* depending on the scrollbar's orientation.
|
2015-11-06 12:51:15 +00:00
|
|
|
|
*
|
2017-10-07 23:10:10 +00:00
|
|
|
|
* The range node gets the style class .fine-tune added when the scrollbar is
|
2015-11-06 12:51:15 +00:00
|
|
|
|
* in 'fine-tuning' mode.
|
|
|
|
|
*
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* Other style classes that may be added to scrollbars inside
|
|
|
|
|
* [class@Gtk.ScrolledWindow] include the positional classes (.left, .right,
|
|
|
|
|
* .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator,
|
|
|
|
|
* .dragging, .hovering).
|
2020-07-27 14:46:52 +00:00
|
|
|
|
*
|
|
|
|
|
* # Accessibility
|
|
|
|
|
*
|
2021-03-01 13:19:09 +00:00
|
|
|
|
* `GtkScrollbar` uses the %GTK_ACCESSIBLE_ROLE_SCROLLBAR role.
|
2010-10-22 20:41:55 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2019-05-27 02:37:42 +00:00
|
|
|
|
typedef struct _GtkScrollbarClass GtkScrollbarClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkScrollbar
|
|
|
|
|
{
|
|
|
|
|
GtkWidget parent_instance;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkScrollbarClass
|
|
|
|
|
{
|
|
|
|
|
GtkWidgetClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-07 14:15:40 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
GtkOrientation orientation;
|
|
|
|
|
GtkWidget *range;
|
|
|
|
|
} GtkScrollbarPrivate;
|
2010-10-22 20:41:55 +00:00
|
|
|
|
|
2017-05-07 14:15:40 +00:00
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_ADJUSTMENT,
|
|
|
|
|
|
|
|
|
|
PROP_ORIENTATION,
|
|
|
|
|
LAST_PROP = PROP_ORIENTATION
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_WIDGET,
|
|
|
|
|
G_ADD_PRIVATE (GtkScrollbar)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static GParamSpec *props[LAST_PROP] = { NULL, };
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
2017-05-07 14:15:40 +00:00
|
|
|
|
gtk_scrollbar_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2017-05-07 14:15:40 +00:00
|
|
|
|
GtkScrollbar *self = GTK_SCROLLBAR (object);
|
|
|
|
|
GtkScrollbarPrivate *priv = gtk_scrollbar_get_instance_private (self);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_ADJUSTMENT:
|
|
|
|
|
g_value_set_object (value, gtk_scrollbar_get_adjustment (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ORIENTATION:
|
|
|
|
|
g_value_set_enum (value, priv->orientation);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-10-22 15:42:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-05-07 14:15:40 +00:00
|
|
|
|
gtk_scrollbar_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2012-10-22 15:42:55 +00:00
|
|
|
|
{
|
2017-05-07 14:15:40 +00:00
|
|
|
|
GtkScrollbar *self = GTK_SCROLLBAR (object);
|
|
|
|
|
GtkScrollbarPrivate *priv = gtk_scrollbar_get_instance_private (self);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_ADJUSTMENT:
|
|
|
|
|
gtk_scrollbar_set_adjustment (self, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ORIENTATION:
|
|
|
|
|
{
|
|
|
|
|
GtkOrientation orientation = g_value_get_enum (value);
|
|
|
|
|
|
|
|
|
|
if (orientation != priv->orientation)
|
|
|
|
|
{
|
2019-07-15 05:48:46 +00:00
|
|
|
|
GtkLayoutManager *layout = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), orientation);
|
2017-05-07 14:15:40 +00:00
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->range), orientation);
|
|
|
|
|
priv->orientation = orientation;
|
2020-04-23 16:48:29 +00:00
|
|
|
|
gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
|
2017-05-07 14:15:40 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
2017-06-16 13:22:59 +00:00
|
|
|
|
g_object_notify_by_pspec (object, pspec);
|
2020-07-28 00:27:27 +00:00
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_ORIENTATION, orientation,
|
|
|
|
|
-1);
|
2017-05-07 14:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-10-22 15:42:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 00:27:27 +00:00
|
|
|
|
static void gtk_scrollbar_adjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static void gtk_scrollbar_adjustment_value_changed (GtkAdjustment *adjustment,
|
|
|
|
|
gpointer data);
|
|
|
|
|
|
2012-10-22 15:42:55 +00:00
|
|
|
|
static void
|
2017-05-07 14:15:40 +00:00
|
|
|
|
gtk_scrollbar_dispose (GObject *object)
|
2012-10-22 15:42:55 +00:00
|
|
|
|
{
|
2017-05-07 14:15:40 +00:00
|
|
|
|
GtkScrollbar *self = GTK_SCROLLBAR (object);
|
|
|
|
|
GtkScrollbarPrivate *priv = gtk_scrollbar_get_instance_private (self);
|
2020-07-28 00:27:27 +00:00
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
|
|
|
|
|
|
adj = gtk_range_get_adjustment (GTK_RANGE (priv->range));
|
|
|
|
|
if (adj)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (adj, gtk_scrollbar_adjustment_changed, self);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (adj, gtk_scrollbar_adjustment_value_changed, self);
|
|
|
|
|
}
|
2017-05-07 14:15:40 +00:00
|
|
|
|
|
2019-07-15 05:48:46 +00:00
|
|
|
|
g_clear_pointer (&priv->range, gtk_widget_unparent);
|
2017-05-07 14:15:40 +00:00
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_scrollbar_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scrollbar_class_init (GtkScrollbarClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
|
|
|
|
|
|
|
|
|
object_class->get_property = gtk_scrollbar_get_property;
|
|
|
|
|
object_class->set_property = gtk_scrollbar_set_property;
|
|
|
|
|
object_class->dispose = gtk_scrollbar_dispose;
|
|
|
|
|
|
2021-02-20 00:51:52 +00:00
|
|
|
|
/**
|
2021-02-25 02:58:11 +00:00
|
|
|
|
* GtkScrollbar:adjustment: (attributes org.gtk.Property.get=gtk_scrollbar_get_adjustment org.gtk.Property.set=gtk_scrollbar_set_adjustment)
|
2021-02-20 00:51:52 +00:00
|
|
|
|
*
|
|
|
|
|
* The `GtkAdjustment` controlled by this scrollbar.
|
|
|
|
|
*/
|
2017-05-07 14:15:40 +00:00
|
|
|
|
props[PROP_ADJUSTMENT] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_object ("adjustment", NULL, NULL,
|
2017-05-07 14:15:40 +00:00
|
|
|
|
GTK_TYPE_ADJUSTMENT,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT);
|
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, LAST_PROP, props);
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
|
|
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("scrollbar"));
|
2019-07-15 05:48:46 +00:00
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
2020-07-13 15:03:27 +00:00
|
|
|
|
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_SCROLLBAR);
|
2017-05-07 14:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scrollbar_init (GtkScrollbar *self)
|
|
|
|
|
{
|
|
|
|
|
GtkScrollbarPrivate *priv = gtk_scrollbar_get_instance_private (self);
|
|
|
|
|
|
|
|
|
|
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
|
|
|
|
|
|
|
|
|
|
priv->range = g_object_new (GTK_TYPE_RANGE, NULL);
|
|
|
|
|
gtk_widget_set_hexpand (priv->range, TRUE);
|
|
|
|
|
gtk_widget_set_vexpand (priv->range, TRUE);
|
2019-07-15 05:48:46 +00:00
|
|
|
|
gtk_widget_set_parent (priv->range, GTK_WIDGET (self));
|
2020-04-23 16:48:29 +00:00
|
|
|
|
gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
|
2020-07-28 00:27:27 +00:00
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_ORIENTATION, priv->orientation,
|
|
|
|
|
-1);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
2005-03-20 07:01:23 +00:00
|
|
|
|
|
2008-11-11 17:47:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_scrollbar_new:
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* @orientation: the scrollbar’s orientation.
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* @adjustment: (nullable): the [class@Gtk.Adjustment] to use, or %NULL
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* to create a new adjustment.
|
2008-11-11 17:47:13 +00:00
|
|
|
|
*
|
|
|
|
|
* Creates a new scrollbar with the given orientation.
|
|
|
|
|
*
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* Returns: the new `GtkScrollbar`.
|
|
|
|
|
*/
|
2008-11-11 17:47:13 +00:00
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_scrollbar_new (GtkOrientation orientation,
|
|
|
|
|
GtkAdjustment *adjustment)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
return g_object_new (GTK_TYPE_SCROLLBAR,
|
|
|
|
|
"orientation", orientation,
|
|
|
|
|
"adjustment", adjustment,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2017-05-07 14:15:40 +00:00
|
|
|
|
|
2020-07-28 00:27:27 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scrollbar_adjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkScrollbar *self = data;
|
|
|
|
|
|
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, gtk_adjustment_get_upper (adjustment),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, gtk_adjustment_get_lower (adjustment),
|
|
|
|
|
-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scrollbar_adjustment_value_changed (GtkAdjustment *adjustment,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkScrollbar *self = data;
|
|
|
|
|
|
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, gtk_adjustment_get_value (adjustment),
|
|
|
|
|
-1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-07 14:15:40 +00:00
|
|
|
|
/**
|
2021-02-25 02:58:11 +00:00
|
|
|
|
* gtk_scrollbar_set_adjustment: (attributes org.gtk.Method.set_property=adjustment)
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* @self: a `GtkScrollbar`
|
2017-05-07 14:15:40 +00:00
|
|
|
|
* @adjustment: (nullable): the adjustment to set
|
|
|
|
|
*
|
|
|
|
|
* Makes the scrollbar use the given adjustment.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scrollbar_set_adjustment (GtkScrollbar *self,
|
|
|
|
|
GtkAdjustment *adjustment)
|
|
|
|
|
{
|
|
|
|
|
GtkScrollbarPrivate *priv = gtk_scrollbar_get_instance_private (self);
|
2020-07-28 00:27:27 +00:00
|
|
|
|
GtkAdjustment *adj;
|
2017-05-07 14:15:40 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_SCROLLBAR (self));
|
|
|
|
|
g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));
|
|
|
|
|
|
2020-07-28 00:27:27 +00:00
|
|
|
|
adj = gtk_range_get_adjustment (GTK_RANGE (priv->range));
|
|
|
|
|
if (adj)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (adj, gtk_scrollbar_adjustment_changed, self);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (adj, gtk_scrollbar_adjustment_value_changed, self);
|
|
|
|
|
}
|
2017-05-07 14:15:40 +00:00
|
|
|
|
|
|
|
|
|
gtk_range_set_adjustment (GTK_RANGE (priv->range), adjustment);
|
|
|
|
|
|
2020-07-28 00:27:27 +00:00
|
|
|
|
if (adjustment)
|
|
|
|
|
{
|
|
|
|
|
g_signal_connect (adjustment, "changed",
|
|
|
|
|
G_CALLBACK (gtk_scrollbar_adjustment_changed), self);
|
|
|
|
|
g_signal_connect (adjustment, "value-changed",
|
|
|
|
|
G_CALLBACK (gtk_scrollbar_adjustment_value_changed), self);
|
|
|
|
|
|
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, gtk_adjustment_get_upper (adjustment),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, gtk_adjustment_get_lower (adjustment),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, gtk_adjustment_get_value (adjustment),
|
|
|
|
|
-1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-07 14:15:40 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ADJUSTMENT]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 02:58:11 +00:00
|
|
|
|
* gtk_scrollbar_get_adjustment: (attributes org.gtk.Method.get_property=adjustment)
|
2021-02-20 00:51:52 +00:00
|
|
|
|
* @self: a `GtkScrollbar`
|
2017-05-07 14:15:40 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the scrollbar's adjustment.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the scrollbar's adjustment
|
|
|
|
|
*/
|
|
|
|
|
GtkAdjustment *
|
|
|
|
|
gtk_scrollbar_get_adjustment (GtkScrollbar *self)
|
|
|
|
|
{
|
|
|
|
|
GtkScrollbarPrivate *priv = gtk_scrollbar_get_instance_private (self);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_SCROLLBAR (self), NULL);
|
|
|
|
|
|
2020-04-04 03:31:45 +00:00
|
|
|
|
if (priv->range)
|
|
|
|
|
return gtk_range_get_adjustment (GTK_RANGE (priv->range));
|
|
|
|
|
|
|
|
|
|
return NULL;
|
2017-05-07 14:15:40 +00:00
|
|
|
|
}
|