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/.
28 #include "gtkscrollbar.h"
31 static void gtk_scrollbar_class_init (GtkScrollbarClass *klass);
32 static void gtk_scrollbar_init (GtkScrollbar *scrollbar);
33 static void gtk_scrollbar_style_set (GtkWidget *widget,
36 static gpointer parent_class;
39 gtk_scrollbar_get_type (void)
41 static GType scrollbar_type = 0;
45 static const GTypeInfo scrollbar_info =
47 sizeof (GtkScrollbarClass),
49 NULL, /* base_finalize */
50 (GClassInitFunc) gtk_scrollbar_class_init,
51 NULL, /* class_finalize */
52 NULL, /* class_data */
53 sizeof (GtkScrollbar),
55 (GInstanceInitFunc) gtk_scrollbar_init,
56 NULL, /* value_table */
60 g_type_register_static (GTK_TYPE_RANGE, "GtkScrollbar",
61 &scrollbar_info, G_TYPE_FLAG_ABSTRACT);
64 return scrollbar_type;
68 gtk_scrollbar_class_init (GtkScrollbarClass *class)
70 GtkWidgetClass *widget_class;
72 widget_class = GTK_WIDGET_CLASS (class);
74 parent_class = g_type_class_peek_parent (class);
76 widget_class->style_set = gtk_scrollbar_style_set;
78 gtk_widget_class_install_style_property (widget_class,
79 g_param_spec_int ("min_slider_length",
80 _("Minimum Slider Length"),
81 _("Minimum length of scrollbar slider"),
87 gtk_widget_class_install_style_property (widget_class,
88 g_param_spec_boolean ("fixed_slider_length",
89 _("Fixed slider size"),
90 _("Don't change slider size, just lock it to the minimum length"),
95 gtk_widget_class_install_style_property (widget_class,
96 g_param_spec_boolean ("has_backward_stepper",
97 _("Backward stepper"),
98 _("Display the standard backward arrow button"),
103 gtk_widget_class_install_style_property (widget_class,
104 g_param_spec_boolean ("has_forward_stepper",
105 _("Forward stepper"),
106 _("Display the standard forward arrow button"),
111 gtk_widget_class_install_style_property (widget_class,
112 g_param_spec_boolean ("has_secondary_backward_stepper",
113 _("Secondary backward stepper"),
114 _("Display a second backward arrow button on the opposite end of the scrollbar"),
119 gtk_widget_class_install_style_property (widget_class,
120 g_param_spec_boolean ("has_secondary_forward_stepper",
121 _("Secondary forward stepper"),
122 _("Display a secondary forward arrow button on the opposite end of the scrollbar"),
129 gtk_scrollbar_init (GtkScrollbar *scrollbar)
133 range = GTK_RANGE (scrollbar);
137 gtk_scrollbar_style_set (GtkWidget *widget,
142 gboolean has_a, has_b, has_c, has_d;
145 range = GTK_RANGE (widget);
147 gtk_widget_style_get (widget,
148 "min_slider_length", &slider_length,
149 "fixed_slider_length", &fixed_size,
150 "has_backward_stepper", &has_a,
151 "has_secondary_forward_stepper", &has_b,
152 "has_secondary_backward_stepper", &has_c,
153 "has_forward_stepper", &has_d,
156 range->min_slider_size = slider_length;
157 range->slider_size_fixed = fixed_size;
159 range->has_stepper_a = has_a;
160 range->has_stepper_b = has_b;
161 range->has_stepper_c = has_c;
162 range->has_stepper_d = has_d;
164 (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous);