]> Pileus Git - ~andy/gtk/blob - gtk/gtkscrollbar.c
a7bfcaefb53c7b74a26d31923a26d1ef2b0ffd52
[~andy/gtk] / gtk / gtkscrollbar.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  * Copyright (C) 2001 Red Hat, Inc.
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 /*
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/. 
26  */
27
28 #include <config.h>
29 #include "gtkscrollbar.h"
30 #include "gtkintl.h"
31 #include "gtkalias.h"
32
33 static void gtk_scrollbar_class_init (GtkScrollbarClass *klass);
34 static void gtk_scrollbar_init       (GtkScrollbar      *scrollbar);
35 static void gtk_scrollbar_style_set  (GtkWidget         *widget,
36                                       GtkStyle          *previous);
37
38 static gpointer parent_class;
39
40 GType
41 gtk_scrollbar_get_type (void)
42 {
43   static GType scrollbar_type = 0;
44
45   if (!scrollbar_type)
46     {
47       static const GTypeInfo scrollbar_info =
48       {
49         sizeof (GtkScrollbarClass),
50         NULL,           /* base_init */
51         NULL,           /* base_finalize */
52         (GClassInitFunc) gtk_scrollbar_class_init,
53         NULL,           /* class_finalize */
54         NULL,           /* class_data */
55         sizeof (GtkScrollbar),
56         0,              /* n_preallocs */
57         (GInstanceInitFunc) gtk_scrollbar_init,
58         NULL,           /* value_table */
59       };
60
61       scrollbar_type =
62         g_type_register_static (GTK_TYPE_RANGE, "GtkScrollbar",
63                                 &scrollbar_info, G_TYPE_FLAG_ABSTRACT);
64     }
65
66   return scrollbar_type;
67 }
68
69 static void
70 gtk_scrollbar_class_init (GtkScrollbarClass *class)
71 {
72   GtkWidgetClass *widget_class;
73
74   widget_class = GTK_WIDGET_CLASS (class);
75
76   parent_class = g_type_class_peek_parent (class);
77   
78   widget_class->style_set = gtk_scrollbar_style_set;
79   
80   gtk_widget_class_install_style_property (widget_class,
81                                            g_param_spec_int ("min-slider-length",
82                                                              P_("Minimum Slider Length"),
83                                                              P_("Minimum length of scrollbar slider"),
84                                                              0,
85                                                              G_MAXINT,
86                                                              21,
87                                                              G_PARAM_READABLE));
88
89   gtk_widget_class_install_style_property (widget_class,
90                                            g_param_spec_boolean ("fixed-slider-length",
91                                                                  P_("Fixed slider size"),
92                                                                  P_("Don't change slider size, just lock it to the minimum length"),
93                                                                  FALSE,
94                                                                  
95                                                                  G_PARAM_READABLE));
96   
97   gtk_widget_class_install_style_property (widget_class,
98                                            g_param_spec_boolean ("has-backward-stepper",
99                                                                  P_("Backward stepper"),
100                                                                  P_("Display the standard backward arrow button"),
101                                                                  TRUE,
102                                                                  
103                                                                  G_PARAM_READABLE));
104
105     gtk_widget_class_install_style_property (widget_class,
106                                              g_param_spec_boolean ("has-forward-stepper",
107                                                                    P_("Forward stepper"),
108                                                                    P_("Display the standard forward arrow button"),
109                                                                    TRUE,
110                                                                    
111                                                                    G_PARAM_READABLE));
112
113   gtk_widget_class_install_style_property (widget_class,
114                                            g_param_spec_boolean ("has-secondary-backward-stepper",
115                                                                  P_("Secondary backward stepper"),
116                                                                  P_("Display a second backward arrow button on the opposite end of the scrollbar"),
117                                                                  FALSE,
118                                                                  
119                                                                  G_PARAM_READABLE));
120
121     gtk_widget_class_install_style_property (widget_class,
122                                              g_param_spec_boolean ("has-secondary-forward-stepper",
123                                                                    P_("Secondary forward stepper"),
124                                                                    P_("Display a secondary forward arrow button on the opposite end of the scrollbar"),
125                                                                    FALSE,
126                                                                    
127                                                                    G_PARAM_READABLE));
128 }
129
130 static void
131 gtk_scrollbar_init (GtkScrollbar *scrollbar)
132 {
133   GtkRange *range;
134
135   range = GTK_RANGE (scrollbar);
136 }
137
138 static void
139 gtk_scrollbar_style_set  (GtkWidget *widget,
140                           GtkStyle  *previous)
141 {
142   gint slider_length;
143   gboolean fixed_size;
144   gboolean has_a, has_b, has_c, has_d;
145   GtkRange *range;
146
147   range = GTK_RANGE (widget);
148   
149   gtk_widget_style_get (widget,
150                         "min_slider_length", &slider_length,
151                         "fixed_slider_length", &fixed_size,
152                         "has_backward_stepper", &has_a,
153                         "has_secondary_forward_stepper", &has_b,
154                         "has_secondary_backward_stepper", &has_c,
155                         "has_forward_stepper", &has_d,
156                         NULL);
157   
158   range->min_slider_size = slider_length;
159   range->slider_size_fixed = fixed_size;
160
161   range->has_stepper_a = has_a;
162   range->has_stepper_b = has_b;
163   range->has_stepper_c = has_c;
164   range->has_stepper_d = has_d;
165   
166   (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous);
167 }
168
169 #define __GTK_SCROLLBAR_C__
170 #include "gtkaliasdef.c"