1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* This file is part of the GtkHTML library. |
---|
3 | |
---|
4 | Copyright (C) 2000 Jonas Borgström <jonas_b@bitsmart.com>. |
---|
5 | |
---|
6 | This library is free software; you can redistribute it and/or |
---|
7 | modify it under the terms of the GNU Library General Public |
---|
8 | License as published by the Free Software Foundation; either |
---|
9 | version 2 of the License, or (at your option) any later version. |
---|
10 | |
---|
11 | This library is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
14 | Library General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU Library General Public License |
---|
17 | along with this library; see the file COPYING.LIB. If not, write to |
---|
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
19 | Boston, MA 02111-1307, USA. |
---|
20 | */ |
---|
21 | |
---|
22 | #include <config.h> |
---|
23 | #include "htmlhidden.h" |
---|
24 | #include <string.h> |
---|
25 | |
---|
26 | HTMLHiddenClass html_hidden_class; |
---|
27 | static HTMLEmbeddedClass *parent_class = NULL; |
---|
28 | |
---|
29 | |
---|
30 | static gchar * |
---|
31 | encode (HTMLEmbedded *e) |
---|
32 | { |
---|
33 | GString *encoding = g_string_new (""); |
---|
34 | gchar *ptr; |
---|
35 | |
---|
36 | if(strlen (e->name)) { |
---|
37 | ptr = html_embedded_encode_string (e->name); |
---|
38 | encoding = g_string_append (encoding, ptr); |
---|
39 | g_free (ptr); |
---|
40 | |
---|
41 | encoding = g_string_append_c (encoding, '='); |
---|
42 | |
---|
43 | ptr = html_embedded_encode_string (e->value); |
---|
44 | encoding = g_string_append (encoding, ptr); |
---|
45 | g_free (ptr); |
---|
46 | } |
---|
47 | |
---|
48 | ptr = encoding->str; |
---|
49 | g_string_free(encoding, FALSE); |
---|
50 | |
---|
51 | return ptr; |
---|
52 | } |
---|
53 | |
---|
54 | void html_hidden_type_init (void) |
---|
55 | { |
---|
56 | html_hidden_class_init (&html_hidden_class, HTML_TYPE_HIDDEN, sizeof (HTMLHidden)); |
---|
57 | } |
---|
58 | |
---|
59 | void html_hidden_class_init (HTMLHiddenClass *klass, |
---|
60 | HTMLType type, |
---|
61 | guint object_size) |
---|
62 | { |
---|
63 | HTMLEmbeddedClass *element_class; |
---|
64 | HTMLObjectClass *object_class; |
---|
65 | |
---|
66 | element_class = HTML_EMBEDDED_CLASS (klass); |
---|
67 | object_class = HTML_OBJECT_CLASS (klass); |
---|
68 | |
---|
69 | html_embedded_class_init (element_class, type, object_size); |
---|
70 | |
---|
71 | element_class->encode = encode; |
---|
72 | |
---|
73 | parent_class = &html_embedded_class; |
---|
74 | } |
---|
75 | |
---|
76 | void html_hidden_init (HTMLHidden *hidden, |
---|
77 | HTMLHiddenClass *klass, |
---|
78 | gchar *name, |
---|
79 | gchar *value) |
---|
80 | { |
---|
81 | HTMLEmbedded *element; |
---|
82 | HTMLObject *object; |
---|
83 | |
---|
84 | element = HTML_EMBEDDED (hidden); |
---|
85 | object = HTML_OBJECT (hidden); |
---|
86 | |
---|
87 | html_embedded_init (element, HTML_EMBEDDED_CLASS (klass), NULL, name, value); |
---|
88 | |
---|
89 | object->descent = 0; |
---|
90 | object->width = 0; |
---|
91 | object->ascent = 0; |
---|
92 | } |
---|
93 | |
---|
94 | HTMLObject *html_hidden_new (gchar *name, gchar *value) |
---|
95 | { |
---|
96 | HTMLHidden *hidden; |
---|
97 | |
---|
98 | hidden = g_new0 (HTMLHidden, 1); |
---|
99 | html_hidden_init (hidden, &html_hidden_class, name, value); |
---|
100 | |
---|
101 | return HTML_OBJECT (hidden); |
---|
102 | } |
---|