Mercurial > pidgin
annotate finch/libgnt/gntline.c @ 20912:f34539eb7a61
Add some xsl magic to generate a .devhelp index from doxygen's XML output,
allowing the documentation to be viewed in Devhelp. It's not perfect ---
there are some broken links and the transformation is a bit fragile --- but
works well enough to be useful.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Sat, 13 Oct 2007 15:44:43 +0000 |
parents | 44b4e8bd759b |
children | 9187d331aebe |
rev | line source |
---|---|
17928
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
1 /** |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
3 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
6 * source distribution. |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
7 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
11 * (at your option) any later version. |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
12 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
16 * GNU General Public License for more details. |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
17 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18869
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
17928
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
21 */ |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15817
diff
changeset
|
22 |
15817 | 23 #include "gntline.h" |
24 | |
25 enum | |
26 { | |
18869
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
27 PROP_0, |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
28 PROP_VERTICAL |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
29 }; |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
30 |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
31 enum |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
32 { |
15817 | 33 SIGS = 1, |
34 }; | |
35 | |
36 static GntWidgetClass *parent_class = NULL; | |
37 | |
38 static void | |
39 gnt_line_draw(GntWidget *widget) | |
40 { | |
41 GntLine *line = GNT_LINE(widget); | |
42 if (line->vertical) | |
43 mvwvline(widget->window, 1, 0, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), | |
44 widget->priv.height - 2); | |
45 else | |
46 mvwhline(widget->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), | |
47 widget->priv.width - 2); | |
48 } | |
49 | |
50 static void | |
51 gnt_line_size_request(GntWidget *widget) | |
52 { | |
53 if (GNT_LINE(widget)->vertical) | |
54 { | |
55 widget->priv.width = 1; | |
56 widget->priv.height = 5; | |
57 } | |
58 else | |
59 { | |
60 widget->priv.width = 5; | |
61 widget->priv.height = 1; | |
62 } | |
63 } | |
64 | |
65 static void | |
66 gnt_line_map(GntWidget *widget) | |
67 { | |
68 if (widget->priv.width == 0 || widget->priv.height == 0) | |
69 gnt_widget_size_request(widget); | |
70 GNTDEBUG; | |
71 } | |
72 | |
73 static void | |
18869
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
74 gnt_line_set_property(GObject *obj, guint prop_id, const GValue *value, |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
75 GParamSpec *spec) |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
76 { |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
77 GntLine *line = GNT_LINE(obj); |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
78 switch (prop_id) { |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
79 case PROP_VERTICAL: |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
80 line->vertical = g_value_get_boolean(value); |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
81 if (line->vertical) { |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
82 GNT_WIDGET_SET_FLAGS(line, GNT_WIDGET_GROW_Y); |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
83 } else { |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
84 GNT_WIDGET_SET_FLAGS(line, GNT_WIDGET_GROW_X); |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
85 } |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
86 break; |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
87 default: |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
88 break; |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
89 } |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
90 } |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
91 |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
92 static void |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
93 gnt_line_get_property(GObject *obj, guint prop_id, GValue *value, |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
94 GParamSpec *spec) |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
95 { |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
96 GntLine *line = GNT_LINE(obj); |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
97 switch (prop_id) { |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
98 case PROP_VERTICAL: |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
99 g_value_set_boolean(value, line->vertical); |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
100 break; |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
101 default: |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
102 break; |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
103 } |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
104 } |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
105 |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
106 static void |
15817 | 107 gnt_line_class_init(GntLineClass *klass) |
108 { | |
18869
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
109 GObjectClass *gclass = G_OBJECT_CLASS(klass); |
15817 | 110 parent_class = GNT_WIDGET_CLASS(klass); |
111 parent_class->draw = gnt_line_draw; | |
112 parent_class->map = gnt_line_map; | |
113 parent_class->size_request = gnt_line_size_request; | |
114 | |
18869
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
115 gclass->set_property = gnt_line_set_property; |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
116 gclass->get_property = gnt_line_get_property; |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
117 g_object_class_install_property(gclass, |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
118 PROP_VERTICAL, |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
119 g_param_spec_boolean("vertical", "Vertical", |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
120 "Whether it's a vertical line or a horizontal one.", |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
121 TRUE, |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
122 G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
123 ) |
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
124 ); |
15817 | 125 } |
126 | |
127 static void | |
128 gnt_line_init(GTypeInstance *instance, gpointer class) | |
129 { | |
130 GntWidget *widget = GNT_WIDGET(instance); | |
131 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER); | |
132 widget->priv.minw = 1; | |
133 widget->priv.minh = 1; | |
134 GNTDEBUG; | |
135 } | |
136 | |
137 /****************************************************************************** | |
138 * GntLine API | |
139 *****************************************************************************/ | |
140 GType | |
141 gnt_line_get_gtype(void) | |
142 { | |
143 static GType type = 0; | |
144 | |
145 if(type == 0) | |
146 { | |
147 static const GTypeInfo info = { | |
148 sizeof(GntLineClass), | |
149 NULL, /* base_init */ | |
150 NULL, /* base_finalize */ | |
151 (GClassInitFunc)gnt_line_class_init, | |
152 NULL, /* class_finalize */ | |
153 NULL, /* class_data */ | |
154 sizeof(GntLine), | |
155 0, /* n_preallocs */ | |
156 gnt_line_init, /* instance_init */ | |
157 NULL /* value_table */ | |
158 }; | |
159 | |
160 type = g_type_register_static(GNT_TYPE_WIDGET, | |
161 "GntLine", | |
162 &info, 0); | |
163 } | |
164 | |
165 return type; | |
166 } | |
167 | |
168 GntWidget *gnt_line_new(gboolean vertical) | |
169 { | |
18869
5dc587a877d6
Use gobject properties for lines.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
170 GntWidget *widget = g_object_new(GNT_TYPE_LINE, "vertical", vertical, NULL); |
15817 | 171 return widget; |
172 } | |
173 |