1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 2001 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
30 #include "gtkscrollbar.h"
32 #include "gtkprivate.h"
34 static void gtk_scrollbar_style_set (GtkWidget *widget,
37 G_DEFINE_TYPE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_RANGE)
40 gtk_scrollbar_class_init (GtkScrollbarClass *class)
42 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
44 widget_class->style_set = gtk_scrollbar_style_set;
46 GTK_RANGE_CLASS (class)->stepper_detail = "Xscrollbar";
48 gtk_widget_class_install_style_property (widget_class,
49 g_param_spec_int ("min-slider-length",
50 P_("Minimum Slider Length"),
51 P_("Minimum length of scrollbar slider"),
57 gtk_widget_class_install_style_property (widget_class,
58 g_param_spec_boolean ("fixed-slider-length",
59 P_("Fixed slider size"),
60 P_("Don't change slider size, just lock it to the minimum length"),
64 gtk_widget_class_install_style_property (widget_class,
65 g_param_spec_boolean ("has-backward-stepper",
66 P_("Backward stepper"),
67 P_("Display the standard backward arrow button"),
71 gtk_widget_class_install_style_property (widget_class,
72 g_param_spec_boolean ("has-forward-stepper",
73 P_("Forward stepper"),
74 P_("Display the standard forward arrow button"),
78 gtk_widget_class_install_style_property (widget_class,
79 g_param_spec_boolean ("has-secondary-backward-stepper",
80 P_("Secondary backward stepper"),
81 P_("Display a second backward arrow button on the opposite end of the scrollbar"),
85 gtk_widget_class_install_style_property (widget_class,
86 g_param_spec_boolean ("has-secondary-forward-stepper",
87 P_("Secondary forward stepper"),
88 P_("Display a second forward arrow button on the opposite end of the scrollbar"),
94 gtk_scrollbar_init (GtkScrollbar *scrollbar)
99 gtk_scrollbar_style_set (GtkWidget *widget,
102 GtkRange *range = GTK_RANGE (widget);
105 gboolean has_a, has_b, has_c, has_d;
107 gtk_widget_style_get (widget,
108 "min-slider-length", &slider_length,
109 "fixed-slider-length", &fixed_size,
110 "has-backward-stepper", &has_a,
111 "has-secondary-forward-stepper", &has_b,
112 "has-secondary-backward-stepper", &has_c,
113 "has-forward-stepper", &has_d,
116 gtk_range_set_min_slider_size (range, slider_length);
117 gtk_range_set_slider_size_fixed (range, fixed_size);
118 _gtk_range_set_steppers (range,
119 has_a, has_b, has_c, has_d);
121 GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_set (widget, previous);
126 * @orientation: the scrollbar's orientation.
127 * @adjustment: (allow-none): the #GtkAdjustment to use, or %NULL to create a new adjustment.
129 * Creates a new scrollbar with the given orientation.
131 * Return value: the new #GtkScrollbar.
136 gtk_scrollbar_new (GtkOrientation orientation,
137 GtkAdjustment *adjustment)
139 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
142 return g_object_new (GTK_TYPE_SCROLLBAR,
143 "orientation", orientation,
144 "adjustment", adjustment,