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