1 | /* GAIL - The GNOME Accessibility Enabling Library |
---|
2 | * Copyright 2001 Sun Microsystems Inc. |
---|
3 | * |
---|
4 | * This library is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU Lesser General Public |
---|
6 | * License as published by the Free Software Foundation; either |
---|
7 | * version 2 of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This library is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | * Lesser General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU Lesser General Public |
---|
15 | * License along with this library; if not, write to the |
---|
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
17 | * Boston, MA 02111-1307, USA. |
---|
18 | */ |
---|
19 | |
---|
20 | #include <gtk/gtk.h> |
---|
21 | #include "gailseparator.h" |
---|
22 | |
---|
23 | static void gail_separator_class_init (GailSeparatorClass *klass); |
---|
24 | static AtkStateSet* gail_separator_ref_state_set (AtkObject *accessible); |
---|
25 | |
---|
26 | static GailWidgetClass *parent_class = NULL; |
---|
27 | |
---|
28 | GType |
---|
29 | gail_separator_get_type (void) |
---|
30 | { |
---|
31 | static GType type = 0; |
---|
32 | |
---|
33 | if (!type) |
---|
34 | { |
---|
35 | static const GTypeInfo tinfo = |
---|
36 | { |
---|
37 | sizeof (GailSeparatorClass), |
---|
38 | (GBaseInitFunc) NULL, /* base init */ |
---|
39 | (GBaseFinalizeFunc) NULL, /* base finalize */ |
---|
40 | (GClassInitFunc) gail_separator_class_init, /* class init */ |
---|
41 | (GClassFinalizeFunc) NULL, /* class finalize */ |
---|
42 | NULL, /* class data */ |
---|
43 | sizeof (GailSeparator), /* instance size */ |
---|
44 | 0, /* nb preallocs */ |
---|
45 | (GInstanceInitFunc) NULL, /* instance init */ |
---|
46 | NULL /* value table */ |
---|
47 | }; |
---|
48 | |
---|
49 | type = g_type_register_static (GAIL_TYPE_WIDGET, |
---|
50 | "GailSeparator", &tinfo, 0); |
---|
51 | } |
---|
52 | return type; |
---|
53 | } |
---|
54 | |
---|
55 | static void |
---|
56 | gail_separator_class_init (GailSeparatorClass *klass) |
---|
57 | { |
---|
58 | AtkObjectClass *class = ATK_OBJECT_CLASS (klass); |
---|
59 | |
---|
60 | parent_class = g_type_class_peek_parent (klass); |
---|
61 | |
---|
62 | class->ref_state_set = gail_separator_ref_state_set; |
---|
63 | } |
---|
64 | |
---|
65 | AtkObject* |
---|
66 | gail_separator_new (GtkWidget *widget) |
---|
67 | { |
---|
68 | GObject *object; |
---|
69 | AtkObject *accessible; |
---|
70 | |
---|
71 | g_return_val_if_fail (GTK_IS_SEPARATOR (widget), NULL); |
---|
72 | |
---|
73 | object = g_object_new (GAIL_TYPE_SEPARATOR, NULL); |
---|
74 | |
---|
75 | g_return_val_if_fail (GTK_IS_ACCESSIBLE (object), NULL); |
---|
76 | |
---|
77 | accessible = ATK_OBJECT (object); |
---|
78 | atk_object_initialize (accessible, widget); |
---|
79 | |
---|
80 | accessible->role = ATK_ROLE_SEPARATOR; |
---|
81 | |
---|
82 | return accessible; |
---|
83 | } |
---|
84 | |
---|
85 | static AtkStateSet* |
---|
86 | gail_separator_ref_state_set (AtkObject *accessible) |
---|
87 | { |
---|
88 | AtkStateSet *state_set; |
---|
89 | GtkWidget *widget; |
---|
90 | |
---|
91 | state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible); |
---|
92 | widget = GTK_ACCESSIBLE (accessible)->widget; |
---|
93 | |
---|
94 | if (widget == NULL) |
---|
95 | return state_set; |
---|
96 | |
---|
97 | if (GTK_IS_VSEPARATOR (widget)) |
---|
98 | atk_state_set_add_state (state_set, ATK_STATE_VERTICAL); |
---|
99 | else if (GTK_IS_HSEPARATOR (widget)) |
---|
100 | atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL); |
---|
101 | |
---|
102 | return state_set; |
---|
103 | } |
---|