gtk2/gtk/gtkscrolledwindow.c

4301 lines
156 KiB
C
Raw Normal View History

/* GTK - The GIMP Toolkit
1997-11-24 22:37:52 +00:00
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* 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
* Lesser General Public License for more details.
1997-11-24 22:37:52 +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
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gtkscrolledwindow.h"
#include "gtkadjustment.h"
#include "gtkadjustmentprivate.h"
#include "gtkbuildable.h"
#include "gtkdragsourceprivate.h"
#include "gtkeventcontrollermotion.h"
#include "gtkeventcontrollerscroll.h"
#include "gtkeventcontrollerprivate.h"
#include "gtkgesturedrag.h"
#include "gtkgesturelongpress.h"
#include "gtkgesturepan.h"
#include "gtkgesturesingle.h"
#include "gtkgestureswipe.h"
#include "gtkgestureprivate.h"
#include "gtkkineticscrollingprivate.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "gtkscrollable.h"
#include "gtkscrollbar.h"
#include "gtksettingsprivate.h"
#include "gtksnapshot.h"
#include "gtkrenderbackgroundprivate.h"
#include "gtkrenderborderprivate.h"
#include "gtktypebuiltins.h"
#include "gtkviewport.h"
#include "gtkwidgetprivate.h"
#include <math.h>
/**
* GtkScrolledWindow:
*
* `GtkScrolledWindow` is a container that makes its child scrollable.
*
* It does so using either internally added scrollbars or externally
* associated adjustments, and optionally draws a frame around the child.
*
* Widgets with native scrolling support, i.e. those whose classes implement
* the [iface@Gtk.Scrollable] interface, are added directly. For other types
* of widget, the class [class@Gtk.Viewport] acts as an adaptor, giving
* scrollability to other widgets. [method@Gtk.ScrolledWindow.set_child]
* intelligently accounts for whether or not the added child is a `GtkScrollable`.
* If it isnt, then it wraps the child in a `GtkViewport`. Therefore, you can
* just add any child widget and not worry about the details.
*
* If [method@Gtk.ScrolledWindow.set_child] has added a `GtkViewport` for you,
* it will be automatically removed hen you unset the child.
* Unless [property@Gtk.ScrolledWindow:hscrollbar-policy] and
* [property@Gtk.ScrolledWindow:vscrollbar-policy] are %GTK_POLICY_NEVER or
* %GTK_POLICY_EXTERNAL, `GtkScrolledWindow` adds internal `GtkScrollbar` widgets
* around its child. The scroll position of the child, and if applicable the
* scrollbars, is controlled by the [property@Gtk.ScrolledWindow:hadjustment]
* and [property@Gtk.ScrolledWindow:vadjustment] that are associated with the
* `GtkScrolledWindow`. See the docs on [class@Gtk.Scrollbar] for the details,
* but note that the step_increment and page_increment fields are only
* effective if the policy causes scrollbars to be present.
*
* If a `GtkScrolledWindow` doesnt behave quite as you would like, or
2014-02-07 18:32:47 +00:00
* doesnt have exactly the right layout, its very possible to set up
* your own scrolling with `GtkScrollbar` and for example a `GtkGrid`.
*
* # Touch support
*
* `GtkScrolledWindow` has built-in support for touch devices. When a
* touchscreen is used, swiping will move the scrolled window, and will
* expose 'kinetic' behavior. This can be turned off with the
* [property@Gtk.ScrolledWindow:kinetic-scrolling] property if it is undesired.
*
* `GtkScrolledWindow` also displays visual 'overshoot' indication when
* the content is pulled beyond the end, and this situation can be
* captured with the [signal@Gtk.ScrolledWindow::edge-overshot] signal.
*
* If no mouse device is present, the scrollbars will overlaid as
* narrow, auto-hiding indicators over the content. If traditional
* scrollbars are desired although no mouse is present, this behaviour
* can be turned off with the [property@Gtk.ScrolledWindow:overlay-scrolling]
* property.
*
* # CSS nodes
*
* `GtkScrolledWindow` has a main CSS node with name scrolledwindow.
* It gets a .frame style class added when [property@Gtk.ScrolledWindow:has-frame]
* is %TRUE.
*
* It uses subnodes with names overshoot and undershoot to draw the overflow
* and underflow indications. These nodes get the .left, .right, .top or .bottom
* style class added depending on where the indication is drawn.
*
* `GtkScrolledWindow` also sets the positional style classes (.left, .right,
* .top, .bottom) and style classes related to overlay scrolling
* (.overlay-indicator, .dragging, .hovering) on its scrollbars.
*
* If both scrollbars are visible, the area where they meet is drawn
* with a subnode named junction.
*
* # Accessibility
*
* `GtkScrolledWindow` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
*/
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
/* scrolled window policy and size requisition handling:
*
* gtk size requisition works as follows:
* a widget upon size-request reports the width and height that it finds
* to be best suited to display its contents, including children.
* the width and/or height reported from a widget upon size requisition
2020-05-28 08:00:03 +00:00
* may be overridden by the user by specifying a width and/or height
* other than 0 through gtk_widget_set_size_request().
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
*
* a scrolled window needs (for implementing all three policy types) to
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
* request its width and height based on two different rationales.
* 1) the user wants the scrolled window to just fit into the space
2020-05-28 08:00:03 +00:00
* that it gets allocated for a specific dimension.
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
* 1.1) this does not apply if the user specified a concrete value
* value for that specific dimension by either specifying usize for the
* scrolled window or for its child.
* 2) the user wants the scrolled window to take as much space up as
2020-05-28 08:00:03 +00:00
* is desired by the child for a specific dimension (i.e. POLICY_NEVER).
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
*
* also, kinda obvious:
2020-05-28 08:00:03 +00:00
* 3) a user would certainly not have chosen a scrolled window as a container
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
* for the child, if the resulting allocation takes up more space than the
* child would have allocated without the scrolled window.
*
* conclusions:
2014-02-07 18:32:47 +00:00
* A) from 1) follows: the scrolled window shouldnt request more space for a
2020-05-28 08:00:03 +00:00
* specific dimension than is required at minimum.
* B) from 1.1) follows: the requisition may be overridden by usize of the scrolled
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
* window (done automatically) or by usize of the child (needs to be checked).
* C) from 2) follows: for POLICY_NEVER, the scrolled window simply reports the
* childs dimension.
* D) from 3) follows: the scrolled window childs minimum width and minimum height
s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. Wed Dec 2 01:39:02 1998 Tim Janik <timj@gtk.org> * gtk/gtknotebook.h: * gtk/gtknotebook.c: s/gtk_notebook_nth_page/gtk_notebook_get_nth_page/. * incremented version number to 1.1.6 and made Gtk dependant on GLib 1.1.6. * gtk/gtkwidget.h (struct _GtkRequisition): changed width and height from guint16 to gint16, since sizes bigger than 32767 are not supported anyways, and aritmethics with intermediate negative values are possible now. Tue Dec 1 00:00:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.c: implementation of GTK_POLICY_NEVER functionality, added rationales on the policy and size requisition handling at the top. (gtk_scrolled_window_size_request): we assume a default minimum for our child's width and height if [hv]scrollbar_policy != GTK_POLICY_NEVER, except when the user specified the dimension explicitely. (gtk_scrolled_window_size_allocate): do not show scrollbars if [hv]scrollbar_policy == GTK_POLICY_NEVER. * gtk/gtkviewport.c (gtk_viewport_size_request): report the real size we require (including the child). * gtk/gtkclist.c: (gtk_clist_size_request): report the real size required. * gtk/gtkenums.h (enum GtkPolicyType): added GTK_POLICY_NEVER. * gtk/gtkobject.c (gtk_object_init_type): object_type doesn't need to be a static variable. Mon Nov 30 22:41:25 1998 Tim Janik <timj@gtk.org> * gtk/gtkclist.h: * gtk/gtkclist.c: * gtk/gtkviewport.h: * gtk/gtkviewport.c: * gtk/gtktext.h: * gtk/gtktext.c: * gtk/gtklayout.h: * gtk/gtklayout.c: * gtk/gtkwidget.h: * gtk/gtkwidget.c: * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: s/scroll_adjustements/scroll_adjustments/ s/scroll_adjustments/set_scroll_adjustments/g
1998-12-02 03:40:03 +00:00
* under A) at least correspond to the space taken up by its scrollbars.
*/
/* Kinetic scrolling */
#define MAX_OVERSHOOT_DISTANCE 100
#define DECELERATION_FRICTION 4
#define OVERSHOOT_FRICTION 20
#define VELOCITY_ACCUMULATION_FLOOR 0.33
#define VELOCITY_ACCUMULATION_CEIL 1.0
#define VELOCITY_ACCUMULATION_MAX 6.0
1997-11-24 22:37:52 +00:00
/* Animated scrolling */
#define ANIMATION_DURATION 200
/* Overlay scrollbars */
#define INDICATOR_FADE_OUT_DELAY 2000
#define INDICATOR_FADE_OUT_DURATION 1000
#define INDICATOR_FADE_OUT_TIME 500
#define INDICATOR_CLOSE_DISTANCE 5
#define INDICATOR_FAR_DISTANCE 10
/* Scrolled off indication */
#define UNDERSHOOT_SIZE 40
#define MAGIC_SCROLL_FACTOR 2.5
2019-05-28 21:04:32 +00:00
typedef struct _GtkScrolledWindowClass GtkScrolledWindowClass;
struct _GtkScrolledWindow
{
GtkWidget parent_instance;
2019-05-28 21:04:32 +00:00
};
struct _GtkScrolledWindowClass
{
GtkWidgetClass parent_class;
2019-05-28 21:04:32 +00:00
/* Unfortunately, GtkScrollType is deficient in that there is
* no horizontal/vertical variants for GTK_SCROLL_START/END,
* so we have to add an additional boolean flag.
*/
gboolean (*scroll_child) (GtkScrolledWindow *scrolled_window,
GtkScrollType scroll,
gboolean horizontal);
void (* move_focus_out) (GtkScrolledWindow *scrolled_window,
GtkDirectionType direction);
};
typedef struct
{
GtkWidget *scrollbar;
gboolean over; /* either mouse over, or while dragging */
gint64 last_scroll_time;
guint conceil_timer;
2020-07-24 20:32:16 +00:00
double current_pos;
double source_pos;
double target_pos;
GtkProgressTracker tracker;
guint tick_id;
guint over_timeout_id;
} Indicator;
2018-06-16 09:47:06 +00:00
typedef struct
{
GtkWidget *child;
GtkWidget *hscrollbar;
GtkWidget *vscrollbar;
GtkCssNode *overshoot_node[4];
GtkCssNode *undershoot_node[4];
GtkCssNode *junction_node;
Indicator hindicator;
Indicator vindicator;
GtkCornerType window_placement;
guint has_frame : 1;
guint hscrollbar_policy : 2;
guint vscrollbar_policy : 2;
guint hscrollbar_visible : 1;
guint vscrollbar_visible : 1;
guint focus_out : 1; /* used by ::move-focus-out implementation */
guint overlay_scrolling : 1;
guint use_indicators : 1;
guint auto_added_viewport : 1;
guint propagate_natural_width : 1;
guint propagate_natural_height : 1;
guint smooth_scroll : 1;
2020-07-24 13:54:49 +00:00
int min_content_width;
int min_content_height;
int max_content_width;
int max_content_height;
guint scroll_events_overshoot_id;
/* Kinetic scrolling */
GtkGesture *long_press_gesture;
GtkGesture *swipe_gesture;
GtkKineticScrolling *hscrolling;
GtkKineticScrolling *vscrolling;
gint64 last_deceleration_time;
/* These two gestures are mutually exclusive */
GtkGesture *drag_gesture;
GtkGesture *pan_gesture;
2020-07-24 20:32:16 +00:00
double drag_start_x;
double drag_start_y;
guint kinetic_scrolling : 1;
guint in_drag : 1;
guint deceleration_id;
2020-07-24 20:32:16 +00:00
double x_velocity;
double y_velocity;
2020-07-24 20:32:16 +00:00
double unclamped_hadj_value;
double unclamped_vadj_value;
2018-06-16 09:47:06 +00:00
} GtkScrolledWindowPrivate;
enum {
PROP_0,
PROP_HADJUSTMENT,
PROP_VADJUSTMENT,
PROP_HSCROLLBAR_POLICY,
PROP_VSCROLLBAR_POLICY,
PROP_WINDOW_PLACEMENT,
PROP_HAS_FRAME,
PROP_MIN_CONTENT_WIDTH,
PROP_MIN_CONTENT_HEIGHT,
PROP_KINETIC_SCROLLING,
PROP_OVERLAY_SCROLLING,
PROP_MAX_CONTENT_WIDTH,
PROP_MAX_CONTENT_HEIGHT,
PROP_PROPAGATE_NATURAL_WIDTH,
PROP_PROPAGATE_NATURAL_HEIGHT,
2020-05-02 04:17:25 +00:00
PROP_CHILD,
NUM_PROPERTIES
};
/* Signals */
enum
{
SCROLL_CHILD,
MOVE_FOCUS_OUT,
EDGE_OVERSHOT,
EDGE_REACHED,
LAST_SIGNAL
};
static void gtk_scrolled_window_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_scrolled_window_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_scrolled_window_dispose (GObject *object);
2016-12-13 14:14:49 +00:00
static void gtk_scrolled_window_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
static void gtk_scrolled_window_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline);
static gboolean gtk_scrolled_window_focus (GtkWidget *widget,
GtkDirectionType direction);
static gboolean gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
GtkScrollType scroll,
gboolean horizontal);
static void gtk_scrolled_window_move_focus_out (GtkScrolledWindow *scrolled_window,
GtkDirectionType direction_type);
2018-06-16 09:47:06 +00:00
static void gtk_scrolled_window_relative_allocation(GtkScrolledWindow *scrolled_window,
GtkAllocation *allocation);
2018-06-16 09:47:06 +00:00
static void gtk_scrolled_window_inner_allocation (GtkScrolledWindow *scrolled_window,
GtkAllocation *rect);
2015-12-23 17:54:42 +00:00
static void gtk_scrolled_window_allocate_scrollbar (GtkScrolledWindow *scrolled_window,
GtkWidget *scrollbar,
GtkAllocation *allocation);
static void gtk_scrolled_window_allocate_child (GtkScrolledWindow *swindow,
int width,
int height);
static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
gpointer data);
static void gtk_scrolled_window_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data);
static gboolean gtk_widget_should_animate (GtkWidget *widget);
2017-05-04 19:50:51 +00:00
static void gtk_scrolled_window_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum_size,
int *natural_size,
int *minimum_baseline,
int *natural_baseline);
static void gtk_scrolled_window_map (GtkWidget *widget);
static void gtk_scrolled_window_unmap (GtkWidget *widget);
static void gtk_scrolled_window_realize (GtkWidget *widget);
static void gtk_scrolled_window_unrealize (GtkWidget *widget);
static void _gtk_scrolled_window_set_adjustment_value (GtkScrolledWindow *scrolled_window,
GtkAdjustment *adjustment,
2020-07-24 20:32:16 +00:00
double value);
static void gtk_scrolled_window_cancel_deceleration (GtkScrolledWindow *scrolled_window);
static gboolean _gtk_scrolled_window_get_overshoot (GtkScrolledWindow *scrolled_window,
2020-07-24 13:54:49 +00:00
int *overshoot_x,
int *overshoot_y);
static void gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window);
static void gtk_scrolled_window_update_use_indicators (GtkScrolledWindow *scrolled_window);
static void remove_indicator (GtkScrolledWindow *sw,
Indicator *indicator);
static gboolean maybe_hide_indicator (gpointer data);
static void indicator_start_fade (Indicator *indicator,
2020-07-24 20:32:16 +00:00
double pos);
static void indicator_set_over (Indicator *indicator,
gboolean over);
static void scrolled_window_scroll (GtkScrolledWindow *scrolled_window,
double delta_x,
double delta_y,
GtkEventControllerScroll *scroll);
static guint signals[LAST_SIGNAL] = {0};
static GParamSpec *properties[NUM_PROPERTIES];
1997-11-24 22:37:52 +00:00
static void gtk_scrolled_window_buildable_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkScrolledWindow)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_scrolled_window_buildable_init))
static GtkBuildableIface *parent_buildable_iface;
static void
gtk_scrolled_window_buildable_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
2020-07-24 18:40:36 +00:00
const char *type)
{
if (GTK_IS_WIDGET (child))
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW(buildable), GTK_WIDGET (child));
else
parent_buildable_iface->add_child (buildable, builder, child, type);
}
static void
gtk_scrolled_window_buildable_init (GtkBuildableIface *iface)
{
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->add_child = gtk_scrolled_window_buildable_add_child;
}
1997-11-24 22:37:52 +00:00
static void
add_scroll_binding (GtkWidgetClass *widget_class,
2020-05-02 04:17:25 +00:00
guint keyval,
GdkModifierType mask,
GtkScrollType scroll,
gboolean horizontal)
{
guint keypad_keyval = keyval - GDK_KEY_Left + GDK_KEY_KP_Left;
gtk_widget_class_add_binding_signal (widget_class,
keyval, mask,
"scroll-child",
"(ib)", scroll, horizontal);
gtk_widget_class_add_binding_signal (widget_class,
keypad_keyval, mask,
"scroll-child",
"(ib)", scroll, horizontal);
}
static void
add_tab_bindings (GtkWidgetClass *widget_class,
2020-05-02 04:17:25 +00:00
GdkModifierType modifiers,
GtkDirectionType direction)
{
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_Tab, modifiers,
"move-focus-out",
"(i)", direction);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_KP_Tab, modifiers,
"move-focus-out",
"(i)", direction);
}
static void
motion_controller_leave (GtkEventController *controller,
GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (priv->use_indicators)
{
indicator_set_over (&priv->hindicator, FALSE);
indicator_set_over (&priv->vindicator, FALSE);
}
}
static void
update_scrollbar_positions (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
gboolean is_rtl;
if (priv->hscrollbar != NULL)
{
if (priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_TOP_RIGHT)
{
gtk_widget_add_css_class (priv->hscrollbar, "bottom");
gtk_widget_remove_css_class (priv->hscrollbar, "top");
}
else
{
gtk_widget_add_css_class (priv->hscrollbar, "top");
gtk_widget_remove_css_class (priv->hscrollbar, "bottom");
}
}
if (priv->vscrollbar != NULL)
{
is_rtl = _gtk_widget_get_direction (GTK_WIDGET (scrolled_window)) == GTK_TEXT_DIR_RTL;
if ((is_rtl &&
(priv->window_placement == GTK_CORNER_TOP_RIGHT ||
priv->window_placement == GTK_CORNER_BOTTOM_RIGHT)) ||
(!is_rtl &&
(priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_BOTTOM_LEFT)))
{
gtk_widget_add_css_class (priv->vscrollbar, "right");
gtk_widget_remove_css_class (priv->vscrollbar, "left");
}
else
{
gtk_widget_add_css_class (priv->vscrollbar, "left");
gtk_widget_remove_css_class (priv->vscrollbar, "right");
}
}
}
static void
gtk_scrolled_window_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
update_scrollbar_positions (scrolled_window);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->direction_changed (widget, previous_dir);
}
static void
gtk_scrolled_window_compute_expand (GtkWidget *widget,
gboolean *hexpand,
gboolean *vexpand)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (priv->child)
{
*hexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_HORIZONTAL);
*vexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_VERTICAL);
}
else
{
*hexpand = FALSE;
*vexpand = FALSE;
}
}
static GtkSizeRequestMode
gtk_scrolled_window_get_request_mode (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (priv->child)
return gtk_widget_get_request_mode (priv->child);
else
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
}
1997-11-24 22:37:52 +00:00
static void
gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
{
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
1997-11-24 22:37:52 +00:00
gobject_class->set_property = gtk_scrolled_window_set_property;
gobject_class->get_property = gtk_scrolled_window_get_property;
gobject_class->dispose = gtk_scrolled_window_dispose;
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
2016-12-13 14:14:49 +00:00
widget_class->snapshot = gtk_scrolled_window_snapshot;
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
widget_class->size_allocate = gtk_scrolled_window_size_allocate;
2017-05-04 19:50:51 +00:00
widget_class->measure = gtk_scrolled_window_measure;
widget_class->focus = gtk_scrolled_window_focus;
widget_class->map = gtk_scrolled_window_map;
widget_class->unmap = gtk_scrolled_window_unmap;
widget_class->realize = gtk_scrolled_window_realize;
widget_class->unrealize = gtk_scrolled_window_unrealize;
widget_class->direction_changed = gtk_scrolled_window_direction_changed;
widget_class->compute_expand = gtk_scrolled_window_compute_expand;
widget_class->get_request_mode = gtk_scrolled_window_get_request_mode;
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
class->scroll_child = gtk_scrolled_window_scroll_child;
class->move_focus_out = gtk_scrolled_window_move_focus_out;
/**
* GtkScrolleWindow:hadjustment: (attributes org.gtk.Property.get=gtk_scrolled_window_get_hadjustment org.gtk.Property.set=gtk_scrolled_window_set_hadjustment)
*
* The `GtkAdjustment` for the horizontal position.
*/
properties[PROP_HADJUSTMENT] =
g_param_spec_object ("hadjustment", NULL, NULL,
GTK_TYPE_ADJUSTMENT,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT);
/**
* GtkScrolleWindow:vadjustment: (attributes org.gtk.Property.get=gtk_scrolled_window_get_vadjustment org.gtk.Property.set=gtk_scrolled_window_set_vadjustment)
*
* The `GtkAdjustment` for the vertical position.
*/
properties[PROP_VADJUSTMENT] =
g_param_spec_object ("vadjustment", NULL, NULL,
GTK_TYPE_ADJUSTMENT,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT);
/**
* GtkScrolledWindow:hscrollbar-policy:
*
* When the horizontal scrollbar is displayed.
*
* Use [method@Gtk.ScrolledWindow.set_policy] to set
* this property.
*/
properties[PROP_HSCROLLBAR_POLICY] =
g_param_spec_enum ("hscrollbar-policy", NULL, NULL,
GTK_TYPE_POLICY_TYPE,
GTK_POLICY_AUTOMATIC,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:vscrollbar-policy:
*
* When the vertical scrollbar is displayed.
*
* Use [method@Gtk.ScrolledWindow.set_policy] to set
* this property.
*/
properties[PROP_VSCROLLBAR_POLICY] =
g_param_spec_enum ("vscrollbar-policy", NULL, NULL,
2020-05-02 04:17:25 +00:00
GTK_TYPE_POLICY_TYPE,
GTK_POLICY_AUTOMATIC,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:window-placement: (attributes org.gtk.Property.get=gtk_scrolled_window_get_placement org.gtk.Property.set=gtk_scrolled_window_set_placement)
*
* Where the contents are located with respect to the scrollbars.
*/
properties[PROP_WINDOW_PLACEMENT] =
g_param_spec_enum ("window-placement", NULL, NULL,
2020-05-02 04:17:25 +00:00
GTK_TYPE_CORNER_TYPE,
GTK_CORNER_TOP_LEFT,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:has-frame: (attributes org.gtk.Property.get=gtk_scrolled_window_get_has_frame org.gtk.Property.set=gtk_scrolled_window_set_has_frame)
*
* Whether to draw a frame around the contents.
*/
properties[PROP_HAS_FRAME] =
g_param_spec_boolean ("has-frame", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:min-content-width: (attributes org.gtk.Property.get=gtk_scrolled_window_get_min_content_width org.gtk.Property.set=gtk_scrolled_window_set_min_content_width)
*
* The minimum content width of @scrolled_window.
*/
properties[PROP_MIN_CONTENT_WIDTH] =
g_param_spec_int ("min-content-width", NULL, NULL,
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:min-content-height: (attributes org.gtk.Property.get=gtk_scrolled_window_get_min_content_height org.gtk.Property.set=gtk_scrolled_window_set_min_content_height)
*
* The minimum content height of @scrolled_window.
*/
properties[PROP_MIN_CONTENT_HEIGHT] =
g_param_spec_int ("min-content-height", NULL, NULL,
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:kinetic-scrolling: (attributes org.gtk.Property.get=gtk_scrolled_window_get_kinetic_scrolling org.gtk.Property.set=gtk_scrolled_window_set_kinetic_scrolling)
*
* Whether kinetic scrolling is enabled or not.
*
* Kinetic scrolling only applies to devices with source %GDK_SOURCE_TOUCHSCREEN.
*/
properties[PROP_KINETIC_SCROLLING] =
g_param_spec_boolean ("kinetic-scrolling", NULL, NULL,
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:overlay-scrolling: (attributes org.gtk.Property.get=gtk_scrolled_window_get_overlay_scrolling org.gtk.Property.set=gtk_scrolled_window_set_overlay_scrolling)
*
* Whether overlay scrolling is enabled or not.
*
* If it is, the scrollbars are only added as traditional widgets
* when a mouse is present. Otherwise, they are overlaid on top of
* the content, as narrow indicators.
*
* Note that overlay scrolling can also be globally disabled, with
* the [property@Gtk.Settings:gtk-overlay-scrolling] setting.
*/
properties[PROP_OVERLAY_SCROLLING] =
g_param_spec_boolean ("overlay-scrolling", NULL, NULL,
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:max-content-width: (attributes org.gtk.Property.get=gtk_scrolled_window_get_max_content_width org.gtk.Property.set=gtk_scrolled_window_set_max_content_width)
*
* The maximum content width of @scrolled_window.
*/
properties[PROP_MAX_CONTENT_WIDTH] =
g_param_spec_int ("max-content-width", NULL, NULL,
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:max-content-height: (attributes org.gtk.Property.get=gtk_scrolled_window_get_max_content_height org.gtk.Property.set=gtk_scrolled_window_set_max_content_height)
*
* The maximum content height of @scrolled_window.
*/
properties[PROP_MAX_CONTENT_HEIGHT] =
g_param_spec_int ("max-content-height", NULL, NULL,
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:propagate-natural-width: (attributes org.gtk.Property.get=gtk_scrolled_window_get_propagate_natural_width org.gtk.Property.set=gtk_scrolled_window_set_propagate_natural_width)
*
* Whether the natural width of the child should be calculated and propagated
* through the scrolled windows requested natural width.
*
* This is useful in cases where an attempt should be made to allocate exactly
* enough space for the natural size of the child.
*/
properties[PROP_PROPAGATE_NATURAL_WIDTH] =
g_param_spec_boolean ("propagate-natural-width", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:propagate-natural-height: (attributes org.gtk.Property.get=gtk_scrolled_window_get_propagate_natural_height org.gtk.Property.set=gtk_scrolled_window_set_propagate_natural_height)
*
* Whether the natural height of the child should be calculated and propagated
* through the scrolled windows requested natural height.
*
* This is useful in cases where an attempt should be made to allocate exactly
* enough space for the natural size of the child.
*/
properties[PROP_PROPAGATE_NATURAL_HEIGHT] =
g_param_spec_boolean ("propagate-natural-height", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkScrolledWindow:child: (attributes org.gtk.Property.get=gtk_scrolled_window_get_child org.gtk.Property.set=gtk_scrolled_window_set_child)
*
* The child widget.
*/
2020-05-02 04:17:25 +00:00
properties[PROP_CHILD] =
g_param_spec_object ("child", NULL, NULL,
2020-05-02 04:17:25 +00:00
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
/**
* GtkScrolledWindow::scroll-child:
* @scrolled_window: a `GtkScrolledWindow`
* @scroll: a `GtkScrollType` describing how much to scroll
* @horizontal: whether the keybinding scrolls the child
* horizontally or not
*
* Emitted when a keybinding that scrolls is pressed.
*
* This is a [keybinding signal](class.SignalAction.html).
*
* The horizontal or vertical adjustment is updated which triggers a
* signal that the scrolled windows child may listen to and scroll itself.
*/
signals[SCROLL_CHILD] =
g_signal_new (I_("scroll-child"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkScrolledWindowClass, scroll_child),
NULL, NULL,
_gtk_marshal_BOOLEAN__ENUM_BOOLEAN,
G_TYPE_BOOLEAN, 2,
GTK_TYPE_SCROLL_TYPE,
2020-05-02 04:17:25 +00:00
G_TYPE_BOOLEAN);
/**
* GtkScrolledWindow::move-focus-out:
* @scrolled_window: a `GtkScrolledWindow`
* @direction_type: either %GTK_DIR_TAB_FORWARD or
* %GTK_DIR_TAB_BACKWARD
*
* Emitted when focus is moved away from the scrolled window by a
* keybinding.
*
* This is a [keybinding signal](class.SignalAction.html).
*
* The default bindings for this signal are
* `Ctrl + Tab` to move forward and `Ctrl + Shift + Tab` to
* move backward.
*/
signals[MOVE_FOCUS_OUT] =
g_signal_new (I_("move-focus-out"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkScrolledWindowClass, move_focus_out),
NULL, NULL,
NULL,
G_TYPE_NONE, 1,
GTK_TYPE_DIRECTION_TYPE);
/**
* GtkScrolledWindow::edge-overshot:
* @scrolled_window: a `GtkScrolledWindow`
* @pos: edge side that was hit
*
* Emitted whenever user initiated scrolling makes the scrolled
* window firmly surpass the limits defined by the adjustment
* in that orientation.
*
* A similar behavior without edge resistance is provided by the
* [signal@Gtk.ScrolledWindow::edge-reached] signal.
*
* Note: The @pos argument is LTR/RTL aware, so callers should be
* aware too if intending to provide behavior on horizontal edges.
*/
signals[EDGE_OVERSHOT] =
g_signal_new (I_("edge-overshot"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST, 0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, GTK_TYPE_POSITION_TYPE);
/**
* GtkScrolledWindow::edge-reached:
* @scrolled_window: a `GtkScrolledWindow`
* @pos: edge side that was reached
*
* Emitted whenever user-initiated scrolling makes the scrolled
* window exactly reach the lower or upper limits defined by the
* adjustment in that orientation.
*
* A similar behavior with edge resistance is provided by the
* [signal@Gtk.ScrolledWindow::edge-overshot] signal.
*
* Note: The @pos argument is LTR/RTL aware, so callers should be
* aware too if intending to provide behavior on horizontal edges.
*/
signals[EDGE_REACHED] =
g_signal_new (I_("edge-reached"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST, 0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, GTK_TYPE_POSITION_TYPE);
add_scroll_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK, GTK_SCROLL_STEP_BACKWARD, TRUE);
add_scroll_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK, GTK_SCROLL_STEP_FORWARD, TRUE);
add_scroll_binding (widget_class, GDK_KEY_Up, GDK_CONTROL_MASK, GTK_SCROLL_STEP_BACKWARD, FALSE);
add_scroll_binding (widget_class, GDK_KEY_Down, GDK_CONTROL_MASK, GTK_SCROLL_STEP_FORWARD, FALSE);
add_scroll_binding (widget_class, GDK_KEY_Page_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_BACKWARD, TRUE);
add_scroll_binding (widget_class, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_FORWARD, TRUE);
add_scroll_binding (widget_class, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_BACKWARD, FALSE);
add_scroll_binding (widget_class, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_FORWARD, FALSE);
add_scroll_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK, GTK_SCROLL_START, TRUE);
add_scroll_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK, GTK_SCROLL_END, TRUE);
add_scroll_binding (widget_class, GDK_KEY_Home, 0, GTK_SCROLL_START, FALSE);
add_scroll_binding (widget_class, GDK_KEY_End, 0, GTK_SCROLL_END, FALSE);
add_tab_bindings (widget_class, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
gtk_widget_class_set_css_name (widget_class, I_("scrolledwindow"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
}
static gboolean
may_hscroll (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
return priv->hscrollbar_visible || priv->hscrollbar_policy == GTK_POLICY_EXTERNAL;
}
static gboolean
may_vscroll (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
return priv->vscrollbar_visible || priv->vscrollbar_policy == GTK_POLICY_EXTERNAL;
}
static inline gboolean
policy_may_be_visible (GtkPolicyType policy)
{
return policy == GTK_POLICY_ALWAYS || policy == GTK_POLICY_AUTOMATIC;
}
static void
scrolled_window_drag_begin_cb (GtkScrolledWindow *scrolled_window,
2020-07-24 20:32:16 +00:00
double start_x,
double start_y,
GtkGesture *gesture)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GdkEventSequence *sequence;
GtkWidget *event_widget;
priv->in_drag = FALSE;
priv->drag_start_x = priv->unclamped_hadj_value;
priv->drag_start_y = priv->unclamped_vadj_value;
gtk_scrolled_window_cancel_deceleration (scrolled_window);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event_widget = gtk_gesture_get_last_target (gesture, sequence);
if (event_widget == priv->vscrollbar || event_widget == priv->hscrollbar ||
(!may_hscroll (scrolled_window) && !may_vscroll (scrolled_window)))
gtk_gesture_set_sequence_state (gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
}
static void
gtk_scrolled_window_invalidate_overshoot (GtkScrolledWindow *scrolled_window)
{
GtkAllocation child_allocation;
2020-07-24 13:54:49 +00:00
int overshoot_x, overshoot_y;
if (!_gtk_scrolled_window_get_overshoot (scrolled_window, &overshoot_x, &overshoot_y))
return;
2018-06-16 09:47:06 +00:00
gtk_scrolled_window_relative_allocation (scrolled_window,
&child_allocation);
if (overshoot_x != 0)
gtk_widget_queue_draw (GTK_WIDGET (scrolled_window));
if (overshoot_y != 0)
gtk_widget_queue_draw (GTK_WIDGET (scrolled_window));
}
static void
scrolled_window_drag_update_cb (GtkScrolledWindow *scrolled_window,
2020-07-24 20:32:16 +00:00
double offset_x,
double offset_y,
GtkGesture *gesture)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GdkEventSequence *sequence;
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
2020-07-24 20:32:16 +00:00
double dx, dy;
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
if (gtk_gesture_get_sequence_state (gesture, sequence) != GTK_EVENT_SEQUENCE_CLAIMED &&
!gtk_drag_check_threshold_double (GTK_WIDGET (scrolled_window),
0, 0, offset_x, offset_y))
return;
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
if (hadjustment && may_hscroll (scrolled_window))
{
dx = priv->drag_start_x - offset_x;
_gtk_scrolled_window_set_adjustment_value (scrolled_window,
hadjustment, dx);
}
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
if (vadjustment && may_vscroll (scrolled_window))
{
dy = priv->drag_start_y - offset_y;
_gtk_scrolled_window_set_adjustment_value (scrolled_window,
vadjustment, dy);
}
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
}
static void
scrolled_window_drag_end_cb (GtkScrolledWindow *scrolled_window,
GdkEventSequence *sequence,
GtkGesture *gesture)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (!priv->in_drag || !gtk_gesture_handles_sequence (gesture, sequence))
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
}
static void
gtk_scrolled_window_decelerate (GtkScrolledWindow *scrolled_window,
2020-07-24 20:32:16 +00:00
double x_velocity,
double y_velocity)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
gboolean overshoot;
overshoot = _gtk_scrolled_window_get_overshoot (scrolled_window, NULL, NULL);
priv->x_velocity = x_velocity;
priv->y_velocity = y_velocity;
/* Zero out vector components for which we don't scroll */
if (!may_hscroll (scrolled_window))
priv->x_velocity = 0;
if (!may_vscroll (scrolled_window))
priv->y_velocity = 0;
if (priv->x_velocity != 0 || priv->y_velocity != 0 || overshoot)
{
if (priv->deceleration_id == 0)
gtk_scrolled_window_start_deceleration (scrolled_window);
priv->x_velocity = priv->y_velocity = 0;
}
else
{
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
}
}
static void
scrolled_window_swipe_cb (GtkScrolledWindow *scrolled_window,
2020-07-24 20:32:16 +00:00
double x_velocity,
double y_velocity)
{
gtk_scrolled_window_decelerate (scrolled_window, -x_velocity, -y_velocity);
}
static void
scrolled_window_long_press_cb (GtkScrolledWindow *scrolled_window,
2020-07-24 20:32:16 +00:00
double x,
double y,
GtkGesture *gesture)
{
GdkEventSequence *sequence;
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
gtk_gesture_set_sequence_state (gesture, sequence,
GTK_EVENT_SEQUENCE_DENIED);
}
static void
scrolled_window_long_press_cancelled_cb (GtkScrolledWindow *scrolled_window,
GtkGesture *gesture)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GdkEventSequence *sequence;
GdkEvent *event;
GdkEventType event_type;
sequence = gtk_gesture_get_last_updated_sequence (gesture);
event = gtk_gesture_get_last_event (gesture, sequence);
event_type = gdk_event_get_event_type (event);
if (event_type == GDK_TOUCH_BEGIN ||
event_type == GDK_BUTTON_PRESS)
gtk_gesture_set_sequence_state (gesture, sequence,
GTK_EVENT_SEQUENCE_DENIED);
else if (event_type != GDK_TOUCH_END &&
event_type != GDK_BUTTON_RELEASE)
priv->in_drag = TRUE;
}
static void
gtk_scrolled_window_check_attach_pan_gesture (GtkScrolledWindow *sw)
{
GtkPropagationPhase phase = GTK_PHASE_NONE;
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
if (priv->kinetic_scrolling &&
((may_hscroll (sw) && !may_vscroll (sw)) ||
(!may_hscroll (sw) && may_vscroll (sw))))
{
GtkOrientation orientation;
if (may_hscroll (sw))
orientation = GTK_ORIENTATION_HORIZONTAL;
else
orientation = GTK_ORIENTATION_VERTICAL;
gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (priv->pan_gesture),
orientation);
phase = GTK_PHASE_CAPTURE;
}
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->pan_gesture), phase);
}
static void
indicator_set_over (Indicator *indicator,
gboolean over)
{
2020-12-27 17:11:29 +00:00
g_clear_handle_id (&indicator->over_timeout_id, g_source_remove);
if (indicator->over == over)
return;
indicator->over = over;
if (indicator->over)
gtk_widget_add_css_class (indicator->scrollbar, "hovering");
else
gtk_widget_remove_css_class (indicator->scrollbar, "hovering");
gtk_widget_queue_resize (indicator->scrollbar);
}
static gboolean
coords_close_to_indicator (GtkScrolledWindow *sw,
Indicator *indicator,
2020-07-24 20:32:16 +00:00
double x,
double y)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
graphene_rect_t indicator_bounds;
2020-07-24 13:54:49 +00:00
int distance;
if (!gtk_widget_compute_bounds (indicator->scrollbar, GTK_WIDGET (sw), &indicator_bounds))
return FALSE;
if (indicator->over)
distance = INDICATOR_FAR_DISTANCE;
else
distance = INDICATOR_CLOSE_DISTANCE;
graphene_rect_inset (&indicator_bounds, - distance, - distance);
if (indicator == &priv->hindicator)
{
if (y >= indicator_bounds.origin.y &&
y < indicator_bounds.origin.y + indicator_bounds.size.height)
return TRUE;
}
else if (indicator == &priv->vindicator)
{
if (x >= indicator_bounds.origin.x &&
x < indicator_bounds.origin.x + indicator_bounds.size.width)
return TRUE;
}
return FALSE;
}
static gboolean
enable_over_timeout_cb (gpointer user_data)
{
Indicator *indicator = user_data;
indicator_set_over (indicator, TRUE);
return G_SOURCE_REMOVE;
}
static gboolean
check_update_scrollbar_proximity (GtkScrolledWindow *sw,
Indicator *indicator,
GtkWidget *target,
2020-07-24 20:32:16 +00:00
double x,
double y)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
gboolean indicator_close, on_scrollbar, on_other_scrollbar;
indicator_close = coords_close_to_indicator (sw, indicator, x, y);
on_scrollbar = (target == indicator->scrollbar ||
gtk_widget_is_ancestor (target, indicator->scrollbar));
on_other_scrollbar = (!on_scrollbar &&
(target == priv->hindicator.scrollbar ||
target == priv->vindicator.scrollbar ||
gtk_widget_is_ancestor (target, priv->hindicator.scrollbar) ||
gtk_widget_is_ancestor (target, priv->vindicator.scrollbar)));
2020-12-27 17:11:29 +00:00
g_clear_handle_id (&indicator->over_timeout_id, g_source_remove);
if (on_scrollbar)
indicator_set_over (indicator, TRUE);
else if (indicator_close && !on_other_scrollbar)
{
indicator->over_timeout_id = g_timeout_add (30, enable_over_timeout_cb, indicator);
gdk_source_set_static_name_by_id (indicator->over_timeout_id, "[gtk] enable_over_timeout_cb");
}
else
indicator_set_over (indicator, FALSE);
return indicator_close;
}
2020-07-24 20:32:16 +00:00
static double
get_wheel_detent_scroll_step (GtkScrolledWindow *sw,
GtkOrientation orientation)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
GtkScrollbar *scrollbar;
GtkAdjustment *adj;
2020-07-24 20:32:16 +00:00
double page_size;
double scroll_step;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
scrollbar = GTK_SCROLLBAR (priv->hscrollbar);
else
scrollbar = GTK_SCROLLBAR (priv->vscrollbar);
if (!scrollbar)
return 0;
adj = gtk_scrollbar_get_adjustment (scrollbar);
page_size = gtk_adjustment_get_page_size (adj);
scroll_step = pow (page_size, 2.0 / 3.0);
return scroll_step;
}
static gboolean
captured_scroll_cb (GtkEventControllerScroll *scroll,
double delta_x,
double delta_y,
GtkScrolledWindow *scrolled_window)
{
GtkScrolledWindowPrivate *priv =
gtk_scrolled_window_get_instance_private (scrolled_window);
gtk_scrolled_window_cancel_deceleration (scrolled_window);
if (priv->smooth_scroll)
{
scrolled_window_scroll (scrolled_window, delta_x, delta_y, scroll);
return GDK_EVENT_STOP;
}
return GDK_EVENT_PROPAGATE;
}
static void
captured_motion (GtkEventController *controller,
double x,
double y,
GtkScrolledWindow *sw)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
GdkDevice *source_device;
GdkInputSource input_source;
GdkModifierType state;
GdkEvent *event;
GtkWidget *target;
if (!priv->use_indicators)
return;
if (!priv->child)
return;
target = gtk_event_controller_get_target (controller);
state = gtk_event_controller_get_current_event_state (controller);
event = gtk_event_controller_get_current_event (controller);
source_device = gdk_event_get_device (event);
input_source = gdk_device_get_source (source_device);
if (priv->hscrollbar_visible)
indicator_start_fade (&priv->hindicator, 1.0);
if (priv->vscrollbar_visible)
indicator_start_fade (&priv->vindicator, 1.0);
if ((target == priv->child ||
gtk_widget_is_ancestor (target, priv->child)) &&
(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) != 0)
{
indicator_set_over (&priv->hindicator, FALSE);
indicator_set_over (&priv->vindicator, FALSE);
}
else if (input_source == GDK_SOURCE_PEN ||
input_source == GDK_SOURCE_TRACKPOINT)
{
indicator_set_over (&priv->hindicator, TRUE);
indicator_set_over (&priv->vindicator, TRUE);
}
else
{
if (!check_update_scrollbar_proximity (sw, &priv->vindicator, target, x, y))
check_update_scrollbar_proximity (sw, &priv->hindicator, target, x, y);
else
indicator_set_over (&priv->hindicator, FALSE);
}
}
static gboolean
start_scroll_deceleration_cb (gpointer user_data)
{
GtkScrolledWindow *scrolled_window = user_data;
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
priv->scroll_events_overshoot_id = 0;
if (!priv->deceleration_id)
gtk_scrolled_window_start_deceleration (scrolled_window);
return FALSE;
}
static void
scroll_controller_scroll_begin (GtkEventControllerScroll *scroll,
GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
priv->smooth_scroll = TRUE;
}
static void
stop_kinetic_scrolling_cb (GtkEventControllerScroll *scroll,
GtkScrolledWindow *scrolled_window)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (priv->hscrolling)
gtk_kinetic_scrolling_stop (priv->hscrolling);
if (priv->vscrolling)
gtk_kinetic_scrolling_stop (priv->vscrolling);
}
static void
scrolled_window_scroll (GtkScrolledWindow *scrolled_window,
double delta_x,
double delta_y,
GtkEventControllerScroll *scroll)
{
GtkScrolledWindowPrivate *priv =
gtk_scrolled_window_get_instance_private (scrolled_window);
gboolean shifted;
GdkModifierType state;
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (scroll));
shifted = (state & GDK_SHIFT_MASK) != 0;
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
if (shifted)
{
2020-07-24 20:32:16 +00:00
double delta;
delta = delta_x;
delta_x = delta_y;
delta_y = delta;
}
if (delta_x != 0.0 &&
may_hscroll (scrolled_window))
{
GtkAdjustment *adj;
2020-07-24 20:32:16 +00:00
double new_value;
GdkScrollUnit scroll_unit;
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
scroll_unit = gtk_event_controller_scroll_get_unit (scroll);
if (scroll_unit == GDK_SCROLL_UNIT_WHEEL)
{
delta_x *= get_wheel_detent_scroll_step (scrolled_window,
GTK_ORIENTATION_HORIZONTAL);
}
else if (scroll_unit == GDK_SCROLL_UNIT_SURFACE)
delta_x *= MAGIC_SCROLL_FACTOR;
new_value = priv->unclamped_hadj_value + delta_x;
_gtk_scrolled_window_set_adjustment_value (scrolled_window, adj,
new_value);
}
if (delta_y != 0.0 &&
may_vscroll (scrolled_window))
{
GtkAdjustment *adj;
2020-07-24 20:32:16 +00:00
double new_value;
GdkScrollUnit scroll_unit;
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
scroll_unit = gtk_event_controller_scroll_get_unit (scroll);
if (scroll_unit == GDK_SCROLL_UNIT_WHEEL)
{
delta_y *= get_wheel_detent_scroll_step (scrolled_window,
GTK_ORIENTATION_VERTICAL);
}
else if (scroll_unit == GDK_SCROLL_UNIT_SURFACE)
delta_y *= MAGIC_SCROLL_FACTOR;
new_value = priv->unclamped_vadj_value + delta_y;
_gtk_scrolled_window_set_adjustment_value (scrolled_window, adj,
new_value);
}
2020-12-27 17:11:29 +00:00
g_clear_handle_id (&priv->scroll_events_overshoot_id, g_source_remove);
if (!priv->smooth_scroll &&
_gtk_scrolled_window_get_overshoot (scrolled_window, NULL, NULL))
{
priv->scroll_events_overshoot_id =
g_timeout_add (50, start_scroll_deceleration_cb, scrolled_window);
gdk_source_set_static_name_by_id (priv->scroll_events_overshoot_id,
"[gtk] start_scroll_deceleration_cb");
}
}
static gboolean
scroll_controller_scroll (GtkEventControllerScroll *scroll,
double delta_x,
double delta_y,
GtkScrolledWindow *scrolled_window)
{
GtkScrolledWindowPrivate *priv =
gtk_scrolled_window_get_instance_private (scrolled_window);
if (!priv->smooth_scroll)
scrolled_window_scroll (scrolled_window, delta_x, delta_y, scroll);
return GDK_EVENT_STOP;
}
static void
scroll_controller_scroll_end (GtkEventControllerScroll *scroll,
GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
priv->smooth_scroll = FALSE;
}
static void
scroll_controller_decelerate (GtkEventControllerScroll *scroll,
2020-07-24 20:32:16 +00:00
double initial_vel_x,
double initial_vel_y,
GtkScrolledWindow *scrolled_window)
{
GdkScrollUnit scroll_unit;
gboolean shifted;
GdkModifierType state;
scroll_unit = gtk_event_controller_scroll_get_unit (scroll);
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (scroll));
shifted = (state & GDK_SHIFT_MASK) != 0;
if (shifted)
{
double tmp;
tmp = initial_vel_x;
initial_vel_x = initial_vel_y;
initial_vel_y = tmp;
}
if (scroll_unit == GDK_SCROLL_UNIT_WHEEL)
{
initial_vel_x *= get_wheel_detent_scroll_step (scrolled_window,
GTK_ORIENTATION_HORIZONTAL);
initial_vel_y *= get_wheel_detent_scroll_step (scrolled_window,
GTK_ORIENTATION_VERTICAL);
}
else
{
initial_vel_x *= MAGIC_SCROLL_FACTOR;
initial_vel_y *= MAGIC_SCROLL_FACTOR;
}
gtk_scrolled_window_decelerate (scrolled_window,
initial_vel_x,
initial_vel_y);
}
static void
gtk_scrolled_window_update_scrollbar_visibility_flags (GtkScrolledWindow *scrolled_window,
GtkWidget *scrollbar)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkAdjustment *adjustment;
if (scrollbar == NULL)
return;
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (scrollbar));
if (scrollbar == priv->hscrollbar)
{
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
priv->hscrollbar_visible = (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment) >
gtk_adjustment_get_page_size (adjustment));
}
}
else if (scrollbar == priv->vscrollbar)
{
if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
priv->vscrollbar_visible = (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment) >
gtk_adjustment_get_page_size (adjustment));
}
}
}
2015-12-23 17:54:42 +00:00
static void
gtk_scrolled_window_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
2015-12-23 17:54:42 +00:00
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2015-12-23 17:54:42 +00:00
GtkAllocation child_allocation;
2020-07-24 13:54:49 +00:00
int sb_width;
int sb_height;
2015-12-23 17:54:42 +00:00
/* Get possible scrollbar dimensions */
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
&sb_width, NULL, NULL, NULL);
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
&sb_height, NULL, NULL, NULL);
2015-12-23 17:54:42 +00:00
if (priv->hscrollbar_policy == GTK_POLICY_ALWAYS)
priv->hscrollbar_visible = TRUE;
else if (priv->hscrollbar_policy == GTK_POLICY_NEVER ||
priv->hscrollbar_policy == GTK_POLICY_EXTERNAL)
priv->hscrollbar_visible = FALSE;
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
2015-12-23 17:54:42 +00:00
if (priv->vscrollbar_policy == GTK_POLICY_ALWAYS)
priv->vscrollbar_visible = TRUE;
else if (priv->vscrollbar_policy == GTK_POLICY_NEVER ||
priv->vscrollbar_policy == GTK_POLICY_EXTERNAL)
priv->vscrollbar_visible = FALSE;
2010-05-24 20:31:36 +00:00
if (priv->child && gtk_widget_get_visible (priv->child))
2015-12-23 17:54:42 +00:00
{
2020-07-24 13:54:49 +00:00
int child_scroll_width;
int child_scroll_height;
2015-12-23 17:54:42 +00:00
gboolean previous_hvis;
gboolean previous_vvis;
guint count = 0;
GtkScrollable *scrollable_child = GTK_SCROLLABLE (priv->child);
GtkScrollablePolicy hscroll_policy = gtk_scrollable_get_hscroll_policy (scrollable_child);
GtkScrollablePolicy vscroll_policy = gtk_scrollable_get_vscroll_policy (scrollable_child);
1997-11-24 22:37:52 +00:00
2015-12-23 17:54:42 +00:00
/* Determine scrollbar visibility first via hfw apis */
if (gtk_widget_get_request_mode (priv->child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
2020-05-02 04:17:25 +00:00
{
if (hscroll_policy == GTK_SCROLL_MINIMUM)
gtk_widget_measure (priv->child, GTK_ORIENTATION_HORIZONTAL, -1,
&child_scroll_width, NULL, NULL, NULL);
else
gtk_widget_measure (priv->child, GTK_ORIENTATION_HORIZONTAL, -1,
NULL, &child_scroll_width, NULL, NULL);
changed scrolled window inheritance, it inherits from GtkBin now. Sat Nov 28 03:13:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled window inheritance, it inherits from GtkBin now. * gtk/gtkbin.c (gtk_bin_unmap): removed superfluous check for visibility of child. (gtk_bin_draw): removed superfluous check for GTK_WIDGET_DRAWABLE(). added check so a child gets only drawn if it's visible. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed gtk_widget_draw_children(). * gtk/gtkstyle.h: * gtk/gtkstyle.c: rmoved gtk_reset_widget_shapes. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed crufty relict: gtk_widget_is_child(). added internal function gtk_widget_reset_shapes() from gtkstyle.c. * gtk/gtkrc.h: * gtk/gtkrc.c: (gtk_rc_find_pixmap_in_path): removed bogus gscanner argument, changed callers. * gtk/gtkmenufactory.c: GtkMenuFactory is deprecated for a long time, it will issue a warning now. * gtk/gtkcompat.h: new file to #define aliases for historic function names. * changed 8 function names for consistency and provided aliases to keep source compatibility in gtkcompat.h: (gtk_accel_label_get_accel_width): renamed from gtk_accel_label_accelerator_width (gtk_container_set_border_width): renamed from gtk_container_border_width (gtk_notebook_get_current_page): renamed from gtk_notebook_current_page (gtk_packer_configure): renamed from gtk_packer_set_child_packing (gtk_paned_set_gutter_size): renamed from gtk_paned_gutter_size (gtk_paned_set_handle_size): renamed from gtk_paned_handle_size (gtk_scale_get_value_width): renamed from gtk_scale_value_width (gtk_window_set_position): renamed from gtk_window_position * renamed a few recently added funtions for consistency: (gtk_notebook_get_tab_label): renamed from gtk_notebook_query_tab_label. (gtk_notebook_get_menu_label): renamed from gtk_notebook_query_menu_label. (gtk_progress_configure): renamed from gtk_progress_reconfigure.
1998-11-28 07:42:37 +00:00
2020-05-02 04:17:25 +00:00
if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
/* First try without a vertical scrollbar if the content will fit the height
* given the extra width of the scrollbar */
if (vscroll_policy == GTK_SCROLL_MINIMUM)
gtk_widget_measure (priv->child, GTK_ORIENTATION_VERTICAL,
MAX (width, child_scroll_width),
&child_scroll_height, NULL, NULL, NULL);
else
gtk_widget_measure (priv->child, GTK_ORIENTATION_VERTICAL,
MAX (width, child_scroll_width),
NULL, &child_scroll_height, NULL, NULL);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
/* Does the content height fit the allocation height ? */
priv->vscrollbar_visible = child_scroll_height > height;
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
/* Does the content width fit the allocation with minus a possible scrollbar ? */
priv->hscrollbar_visible = child_scroll_width > width -
2020-05-02 04:17:25 +00:00
(priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
/* Now that we've guessed the hscrollbar, does the content height fit
* the possible new allocation height ?
*/
priv->vscrollbar_visible = child_scroll_height > height -
2020-05-02 04:17:25 +00:00
(priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
/* Now that we've guessed the vscrollbar, does the content width fit
* the possible new allocation width ?
*/
priv->hscrollbar_visible = child_scroll_width > width -
2020-05-02 04:17:25 +00:00
(priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0);
}
else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
{
priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy);
priv->vscrollbar_visible = child_scroll_height > height -
(priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0);
}
}
else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
{
priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy);
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
priv->hscrollbar_visible = child_scroll_width > width -
2020-05-02 04:17:25 +00:00
(priv->vscrollbar_visible && !priv->use_indicators ? 0 : sb_width);
else
priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy);
}
}
2015-12-23 17:54:42 +00:00
else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT */
2020-05-02 04:17:25 +00:00
{
if (vscroll_policy == GTK_SCROLL_MINIMUM)
gtk_widget_measure (priv->child, GTK_ORIENTATION_VERTICAL, -1,
&child_scroll_height, NULL, NULL, NULL);
else
gtk_widget_measure (priv->child, GTK_ORIENTATION_VERTICAL, -1,
NULL, &child_scroll_height, NULL, NULL);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
/* First try without a horizontal scrollbar if the content will fit the width
* given the extra height of the scrollbar */
if (hscroll_policy == GTK_SCROLL_MINIMUM)
gtk_widget_measure (priv->child, GTK_ORIENTATION_HORIZONTAL,
MAX (height, child_scroll_height),
&child_scroll_width, NULL, NULL, NULL);
else
gtk_widget_measure (priv->child, GTK_ORIENTATION_HORIZONTAL,
MAX (height, child_scroll_height),
NULL, &child_scroll_width, NULL, NULL);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
/* Does the content width fit the allocation width ? */
priv->hscrollbar_visible = child_scroll_width > width;
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
/* Does the content height fit the allocation with minus a possible scrollbar ? */
priv->vscrollbar_visible = child_scroll_height > height -
2020-05-02 04:17:25 +00:00
(priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
/* Now that we've guessed the vscrollbar, does the content width fit
* the possible new allocation width ?
*/
priv->hscrollbar_visible = child_scroll_width > width -
2020-05-02 04:17:25 +00:00
(priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
/* Now that we've guessed the hscrollbar, does the content height fit
* the possible new allocation height ?
*/
priv->vscrollbar_visible = child_scroll_height > height -
2020-05-02 04:17:25 +00:00
(priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0);
}
else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
{
priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy);
priv->hscrollbar_visible = child_scroll_width > width -
2020-05-02 04:17:25 +00:00
(priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0);
}
}
else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
{
priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy);
if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
priv->vscrollbar_visible = child_scroll_height > height -
2020-05-02 04:17:25 +00:00
(priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0);
else
priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy);
}
}
2015-12-23 17:54:42 +00:00
/* Now after guessing scrollbar visibility; fall back on the allocation loop which
* observes the adjustments to detect scrollbar visibility and also avoids
* infinite recursion
*/
do
2020-05-02 04:17:25 +00:00
{
previous_hvis = priv->hscrollbar_visible;
previous_vvis = priv->vscrollbar_visible;
2020-05-02 04:17:25 +00:00
gtk_scrolled_window_allocate_child (scrolled_window, width, height);
2015-12-23 17:54:42 +00:00
/* Explicitly force scrollbar visibility checks.
*
* Since we make a guess above, the child might not decide to update the adjustments
* if they logically did not change since the last configuration
*
* These will update priv->hscrollbar_visible and priv->vscrollbar_visible.
*/
gtk_scrolled_window_update_scrollbar_visibility_flags (scrolled_window,
priv->hscrollbar);
2015-12-23 17:54:42 +00:00
gtk_scrolled_window_update_scrollbar_visibility_flags (scrolled_window,
priv->vscrollbar);
2015-12-23 17:54:42 +00:00
2020-05-02 04:17:25 +00:00
/* If, after the first iteration, the hscrollbar and the
2020-05-28 08:00:03 +00:00
* vscrollbar flip visibility... or if one of the scrollbars flip
* on each iteration indefinitely/infinitely, then we just need both
2020-05-02 04:17:25 +00:00
* at this size.
*/
if ((count &&
previous_hvis != priv->hscrollbar_visible &&
previous_vvis != priv->vscrollbar_visible) || count > 3)
{
priv->hscrollbar_visible = TRUE;
priv->vscrollbar_visible = TRUE;
gtk_scrolled_window_allocate_child (scrolled_window, width, height);
break;
}
count++;
}
2015-12-23 17:54:42 +00:00
while (previous_hvis != priv->hscrollbar_visible ||
2020-05-02 04:17:25 +00:00
previous_vvis != priv->vscrollbar_visible);
2015-12-23 17:54:42 +00:00
}
else
{
priv->hscrollbar_visible = priv->hscrollbar_policy == GTK_POLICY_ALWAYS;
priv->vscrollbar_visible = priv->vscrollbar_policy == GTK_POLICY_ALWAYS;
}
gtk_widget_set_child_visible (priv->hscrollbar, priv->hscrollbar_visible);
if (priv->hscrollbar_visible)
{
gtk_scrolled_window_allocate_scrollbar (scrolled_window,
priv->hscrollbar,
&child_allocation);
gtk_widget_size_allocate (priv->hscrollbar, &child_allocation, -1);
2015-12-23 17:54:42 +00:00
}
gtk_widget_set_child_visible (priv->vscrollbar, priv->vscrollbar_visible);
if (priv->vscrollbar_visible)
{
gtk_scrolled_window_allocate_scrollbar (scrolled_window,
priv->vscrollbar,
&child_allocation);
gtk_widget_size_allocate (priv->vscrollbar, &child_allocation, -1);
2015-12-23 17:54:42 +00:00
}
gtk_scrolled_window_check_attach_pan_gesture (scrolled_window);
}
static void
2017-05-04 19:50:51 +00:00
gtk_scrolled_window_measure (GtkWidget *widget,
2015-12-23 17:54:42 +00:00
GtkOrientation orientation,
int for_size,
int *minimum_size,
int *natural_size,
int *minimum_baseline,
2017-05-04 19:50:51 +00:00
int *natural_baseline)
2015-12-23 17:54:42 +00:00
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
int minimum_req = 0, natural_req = 0;
GtkBorder sborder = { 0 };
2015-12-23 17:54:42 +00:00
if (priv->child)
gtk_scrollable_get_border (GTK_SCROLLABLE (priv->child), &sborder);
/*
* First collect the child requisition
*/
if (priv->child && gtk_widget_get_visible (priv->child))
2015-12-23 17:54:42 +00:00
{
int min_child_size, nat_child_size;
gtk_widget_measure (priv->child, orientation, -1,
&min_child_size, &nat_child_size,
NULL, NULL);
2015-12-23 17:54:42 +00:00
if (orientation == GTK_ORIENTATION_HORIZONTAL)
2020-05-02 04:17:25 +00:00
{
if (priv->propagate_natural_width)
natural_req += nat_child_size;
2020-05-02 04:17:25 +00:00
if (priv->hscrollbar_policy == GTK_POLICY_NEVER)
{
minimum_req += min_child_size;
2020-05-02 04:17:25 +00:00
}
else
{
2020-07-24 13:54:49 +00:00
int min = priv->min_content_width >= 0 ? priv->min_content_width : 0;
int max = priv->max_content_width >= 0 ? priv->max_content_width : G_MAXINT;
minimum_req = CLAMP (minimum_req, min, max);
natural_req = CLAMP (natural_req, min, max);
2020-05-02 04:17:25 +00:00
}
}
2015-12-23 17:54:42 +00:00
else /* GTK_ORIENTATION_VERTICAL */
2020-05-02 04:17:25 +00:00
{
if (priv->propagate_natural_height)
natural_req += nat_child_size;
2020-05-02 04:17:25 +00:00
if (priv->vscrollbar_policy == GTK_POLICY_NEVER)
{
minimum_req += min_child_size;
2020-05-02 04:17:25 +00:00
}
else
{
2020-07-24 13:54:49 +00:00
int min = priv->min_content_height >= 0 ? priv->min_content_height : 0;
int max = priv->max_content_height >= 0 ? priv->max_content_height : G_MAXINT;
minimum_req = CLAMP (minimum_req, min, max);
natural_req = CLAMP (natural_req, min, max);
2020-05-02 04:17:25 +00:00
}
}
2015-12-23 17:54:42 +00:00
}
/* Ensure we make requests with natural size >= minimum size */
natural_req = MAX (minimum_req, natural_req);
/*
* Now add to the requisition any additional space for surrounding scrollbars
* and the special scrollable border.
*/
if (policy_may_be_visible (priv->hscrollbar_policy))
2015-12-23 17:54:42 +00:00
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
int min_scrollbar_width, nat_scrollbar_width;
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
&min_scrollbar_width, &nat_scrollbar_width,
NULL, NULL);
minimum_req = MAX (minimum_req, min_scrollbar_width + sborder.left + sborder.right);
natural_req = MAX (natural_req, nat_scrollbar_width + sborder.left + sborder.right);
}
else if (!priv->use_indicators && priv->hscrollbar_policy == GTK_POLICY_ALWAYS)
{
int min_scrollbar_height, nat_scrollbar_height;
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
&min_scrollbar_height, &nat_scrollbar_height,
NULL, NULL);
minimum_req += min_scrollbar_height;
natural_req += nat_scrollbar_height;
}
2015-12-23 17:54:42 +00:00
}
if (policy_may_be_visible (priv->vscrollbar_policy))
2015-12-23 17:54:42 +00:00
{
if (orientation == GTK_ORIENTATION_VERTICAL)
{
int min_scrollbar_height, nat_scrollbar_height;
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_VERTICAL, -1,
&min_scrollbar_height, &nat_scrollbar_height,
NULL, NULL);
minimum_req = MAX (minimum_req, min_scrollbar_height + sborder.top + sborder.bottom);
natural_req = MAX (natural_req, nat_scrollbar_height + sborder.top + sborder.bottom);
}
else if (!priv->use_indicators && priv->vscrollbar_policy == GTK_POLICY_ALWAYS)
{
int min_scrollbar_width, nat_scrollbar_width;
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
&min_scrollbar_width, &nat_scrollbar_width,
NULL, NULL);
minimum_req += min_scrollbar_width;
natural_req += nat_scrollbar_width;
}
}
2015-12-23 17:54:42 +00:00
*minimum_size = minimum_req;
*natural_size = natural_req;
2015-12-23 17:54:42 +00:00
}
static void
2016-12-13 14:14:49 +00:00
gtk_scrolled_window_snapshot_scrollbars_junction (GtkScrolledWindow *scrolled_window,
GtkSnapshot *snapshot)
2015-12-23 17:54:42 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkAllocation hscr_allocation, vscr_allocation;
GtkCssStyle *style;
2015-12-23 17:54:42 +00:00
GdkRectangle junction_rect;
GtkCssBoxes boxes;
2015-12-23 17:54:42 +00:00
gtk_widget_get_allocation (GTK_WIDGET (priv->hscrollbar), &hscr_allocation);
gtk_widget_get_allocation (GTK_WIDGET (priv->vscrollbar), &vscr_allocation);
junction_rect.x = vscr_allocation.x;
junction_rect.y = hscr_allocation.y;
2015-12-23 17:54:42 +00:00
junction_rect.width = vscr_allocation.width;
junction_rect.height = hscr_allocation.height;
style = gtk_css_node_get_style (priv->junction_node);
2015-12-23 17:54:42 +00:00
gtk_css_boxes_init_border_box (&boxes, style,
junction_rect.x, junction_rect.y,
junction_rect.width, junction_rect.height);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
static void
2016-12-13 14:14:49 +00:00
gtk_scrolled_window_snapshot_overshoot (GtkScrolledWindow *scrolled_window,
GtkSnapshot *snapshot)
2015-12-23 17:54:42 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2020-07-24 13:54:49 +00:00
int overshoot_x, overshoot_y;
GtkCssStyle *style;
2015-12-23 17:54:42 +00:00
GdkRectangle rect;
GtkCssBoxes boxes;
2015-12-23 17:54:42 +00:00
if (!_gtk_scrolled_window_get_overshoot (scrolled_window, &overshoot_x, &overshoot_y))
return;
2018-06-16 09:47:06 +00:00
gtk_scrolled_window_inner_allocation (scrolled_window, &rect);
2015-12-23 17:54:42 +00:00
overshoot_x = CLAMP (overshoot_x, - MAX_OVERSHOOT_DISTANCE, MAX_OVERSHOOT_DISTANCE);
overshoot_y = CLAMP (overshoot_y, - MAX_OVERSHOOT_DISTANCE, MAX_OVERSHOOT_DISTANCE);
if (overshoot_x > 0)
{
style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_RIGHT]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x + rect.width - overshoot_x, rect.y, overshoot_x, rect.height);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
else if (overshoot_x < 0)
{
style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_LEFT]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x, rect.y, -overshoot_x, rect.height);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
if (overshoot_y > 0)
{
style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_BOTTOM]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x, rect.y + rect.height - overshoot_y, rect.width, overshoot_y);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
else if (overshoot_y < 0)
{
style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_TOP]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x, rect.y, rect.width, -overshoot_y);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
}
static void
2016-12-13 14:14:49 +00:00
gtk_scrolled_window_snapshot_undershoot (GtkScrolledWindow *scrolled_window,
GtkSnapshot *snapshot)
2015-12-23 17:54:42 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkCssStyle *style;
2015-12-23 17:54:42 +00:00
GdkRectangle rect;
GtkAdjustment *adj;
GtkCssBoxes boxes;
2015-12-23 17:54:42 +00:00
2018-06-16 09:47:06 +00:00
gtk_scrolled_window_inner_allocation (scrolled_window, &rect);
2015-12-23 17:54:42 +00:00
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
2015-12-23 17:54:42 +00:00
if (gtk_adjustment_get_value (adj) < gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj))
{
style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_RIGHT]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x + rect.width - UNDERSHOOT_SIZE, rect.y, UNDERSHOOT_SIZE, rect.height);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
if (gtk_adjustment_get_value (adj) > gtk_adjustment_get_lower (adj))
{
style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_LEFT]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x, rect.y, UNDERSHOOT_SIZE, rect.height);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
2015-12-23 17:54:42 +00:00
if (gtk_adjustment_get_value (adj) < gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj))
{
style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_BOTTOM]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x, rect.y + rect.height - UNDERSHOOT_SIZE, rect.width, UNDERSHOOT_SIZE);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
if (gtk_adjustment_get_value (adj) > gtk_adjustment_get_lower (adj))
{
style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_TOP]);
gtk_css_boxes_init_border_box (&boxes, style,
rect.x, rect.y, rect.width, UNDERSHOOT_SIZE);
gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot);
2015-12-23 17:54:42 +00:00
}
}
static void
gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
{
GtkWidget *widget = GTK_WIDGET (scrolled_window);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkEventController *controller;
2015-12-23 17:54:42 +00:00
GtkCssNode *widget_node;
GQuark classes[4] = {
g_quark_from_static_string ("left"),
g_quark_from_static_string ("right"),
g_quark_from_static_string ("top"),
g_quark_from_static_string ("bottom"),
2015-12-23 17:54:42 +00:00
};
2020-07-24 13:54:49 +00:00
int i;
2015-12-23 17:54:42 +00:00
gtk_widget_set_focusable (widget, TRUE);
2015-12-23 17:54:42 +00:00
/* Instantiated by gtk_scrolled_window_set_[hv]adjustment
* which are both construct properties
*/
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->auto_added_viewport = FALSE;
2015-12-23 17:54:42 +00:00
priv->window_placement = GTK_CORNER_TOP_LEFT;
priv->min_content_width = -1;
priv->min_content_height = -1;
priv->max_content_width = -1;
priv->max_content_height = -1;
2015-12-23 17:54:42 +00:00
priv->overlay_scrolling = TRUE;
2018-03-10 17:05:57 +00:00
priv->drag_gesture = gtk_gesture_drag_new ();
2015-12-23 17:54:42 +00:00
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture), TRUE);
g_signal_connect_swapped (priv->drag_gesture, "drag-begin",
G_CALLBACK (scrolled_window_drag_begin_cb),
scrolled_window);
g_signal_connect_swapped (priv->drag_gesture, "drag-update",
G_CALLBACK (scrolled_window_drag_update_cb),
scrolled_window);
g_signal_connect_swapped (priv->drag_gesture, "end",
G_CALLBACK (scrolled_window_drag_end_cb),
scrolled_window);
2018-03-10 17:05:57 +00:00
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->drag_gesture));
2015-12-23 17:54:42 +00:00
2018-03-08 23:03:15 +00:00
priv->pan_gesture = gtk_gesture_pan_new (GTK_ORIENTATION_VERTICAL);
2015-12-23 17:54:42 +00:00
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->pan_gesture), TRUE);
2018-03-08 23:03:15 +00:00
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->pan_gesture));
gtk_gesture_group (priv->pan_gesture, priv->drag_gesture);
2015-12-23 17:54:42 +00:00
2018-03-08 22:49:41 +00:00
priv->swipe_gesture = gtk_gesture_swipe_new ();
2015-12-23 17:54:42 +00:00
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->swipe_gesture), TRUE);
g_signal_connect_swapped (priv->swipe_gesture, "swipe",
G_CALLBACK (scrolled_window_swipe_cb),
scrolled_window);
2018-03-08 22:49:41 +00:00
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->swipe_gesture));
gtk_gesture_group (priv->swipe_gesture, priv->drag_gesture);
priv->long_press_gesture = gtk_gesture_long_press_new ();
2015-12-23 17:54:42 +00:00
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->long_press_gesture), TRUE);
g_signal_connect_swapped (priv->long_press_gesture, "pressed",
G_CALLBACK (scrolled_window_long_press_cb),
scrolled_window);
g_signal_connect_swapped (priv->long_press_gesture, "cancelled",
G_CALLBACK (scrolled_window_long_press_cancelled_cb),
scrolled_window);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->long_press_gesture));
gtk_gesture_group (priv->long_press_gesture, priv->drag_gesture);
2015-12-23 17:54:42 +00:00
gtk_scrolled_window_set_kinetic_scrolling (scrolled_window, TRUE);
controller = gtk_event_controller_motion_new ();
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
g_signal_connect (controller, "motion",
G_CALLBACK (captured_motion), scrolled_window);
gtk_widget_add_controller (widget, controller);
2015-12-23 17:54:42 +00:00
widget_node = gtk_widget_get_css_node (widget);
for (i = 0; i < 4; i++)
{
priv->overshoot_node[i] = gtk_css_node_new ();
gtk_css_node_set_name (priv->overshoot_node[i], g_quark_from_static_string ("overshoot"));
2015-12-23 17:54:42 +00:00
gtk_css_node_add_class (priv->overshoot_node[i], classes[i]);
gtk_css_node_set_parent (priv->overshoot_node[i], widget_node);
gtk_css_node_set_state (priv->overshoot_node[i], gtk_css_node_get_state (widget_node));
g_object_unref (priv->overshoot_node[i]);
priv->undershoot_node[i] = gtk_css_node_new ();
gtk_css_node_set_name (priv->undershoot_node[i], g_quark_from_static_string ("undershoot"));
2015-12-23 17:54:42 +00:00
gtk_css_node_add_class (priv->undershoot_node[i], classes[i]);
gtk_css_node_set_parent (priv->undershoot_node[i], widget_node);
gtk_css_node_set_state (priv->undershoot_node[i], gtk_css_node_get_state (widget_node));
g_object_unref (priv->undershoot_node[i]);
}
gtk_scrolled_window_update_use_indicators (scrolled_window);
priv->junction_node = gtk_css_node_new ();
gtk_css_node_set_name (priv->junction_node, g_quark_from_static_string ("junction"));
gtk_css_node_set_parent (priv->junction_node, widget_node);
gtk_css_node_set_state (priv->junction_node, gtk_css_node_get_state (widget_node));
g_object_unref (priv->junction_node);
controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES |
GTK_EVENT_CONTROLLER_SCROLL_KINETIC);
g_signal_connect (controller, "scroll-begin",
G_CALLBACK (scroll_controller_scroll_begin), scrolled_window);
g_signal_connect (controller, "scroll",
G_CALLBACK (scroll_controller_scroll), scrolled_window);
g_signal_connect (controller, "scroll-end",
G_CALLBACK (scroll_controller_scroll_end), scrolled_window);
gtk_widget_add_controller (widget, controller);
controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES |
GTK_EVENT_CONTROLLER_SCROLL_KINETIC);
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
g_signal_connect (controller, "scroll-begin",
G_CALLBACK (stop_kinetic_scrolling_cb), scrolled_window);
g_signal_connect (controller, "scroll",
G_CALLBACK (captured_scroll_cb), scrolled_window);
g_signal_connect (controller, "decelerate",
G_CALLBACK (scroll_controller_decelerate), scrolled_window);
gtk_widget_add_controller (widget, controller);
controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "leave",
G_CALLBACK (motion_controller_leave), scrolled_window);
gtk_widget_add_controller (widget, controller);
2015-12-23 17:54:42 +00:00
}
/**
* gtk_scrolled_window_new:
*
* Creates a new scrolled window.
*
* Returns: a new scrolled window
*/
GtkWidget *
gtk_scrolled_window_new (void)
2015-12-23 17:54:42 +00:00
{
return g_object_new (GTK_TYPE_SCROLLED_WINDOW, NULL);
2015-12-23 17:54:42 +00:00
}
/**
* gtk_scrolled_window_set_hadjustment: (attributes org.gtk.Method.set_property=hadjustment)
* @scrolled_window: a `GtkScrolledWindow`
* @hadjustment: (nullable): the `GtkAdjustment` to use, or %NULL to create a new one
2015-12-23 17:54:42 +00:00
*
* Sets the `GtkAdjustment` for the horizontal scrollbar.
2015-12-23 17:54:42 +00:00
*/
void
gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window,
2018-06-16 09:47:06 +00:00
GtkAdjustment *hadjustment)
2015-12-23 17:54:42 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2015-12-23 17:54:42 +00:00
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
2015-12-23 17:54:42 +00:00
if (hadjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (hadjustment));
else
hadjustment = (GtkAdjustment*) g_object_new (GTK_TYPE_ADJUSTMENT, NULL);
if (!priv->hscrollbar)
{
priv->hscrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, hadjustment);
gtk_widget_insert_before (priv->hscrollbar, GTK_WIDGET (scrolled_window), priv->vscrollbar);
2015-12-23 17:54:42 +00:00
update_scrollbar_positions (scrolled_window);
}
else
{
GtkAdjustment *old_adjustment;
old_adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
2015-12-23 17:54:42 +00:00
if (old_adjustment == hadjustment)
2020-05-02 04:17:25 +00:00
return;
2015-12-23 17:54:42 +00:00
g_signal_handlers_disconnect_by_func (old_adjustment,
gtk_scrolled_window_adjustment_changed,
scrolled_window);
g_signal_handlers_disconnect_by_func (old_adjustment,
gtk_scrolled_window_adjustment_value_changed,
scrolled_window);
2015-12-23 17:54:42 +00:00
gtk_adjustment_enable_animation (old_adjustment, NULL, 0);
gtk_scrollbar_set_adjustment (GTK_SCROLLBAR (priv->hscrollbar), hadjustment);
2015-12-23 17:54:42 +00:00
}
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
2015-12-23 17:54:42 +00:00
g_signal_connect (hadjustment,
"changed",
2020-05-02 04:17:25 +00:00
G_CALLBACK (gtk_scrolled_window_adjustment_changed),
scrolled_window);
2015-12-23 17:54:42 +00:00
g_signal_connect (hadjustment,
"value-changed",
2020-05-02 04:17:25 +00:00
G_CALLBACK (gtk_scrolled_window_adjustment_value_changed),
scrolled_window);
2015-12-23 17:54:42 +00:00
gtk_scrolled_window_adjustment_changed (hadjustment, scrolled_window);
gtk_scrolled_window_adjustment_value_changed (hadjustment, scrolled_window);
if (priv->child)
gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (priv->child), hadjustment);
2015-12-23 17:54:42 +00:00
if (gtk_widget_should_animate (GTK_WIDGET (scrolled_window)))
2015-12-23 17:54:42 +00:00
gtk_adjustment_enable_animation (hadjustment, gtk_widget_get_frame_clock (GTK_WIDGET (scrolled_window)), ANIMATION_DURATION);
2015-12-23 17:54:42 +00:00
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_HADJUSTMENT]);
}
/**
* gtk_scrolled_window_set_vadjustment: (attributes org.gtk.Method.set_property=vadjustment)
* @scrolled_window: a `GtkScrolledWindow`
* @vadjustment: (nullable): the `GtkAdjustment` to use, or %NULL to create a new one
2015-12-23 17:54:42 +00:00
*
* Sets the `GtkAdjustment` for the vertical scrollbar.
2015-12-23 17:54:42 +00:00
*/
void
gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window,
GtkAdjustment *vadjustment)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2015-12-23 17:54:42 +00:00
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
2015-12-23 17:54:42 +00:00
if (vadjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (vadjustment));
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
else
vadjustment = (GtkAdjustment*) g_object_new (GTK_TYPE_ADJUSTMENT, NULL);
1997-11-24 22:37:52 +00:00
if (!priv->vscrollbar)
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
{
priv->vscrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, vadjustment);
1997-11-24 22:37:52 +00:00
gtk_widget_insert_after (priv->vscrollbar, GTK_WIDGET (scrolled_window), priv->hscrollbar);
update_scrollbar_positions (scrolled_window);
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
}
else
{
GtkAdjustment *old_adjustment;
old_adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
if (old_adjustment == vadjustment)
2020-05-02 04:17:25 +00:00
return;
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
g_signal_handlers_disconnect_by_func (old_adjustment,
gtk_scrolled_window_adjustment_changed,
scrolled_window);
g_signal_handlers_disconnect_by_func (old_adjustment,
gtk_scrolled_window_adjustment_value_changed,
scrolled_window);
gtk_adjustment_enable_animation (old_adjustment, NULL, 0);
gtk_scrollbar_set_adjustment (GTK_SCROLLBAR (priv->vscrollbar), vadjustment);
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
}
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
g_signal_connect (vadjustment,
"changed",
2020-05-02 04:17:25 +00:00
G_CALLBACK (gtk_scrolled_window_adjustment_changed),
scrolled_window);
g_signal_connect (vadjustment,
"value-changed",
2020-05-02 04:17:25 +00:00
G_CALLBACK (gtk_scrolled_window_adjustment_value_changed),
scrolled_window);
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
gtk_scrolled_window_adjustment_changed (vadjustment, scrolled_window);
gtk_scrolled_window_adjustment_value_changed (vadjustment, scrolled_window);
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
if (priv->child)
gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (priv->child), vadjustment);
if (gtk_widget_should_animate (GTK_WIDGET (scrolled_window)))
gtk_adjustment_enable_animation (vadjustment, gtk_widget_get_frame_clock (GTK_WIDGET (scrolled_window)), ANIMATION_DURATION);
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_VADJUSTMENT]);
1997-11-24 22:37:52 +00:00
}
/**
* gtk_scrolled_window_get_hadjustment: (attributes org.gtk.Method.get_property=hadjustment)
* @scrolled_window: a `GtkScrolledWindow`
*
* Returns the horizontal scrollbars adjustment.
*
* This is the adjustment used to connect the horizontal scrollbar
* to the child widgets horizontal scroll functionality.
*
* Returns: (transfer none): the horizontal `GtkAdjustment`
*/
1997-11-24 22:37:52 +00:00
GtkAdjustment*
gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
1997-11-24 22:37:52 +00:00
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), NULL);
return gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
1997-11-24 22:37:52 +00:00
}
/**
* gtk_scrolled_window_get_vadjustment: (attributes org.gtk.Method.get_property=vadjustment)
* @scrolled_window: a `GtkScrolledWindow`
*
* Returns the vertical scrollbars adjustment.
*
* This is the adjustment used to connect the vertical
* scrollbar to the child widgets vertical scroll functionality.
*
* Returns: (transfer none): the vertical `GtkAdjustment`
*/
1997-11-24 22:37:52 +00:00
GtkAdjustment*
gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
1997-11-24 22:37:52 +00:00
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), NULL);
return gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
1997-11-24 22:37:52 +00:00
}
/**
* gtk_scrolled_window_get_hscrollbar:
* @scrolled_window: a `GtkScrolledWindow`
2010-09-21 04:18:11 +00:00
*
* Returns the horizontal scrollbar of @scrolled_window.
*
* Returns: (transfer none): the horizontal scrollbar of the scrolled window.
*/
GtkWidget*
gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), NULL);
2018-06-16 09:47:06 +00:00
return priv->hscrollbar;
}
/**
* gtk_scrolled_window_get_vscrollbar:
* @scrolled_window: a `GtkScrolledWindow`
*
* Returns the vertical scrollbar of @scrolled_window.
*
* Returns: (transfer none): the vertical scrollbar of the scrolled window.
*/
GtkWidget*
gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), NULL);
2018-06-16 09:47:06 +00:00
return priv->vscrollbar;
}
/**
* gtk_scrolled_window_set_policy:
* @scrolled_window: a `GtkScrolledWindow`
* @hscrollbar_policy: policy for horizontal bar
* @vscrollbar_policy: policy for vertical bar
*
* Sets the scrollbar policy for the horizontal and vertical scrollbars.
*
* The policy determines when the scrollbar should appear; it is a value
* from the [enum@Gtk.PolicyType] enumeration. If %GTK_POLICY_ALWAYS, the
* scrollbar is always present; if %GTK_POLICY_NEVER, the scrollbar is
* never present; if %GTK_POLICY_AUTOMATIC, the scrollbar is present only
* if needed (that is, if the slider part of the bar would be smaller
2014-10-05 04:13:09 +00:00
* than the trough the display is larger than the page size).
*/
1997-11-24 22:37:52 +00:00
void
gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
2020-05-02 04:17:25 +00:00
GtkPolicyType hscrollbar_policy,
GtkPolicyType vscrollbar_policy)
1997-11-24 22:37:52 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GObject *object = G_OBJECT (scrolled_window);
1997-11-24 22:37:52 +00:00
2018-06-16 09:47:06 +00:00
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if ((priv->hscrollbar_policy != hscrollbar_policy) ||
(priv->vscrollbar_policy != vscrollbar_policy))
1997-11-24 22:37:52 +00:00
{
priv->hscrollbar_policy = hscrollbar_policy;
priv->vscrollbar_policy = vscrollbar_policy;
1997-11-24 22:37:52 +00:00
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
g_object_notify_by_pspec (object, properties[PROP_HSCROLLBAR_POLICY]);
g_object_notify_by_pspec (object, properties[PROP_VSCROLLBAR_POLICY]);
1997-11-24 22:37:52 +00:00
}
}
/**
* gtk_scrolled_window_get_policy:
* @scrolled_window: a `GtkScrolledWindow`
* @hscrollbar_policy: (out) (optional): location to store the policy
* for the horizontal scrollbar
* @vscrollbar_policy: (out) (optional): location to store the policy
* for the vertical scrollbar
*
* Retrieves the current policy values for the horizontal and vertical
* scrollbars.
*
* See [method@Gtk.ScrolledWindow.set_policy].
*/
void
gtk_scrolled_window_get_policy (GtkScrolledWindow *scrolled_window,
2020-05-02 04:17:25 +00:00
GtkPolicyType *hscrollbar_policy,
GtkPolicyType *vscrollbar_policy)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (hscrollbar_policy)
*hscrollbar_policy = priv->hscrollbar_policy;
if (vscrollbar_policy)
*vscrollbar_policy = priv->vscrollbar_policy;
}
/**
* gtk_scrolled_window_set_placement: (attributes org.gtk.Method.set_property=window-placement)
* @scrolled_window: a `GtkScrolledWindow`
* @window_placement: position of the child window
*
* Sets the placement of the contents with respect to the scrollbars
* for the scrolled window.
*
* The default is %GTK_CORNER_TOP_LEFT, meaning the child is
* in the top left, with the scrollbars underneath and to the right.
* Other values in [enum@Gtk.CornerType] are %GTK_CORNER_TOP_RIGHT,
* %GTK_CORNER_BOTTOM_LEFT, and %GTK_CORNER_BOTTOM_RIGHT.
*
* See also [method@Gtk.ScrolledWindow.get_placement] and
* [method@Gtk.ScrolledWindow.unset_placement].
*/
void
gtk_scrolled_window_set_placement (GtkScrolledWindow *scrolled_window,
GtkCornerType window_placement)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (priv->window_placement != window_placement)
{
priv->window_placement = window_placement;
update_scrollbar_positions (scrolled_window);
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_WINDOW_PLACEMENT]);
}
}
/**
* gtk_scrolled_window_get_placement: (attributes org.gtk.Method.get_property=window-placement)
* @scrolled_window: a `GtkScrolledWindow`
*
* Gets the placement of the contents with respect to the scrollbars.
*
* Returns: the current placement value.
*/
GtkCornerType
gtk_scrolled_window_get_placement (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), GTK_CORNER_TOP_LEFT);
2018-06-16 09:47:06 +00:00
return priv->window_placement;
}
/**
* gtk_scrolled_window_unset_placement:
* @scrolled_window: a `GtkScrolledWindow`
*
* Unsets the placement of the contents with respect to the scrollbars.
*
* If no window placement is set for a scrolled window,
* it defaults to %GTK_CORNER_TOP_LEFT.
*/
void
gtk_scrolled_window_unset_placement (GtkScrolledWindow *scrolled_window)
{
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
gtk_scrolled_window_set_placement (scrolled_window, GTK_CORNER_TOP_LEFT);
}
/**
* gtk_scrolled_window_set_has_frame: (attributes org.gtk.Method.set_property=has-frame)
* @scrolled_window: a `GtkScrolledWindow`
* @has_frame: whether to draw a frame around scrolled window contents
*
* Changes the frame drawn around the contents of @scrolled_window.
*/
void
gtk_scrolled_window_set_has_frame (GtkScrolledWindow *scrolled_window,
gboolean has_frame)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (priv->has_frame == !!has_frame)
return;
priv->has_frame = has_frame;
if (has_frame)
gtk_widget_add_css_class (GTK_WIDGET (scrolled_window), "frame");
else
gtk_widget_remove_css_class (GTK_WIDGET (scrolled_window), "frame");
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_HAS_FRAME]);
}
/**
* gtk_scrolled_window_get_has_frame: (attributes org.gtk.Method.get_property=has-frame)
* @scrolled_window: a `GtkScrolledWindow`
*
* Gets whether the scrolled window draws a frame.
*
* Returns: %TRUE if the @scrolled_window has a frame
*/
gboolean
gtk_scrolled_window_get_has_frame (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), FALSE);
return priv->has_frame;
}
/**
* gtk_scrolled_window_set_kinetic_scrolling: (attributes org.gtk.Method.set_property=kinetic-scrolling)
* @scrolled_window: a `GtkScrolledWindow`
* @kinetic_scrolling: %TRUE to enable kinetic scrolling
*
* Turns kinetic scrolling on or off.
*
* Kinetic scrolling only applies to devices with source
* %GDK_SOURCE_TOUCHSCREEN.
**/
void
gtk_scrolled_window_set_kinetic_scrolling (GtkScrolledWindow *scrolled_window,
gboolean kinetic_scrolling)
{
GtkPropagationPhase phase = GTK_PHASE_NONE;
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (priv->kinetic_scrolling == kinetic_scrolling)
return;
priv->kinetic_scrolling = kinetic_scrolling;
gtk_scrolled_window_check_attach_pan_gesture (scrolled_window);
if (priv->kinetic_scrolling)
phase = GTK_PHASE_CAPTURE;
else
gtk_scrolled_window_cancel_deceleration (scrolled_window);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->drag_gesture), phase);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->swipe_gesture), phase);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->long_press_gesture), phase);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->pan_gesture), phase);
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_KINETIC_SCROLLING]);
}
/**
* gtk_scrolled_window_get_kinetic_scrolling: (attributes org.gtk.Method.get_property=kinetic-scrolling)
* @scrolled_window: a `GtkScrolledWindow`
*
* Returns the specified kinetic scrolling behavior.
*
* Returns: the scrolling behavior flags.
*/
gboolean
gtk_scrolled_window_get_kinetic_scrolling (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), FALSE);
2018-06-16 09:47:06 +00:00
return priv->kinetic_scrolling;
}
1997-11-24 22:37:52 +00:00
static void
gtk_scrolled_window_dispose (GObject *object)
1997-11-24 22:37:52 +00:00
{
GtkScrolledWindow *self = GTK_SCROLLED_WINDOW (object);
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (self);
g_clear_pointer (&priv->child, gtk_widget_unparent);
1997-11-24 22:37:52 +00:00
remove_indicator (self, &priv->hindicator);
remove_indicator (self, &priv->vindicator);
if (priv->hscrollbar)
{
GtkAdjustment *hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
g_signal_handlers_disconnect_by_data (hadjustment, self);
g_signal_handlers_disconnect_by_data (hadjustment, &priv->hindicator);
gtk_widget_unparent (priv->hscrollbar);
priv->hscrollbar = NULL;
}
if (priv->vscrollbar)
{
GtkAdjustment *vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
g_signal_handlers_disconnect_by_data (vadjustment, self);
g_signal_handlers_disconnect_by_data (vadjustment, &priv->vindicator);
gtk_widget_unparent (priv->vscrollbar);
priv->vscrollbar = NULL;
}
1997-11-24 22:37:52 +00:00
if (priv->deceleration_id)
{
gtk_widget_remove_tick_callback (GTK_WIDGET (self), priv->deceleration_id);
priv->deceleration_id = 0;
}
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
2020-12-27 17:11:29 +00:00
g_clear_handle_id (&priv->scroll_events_overshoot_id, g_source_remove);
G_OBJECT_CLASS (gtk_scrolled_window_parent_class)->dispose (object);
}
static void
gtk_scrolled_window_set_property (GObject *object,
2020-05-02 04:17:25 +00:00
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (object);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
switch (prop_id)
{
case PROP_HADJUSTMENT:
gtk_scrolled_window_set_hadjustment (scrolled_window,
2020-05-02 04:17:25 +00:00
g_value_get_object (value));
break;
case PROP_VADJUSTMENT:
gtk_scrolled_window_set_vadjustment (scrolled_window,
2020-05-02 04:17:25 +00:00
g_value_get_object (value));
break;
case PROP_HSCROLLBAR_POLICY:
gtk_scrolled_window_set_policy (scrolled_window,
2020-05-02 04:17:25 +00:00
g_value_get_enum (value),
priv->vscrollbar_policy);
break;
case PROP_VSCROLLBAR_POLICY:
gtk_scrolled_window_set_policy (scrolled_window,
2020-05-02 04:17:25 +00:00
priv->hscrollbar_policy,
g_value_get_enum (value));
break;
case PROP_WINDOW_PLACEMENT:
gtk_scrolled_window_set_placement (scrolled_window,
g_value_get_enum (value));
break;
case PROP_HAS_FRAME:
gtk_scrolled_window_set_has_frame (scrolled_window,
2020-05-02 04:17:25 +00:00
g_value_get_boolean (value));
break;
case PROP_MIN_CONTENT_WIDTH:
gtk_scrolled_window_set_min_content_width (scrolled_window,
g_value_get_int (value));
break;
case PROP_MIN_CONTENT_HEIGHT:
gtk_scrolled_window_set_min_content_height (scrolled_window,
g_value_get_int (value));
break;
case PROP_KINETIC_SCROLLING:
gtk_scrolled_window_set_kinetic_scrolling (scrolled_window,
g_value_get_boolean (value));
break;
case PROP_OVERLAY_SCROLLING:
gtk_scrolled_window_set_overlay_scrolling (scrolled_window,
g_value_get_boolean (value));
break;
case PROP_MAX_CONTENT_WIDTH:
gtk_scrolled_window_set_max_content_width (scrolled_window,
g_value_get_int (value));
break;
case PROP_MAX_CONTENT_HEIGHT:
gtk_scrolled_window_set_max_content_height (scrolled_window,
g_value_get_int (value));
break;
case PROP_PROPAGATE_NATURAL_WIDTH:
gtk_scrolled_window_set_propagate_natural_width (scrolled_window,
2020-05-02 04:17:25 +00:00
g_value_get_boolean (value));
break;
case PROP_PROPAGATE_NATURAL_HEIGHT:
gtk_scrolled_window_set_propagate_natural_height (scrolled_window,
2020-05-02 04:17:25 +00:00
g_value_get_boolean (value));
break;
case PROP_CHILD:
gtk_scrolled_window_set_child (scrolled_window, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_scrolled_window_get_property (GObject *object,
2020-05-02 04:17:25 +00:00
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (object);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
switch (prop_id)
{
case PROP_HADJUSTMENT:
g_value_set_object (value,
2020-05-02 04:17:25 +00:00
G_OBJECT (gtk_scrolled_window_get_hadjustment (scrolled_window)));
break;
case PROP_VADJUSTMENT:
g_value_set_object (value,
2020-05-02 04:17:25 +00:00
G_OBJECT (gtk_scrolled_window_get_vadjustment (scrolled_window)));
break;
case PROP_WINDOW_PLACEMENT:
g_value_set_enum (value, priv->window_placement);
break;
case PROP_HAS_FRAME:
g_value_set_boolean (value, priv->has_frame);
break;
case PROP_HSCROLLBAR_POLICY:
g_value_set_enum (value, priv->hscrollbar_policy);
break;
case PROP_VSCROLLBAR_POLICY:
g_value_set_enum (value, priv->vscrollbar_policy);
break;
case PROP_MIN_CONTENT_WIDTH:
g_value_set_int (value, priv->min_content_width);
break;
case PROP_MIN_CONTENT_HEIGHT:
g_value_set_int (value, priv->min_content_height);
break;
case PROP_KINETIC_SCROLLING:
g_value_set_boolean (value, priv->kinetic_scrolling);
break;
case PROP_OVERLAY_SCROLLING:
g_value_set_boolean (value, priv->overlay_scrolling);
2015-12-23 17:54:42 +00:00
break;
case PROP_MAX_CONTENT_WIDTH:
g_value_set_int (value, priv->max_content_width);
break;
case PROP_MAX_CONTENT_HEIGHT:
g_value_set_int (value, priv->max_content_height);
break;
case PROP_PROPAGATE_NATURAL_WIDTH:
g_value_set_boolean (value, priv->propagate_natural_width);
break;
case PROP_PROPAGATE_NATURAL_HEIGHT:
g_value_set_boolean (value, priv->propagate_natural_height);
break;
2020-05-02 04:17:25 +00:00
case PROP_CHILD:
g_value_set_object (value, gtk_scrolled_window_get_child (scrolled_window));
break;
2015-12-23 17:54:42 +00:00
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
2015-12-23 17:54:42 +00:00
}
2015-12-23 17:54:42 +00:00
static void
2018-06-16 09:47:06 +00:00
gtk_scrolled_window_inner_allocation (GtkScrolledWindow *scrolled_window,
GtkAllocation *rect)
2015-12-23 17:54:42 +00:00
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2015-12-23 17:54:42 +00:00
GtkBorder border = { 0 };
2018-06-16 09:47:06 +00:00
gtk_scrolled_window_relative_allocation (scrolled_window, rect);
rect->x = 0;
rect->y = 0;
if (priv->child && gtk_scrollable_get_border (GTK_SCROLLABLE (priv->child), &border))
{
2015-12-23 17:54:42 +00:00
rect->x += border.left;
rect->y += border.top;
rect->width -= border.left + border.right;
rect->height -= border.top + border.bottom;
}
}
2016-12-13 14:14:49 +00:00
static void
gtk_scrolled_window_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2017-05-03 09:43:47 +00:00
if (priv->hscrollbar_visible &&
priv->vscrollbar_visible &&
!priv->use_indicators)
2017-05-03 09:43:47 +00:00
gtk_scrolled_window_snapshot_scrollbars_junction (scrolled_window, snapshot);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->snapshot (widget, snapshot);
gtk_scrolled_window_snapshot_undershoot (scrolled_window, snapshot);
gtk_scrolled_window_snapshot_overshoot (scrolled_window, snapshot);
1997-11-24 22:37:52 +00:00
}
static gboolean
gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
2020-05-02 04:17:25 +00:00
GtkScrollType scroll,
gboolean horizontal)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkAdjustment *adjustment = NULL;
2018-06-16 09:47:06 +00:00
switch (scroll)
{
case GTK_SCROLL_STEP_UP:
scroll = GTK_SCROLL_STEP_BACKWARD;
horizontal = FALSE;
break;
case GTK_SCROLL_STEP_DOWN:
scroll = GTK_SCROLL_STEP_FORWARD;
horizontal = FALSE;
break;
case GTK_SCROLL_STEP_LEFT:
scroll = GTK_SCROLL_STEP_BACKWARD;
horizontal = TRUE;
break;
case GTK_SCROLL_STEP_RIGHT:
scroll = GTK_SCROLL_STEP_FORWARD;
horizontal = TRUE;
break;
case GTK_SCROLL_PAGE_UP:
scroll = GTK_SCROLL_PAGE_BACKWARD;
horizontal = FALSE;
break;
case GTK_SCROLL_PAGE_DOWN:
scroll = GTK_SCROLL_PAGE_FORWARD;
horizontal = FALSE;
break;
case GTK_SCROLL_PAGE_LEFT:
scroll = GTK_SCROLL_STEP_BACKWARD;
horizontal = TRUE;
break;
case GTK_SCROLL_PAGE_RIGHT:
scroll = GTK_SCROLL_STEP_FORWARD;
horizontal = TRUE;
break;
case GTK_SCROLL_STEP_BACKWARD:
case GTK_SCROLL_STEP_FORWARD:
case GTK_SCROLL_PAGE_BACKWARD:
case GTK_SCROLL_PAGE_FORWARD:
case GTK_SCROLL_START:
case GTK_SCROLL_END:
break;
case GTK_SCROLL_NONE:
case GTK_SCROLL_JUMP:
default:
g_warning ("Invalid scroll type %u for GtkScrolledWindow::scroll-child", scroll);
return FALSE;
}
if (horizontal)
{
if (may_hscroll (scrolled_window))
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
else
return FALSE;
}
else
{
if (may_vscroll (scrolled_window))
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
else
return FALSE;
}
if (adjustment)
{
2020-07-24 20:32:16 +00:00
double value = gtk_adjustment_get_value (adjustment);
switch (scroll)
2020-05-02 04:17:25 +00:00
{
case GTK_SCROLL_STEP_FORWARD:
value += gtk_adjustment_get_step_increment (adjustment);
break;
case GTK_SCROLL_STEP_BACKWARD:
value -= gtk_adjustment_get_step_increment (adjustment);
break;
case GTK_SCROLL_PAGE_FORWARD:
value += gtk_adjustment_get_page_increment (adjustment);
break;
case GTK_SCROLL_PAGE_BACKWARD:
value -= gtk_adjustment_get_page_increment (adjustment);
break;
case GTK_SCROLL_START:
value = gtk_adjustment_get_lower (adjustment);
break;
case GTK_SCROLL_END:
value = gtk_adjustment_get_upper (adjustment);
break;
case GTK_SCROLL_STEP_UP:
case GTK_SCROLL_STEP_DOWN:
case GTK_SCROLL_STEP_LEFT:
case GTK_SCROLL_STEP_RIGHT:
case GTK_SCROLL_PAGE_UP:
case GTK_SCROLL_PAGE_DOWN:
case GTK_SCROLL_PAGE_LEFT:
case GTK_SCROLL_PAGE_RIGHT:
case GTK_SCROLL_NONE:
case GTK_SCROLL_JUMP:
2020-05-02 04:17:25 +00:00
default:
g_assert_not_reached ();
break;
}
gtk_adjustment_animate_to_value (adjustment, value);
return TRUE;
}
return FALSE;
}
static void
gtk_scrolled_window_move_focus_out (GtkScrolledWindow *scrolled_window,
2020-05-02 04:17:25 +00:00
GtkDirectionType direction_type)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkWidget *toplevel;
2018-06-16 09:47:06 +00:00
/* Focus out of the scrolled window entirely. We do this by setting
* a flag, then propagating the focus motion to the notebook.
*/
toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (scrolled_window)));
2019-05-20 03:31:03 +00:00
if (!GTK_IS_ROOT (toplevel))
return;
g_object_ref (scrolled_window);
priv->focus_out = TRUE;
g_signal_emit_by_name (toplevel, "move-focus", direction_type);
priv->focus_out = FALSE;
g_object_unref (scrolled_window);
}
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
static void
2018-06-16 09:47:06 +00:00
gtk_scrolled_window_relative_allocation (GtkScrolledWindow *scrolled_window,
GtkAllocation *allocation)
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2020-07-24 13:54:49 +00:00
int sb_width;
int sb_height;
int width, height;
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
2018-06-16 09:47:06 +00:00
g_return_if_fail (scrolled_window != NULL);
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
g_return_if_fail (allocation != NULL);
/* Get possible scrollbar dimensions */
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
&sb_width, NULL, NULL, NULL);
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
&sb_height, NULL, NULL, NULL);
2018-06-16 09:47:06 +00:00
width = gtk_widget_get_width (GTK_WIDGET (scrolled_window));
height = gtk_widget_get_height (GTK_WIDGET (scrolled_window));
2017-05-04 19:50:51 +00:00
allocation->x = 0;
allocation->y = 0;
allocation->width = width;
allocation->height = height;
2015-12-23 17:54:42 +00:00
/* Subtract some things from our available allocation size */
if (priv->vscrollbar_visible && !priv->use_indicators)
1997-11-24 22:37:52 +00:00
{
2015-12-23 17:54:42 +00:00
gboolean is_rtl;
2018-06-16 09:47:06 +00:00
is_rtl = _gtk_widget_get_direction (GTK_WIDGET (scrolled_window)) == GTK_TEXT_DIR_RTL;
2015-12-23 17:54:42 +00:00
if ((!is_rtl &&
2020-05-02 04:17:25 +00:00
(priv->window_placement == GTK_CORNER_TOP_RIGHT ||
priv->window_placement == GTK_CORNER_BOTTOM_RIGHT)) ||
(is_rtl &&
(priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_BOTTOM_LEFT)))
allocation->x += sb_width;
allocation->width = MAX (1, width - sb_width);
2015-12-23 17:54:42 +00:00
}
2015-12-23 17:54:42 +00:00
if (priv->hscrollbar_visible && !priv->use_indicators)
{
2015-12-23 17:54:42 +00:00
if (priv->window_placement == GTK_CORNER_BOTTOM_LEFT ||
2020-05-02 04:17:25 +00:00
priv->window_placement == GTK_CORNER_BOTTOM_RIGHT)
allocation->y += (sb_height);
allocation->height = MAX (1, height - sb_height);
2015-12-23 17:54:42 +00:00
}
}
2015-12-23 17:54:42 +00:00
static gboolean
_gtk_scrolled_window_get_overshoot (GtkScrolledWindow *scrolled_window,
2020-07-24 13:54:49 +00:00
int *overshoot_x,
int *overshoot_y)
2015-12-23 17:54:42 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2015-12-23 17:54:42 +00:00
GtkAdjustment *vadjustment, *hadjustment;
2020-07-24 20:32:16 +00:00
double lower, upper, x, y;
2015-12-23 17:54:42 +00:00
/* Vertical overshoot */
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
2015-12-23 17:54:42 +00:00
lower = gtk_adjustment_get_lower (vadjustment);
upper = gtk_adjustment_get_upper (vadjustment) -
gtk_adjustment_get_page_size (vadjustment);
2015-12-23 17:54:42 +00:00
if (priv->unclamped_vadj_value < lower)
y = priv->unclamped_vadj_value - lower;
else if (priv->unclamped_vadj_value > upper)
y = priv->unclamped_vadj_value - upper;
else
y = 0;
2015-12-23 17:54:42 +00:00
/* Horizontal overshoot */
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
2015-12-23 17:54:42 +00:00
lower = gtk_adjustment_get_lower (hadjustment);
upper = gtk_adjustment_get_upper (hadjustment) -
gtk_adjustment_get_page_size (hadjustment);
2015-12-23 17:54:42 +00:00
if (priv->unclamped_hadj_value < lower)
x = priv->unclamped_hadj_value - lower;
else if (priv->unclamped_hadj_value > upper)
x = priv->unclamped_hadj_value - upper;
else
x = 0;
2015-12-23 17:54:42 +00:00
if (overshoot_x)
*overshoot_x = x;
2015-12-23 17:54:42 +00:00
if (overshoot_y)
*overshoot_y = y;
2015-12-23 17:54:42 +00:00
return (x != 0 || y != 0);
}
2015-12-23 17:54:42 +00:00
static void
gtk_scrolled_window_allocate_child (GtkScrolledWindow *swindow,
int width,
int height)
2015-12-23 17:54:42 +00:00
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (swindow);
GtkWidget *widget = GTK_WIDGET (swindow);
GtkAllocation child_allocation;
int sb_width;
int sb_height;
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
child_allocation = (GtkAllocation) {0, 0, width, height};
/* Get possible scrollbar dimensions */
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
&sb_width, NULL, NULL, NULL);
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
&sb_height, NULL, NULL, NULL);
/* Subtract some things from our available allocation size */
if (priv->vscrollbar_visible && !priv->use_indicators)
{
gboolean is_rtl;
is_rtl = _gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
if ((!is_rtl &&
(priv->window_placement == GTK_CORNER_TOP_RIGHT ||
priv->window_placement == GTK_CORNER_BOTTOM_RIGHT)) ||
(is_rtl &&
(priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_BOTTOM_LEFT)))
child_allocation.x += sb_width;
child_allocation.width = MAX (1, child_allocation.width - sb_width);
}
if (priv->hscrollbar_visible && !priv->use_indicators)
{
if (priv->window_placement == GTK_CORNER_BOTTOM_LEFT ||
priv->window_placement == GTK_CORNER_BOTTOM_RIGHT)
child_allocation.y += (sb_height);
child_allocation.height = MAX (1, child_allocation.height - sb_height);
}
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
gtk_widget_size_allocate (priv->child, &child_allocation, -1);
2015-12-23 17:54:42 +00:00
}
2015-12-23 17:54:42 +00:00
static void
gtk_scrolled_window_allocate_scrollbar (GtkScrolledWindow *scrolled_window,
GtkWidget *scrollbar,
GtkAllocation *allocation)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2015-12-23 17:54:42 +00:00
GtkAllocation child_allocation, content_allocation;
GtkWidget *widget = GTK_WIDGET (scrolled_window);
2020-07-24 13:54:49 +00:00
int sb_height, sb_width;
2015-12-23 17:54:42 +00:00
2018-06-16 09:47:06 +00:00
gtk_scrolled_window_inner_allocation (scrolled_window, &content_allocation);
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
&sb_width, NULL, NULL, NULL);
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
&sb_height, NULL, NULL, NULL);
2015-12-23 17:54:42 +00:00
if (scrollbar == priv->hscrollbar)
{
2015-12-23 17:54:42 +00:00
child_allocation.x = content_allocation.x;
2015-12-23 17:54:42 +00:00
if (priv->window_placement == GTK_CORNER_TOP_LEFT ||
2020-05-02 04:17:25 +00:00
priv->window_placement == GTK_CORNER_TOP_RIGHT)
{
2015-12-23 17:54:42 +00:00
if (priv->use_indicators)
2020-05-02 04:17:25 +00:00
child_allocation.y = content_allocation.y + content_allocation.height - sb_height;
2015-12-23 17:54:42 +00:00
else
2020-05-02 04:17:25 +00:00
child_allocation.y = content_allocation.y + content_allocation.height;
2015-12-23 17:54:42 +00:00
}
else
{
if (priv->use_indicators)
2020-05-02 04:17:25 +00:00
child_allocation.y = content_allocation.y;
2015-12-23 17:54:42 +00:00
else
2020-05-02 04:17:25 +00:00
child_allocation.y = content_allocation.y - sb_height;
}
1997-11-24 22:37:52 +00:00
2015-12-23 17:54:42 +00:00
child_allocation.width = content_allocation.width;
child_allocation.height = sb_height;
}
else
1997-11-24 22:37:52 +00:00
{
g_assert (scrollbar == priv->vscrollbar);
if ((_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL &&
2020-05-02 04:17:25 +00:00
(priv->window_placement == GTK_CORNER_TOP_RIGHT ||
priv->window_placement == GTK_CORNER_BOTTOM_RIGHT)) ||
(_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR &&
(priv->window_placement == GTK_CORNER_TOP_LEFT ||
priv->window_placement == GTK_CORNER_BOTTOM_LEFT)))
{
2015-12-23 17:54:42 +00:00
if (priv->use_indicators)
2020-05-02 04:17:25 +00:00
child_allocation.x = content_allocation.x + content_allocation.width - sb_width;
2015-12-23 17:54:42 +00:00
else
2020-05-02 04:17:25 +00:00
child_allocation.x = content_allocation.x + content_allocation.width;
}
2015-12-23 17:54:42 +00:00
else
{
if (priv->use_indicators)
2020-05-02 04:17:25 +00:00
child_allocation.x = content_allocation.x;
2015-12-23 17:54:42 +00:00
else
2020-05-02 04:17:25 +00:00
child_allocation.x = content_allocation.x - sb_width;
2015-12-23 17:54:42 +00:00
}
child_allocation.y = content_allocation.y;
child_allocation.width = sb_width;
child_allocation.height = content_allocation.height;
1997-11-24 22:37:52 +00:00
}
2015-12-23 17:54:42 +00:00
*allocation = child_allocation;
}
static void
_gtk_scrolled_window_set_adjustment_value (GtkScrolledWindow *scrolled_window,
GtkAdjustment *adjustment,
2020-07-24 20:32:16 +00:00
double value)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2020-07-24 20:32:16 +00:00
double lower, upper, *prev_value;
GtkPositionType edge_pos;
gboolean vertical;
lower = gtk_adjustment_get_lower (adjustment) - MAX_OVERSHOOT_DISTANCE;
upper = gtk_adjustment_get_upper (adjustment) -
gtk_adjustment_get_page_size (adjustment) + MAX_OVERSHOOT_DISTANCE;
if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar)))
vertical = FALSE;
else if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar)))
vertical = TRUE;
else
return;
if (vertical)
prev_value = &priv->unclamped_vadj_value;
else
prev_value = &priv->unclamped_hadj_value;
value = CLAMP (value, lower, upper);
if (*prev_value == value)
return;
*prev_value = value;
gtk_adjustment_set_value (adjustment, value);
if (value == lower)
edge_pos = vertical ? GTK_POS_TOP : GTK_POS_LEFT;
else if (value == upper)
edge_pos = vertical ? GTK_POS_BOTTOM : GTK_POS_RIGHT;
else
return;
/* Invert horizontal edge position on RTL */
if (!vertical &&
_gtk_widget_get_direction (GTK_WIDGET (scrolled_window)) == GTK_TEXT_DIR_RTL)
edge_pos = (edge_pos == GTK_POS_LEFT) ? GTK_POS_RIGHT : GTK_POS_LEFT;
g_signal_emit (scrolled_window, signals[EDGE_OVERSHOT], 0, edge_pos);
}
static gboolean
scrolled_window_deceleration_cb (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GtkScrolledWindow *scrolled_window = user_data;
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkAdjustment *hadjustment, *vadjustment;
gint64 current_time;
2020-07-24 20:32:16 +00:00
double position, elapsed;
gboolean retval = G_SOURCE_REMOVE;
current_time = gdk_frame_clock_get_frame_time (frame_clock);
elapsed = (current_time - priv->last_deceleration_time) / (double)G_TIME_SPAN_SECOND;
priv->last_deceleration_time = current_time;
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
if (priv->hscrolling &&
gtk_kinetic_scrolling_tick (priv->hscrolling, elapsed, &position, NULL))
{
priv->unclamped_hadj_value = position;
gtk_adjustment_set_value (hadjustment, position);
retval = G_SOURCE_CONTINUE;
}
if (priv->vscrolling &&
gtk_kinetic_scrolling_tick (priv->vscrolling, elapsed, &position, NULL))
{
priv->unclamped_vadj_value = position;
gtk_adjustment_set_value (vadjustment, position);
retval = G_SOURCE_CONTINUE;
}
if (retval == G_SOURCE_REMOVE)
gtk_scrolled_window_cancel_deceleration (scrolled_window);
else
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
return retval;
}
static void
gtk_scrolled_window_cancel_deceleration (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (priv->deceleration_id)
{
gtk_widget_remove_tick_callback (GTK_WIDGET (scrolled_window),
priv->deceleration_id);
priv->deceleration_id = 0;
}
}
static void
kinetic_scroll_stop_notify (GtkScrolledWindow *scrolled_window)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
priv->deceleration_id = 0;
}
static void
gtk_scrolled_window_accumulate_velocity (GtkKineticScrolling **scrolling, double elapsed, double *velocity)
{
if (!*scrolling)
return;
double last_velocity;
gtk_kinetic_scrolling_tick (*scrolling, elapsed, NULL, &last_velocity);
if (((*velocity >= 0) == (last_velocity >= 0)) &&
(fabs (*velocity) >= fabs (last_velocity) * VELOCITY_ACCUMULATION_FLOOR))
{
double min_velocity = last_velocity * VELOCITY_ACCUMULATION_FLOOR;
double max_velocity = last_velocity * VELOCITY_ACCUMULATION_CEIL;
double accumulation_multiplier = (*velocity - min_velocity) / (max_velocity - min_velocity);
*velocity += last_velocity * fmin (accumulation_multiplier, VELOCITY_ACCUMULATION_MAX);
}
g_clear_pointer (scrolling, gtk_kinetic_scrolling_free);
}
static void
gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GdkFrameClock *frame_clock;
gint64 current_time;
double elapsed;
int overshoot_x, overshoot_y;
g_return_if_fail (priv->deceleration_id == 0);
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (scrolled_window));
current_time = gdk_frame_clock_get_frame_time (frame_clock);
elapsed = (current_time - priv->last_deceleration_time) / (double)G_TIME_SPAN_SECOND;
priv->last_deceleration_time = current_time;
_gtk_scrolled_window_get_overshoot (scrolled_window, &overshoot_x, &overshoot_y);
if (may_hscroll (scrolled_window))
{
2020-07-24 20:32:16 +00:00
double lower,upper;
GtkAdjustment *hadjustment;
gtk_scrolled_window_accumulate_velocity (&priv->hscrolling, elapsed, &priv->x_velocity);
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
if (priv->x_velocity != 0 || overshoot_x != 0)
{
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
lower = gtk_adjustment_get_lower (hadjustment);
upper = gtk_adjustment_get_upper (hadjustment);
upper -= gtk_adjustment_get_page_size (hadjustment);
priv->hscrolling =
gtk_kinetic_scrolling_new (lower,
upper,
MAX_OVERSHOOT_DISTANCE,
DECELERATION_FRICTION,
OVERSHOOT_FRICTION,
priv->unclamped_hadj_value,
priv->x_velocity);
}
}
else
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
if (may_vscroll (scrolled_window))
{
2020-07-24 20:32:16 +00:00
double lower,upper;
GtkAdjustment *vadjustment;
gtk_scrolled_window_accumulate_velocity (&priv->vscrolling, elapsed, &priv->y_velocity);
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
if (priv->y_velocity != 0 || overshoot_y != 0)
{
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
lower = gtk_adjustment_get_lower(vadjustment);
upper = gtk_adjustment_get_upper(vadjustment);
upper -= gtk_adjustment_get_page_size(vadjustment);
priv->vscrolling =
gtk_kinetic_scrolling_new (lower,
upper,
MAX_OVERSHOOT_DISTANCE,
DECELERATION_FRICTION,
OVERSHOOT_FRICTION,
priv->unclamped_vadj_value,
priv->y_velocity);
}
}
else
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
2018-06-16 09:47:06 +00:00
priv->deceleration_id = gtk_widget_add_tick_callback (GTK_WIDGET (scrolled_window),
scrolled_window_deceleration_cb, scrolled_window,
(GDestroyNotify) kinetic_scroll_stop_notify);
}
static gboolean
gtk_scrolled_window_focus (GtkWidget *widget,
2020-05-02 04:17:25 +00:00
GtkDirectionType direction)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
gboolean had_focus_child;
had_focus_child = gtk_widget_get_focus_child (widget) != NULL;
2010-05-24 20:31:36 +00:00
if (priv->focus_out)
{
priv->focus_out = FALSE; /* Clear this to catch the wrap-around case */
return FALSE;
}
if (gtk_widget_is_focus (widget))
return FALSE;
/* We only put the scrolled window itself in the focus chain if it
* isn't possible to focus any children.
*/
if (priv->child)
{
if (gtk_widget_child_focus (priv->child, direction))
2020-05-02 04:17:25 +00:00
return TRUE;
}
if (!had_focus_child && gtk_widget_get_can_focus (widget))
{
gtk_widget_grab_focus (widget);
return TRUE;
}
else
return FALSE;
}
1997-11-24 22:37:52 +00:00
static void
added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. Sun Nov 22 16:21:28 1998 Tim Janik <timj@gtk.org> * gtk/gtkprogress.c: added args ::show_text, ::text_xalign, ::text_yalign, ::activity_mode. * gtk/gtkprogressbar.c: added construct arg ::adjustment. added args ::bar_style, ::orientation, ::discrete_blocks, ::activity_step, ::activity_blocks. (gtk_progress_bar_new): (gtk_progress_bar_new_with_adjustment): use gtk_widget_new(). (gtk_progress_bar_construct): deprecated. * gtk/gtkvscrollbar.c: (gtk_vscrollbar_draw_step_back): (gtk_vscrollbar_draw_step_forw): use "vscrollbar" as detail for gtk_paint_arrow, to be consistent with hscrollbar. * gtk/gtktext.c added construct args ::hadjustment, ::vadjustment. added args ::line_wrap, ::word_wrap. (gtk_text_class_init): added scroll_adjustments signal. (gtk_text_new): use gtk_widget_new. (gtk_text_disconnect): remove adjustement with gtk_text_set_adjustments, so we don't screw the reference counts and don't leave signals connected. (gtk_text_destroy): disconnect adjustments signals. (gtk_text_finalize): unref adjustments. * gtk/gtkctree.c: added construct args ::n_columns and ::tree_column. added args ::indent, ::spacing, ::show_stub, ::reorderable, ::use_drag_icons, ::line_style and ::expander_style. (gtk_ctree_set_show_stub): renamed from gtk_ctree_show_stub, which is deprecated now. * gtk/gtkclist.h: remove GTK_CLIST_CONSTRUCT flag. * gtk/gtkclist.c: removed ::vadjustment and ::hadjustment args, introduced ::scroll_adjustments signal. added ::shadow_type, ::selection_mode and ::row_height args. added n_columns construct arg. (gtk_clist_construct): call gtk_object_constructed(). (gtk_clist_set_row_height): if height is passed as 0, revert to automatic height calculation. (gtk_clist_destroy): before unrefing the adjustments, disconnect our signal handlers. Fri Nov 21 22:34:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_new): call gtk_object_default_construct like gtk_object_new. (gtk_widget_destroy): assert that we only destroy constructed widgets. * gtk/gtkobject.h (enum GtkArgFlags): new flag GTK_ARG_CONSTRUCT_ONLY to identify args that may only be used for construction. GTK_ARG_CONSTRUCT maybe used as normal arguments besides construction time. * gtk/gtkobject.c (gtk_object_new): invoke gtk_object_default_construct at the end if the object is not fully constructed. (gtk_object_newv): likewise. (gtk_object_destroy): assert that we only destroy constructed objects. (gtk_object_init): setup GTK_CONSTRUCTED from the objects real klass. (gtk_object_default_construct): new function to complete default construction of an object by applying missing construtor args with default values of 0, 0.0 or NULL. (gtk_object_constructed): new function to mark an object as being constructed (used from within constructors). * gtk/gtkarg.c (gtk_arg_type_new_static): return the args info pointer so it is immediatedly available for the caller. * gtk/gtktypeutils.c (gtk_type_new): pass an object's real class to the object initilizer (GtkObjectInitFunc takes a second arg now, the real klass), and asure that object initializers may temporarily alter the class pointer. Fri Nov 20 08:00:30 1998 Tim Janik <timj@gtk.org> * gtk/testgtk.c: change all occourances of gtk_container_add ( scrolled_window, widget) to gtk_scrolled_window_add_with_viewport (...) for widget!=(clist, ctree, text, viewport). * gtk/gtkcombo.c: (gtk_combo_init): use gtk_scrolled_window_add_with_viewport() to add children to the scrolled window. * gtk/gtkscrolledwindow.h: * gtk/gtkscrolledwindow.c: changed scrolled_window->viewport to scrolled_window->child, and use gtk_widget_scroll_adjustements() to set the scroll adjustments for the widget, we do not create an additional viewport anymore. added ::hadjustment and ::vadjustment constructor args. (gtk_scrolled_window_new): use gtk_widget_new() to create the widget. (gtk_scrolled_window_set_hadjustment): (gtk_scrolled_window_set_vadjustment): new functions that superceed gtk_scrolled_window_construct. (gtk_scrolled_window_construct): deprecated this function. * gtk/gtkhscrollbar.c: * gtk/gtkvscrollbar.c: * gtk/gtkhscale.c: * gtk/gtkvscale.c: support a constructor arg "::adjustment", and use gtk_widget_new() for the widget creation. * gtk/gtkrange.c: added ::update_policy arg. (gtk_range_set_adjustment): if adjustment is passed in as NULL, create a default adjustment so this function can be used for derived widgets that depend on the adjustment's existance. (gtk_range_destroy): disconnect the adjustment signal, so we don't get called after we got destroyed, we don't destroy the adjustment in here, because it might have been provided from another widget. * gtk/gtkviewport.c: introduced ::scroll_adjustments signal. (gtk_viewport_destroy): same as gtk_range_destroy. * gtk/gtkprogress.c (gtk_progress_destroy): same as gtk_range_destroy. * gtk/gtkwidget.h: * gtk/gtkwidget.c: changed gtk_widget_activate() to return a gboolean, indicating whether this widget supports activation. added gtk_widget_scroll_adjustements() to set the scrolling adjustments of a widget. Wed Nov 19 01:22:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: (gtk_option_menu_remove_contents): (gtk_option_menu_update_contents): removed gtk_container_[un]block_resize() pairs. * gtk/gtknotebook.h: * gtk/gtknotebook.c: removed the tab_border field, since it shouldn't be used outside of gtknotebook.c anyways. made ARG_TAB_BORDER a wrtie-only argument. * *.c: made deprecated functions issue a message: gtk_clist_set_border, gtk_container_block_resize, gtk_container_unblock_resize, gtk_container_need_resize, gtk_object_class_add_user_signal, gtk_spin_button_construct, gtk_scrolled_window_construct. removed non-functional functions: gtk_container_disable_resize, gtk_container_enable_resize, gtk_clist_set_policy. Wed Nov 18 22:54:36 1998 Tim Janik <timj@gtk.org> * gtk/gtkbox.c (gtk_box_init): * gtk/gtkdrawingarea.c (gtk_drawing_area_init): * gtk/gtkeventbox.c (gtk_event_box_init): * gtk/gtkfixed.c (gtk_fixed_init): * gtk/gtkframe.c (gtk_frame_init): * gtk/gtkhandlebox.c (gtk_handle_box_init): * gtk/gtkpacker.c (gtk_packer_init): * gtk/gtkmisc.c (gtk_misc_init): * gtk/gtkpreview.c (gtk_preview_init): * gtk/gtkprogress.c (gtk_progress_init): * gtk/gtkprogressbar.c (gtk_progress_bar_init): * gtk/gtkseparator.c (gtk_separator_init): * gtk/gtktable.c (gtk_table_init): * gtk/gtkviewport.c (gtk_viewport_init): * gtk/gtkalignment.c (gtk_alignment_init): removed setting of the GTK_BASIC flag. * gtk/gtkwidget.h: * gtk/gtkwidget.c: removed GTK_BASIC, GTK_WIDGET_BASIC and gtk_widget_basic. * miscellaneous GtkType and macro fixups.
1998-11-23 01:54:45 +00:00
gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
2020-05-02 04:17:25 +00:00
gpointer data)
1997-11-24 22:37:52 +00:00
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindow *scrolled_window = data;
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. Thu Nov 5 16:00:32 1998 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCList): removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. added h/vadjustment. * gtk/gtkclist.c (gtk_clist_class_init): added new args types "hadjustment" & "vadjustment" (gtk_clist_set_arg) (gtk_clist_get_arg): new object class set/get_arg functions (gtk_clist_construct): don't create/adjust scrollbars. (gtk_clist_set_hadjustment) (gtk_clist_set_vadjustment): new functions to set h/vadjustments (gtk_clist_get_vadjustment) (gtk_clist_get_hadjustment): new functions to query h/vadjustments (create_scrollbars): removed. (create_adjustments): replacement for create_scrollbars (gtk_clist_new): call gtk_clist_new_with_titles (gtk_clist_new_with_titles): don't warn on titles == NULL (move_horizontal): use CLAMP instead (gtk_clist_set_policy): deprecated method. use gtk_scrolled_window_set_policy instead. (vadjustment_value_changed): use clist->vadj. (adjust_scrollbars): renamed to adjust_adjustments (adjust_adjustments): former adjust_scrollbars (gtk_clist_destroy): unref adjustments (gtk_clist_size_allocate) (gtk_clist_map) (title_focus) (gtk_clist_unmap) (gtk_clist_size_request) (gtk_clist_focus) (gtk_clist_size_allocate) (gtk_clist_forall): don't use scrollbars (gtk_clist_thaw) (real_insert_row) (real_remove_row) (gtk_clist_set_row_height) (real_resize_column): call adjust_adjustments (gtk_clist_moveto): return if clist has no adjustments yet. (gtk_clist_parent_set): new GtkWidget::parent_set function. Autogenerate h/vadjustments if needed. (move_horizontal) (move_vertical): some cleanups * gtk/gtkviewport.c (gtk_viewport_set_arg) (gtk_viewport_new): call only gtk_viewport_set_h/vadjustment and let these functions do the work. (gtk_viewport_set_hadjustment) (gtk_viewport_set_vadjustment): generate a new adjustment if needed * gtk/gtkscrolledwindow.h ((struct _GtkScrolledWindow): use a guint bitfield for h/vscrollbar_policy and h/vscrollbar_visible * gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed): queue_resize if visibility of scrollbars changes (gtk_scrolled_window_remove): only call container_remove with scrolled_window->viewport automatically if viewport was autogenerated (gtk_scrolled_window_add): add widget as scrolled_window->viewport. auto create a viewport only if widget does not take h/vadjustments. (gtk_scrolled_window_construct): don't generate a viewport automatically. (gtk_scrolled_window_forall): call callback with viewport in any case (gtk_scrolled_window_set_arg): call gtk_container_add in case of ARG_VIEWPORT (gtk_scrolled_window_size_allocate) (gtk_scrolled_window_size_request) (gtk_scrolled_window_map) (gtk_scrolled_window_unmap): check viewport != NULL * gtk/testgtk.c (create_ctree) (export_ctree) (create_clist): use a scrolled_window in conjunction with clists/ctrees * gtk/gtkfilesel.c (gtk_file_selection_init): use a scrolled_window in conjunction with clists * gtk/gtkfontsel.c (gtk_font_selection_init): use a scrolled_window in conjunction with clists
1998-11-05 15:44:22 +00:00
if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar)))
removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. Thu Nov 5 16:00:32 1998 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCList): removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. added h/vadjustment. * gtk/gtkclist.c (gtk_clist_class_init): added new args types "hadjustment" & "vadjustment" (gtk_clist_set_arg) (gtk_clist_get_arg): new object class set/get_arg functions (gtk_clist_construct): don't create/adjust scrollbars. (gtk_clist_set_hadjustment) (gtk_clist_set_vadjustment): new functions to set h/vadjustments (gtk_clist_get_vadjustment) (gtk_clist_get_hadjustment): new functions to query h/vadjustments (create_scrollbars): removed. (create_adjustments): replacement for create_scrollbars (gtk_clist_new): call gtk_clist_new_with_titles (gtk_clist_new_with_titles): don't warn on titles == NULL (move_horizontal): use CLAMP instead (gtk_clist_set_policy): deprecated method. use gtk_scrolled_window_set_policy instead. (vadjustment_value_changed): use clist->vadj. (adjust_scrollbars): renamed to adjust_adjustments (adjust_adjustments): former adjust_scrollbars (gtk_clist_destroy): unref adjustments (gtk_clist_size_allocate) (gtk_clist_map) (title_focus) (gtk_clist_unmap) (gtk_clist_size_request) (gtk_clist_focus) (gtk_clist_size_allocate) (gtk_clist_forall): don't use scrollbars (gtk_clist_thaw) (real_insert_row) (real_remove_row) (gtk_clist_set_row_height) (real_resize_column): call adjust_adjustments (gtk_clist_moveto): return if clist has no adjustments yet. (gtk_clist_parent_set): new GtkWidget::parent_set function. Autogenerate h/vadjustments if needed. (move_horizontal) (move_vertical): some cleanups * gtk/gtkviewport.c (gtk_viewport_set_arg) (gtk_viewport_new): call only gtk_viewport_set_h/vadjustment and let these functions do the work. (gtk_viewport_set_hadjustment) (gtk_viewport_set_vadjustment): generate a new adjustment if needed * gtk/gtkscrolledwindow.h ((struct _GtkScrolledWindow): use a guint bitfield for h/vscrollbar_policy and h/vscrollbar_visible * gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed): queue_resize if visibility of scrollbars changes (gtk_scrolled_window_remove): only call container_remove with scrolled_window->viewport automatically if viewport was autogenerated (gtk_scrolled_window_add): add widget as scrolled_window->viewport. auto create a viewport only if widget does not take h/vadjustments. (gtk_scrolled_window_construct): don't generate a viewport automatically. (gtk_scrolled_window_forall): call callback with viewport in any case (gtk_scrolled_window_set_arg): call gtk_container_add in case of ARG_VIEWPORT (gtk_scrolled_window_size_allocate) (gtk_scrolled_window_size_request) (gtk_scrolled_window_map) (gtk_scrolled_window_unmap): check viewport != NULL * gtk/testgtk.c (create_ctree) (export_ctree) (create_clist): use a scrolled_window in conjunction with clists/ctrees * gtk/gtkfilesel.c (gtk_file_selection_init): use a scrolled_window in conjunction with clists * gtk/gtkfontsel.c (gtk_font_selection_init): use a scrolled_window in conjunction with clists
1998-11-05 15:44:22 +00:00
{
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
2020-05-02 04:17:25 +00:00
{
gboolean visible;
visible = priv->hscrollbar_visible;
gtk_scrolled_window_update_scrollbar_visibility_flags (scrolled_window, priv->hscrollbar);
if (priv->hscrollbar_visible != visible)
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
if (priv->hscrolling)
{
GtkKineticScrollingChange change;
double lower = gtk_adjustment_get_lower (adjustment);
double upper = gtk_adjustment_get_upper (adjustment);
upper -= gtk_adjustment_get_page_size (adjustment);
change = gtk_kinetic_scrolling_update_size (priv->hscrolling, lower, upper);
if ((change & GTK_KINETIC_SCROLLING_CHANGE_IN_OVERSHOOT) &&
(change & (GTK_KINETIC_SCROLLING_CHANGE_UPPER | GTK_KINETIC_SCROLLING_CHANGE_LOWER)))
{
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
priv->unclamped_hadj_value = gtk_adjustment_get_value (adjustment);
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
}
}
2020-05-02 04:17:25 +00:00
}
removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. Thu Nov 5 16:00:32 1998 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCList): removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. added h/vadjustment. * gtk/gtkclist.c (gtk_clist_class_init): added new args types "hadjustment" & "vadjustment" (gtk_clist_set_arg) (gtk_clist_get_arg): new object class set/get_arg functions (gtk_clist_construct): don't create/adjust scrollbars. (gtk_clist_set_hadjustment) (gtk_clist_set_vadjustment): new functions to set h/vadjustments (gtk_clist_get_vadjustment) (gtk_clist_get_hadjustment): new functions to query h/vadjustments (create_scrollbars): removed. (create_adjustments): replacement for create_scrollbars (gtk_clist_new): call gtk_clist_new_with_titles (gtk_clist_new_with_titles): don't warn on titles == NULL (move_horizontal): use CLAMP instead (gtk_clist_set_policy): deprecated method. use gtk_scrolled_window_set_policy instead. (vadjustment_value_changed): use clist->vadj. (adjust_scrollbars): renamed to adjust_adjustments (adjust_adjustments): former adjust_scrollbars (gtk_clist_destroy): unref adjustments (gtk_clist_size_allocate) (gtk_clist_map) (title_focus) (gtk_clist_unmap) (gtk_clist_size_request) (gtk_clist_focus) (gtk_clist_size_allocate) (gtk_clist_forall): don't use scrollbars (gtk_clist_thaw) (real_insert_row) (real_remove_row) (gtk_clist_set_row_height) (real_resize_column): call adjust_adjustments (gtk_clist_moveto): return if clist has no adjustments yet. (gtk_clist_parent_set): new GtkWidget::parent_set function. Autogenerate h/vadjustments if needed. (move_horizontal) (move_vertical): some cleanups * gtk/gtkviewport.c (gtk_viewport_set_arg) (gtk_viewport_new): call only gtk_viewport_set_h/vadjustment and let these functions do the work. (gtk_viewport_set_hadjustment) (gtk_viewport_set_vadjustment): generate a new adjustment if needed * gtk/gtkscrolledwindow.h ((struct _GtkScrolledWindow): use a guint bitfield for h/vscrollbar_policy and h/vscrollbar_visible * gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed): queue_resize if visibility of scrollbars changes (gtk_scrolled_window_remove): only call container_remove with scrolled_window->viewport automatically if viewport was autogenerated (gtk_scrolled_window_add): add widget as scrolled_window->viewport. auto create a viewport only if widget does not take h/vadjustments. (gtk_scrolled_window_construct): don't generate a viewport automatically. (gtk_scrolled_window_forall): call callback with viewport in any case (gtk_scrolled_window_set_arg): call gtk_container_add in case of ARG_VIEWPORT (gtk_scrolled_window_size_allocate) (gtk_scrolled_window_size_request) (gtk_scrolled_window_map) (gtk_scrolled_window_unmap): check viewport != NULL * gtk/testgtk.c (create_ctree) (export_ctree) (create_clist): use a scrolled_window in conjunction with clists/ctrees * gtk/gtkfilesel.c (gtk_file_selection_init): use a scrolled_window in conjunction with clists * gtk/gtkfontsel.c (gtk_font_selection_init): use a scrolled_window in conjunction with clists
1998-11-05 15:44:22 +00:00
}
else if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar)))
removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. Thu Nov 5 16:00:32 1998 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCList): removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. added h/vadjustment. * gtk/gtkclist.c (gtk_clist_class_init): added new args types "hadjustment" & "vadjustment" (gtk_clist_set_arg) (gtk_clist_get_arg): new object class set/get_arg functions (gtk_clist_construct): don't create/adjust scrollbars. (gtk_clist_set_hadjustment) (gtk_clist_set_vadjustment): new functions to set h/vadjustments (gtk_clist_get_vadjustment) (gtk_clist_get_hadjustment): new functions to query h/vadjustments (create_scrollbars): removed. (create_adjustments): replacement for create_scrollbars (gtk_clist_new): call gtk_clist_new_with_titles (gtk_clist_new_with_titles): don't warn on titles == NULL (move_horizontal): use CLAMP instead (gtk_clist_set_policy): deprecated method. use gtk_scrolled_window_set_policy instead. (vadjustment_value_changed): use clist->vadj. (adjust_scrollbars): renamed to adjust_adjustments (adjust_adjustments): former adjust_scrollbars (gtk_clist_destroy): unref adjustments (gtk_clist_size_allocate) (gtk_clist_map) (title_focus) (gtk_clist_unmap) (gtk_clist_size_request) (gtk_clist_focus) (gtk_clist_size_allocate) (gtk_clist_forall): don't use scrollbars (gtk_clist_thaw) (real_insert_row) (real_remove_row) (gtk_clist_set_row_height) (real_resize_column): call adjust_adjustments (gtk_clist_moveto): return if clist has no adjustments yet. (gtk_clist_parent_set): new GtkWidget::parent_set function. Autogenerate h/vadjustments if needed. (move_horizontal) (move_vertical): some cleanups * gtk/gtkviewport.c (gtk_viewport_set_arg) (gtk_viewport_new): call only gtk_viewport_set_h/vadjustment and let these functions do the work. (gtk_viewport_set_hadjustment) (gtk_viewport_set_vadjustment): generate a new adjustment if needed * gtk/gtkscrolledwindow.h ((struct _GtkScrolledWindow): use a guint bitfield for h/vscrollbar_policy and h/vscrollbar_visible * gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed): queue_resize if visibility of scrollbars changes (gtk_scrolled_window_remove): only call container_remove with scrolled_window->viewport automatically if viewport was autogenerated (gtk_scrolled_window_add): add widget as scrolled_window->viewport. auto create a viewport only if widget does not take h/vadjustments. (gtk_scrolled_window_construct): don't generate a viewport automatically. (gtk_scrolled_window_forall): call callback with viewport in any case (gtk_scrolled_window_set_arg): call gtk_container_add in case of ARG_VIEWPORT (gtk_scrolled_window_size_allocate) (gtk_scrolled_window_size_request) (gtk_scrolled_window_map) (gtk_scrolled_window_unmap): check viewport != NULL * gtk/testgtk.c (create_ctree) (export_ctree) (create_clist): use a scrolled_window in conjunction with clists/ctrees * gtk/gtkfilesel.c (gtk_file_selection_init): use a scrolled_window in conjunction with clists * gtk/gtkfontsel.c (gtk_font_selection_init): use a scrolled_window in conjunction with clists
1998-11-05 15:44:22 +00:00
{
if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
2020-05-02 04:17:25 +00:00
{
gboolean visible;
removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. Thu Nov 5 16:00:32 1998 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCList): removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. added h/vadjustment. * gtk/gtkclist.c (gtk_clist_class_init): added new args types "hadjustment" & "vadjustment" (gtk_clist_set_arg) (gtk_clist_get_arg): new object class set/get_arg functions (gtk_clist_construct): don't create/adjust scrollbars. (gtk_clist_set_hadjustment) (gtk_clist_set_vadjustment): new functions to set h/vadjustments (gtk_clist_get_vadjustment) (gtk_clist_get_hadjustment): new functions to query h/vadjustments (create_scrollbars): removed. (create_adjustments): replacement for create_scrollbars (gtk_clist_new): call gtk_clist_new_with_titles (gtk_clist_new_with_titles): don't warn on titles == NULL (move_horizontal): use CLAMP instead (gtk_clist_set_policy): deprecated method. use gtk_scrolled_window_set_policy instead. (vadjustment_value_changed): use clist->vadj. (adjust_scrollbars): renamed to adjust_adjustments (adjust_adjustments): former adjust_scrollbars (gtk_clist_destroy): unref adjustments (gtk_clist_size_allocate) (gtk_clist_map) (title_focus) (gtk_clist_unmap) (gtk_clist_size_request) (gtk_clist_focus) (gtk_clist_size_allocate) (gtk_clist_forall): don't use scrollbars (gtk_clist_thaw) (real_insert_row) (real_remove_row) (gtk_clist_set_row_height) (real_resize_column): call adjust_adjustments (gtk_clist_moveto): return if clist has no adjustments yet. (gtk_clist_parent_set): new GtkWidget::parent_set function. Autogenerate h/vadjustments if needed. (move_horizontal) (move_vertical): some cleanups * gtk/gtkviewport.c (gtk_viewport_set_arg) (gtk_viewport_new): call only gtk_viewport_set_h/vadjustment and let these functions do the work. (gtk_viewport_set_hadjustment) (gtk_viewport_set_vadjustment): generate a new adjustment if needed * gtk/gtkscrolledwindow.h ((struct _GtkScrolledWindow): use a guint bitfield for h/vscrollbar_policy and h/vscrollbar_visible * gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed): queue_resize if visibility of scrollbars changes (gtk_scrolled_window_remove): only call container_remove with scrolled_window->viewport automatically if viewport was autogenerated (gtk_scrolled_window_add): add widget as scrolled_window->viewport. auto create a viewport only if widget does not take h/vadjustments. (gtk_scrolled_window_construct): don't generate a viewport automatically. (gtk_scrolled_window_forall): call callback with viewport in any case (gtk_scrolled_window_set_arg): call gtk_container_add in case of ARG_VIEWPORT (gtk_scrolled_window_size_allocate) (gtk_scrolled_window_size_request) (gtk_scrolled_window_map) (gtk_scrolled_window_unmap): check viewport != NULL * gtk/testgtk.c (create_ctree) (export_ctree) (create_clist): use a scrolled_window in conjunction with clists/ctrees * gtk/gtkfilesel.c (gtk_file_selection_init): use a scrolled_window in conjunction with clists * gtk/gtkfontsel.c (gtk_font_selection_init): use a scrolled_window in conjunction with clists
1998-11-05 15:44:22 +00:00
visible = priv->vscrollbar_visible;
gtk_scrolled_window_update_scrollbar_visibility_flags (scrolled_window, priv->vscrollbar);
if (priv->vscrollbar_visible != visible)
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
if (priv->vscrolling)
{
GtkKineticScrollingChange change;
double lower = gtk_adjustment_get_lower (adjustment);
double upper = gtk_adjustment_get_upper (adjustment);
upper -= gtk_adjustment_get_page_size (adjustment);
change = gtk_kinetic_scrolling_update_size (priv->vscrolling, lower, upper);
if ((change & GTK_KINETIC_SCROLLING_CHANGE_IN_OVERSHOOT) &&
(change & (GTK_KINETIC_SCROLLING_CHANGE_UPPER | GTK_KINETIC_SCROLLING_CHANGE_LOWER)))
{
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
priv->unclamped_vadj_value = gtk_adjustment_get_value (adjustment);
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
}
}
2020-05-02 04:17:25 +00:00
}
removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. Thu Nov 5 16:00:32 1998 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCList): removed vscrollbar, hscrollbar, vscrollbar_policy, hscrollbar_policy. added h/vadjustment. * gtk/gtkclist.c (gtk_clist_class_init): added new args types "hadjustment" & "vadjustment" (gtk_clist_set_arg) (gtk_clist_get_arg): new object class set/get_arg functions (gtk_clist_construct): don't create/adjust scrollbars. (gtk_clist_set_hadjustment) (gtk_clist_set_vadjustment): new functions to set h/vadjustments (gtk_clist_get_vadjustment) (gtk_clist_get_hadjustment): new functions to query h/vadjustments (create_scrollbars): removed. (create_adjustments): replacement for create_scrollbars (gtk_clist_new): call gtk_clist_new_with_titles (gtk_clist_new_with_titles): don't warn on titles == NULL (move_horizontal): use CLAMP instead (gtk_clist_set_policy): deprecated method. use gtk_scrolled_window_set_policy instead. (vadjustment_value_changed): use clist->vadj. (adjust_scrollbars): renamed to adjust_adjustments (adjust_adjustments): former adjust_scrollbars (gtk_clist_destroy): unref adjustments (gtk_clist_size_allocate) (gtk_clist_map) (title_focus) (gtk_clist_unmap) (gtk_clist_size_request) (gtk_clist_focus) (gtk_clist_size_allocate) (gtk_clist_forall): don't use scrollbars (gtk_clist_thaw) (real_insert_row) (real_remove_row) (gtk_clist_set_row_height) (real_resize_column): call adjust_adjustments (gtk_clist_moveto): return if clist has no adjustments yet. (gtk_clist_parent_set): new GtkWidget::parent_set function. Autogenerate h/vadjustments if needed. (move_horizontal) (move_vertical): some cleanups * gtk/gtkviewport.c (gtk_viewport_set_arg) (gtk_viewport_new): call only gtk_viewport_set_h/vadjustment and let these functions do the work. (gtk_viewport_set_hadjustment) (gtk_viewport_set_vadjustment): generate a new adjustment if needed * gtk/gtkscrolledwindow.h ((struct _GtkScrolledWindow): use a guint bitfield for h/vscrollbar_policy and h/vscrollbar_visible * gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed): queue_resize if visibility of scrollbars changes (gtk_scrolled_window_remove): only call container_remove with scrolled_window->viewport automatically if viewport was autogenerated (gtk_scrolled_window_add): add widget as scrolled_window->viewport. auto create a viewport only if widget does not take h/vadjustments. (gtk_scrolled_window_construct): don't generate a viewport automatically. (gtk_scrolled_window_forall): call callback with viewport in any case (gtk_scrolled_window_set_arg): call gtk_container_add in case of ARG_VIEWPORT (gtk_scrolled_window_size_allocate) (gtk_scrolled_window_size_request) (gtk_scrolled_window_map) (gtk_scrolled_window_unmap): check viewport != NULL * gtk/testgtk.c (create_ctree) (export_ctree) (create_clist): use a scrolled_window in conjunction with clists/ctrees * gtk/gtkfilesel.c (gtk_file_selection_init): use a scrolled_window in conjunction with clists * gtk/gtkfontsel.c (gtk_font_selection_init): use a scrolled_window in conjunction with clists
1998-11-05 15:44:22 +00:00
}
if (!priv->hscrolling && !priv->vscrolling)
gtk_scrolled_window_cancel_deceleration (scrolled_window);
1997-11-24 22:37:52 +00:00
}
static void
maybe_emit_edge_reached (GtkScrolledWindow *scrolled_window,
2020-05-02 04:17:25 +00:00
GtkAdjustment *adjustment)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2020-07-24 20:32:16 +00:00
double value, lower, upper, page_size;
GtkPositionType edge_pos;
gboolean vertical;
if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar)))
vertical = FALSE;
else if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar)))
vertical = TRUE;
else
return;
value = gtk_adjustment_get_value (adjustment);
lower = gtk_adjustment_get_lower (adjustment);
upper = gtk_adjustment_get_upper (adjustment);
page_size = gtk_adjustment_get_page_size (adjustment);
if (value == lower)
edge_pos = vertical ? GTK_POS_TOP: GTK_POS_LEFT;
else if (value == upper - page_size)
edge_pos = vertical ? GTK_POS_BOTTOM : GTK_POS_RIGHT;
else
return;
if (!vertical &&
_gtk_widget_get_direction (GTK_WIDGET (scrolled_window)) == GTK_TEXT_DIR_RTL)
edge_pos = (edge_pos == GTK_POS_LEFT) ? GTK_POS_RIGHT : GTK_POS_LEFT;
g_signal_emit (scrolled_window, signals[EDGE_REACHED], 0, edge_pos);
}
static void
gtk_scrolled_window_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer user_data)
{
GtkScrolledWindow *scrolled_window = user_data;
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
maybe_emit_edge_reached (scrolled_window, adjustment);
/* Allow overshooting for kinetic scrolling operations */
if (priv->deceleration_id)
return;
/* Ensure GtkAdjustment and unclamped values are in sync */
if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar)))
priv->unclamped_hadj_value = gtk_adjustment_get_value (adjustment);
else if (adjustment == gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar)))
priv->unclamped_vadj_value = gtk_adjustment_get_value (adjustment);
}
static gboolean
gtk_widget_should_animate (GtkWidget *widget)
{
if (!gtk_widget_get_mapped (widget))
return FALSE;
return gtk_settings_get_enable_animations (gtk_widget_get_settings (widget));
}
static void
gtk_scrolled_window_update_animating (GtkScrolledWindow *sw)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
GtkAdjustment *adjustment;
GdkFrameClock *clock = NULL;
guint duration = 0;
if (gtk_widget_should_animate (GTK_WIDGET (sw)))
{
clock = gtk_widget_get_frame_clock (GTK_WIDGET (sw)),
duration = ANIMATION_DURATION;
}
2018-06-16 09:47:06 +00:00
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
gtk_adjustment_enable_animation (adjustment, clock, duration);
2018-06-16 09:47:06 +00:00
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
gtk_adjustment_enable_animation (adjustment, clock, duration);
}
static void
gtk_scrolled_window_map (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->map (widget);
gtk_scrolled_window_update_animating (scrolled_window);
gtk_scrolled_window_update_use_indicators (scrolled_window);
}
static void
indicator_reset (Indicator *indicator)
{
2020-12-27 17:11:29 +00:00
g_clear_handle_id (&indicator->conceil_timer, g_source_remove);
g_clear_handle_id (&indicator->over_timeout_id, g_source_remove);
if (indicator->scrollbar && indicator->tick_id)
{
gtk_widget_remove_tick_callback (indicator->scrollbar,
indicator->tick_id);
indicator->tick_id = 0;
}
indicator->over = FALSE;
gtk_progress_tracker_finish (&indicator->tracker);
indicator->current_pos = indicator->source_pos = indicator->target_pos = 0;
indicator->last_scroll_time = 0;
}
static void
gtk_scrolled_window_unmap (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->unmap (widget);
gtk_scrolled_window_update_animating (scrolled_window);
indicator_reset (&priv->hindicator);
indicator_reset (&priv->vindicator);
}
static void
indicator_set_fade (Indicator *indicator,
2020-07-24 20:32:16 +00:00
double pos)
{
gboolean visible, changed;
changed = indicator->current_pos != pos;
indicator->current_pos = pos;
visible = indicator->current_pos != 0.0 || indicator->target_pos != 0.0;
if (visible && indicator->conceil_timer == 0)
{
indicator->conceil_timer = g_timeout_add (INDICATOR_FADE_OUT_TIME, maybe_hide_indicator, indicator);
gdk_source_set_static_name_by_id (indicator->conceil_timer, "[gtk] maybe_hide_indicator");
}
if (!visible && indicator->conceil_timer != 0)
{
g_source_remove (indicator->conceil_timer);
indicator->conceil_timer = 0;
}
if (changed)
{
gtk_widget_set_opacity (indicator->scrollbar, indicator->current_pos);
}
}
static gboolean
indicator_fade_cb (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
Indicator *indicator = user_data;
2020-07-24 20:32:16 +00:00
double t;
gtk_progress_tracker_advance_frame (&indicator->tracker,
gdk_frame_clock_get_frame_time (frame_clock));
t = gtk_progress_tracker_get_ease_out_cubic (&indicator->tracker, FALSE);
indicator_set_fade (indicator,
indicator->source_pos + (t * (indicator->target_pos - indicator->source_pos)));
if (gtk_progress_tracker_get_state (&indicator->tracker) == GTK_PROGRESS_STATE_AFTER)
{
indicator->tick_id = 0;
return FALSE;
}
return TRUE;
}
static void
indicator_start_fade (Indicator *indicator,
2020-07-24 20:32:16 +00:00
double target)
{
if (indicator->target_pos == target)
return;
indicator->target_pos = target;
if (target != 0.0)
indicator->last_scroll_time = g_get_monotonic_time ();
if (gtk_widget_should_animate (indicator->scrollbar))
{
indicator->source_pos = indicator->current_pos;
gtk_progress_tracker_start (&indicator->tracker, INDICATOR_FADE_OUT_DURATION * 1000, 0, 1.0);
if (indicator->tick_id == 0)
indicator->tick_id = gtk_widget_add_tick_callback (indicator->scrollbar, indicator_fade_cb, indicator, NULL);
}
else
indicator_set_fade (indicator, target);
}
static gboolean
maybe_hide_indicator (gpointer data)
{
Indicator *indicator = data;
if (g_get_monotonic_time () - indicator->last_scroll_time >= INDICATOR_FADE_OUT_DELAY * 1000 &&
!indicator->over)
indicator_start_fade (indicator, 0.0);
return G_SOURCE_CONTINUE;
}
static void
indicator_value_changed (GtkAdjustment *adjustment,
Indicator *indicator)
{
indicator->last_scroll_time = g_get_monotonic_time ();
indicator_start_fade (indicator, 1.0);
}
static void
setup_indicator (GtkScrolledWindow *scrolled_window,
Indicator *indicator,
GtkWidget *scrollbar)
{
GtkAdjustment *adjustment;
if (scrollbar == NULL)
return;
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (scrollbar));
indicator->scrollbar = scrollbar;
gtk_widget_add_css_class (scrollbar, "overlay-indicator");
g_signal_connect (adjustment, "value-changed",
G_CALLBACK (indicator_value_changed), indicator);
gtk_widget_set_opacity (scrollbar, 0.0);
indicator->current_pos = 0.0;
}
static void
remove_indicator (GtkScrolledWindow *scrolled_window,
Indicator *indicator)
{
GtkWidget *scrollbar;
GtkAdjustment *adjustment;
if (indicator->scrollbar == NULL)
return;
scrollbar = indicator->scrollbar;
indicator->scrollbar = NULL;
gtk_widget_remove_css_class (scrollbar, "overlay-indicator");
adjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (scrollbar));
g_signal_handlers_disconnect_by_data (adjustment, indicator);
if (indicator->conceil_timer)
{
g_source_remove (indicator->conceil_timer);
indicator->conceil_timer = 0;
}
if (indicator->over_timeout_id)
{
g_source_remove (indicator->over_timeout_id);
indicator->over_timeout_id = 0;
}
if (indicator->tick_id)
{
gtk_widget_remove_tick_callback (scrollbar, indicator->tick_id);
indicator->tick_id = 0;
}
gtk_widget_set_opacity (scrollbar, 1.0);
indicator->current_pos = 1.0;
}
static void
gtk_scrolled_window_sync_use_indicators (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
if (priv->use_indicators)
{
setup_indicator (scrolled_window, &priv->hindicator, priv->hscrollbar);
setup_indicator (scrolled_window, &priv->vindicator, priv->vscrollbar);
}
else
{
remove_indicator (scrolled_window, &priv->hindicator);
remove_indicator (scrolled_window, &priv->vindicator);
}
}
static void
gtk_scrolled_window_update_use_indicators (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
gboolean use_indicators;
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (scrolled_window));
gboolean overlay_scrolling;
g_object_get (settings, "gtk-overlay-scrolling", &overlay_scrolling, NULL);
use_indicators = overlay_scrolling && priv->overlay_scrolling;
if (priv->use_indicators != use_indicators)
{
priv->use_indicators = use_indicators;
if (gtk_widget_get_realized (GTK_WIDGET (scrolled_window)))
gtk_scrolled_window_sync_use_indicators (scrolled_window);
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
}
}
static void
gtk_scrolled_window_realize (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkSettings *settings;
priv->hindicator.scrollbar = priv->hscrollbar;
priv->vindicator.scrollbar = priv->vscrollbar;
gtk_scrolled_window_sync_use_indicators (scrolled_window);
settings = gtk_widget_get_settings (widget);
g_signal_connect_swapped (settings, "notify::gtk-overlay-scrolling",
G_CALLBACK (gtk_scrolled_window_update_use_indicators), widget);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->realize (widget);
}
static void
gtk_scrolled_window_unrealize (GtkWidget *widget)
{
GtkSettings *settings;
settings = gtk_widget_get_settings (widget);
g_signal_handlers_disconnect_by_func (settings, gtk_scrolled_window_sync_use_indicators, widget);
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->unrealize (widget);
}
2010-10-23 21:02:40 +00:00
/**
* gtk_scrolled_window_get_min_content_width: (attributes org.gtk.Method.get_property=min-content-width)
* @scrolled_window: a `GtkScrolledWindow`
2010-10-23 21:02:40 +00:00
*
* Gets the minimum content width of @scrolled_window.
2010-10-23 21:02:40 +00:00
*
* Returns: the minimum content width
*/
2020-07-24 13:54:49 +00:00
int
gtk_scrolled_window_get_min_content_width (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0);
2018-06-16 09:47:06 +00:00
return priv->min_content_width;
}
2010-10-23 21:02:40 +00:00
/**
* gtk_scrolled_window_set_min_content_width: (attributes org.gtk.Method.set_property=min-content-width)
* @scrolled_window: a `GtkScrolledWindow`
2010-10-23 21:02:40 +00:00
* @width: the minimal content width
*
* Sets the minimum width that @scrolled_window should keep visible.
*
2010-10-23 21:02:40 +00:00
* Note that this can and (usually will) be smaller than the minimum
* size of the content.
*
* It is a programming error to set the minimum content width to a
* value greater than [property@Gtk.ScrolledWindow:max-content-width].
2010-10-23 21:02:40 +00:00
*/
void
gtk_scrolled_window_set_min_content_width (GtkScrolledWindow *scrolled_window,
2020-07-24 13:54:49 +00:00
int width)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
g_return_if_fail (width == -1 || priv->max_content_width == -1 || width <= priv->max_content_width);
2010-10-23 21:02:40 +00:00
if (priv->min_content_width != width)
{
2010-10-23 21:02:40 +00:00
priv->min_content_width = width;
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_MIN_CONTENT_WIDTH]);
}
}
2010-10-23 21:02:40 +00:00
/**
* gtk_scrolled_window_get_min_content_height: (attributes org.gtk.Method.get_property=min-content-height)
* @scrolled_window: a `GtkScrolledWindow`
2010-10-23 21:02:40 +00:00
*
* Gets the minimal content height of @scrolled_window.
2010-10-23 21:02:40 +00:00
*
* Returns: the minimal content height
*/
2020-07-24 13:54:49 +00:00
int
gtk_scrolled_window_get_min_content_height (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0);
2018-06-16 09:47:06 +00:00
return priv->min_content_height;
}
2010-10-23 21:02:40 +00:00
/**
* gtk_scrolled_window_set_min_content_height: (attributes org.gtk.Method.set_property=min-content-height)
* @scrolled_window: a `GtkScrolledWindow`
2010-10-23 21:02:40 +00:00
* @height: the minimal content height
*
* Sets the minimum height that @scrolled_window should keep visible.
*
2010-10-23 21:02:40 +00:00
* Note that this can and (usually will) be smaller than the minimum
* size of the content.
*
* It is a programming error to set the minimum content height to a
* value greater than [property@Gtk.ScrolledWindow:max-content-height].
2010-10-23 21:02:40 +00:00
*/
void
gtk_scrolled_window_set_min_content_height (GtkScrolledWindow *scrolled_window,
2020-07-24 13:54:49 +00:00
int height)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
g_return_if_fail (height == -1 || priv->max_content_height == -1 || height <= priv->max_content_height);
2010-10-23 21:02:40 +00:00
if (priv->min_content_height != height)
{
2010-10-23 21:02:40 +00:00
priv->min_content_height = height;
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_MIN_CONTENT_HEIGHT]);
}
}
/**
* gtk_scrolled_window_set_overlay_scrolling: (attributes org.gtk.Method.set_property=overlay-scrolling)
* @scrolled_window: a `GtkScrolledWindow`
* @overlay_scrolling: whether to enable overlay scrolling
*
* Enables or disables overlay scrolling for this scrolled window.
*/
void
gtk_scrolled_window_set_overlay_scrolling (GtkScrolledWindow *scrolled_window,
gboolean overlay_scrolling)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (priv->overlay_scrolling != overlay_scrolling)
{
priv->overlay_scrolling = overlay_scrolling;
gtk_scrolled_window_update_use_indicators (scrolled_window);
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_OVERLAY_SCROLLING]);
}
}
/**
* gtk_scrolled_window_get_overlay_scrolling: (attributes org.gtk.Method.get_property=overlay-scrolling)
* @scrolled_window: a `GtkScrolledWindow`
*
* Returns whether overlay scrolling is enabled for this scrolled window.
*
* Returns: %TRUE if overlay scrolling is enabled
*/
gboolean
gtk_scrolled_window_get_overlay_scrolling (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), TRUE);
2018-06-16 09:47:06 +00:00
return priv->overlay_scrolling;
}
/**
* gtk_scrolled_window_set_max_content_width: (attributes org.gtk.Method.set_property=max-content-width)
* @scrolled_window: a `GtkScrolledWindow`
* @width: the maximum content width
*
* Sets the maximum width that @scrolled_window should keep visible.
*
* The @scrolled_window will grow up to this width before it starts
* scrolling the content.
*
* It is a programming error to set the maximum content width to a
* value smaller than [property@Gtk.ScrolledWindow:min-content-width].
*/
void
gtk_scrolled_window_set_max_content_width (GtkScrolledWindow *scrolled_window,
2020-07-24 13:54:49 +00:00
int width)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
g_return_if_fail (width == -1 || priv->min_content_width == -1 || width >= priv->min_content_width);
if (width != priv->max_content_width)
{
priv->max_content_width = width;
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties [PROP_MAX_CONTENT_WIDTH]);
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
}
}
/**
* gtk_scrolled_window_get_max_content_width: (attributes org.gtk.Method.get_property=max-content-width)
* @scrolled_window: a `GtkScrolledWindow`
*
* Returns the maximum content width set.
*
* Returns: the maximum content width, or -1
*/
2020-07-24 13:54:49 +00:00
int
gtk_scrolled_window_get_max_content_width (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), -1);
2018-06-16 09:47:06 +00:00
return priv->max_content_width;
}
/**
* gtk_scrolled_window_set_max_content_height: (attributes org.gtk.Method.set_property=max-content-height)
* @scrolled_window: a `GtkScrolledWindow`
* @height: the maximum content height
*
* Sets the maximum height that @scrolled_window should keep visible.
*
* The @scrolled_window will grow up to this height before it starts
* scrolling the content.
*
* It is a programming error to set the maximum content height to a value
* smaller than [property@Gtk.ScrolledWindow:min-content-height].
*/
void
gtk_scrolled_window_set_max_content_height (GtkScrolledWindow *scrolled_window,
2020-07-24 13:54:49 +00:00
int height)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
g_return_if_fail (height == -1 || priv->min_content_height == -1 || height >= priv->min_content_height);
if (height != priv->max_content_height)
{
priv->max_content_height = height;
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties [PROP_MAX_CONTENT_HEIGHT]);
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
}
}
/**
* gtk_scrolled_window_get_max_content_height: (attributes org.gtk.Method.get_property=max-content-height)
* @scrolled_window: a `GtkScrolledWindow`
*
* Returns the maximum content height set.
*
* Returns: the maximum content height, or -1
*/
2020-07-24 13:54:49 +00:00
int
gtk_scrolled_window_get_max_content_height (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), -1);
2018-06-16 09:47:06 +00:00
return priv->max_content_height;
}
/**
* gtk_scrolled_window_set_propagate_natural_width: (attributes org.gtk.Method.set_property=propagate-natural-width)
* @scrolled_window: a `GtkScrolledWindow`
* @propagate: whether to propagate natural width
*
* Sets whether the natural width of the child should be calculated
* and propagated through the scrolled windows requested natural width.
*/
void
gtk_scrolled_window_set_propagate_natural_width (GtkScrolledWindow *scrolled_window,
gboolean propagate)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
propagate = !!propagate;
if (priv->propagate_natural_width != propagate)
{
priv->propagate_natural_width = propagate;
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties [PROP_PROPAGATE_NATURAL_WIDTH]);
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
}
}
/**
* gtk_scrolled_window_get_propagate_natural_width: (attributes org.gtk.Method.get_property=propagate-natural-width)
* @scrolled_window: a `GtkScrolledWindow`
*
* Reports whether the natural width of the child will be calculated
* and propagated through the scrolled windows requested natural width.
*
* Returns: whether natural width propagation is enabled.
*/
gboolean
gtk_scrolled_window_get_propagate_natural_width (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), -1);
2018-06-16 09:47:06 +00:00
return priv->propagate_natural_width;
}
/**
* gtk_scrolled_window_set_propagate_natural_height: (attributes org.gtk.Method.set_property=propagate-natural-height)
* @scrolled_window: a `GtkScrolledWindow`
* @propagate: whether to propagate natural height
*
* Sets whether the natural height of the child should be calculated
* and propagated through the scrolled windows requested natural height.
*/
void
gtk_scrolled_window_set_propagate_natural_height (GtkScrolledWindow *scrolled_window,
gboolean propagate)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
propagate = !!propagate;
if (priv->propagate_natural_height != propagate)
{
priv->propagate_natural_height = propagate;
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties [PROP_PROPAGATE_NATURAL_HEIGHT]);
gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
}
}
/**
* gtk_scrolled_window_get_propagate_natural_height: (attributes org.gtk.Method.get_property=propagate-natural-height)
* @scrolled_window: a `GtkScrolledWindow`
*
* Reports whether the natural height of the child will be calculated
* and propagated through the scrolled windows requested natural height.
*
* Returns: whether natural height propagation is enabled.
*/
gboolean
gtk_scrolled_window_get_propagate_natural_height (GtkScrolledWindow *scrolled_window)
{
2018-06-16 09:47:06 +00:00
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), -1);
2018-06-16 09:47:06 +00:00
return priv->propagate_natural_height;
}
2020-05-02 04:17:25 +00:00
/**
* gtk_scrolled_window_set_child: (attributes org.gtk.Method.set_property=child)
* @scrolled_window: a `GtkScrolledWindow`
* @child: (nullable): the child widget
2020-05-02 04:17:25 +00:00
*
* Sets the child widget of @scrolled_window.
*/
void
gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window,
GtkWidget *child)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkWidget *scrollable_child;
2020-05-02 04:17:25 +00:00
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (priv->child)
{
if (priv->auto_added_viewport)
{
gtk_viewport_set_child (GTK_VIEWPORT (priv->child), NULL);
}
g_object_set (priv->child,
"hadjustment", NULL,
"vadjustment", NULL,
NULL);
g_clear_pointer (&priv->child, gtk_widget_unparent);
}
if (child)
{
GtkAdjustment *hadj, *vadj;
/* gtk_scrolled_window_set_[hv]adjustment have the side-effect
* of creating the scrollbars
*/
if (!priv->hscrollbar)
gtk_scrolled_window_set_hadjustment (scrolled_window, NULL);
if (!priv->vscrollbar)
gtk_scrolled_window_set_vadjustment (scrolled_window, NULL);
hadj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
vadj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
if (GTK_IS_SCROLLABLE (child))
{
scrollable_child = child;
priv->auto_added_viewport = FALSE;
}
else
{
scrollable_child = gtk_viewport_new (hadj, vadj);
gtk_viewport_set_child (GTK_VIEWPORT (scrollable_child), child);
priv->auto_added_viewport = TRUE;
}
priv->child = scrollable_child;
gtk_widget_insert_after (scrollable_child, GTK_WIDGET (scrolled_window), NULL);
g_object_set (scrollable_child,
"hadjustment", hadj,
"vadjustment", vadj,
NULL);
}
if (priv->child)
{
gtk_accessible_update_relation (GTK_ACCESSIBLE (priv->hscrollbar),
GTK_ACCESSIBLE_RELATION_CONTROLS, priv->child, NULL,
-1);
gtk_accessible_update_relation (GTK_ACCESSIBLE (priv->vscrollbar),
GTK_ACCESSIBLE_RELATION_CONTROLS, priv->child, NULL,
-1);
}
else
{
gtk_accessible_reset_relation (GTK_ACCESSIBLE (priv->hscrollbar),
GTK_ACCESSIBLE_RELATION_CONTROLS);
gtk_accessible_reset_relation (GTK_ACCESSIBLE (priv->vscrollbar),
GTK_ACCESSIBLE_RELATION_CONTROLS);
}
2020-05-02 04:17:25 +00:00
g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_CHILD]);
}
/**
* gtk_scrolled_window_get_child: (attributes org.gtk.Method.get_property=child)
* @scrolled_window: a `GtkScrolledWindow`
2020-05-02 04:17:25 +00:00
*
* Gets the child widget of @scrolled_window.
*
* Returns: (nullable) (transfer none): the child widget of @scrolled_window
*/
GtkWidget *
gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled_window)
{
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
2020-05-02 04:17:25 +00:00
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), NULL);
return priv->child;
2020-05-02 04:17:25 +00:00
}