source: trunk/third/gtkhtml3/src/htmltype.c @ 21116

Revision 21116, 4.5 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21115, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2/* htmltype.h
3
4   Copyright (C) 1999, 2000 Helix Code, Inc.
5
6   The Gnome Library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Library General Public License as
8   published by the Free Software Foundation; either version 2 of the
9   License, or (at your option) any later version.
10
11   The Gnome 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
17   License along with the Gnome Library; see the file COPYING.LIB.  If not,
18   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19   Boston, MA 02111-1307, USA.
20
21   Author: Ettore Perazzoli <ettore@comm2000.it>
22*/
23
24#include <config.h>
25#include "htmltype.h"
26
27#include "htmlanchor.h"
28#include "htmlbutton.h"
29#include "htmlcheckbox.h"
30#include "htmlclue.h"
31#include "htmlcluealigned.h"
32#include "htmlclueflow.h"
33#include "htmlclueh.h"
34#include "htmlcluev.h"
35#include "htmlembedded.h"
36#include "htmlframe.h"
37#include "htmlframeset.h"
38#include "htmlhidden.h"
39#include "htmliframe.h"
40#include "htmlimage.h"
41#include "htmlimageinput.h"
42#include "htmlmap.h"
43#include "htmlobject.h"
44#include "htmlradio.h"
45#include "htmlrule.h"
46#include "htmlselect.h"
47#include "htmltable.h"
48#include "htmltablecell.h"
49#include "htmltext.h"
50#include "htmltextarea.h"
51#include "htmltextinput.h"
52#include "htmltextslave.h"
53
54/* This is used to statically initialize all the classes we are using.  */
55
56static gboolean types_inited = FALSE;
57static GHashTable *type_names = NULL;
58
59static void
60build_type_names_table ()
61{
62        HTMLType t;
63
64        g_assert (type_names == NULL);
65
66        type_names = g_hash_table_new (g_str_hash, g_str_equal);
67
68        for (t = HTML_TYPE_NONE + 1; t<HTML_NUM_TYPES; t++)
69                g_hash_table_insert (type_names, (gpointer) html_type_name (t), GINT_TO_POINTER (t));
70}
71
72void
73html_types_init (void)
74{
75        if (types_inited)
76                return;
77
78        html_anchor_type_init ();
79        html_button_type_init();
80        html_checkbox_type_init ();
81        html_clue_type_init ();
82        html_cluealigned_type_init ();
83        html_clueflow_type_init ();
84        html_clueh_type_init ();
85        html_cluev_type_init ();
86        html_embedded_type_init ();
87        html_hidden_type_init ();
88        html_image_type_init ();
89        html_imageinput_type_init ();
90        html_object_type_init ();
91        html_radio_type_init ();
92        html_rule_type_init ();
93        html_select_type_init ();
94        html_table_cell_type_init ();
95        html_table_type_init ();
96        html_textarea_type_init ();
97        html_text_input_type_init ();
98        html_text_slave_type_init ();
99        html_text_type_init ();
100
101        html_frameset_type_init ();
102        html_frame_type_init ();
103        html_iframe_type_init ();       
104
105        build_type_names_table ();
106
107        types_inited = TRUE;
108}
109
110
111const gchar *
112html_type_name (HTMLType type)
113{
114        g_return_val_if_fail (type != HTML_TYPE_NONE, NULL);
115        g_return_val_if_fail (type < HTML_NUM_TYPES, NULL);
116
117        switch (type) {
118        case HTML_TYPE_ANCHOR:
119                return "Anchor";
120        case HTML_TYPE_BULLET:
121                return "Bullet";
122        case HTML_TYPE_BUTTON:
123                return "Button";
124        case HTML_TYPE_CHECKBOX:
125                return "CheckBox";
126        case HTML_TYPE_CLUE:
127                return "Clue";
128        case HTML_TYPE_CLUEALIGNED:
129                return "ClueAligned";
130        case HTML_TYPE_CLUEFLOW:
131                return "ClueFlow";
132        case HTML_TYPE_CLUEH:
133                return "ClueH";
134        case HTML_TYPE_CLUEV:
135                return "ClueV";
136        case HTML_TYPE_EMBEDDED:
137                return "Embedded";
138        case HTML_TYPE_HIDDEN:
139                return "Hidden";
140        case HTML_TYPE_HSPACE:
141                return "HSpace";
142        case HTML_TYPE_IMAGE:
143                return "Image";
144        case HTML_TYPE_IMAGEINPUT:
145                return "ImageInput";
146        case HTML_TYPE_LINKTEXT:
147                return "LinkText";
148        case HTML_TYPE_OBJECT:
149                return "Object";
150        case HTML_TYPE_RADIO:
151                return "Radio";
152        case HTML_TYPE_RULE:
153                return "Rule";
154        case HTML_TYPE_SELECT:
155                return "Select";
156        case HTML_TYPE_TABLE:
157                return "Table";
158        case HTML_TYPE_TABLECELL:
159                return "TableCell";
160        case HTML_TYPE_TEXT:
161                return "Text";
162        case HTML_TYPE_TEXTAREA:
163                return "TextArea";
164        case HTML_TYPE_TEXTINPUT:
165                return "TextInput";
166        case HTML_TYPE_TEXTSLAVE:
167                return "TextSlave";
168        case HTML_TYPE_IFRAME:
169                return "IFrame";
170        case HTML_TYPE_FRAME:
171                return "Frame";
172        case HTML_TYPE_FRAMESET:
173                return "Framset";
174        case HTML_TYPE_NONE:
175        case HTML_NUM_TYPES:
176                /* Make compiler happy.  */
177                g_assert_not_reached ();
178        }
179
180        g_assert_not_reached ();
181        return NULL;
182}
183
184HTMLType
185html_type_from_name (const gchar *name)
186{
187        g_assert (type_names);
188
189        return GPOINTER_TO_INT (g_hash_table_lookup (type_names, name));
190}
Note: See TracBrowser for help on using the repository browser.