2 * Copyright © 2000-2004 Marco Pesenti Gritti
3 * Copyright © 2003, 2004 Christian Persch
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "mozilla-config.h"
25 #include "ephy-debug.h"
26 #include "ephy-embed-find.h"
27 #include "ephy-embed-shell.h"
31 #include "mozilla-embed-find.h"
33 #define MOZILLA_EMBED_FIND_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_FIND, MozillaEmbedFindPrivate))
35 struct _MozillaEmbedFindPrivate
40 static GObjectClass *parent_class = NULL;
43 impl_set_embed (EphyEmbedFind *efind,
46 MozillaEmbedFind *find = MOZILLA_EMBED_FIND (efind);
47 MozillaEmbedFindPrivate *priv = find->priv;
49 priv->find->SetEmbed (embed);
53 impl_set_properties (EphyEmbedFind *efind,
54 const char *find_string,
55 gboolean case_sensitive)
57 MozillaEmbedFind *find = MOZILLA_EMBED_FIND (efind);
58 MozillaEmbedFindPrivate *priv = find->priv;
60 priv->find->SetFindProperties (find_string, case_sensitive);
63 static EphyEmbedFindResult
64 impl_find (EphyEmbedFind *efind,
65 const char *find_string,
68 MozillaEmbedFind *find = MOZILLA_EMBED_FIND (efind);
69 MozillaEmbedFindPrivate *priv = find->priv;
71 return priv->find->Find (find_string, links_only);
74 static EphyEmbedFindResult
75 impl_find_again (EphyEmbedFind *efind,
79 MozillaEmbedFind *find = MOZILLA_EMBED_FIND (efind);
80 MozillaEmbedFindPrivate *priv = find->priv;
82 return priv->find->FindAgain (forward, links_only);
86 impl_set_selection (EphyEmbedFind *efind,
89 MozillaEmbedFind *find = MOZILLA_EMBED_FIND (efind);
90 MozillaEmbedFindPrivate *priv = find->priv;
92 priv->find->SetSelectionAttention (attention);
96 impl_activate_link (EphyEmbedFind *efind,
99 MozillaEmbedFind *find = MOZILLA_EMBED_FIND (efind);
100 MozillaEmbedFindPrivate *priv = find->priv;
102 return priv->find->ActivateLink (mask);
106 ephy_find_iface_init (EphyEmbedFindIface *iface)
108 iface->set_embed = impl_set_embed;
109 iface->set_properties = impl_set_properties;
110 iface->find = impl_find;
111 iface->find_again = impl_find_again;
112 iface->set_selection = impl_set_selection;
113 iface->activate_link = impl_activate_link;
117 mozilla_embed_find_init (MozillaEmbedFind *find)
119 find->priv = MOZILLA_EMBED_FIND_GET_PRIVATE (find);
120 find->priv->find = new EphyFind ();
124 mozilla_embed_find_constructor (GType type, guint n_construct_properties,
125 GObjectConstructParam *construct_params)
127 g_object_ref (embed_shell);
129 /* we depend on single because of mozilla initialization */
130 ephy_embed_shell_get_embed_single (embed_shell);
132 return parent_class->constructor (type, n_construct_properties,
137 mozilla_embed_find_finalize (GObject *object)
139 MozillaEmbedFind *find = MOZILLA_EMBED_FIND (object);
141 delete find->priv->find;
143 parent_class->finalize (object);
145 g_object_unref (embed_shell);
149 mozilla_embed_find_class_init (MozillaEmbedFindClass *klass)
151 GObjectClass *object_class = G_OBJECT_CLASS (klass);
153 parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
155 object_class->constructor = mozilla_embed_find_constructor;
156 object_class->finalize = mozilla_embed_find_finalize;
158 g_type_class_add_private (object_class, sizeof (MozillaEmbedFindPrivate));
162 mozilla_embed_find_get_type (void)
164 static GType type = 0;
166 if (G_UNLIKELY (type == 0))
168 const GTypeInfo our_info =
170 sizeof (MozillaEmbedFindClass),
171 NULL, /* base_init */
172 NULL, /* base_finalize */
173 (GClassInitFunc) mozilla_embed_find_class_init,
175 NULL, /* class_data */
176 sizeof (MozillaEmbedFind),
178 (GInstanceInitFunc) mozilla_embed_find_init
181 const GInterfaceInfo find_info =
183 (GInterfaceInitFunc) ephy_find_iface_init,
188 type = g_type_register_static (G_TYPE_OBJECT,
192 g_type_add_interface_static (type,
193 EPHY_TYPE_EMBED_FIND,