Mercurial > pidgin
annotate finch/libgnt/gntline.c @ 18411:3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 01 Jul 2007 17:05:16 +0000 |
parents | 1cedd520cd18 |
children | 5dc587a877d6 |
rev | line source |
---|---|
18049
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
1 /** |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
3 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
6 * source distribution. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
7 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
11 * (at your option) any later version. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
12 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
16 * GNU General Public License for more details. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
17 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
21 */ |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
22 |
15817 | 23 #include "gntline.h" |
24 | |
25 enum | |
26 { | |
27 SIGS = 1, | |
28 }; | |
29 | |
30 static GntWidgetClass *parent_class = NULL; | |
31 | |
32 static void | |
33 gnt_line_draw(GntWidget *widget) | |
34 { | |
35 GntLine *line = GNT_LINE(widget); | |
36 if (line->vertical) | |
37 mvwvline(widget->window, 1, 0, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), | |
38 widget->priv.height - 2); | |
39 else | |
40 mvwhline(widget->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), | |
41 widget->priv.width - 2); | |
42 } | |
43 | |
44 static void | |
45 gnt_line_size_request(GntWidget *widget) | |
46 { | |
47 if (GNT_LINE(widget)->vertical) | |
48 { | |
49 widget->priv.width = 1; | |
50 widget->priv.height = 5; | |
51 } | |
52 else | |
53 { | |
54 widget->priv.width = 5; | |
55 widget->priv.height = 1; | |
56 } | |
57 } | |
58 | |
59 static void | |
60 gnt_line_map(GntWidget *widget) | |
61 { | |
62 if (widget->priv.width == 0 || widget->priv.height == 0) | |
63 gnt_widget_size_request(widget); | |
64 GNTDEBUG; | |
65 } | |
66 | |
67 static void | |
68 gnt_line_class_init(GntLineClass *klass) | |
69 { | |
70 parent_class = GNT_WIDGET_CLASS(klass); | |
71 parent_class->draw = gnt_line_draw; | |
72 parent_class->map = gnt_line_map; | |
73 parent_class->size_request = gnt_line_size_request; | |
74 | |
75 GNTDEBUG; | |
76 } | |
77 | |
78 static void | |
79 gnt_line_init(GTypeInstance *instance, gpointer class) | |
80 { | |
81 GntWidget *widget = GNT_WIDGET(instance); | |
82 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER); | |
83 widget->priv.minw = 1; | |
84 widget->priv.minh = 1; | |
85 GNTDEBUG; | |
86 } | |
87 | |
88 /****************************************************************************** | |
89 * GntLine API | |
90 *****************************************************************************/ | |
91 GType | |
92 gnt_line_get_gtype(void) | |
93 { | |
94 static GType type = 0; | |
95 | |
96 if(type == 0) | |
97 { | |
98 static const GTypeInfo info = { | |
99 sizeof(GntLineClass), | |
100 NULL, /* base_init */ | |
101 NULL, /* base_finalize */ | |
102 (GClassInitFunc)gnt_line_class_init, | |
103 NULL, /* class_finalize */ | |
104 NULL, /* class_data */ | |
105 sizeof(GntLine), | |
106 0, /* n_preallocs */ | |
107 gnt_line_init, /* instance_init */ | |
108 NULL /* value_table */ | |
109 }; | |
110 | |
111 type = g_type_register_static(GNT_TYPE_WIDGET, | |
112 "GntLine", | |
113 &info, 0); | |
114 } | |
115 | |
116 return type; | |
117 } | |
118 | |
119 GntWidget *gnt_line_new(gboolean vertical) | |
120 { | |
121 GntWidget *widget = g_object_new(GNT_TYPE_LINE, 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; | |
136 } | |
137 |