]> Pileus Git - ~andy/gtk/blob - gtk/gtkscrollbar.c
26dba303097dc10c9fc25e42fd4ffe386cfe4b98
[~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_style_set  (GtkWidget         *widget,
35                                       GtkStyle          *previous);
36
37 G_DEFINE_ABSTRACT_TYPE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_RANGE)
38
39 static void
40 gtk_scrollbar_class_init (GtkScrollbarClass *class)
41 {
42   GtkWidgetClass *widget_class;
43
44   widget_class = GTK_WIDGET_CLASS (class);
45
46   widget_class->style_set = gtk_scrollbar_style_set;
47   
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"),
52                                                              0,
53                                                              G_MAXINT,
54                                                              21,
55                                                              GTK_PARAM_READABLE));
56
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"),
61                                                                  FALSE,
62                                                                  
63                                                                  GTK_PARAM_READABLE));
64   
65   gtk_widget_class_install_style_property (widget_class,
66                                            g_param_spec_boolean ("has-backward-stepper",
67                                                                  P_("Backward stepper"),
68                                                                  P_("Display the standard backward arrow button"),
69                                                                  TRUE,
70                                                                  
71                                                                  GTK_PARAM_READABLE));
72
73     gtk_widget_class_install_style_property (widget_class,
74                                              g_param_spec_boolean ("has-forward-stepper",
75                                                                    P_("Forward stepper"),
76                                                                    P_("Display the standard forward arrow button"),
77                                                                    TRUE,
78                                                                    
79                                                                    GTK_PARAM_READABLE));
80
81   gtk_widget_class_install_style_property (widget_class,
82                                            g_param_spec_boolean ("has-secondary-backward-stepper",
83                                                                  P_("Secondary backward stepper"),
84                                                                  P_("Display a second backward arrow button on the opposite end of the scrollbar"),
85                                                                  FALSE,
86                                                                  
87                                                                  GTK_PARAM_READABLE));
88
89     gtk_widget_class_install_style_property (widget_class,
90                                              g_param_spec_boolean ("has-secondary-forward-stepper",
91                                                                    P_("Secondary forward stepper"),
92                                                                    P_("Display a second forward arrow button on the opposite end of the scrollbar"),
93                                                                    FALSE,
94                                                                    
95                                                                    GTK_PARAM_READABLE));
96 }
97
98 static void
99 gtk_scrollbar_init (GtkScrollbar *scrollbar)
100 {
101 }
102
103 static void
104 gtk_scrollbar_style_set  (GtkWidget *widget,
105                           GtkStyle  *previous)
106 {
107   gint slider_length;
108   gboolean fixed_size;
109   gboolean has_a, has_b, has_c, has_d;
110   GtkRange *range;
111
112   range = GTK_RANGE (widget);
113   
114   gtk_widget_style_get (widget,
115                         "min-slider-length", &slider_length,
116                         "fixed-slider-length", &fixed_size,
117                         "has-backward-stepper", &has_a,
118                         "has-secondary-forward-stepper", &has_b,
119                         "has-secondary-backward-stepper", &has_c,
120                         "has-forward-stepper", &has_d,
121                         NULL);
122   
123   range->min_slider_size = slider_length;
124   range->slider_size_fixed = fixed_size;
125
126   range->has_stepper_a = has_a;
127   range->has_stepper_b = has_b;
128   range->has_stepper_c = has_c;
129   range->has_stepper_d = has_d;
130   
131   (* GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_set) (widget, previous);
132 }
133
134 #define __GTK_SCROLLBAR_C__
135 #include "gtkaliasdef.c"