]> Pileus Git - ~andy/gtk/blob - gtk/gtkscrollbar.c
Deprecation cleanup
[~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 "gtkscrollbar.h"
29 #include "gtkintl.h"
30
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,
34                                       GtkStyle          *previous);
35
36 static gpointer parent_class;
37
38 GType
39 gtk_scrollbar_get_type (void)
40 {
41   static GType scrollbar_type = 0;
42
43   if (!scrollbar_type)
44     {
45       static const GTypeInfo scrollbar_info =
46       {
47         sizeof (GtkScrollbarClass),
48         NULL,           /* base_init */
49         NULL,           /* base_finalize */
50         (GClassInitFunc) gtk_scrollbar_class_init,
51         NULL,           /* class_finalize */
52         NULL,           /* class_data */
53         sizeof (GtkScrollbar),
54         0,              /* n_preallocs */
55         (GInstanceInitFunc) gtk_scrollbar_init,
56         NULL,           /* value_table */
57       };
58
59       scrollbar_type =
60         g_type_register_static (GTK_TYPE_RANGE, "GtkScrollbar",
61                                 &scrollbar_info, G_TYPE_FLAG_ABSTRACT);
62     }
63
64   return scrollbar_type;
65 }
66
67 static void
68 gtk_scrollbar_class_init (GtkScrollbarClass *class)
69 {
70   GtkWidgetClass *widget_class;
71
72   widget_class = GTK_WIDGET_CLASS (class);
73
74   parent_class = g_type_class_peek_parent (class);
75   
76   widget_class->style_set = gtk_scrollbar_style_set;
77   
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"),
82                                                              0,
83                                                              G_MAXINT,
84                                                              7,
85                                                              G_PARAM_READABLE));
86
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"),
91                                                                  FALSE,
92                                                                  
93                                                                  G_PARAM_READABLE));
94   
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"),
99                                                                  TRUE,
100                                                                  
101                                                                  G_PARAM_READABLE));
102
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"),
107                                                                    TRUE,
108                                                                    
109                                                                    G_PARAM_READABLE));
110
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"),
115                                                                  FALSE,
116                                                                  
117                                                                  G_PARAM_READABLE));
118
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"),
123                                                                    FALSE,
124                                                                    
125                                                                    G_PARAM_READABLE));
126 }
127
128 static void
129 gtk_scrollbar_init (GtkScrollbar *scrollbar)
130 {
131   GtkRange *range;
132
133   range = GTK_RANGE (scrollbar);
134 }
135
136 static void
137 gtk_scrollbar_style_set  (GtkWidget *widget,
138                           GtkStyle  *previous)
139 {
140   gint slider_length;
141   gboolean fixed_size;
142   gboolean has_a, has_b, has_c, has_d;
143   GtkRange *range;
144
145   range = GTK_RANGE (widget);
146   
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,
154                         NULL);
155   
156   range->min_slider_size = slider_length;
157   range->slider_size_fixed = fixed_size;
158
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;
163   
164   (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous);
165 }
166
167