Mercurial > pidgin
comparison finch/libgnt/gntline.c @ 18869:5dc587a877d6
Use gobject properties for lines.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 11 Aug 2007 04:13:11 +0000 |
parents | 1cedd520cd18 |
children | 44b4e8bd759b |
comparison
equal
deleted
inserted
replaced
18868:d470282d49da | 18869:5dc587a877d6 |
---|---|
19 * along with this program; if not, write to the Free Software | 19 * along with this program; if not, write to the Free Software |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 */ | 21 */ |
22 | 22 |
23 #include "gntline.h" | 23 #include "gntline.h" |
24 | |
25 enum | |
26 { | |
27 PROP_0, | |
28 PROP_VERTICAL | |
29 }; | |
24 | 30 |
25 enum | 31 enum |
26 { | 32 { |
27 SIGS = 1, | 33 SIGS = 1, |
28 }; | 34 }; |
63 gnt_widget_size_request(widget); | 69 gnt_widget_size_request(widget); |
64 GNTDEBUG; | 70 GNTDEBUG; |
65 } | 71 } |
66 | 72 |
67 static void | 73 static void |
74 gnt_line_set_property(GObject *obj, guint prop_id, const GValue *value, | |
75 GParamSpec *spec) | |
76 { | |
77 GntLine *line = GNT_LINE(obj); | |
78 switch (prop_id) { | |
79 case PROP_VERTICAL: | |
80 line->vertical = g_value_get_boolean(value); | |
81 if (line->vertical) { | |
82 GNT_WIDGET_SET_FLAGS(line, GNT_WIDGET_GROW_Y); | |
83 } else { | |
84 GNT_WIDGET_SET_FLAGS(line, GNT_WIDGET_GROW_X); | |
85 } | |
86 break; | |
87 default: | |
88 break; | |
89 } | |
90 } | |
91 | |
92 static void | |
93 gnt_line_get_property(GObject *obj, guint prop_id, GValue *value, | |
94 GParamSpec *spec) | |
95 { | |
96 GntLine *line = GNT_LINE(obj); | |
97 switch (prop_id) { | |
98 case PROP_VERTICAL: | |
99 g_value_set_boolean(value, line->vertical); | |
100 break; | |
101 default: | |
102 break; | |
103 } | |
104 } | |
105 | |
106 static void | |
68 gnt_line_class_init(GntLineClass *klass) | 107 gnt_line_class_init(GntLineClass *klass) |
69 { | 108 { |
109 GObjectClass *gclass = G_OBJECT_CLASS(klass); | |
70 parent_class = GNT_WIDGET_CLASS(klass); | 110 parent_class = GNT_WIDGET_CLASS(klass); |
71 parent_class->draw = gnt_line_draw; | 111 parent_class->draw = gnt_line_draw; |
72 parent_class->map = gnt_line_map; | 112 parent_class->map = gnt_line_map; |
73 parent_class->size_request = gnt_line_size_request; | 113 parent_class->size_request = gnt_line_size_request; |
74 | 114 |
75 GNTDEBUG; | 115 gclass->set_property = gnt_line_set_property; |
116 gclass->get_property = gnt_line_get_property; | |
117 g_object_class_install_property(gclass, | |
118 PROP_VERTICAL, | |
119 g_param_spec_boolean("vertical", "Vertical", | |
120 "Whether it's a vertical line or a horizontal one.", | |
121 TRUE, | |
122 G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | |
123 ) | |
124 ); | |
76 } | 125 } |
77 | 126 |
78 static void | 127 static void |
79 gnt_line_init(GTypeInstance *instance, gpointer class) | 128 gnt_line_init(GTypeInstance *instance, gpointer class) |
80 { | 129 { |
116 return type; | 165 return type; |
117 } | 166 } |
118 | 167 |
119 GntWidget *gnt_line_new(gboolean vertical) | 168 GntWidget *gnt_line_new(gboolean vertical) |
120 { | 169 { |
121 GntWidget *widget = g_object_new(GNT_TYPE_LINE, NULL); | 170 GntWidget *widget = g_object_new(GNT_TYPE_LINE, "vertical", vertical, NULL); |
122 GntLine *line = GNT_LINE(widget); | |
123 | |
124 line->vertical = vertical; | |
125 | |
126 if (vertical) | |
127 { | |
128 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_Y); | |
129 } | |
130 else | |
131 { | |
132 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X); | |
133 } | |
134 | |
135 return widget; | 171 return widget; |
136 } | 172 } |
137 | 173 |