1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/*
* Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "ephy-embed-event.h"
#include <glib/ghash.h>
#include <gtk/gtktypeutils.h>
struct EphyEmbedEventPrivate
{
GHashTable *props;
};
static void
ephy_embed_event_class_init (EphyEmbedEventClass *klass);
static void
ephy_embed_event_init (EphyEmbedEvent *ges);
static void
ephy_embed_event_finalize (GObject *object);
static GObjectClass *parent_class = NULL;
GType
ephy_embed_event_get_type (void)
{
static GType ephy_embed_event_type = 0;
if (ephy_embed_event_type == 0)
{
static const GTypeInfo our_info =
{
sizeof (EphyEmbedEventClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) ephy_embed_event_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (EphyEmbedEvent),
0, /* n_preallocs */
(GInstanceInitFunc) ephy_embed_event_init
};
ephy_embed_event_type = g_type_register_static (G_TYPE_OBJECT,
"EphyEmbedEvent",
&our_info, 0);
}
return ephy_embed_event_type;
}
static void
ephy_embed_event_class_init (EphyEmbedEventClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = ephy_embed_event_finalize;
}
static void
free_g_value (gpointer value)
{
g_value_unset (value);
g_free (value);
}
static void
ephy_embed_event_init (EphyEmbedEvent *event)
{
event->priv = g_new0 (EphyEmbedEventPrivate, 1);
event->priv->props = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, free_g_value);
}
static void
ephy_embed_event_finalize (GObject *object)
{
EphyEmbedEvent *event;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_EPHY_EMBED_EVENT (object));
event = EPHY_EMBED_EVENT (object);
g_return_if_fail (event->priv != NULL);
g_hash_table_destroy (event->priv->props);
g_free (event->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
EphyEmbedEvent *
ephy_embed_event_new (void)
{
EphyEmbedEvent *event;
event = EPHY_EMBED_EVENT (g_object_new (EPHY_EMBED_EVENT_TYPE, NULL));
g_return_val_if_fail (event->priv != NULL, NULL);
return event;
}
guint
ephy_embed_event_get_modifier (EphyEmbedEvent *event)
{
return event->modifier;
}
gresult
ephy_embed_event_get_mouse_button (EphyEmbedEvent *event,
guint *mouse_button)
{
*mouse_button = event->mouse_button;
return G_OK;
}
gresult
ephy_embed_event_get_mouse_coords (EphyEmbedEvent *event,
guint *x, guint *y)
{
*x = event->mouse_x;
*y = event->mouse_y;
return G_OK;
}
gresult
ephy_embed_event_get_context (EphyEmbedEvent *event,
EmbedEventContext *context)
{
*context = event->context;
return G_OK;
}
void
ephy_embed_event_set_property (EphyEmbedEvent *event,
const char *name,
GValue *value)
{
g_hash_table_insert (event->priv->props,
g_strdup (name),
value);
}
void
ephy_embed_event_get_property (EphyEmbedEvent *event,
const char *name,
const GValue **value)
{
*value = g_hash_table_lookup (event->priv->props, name);
}
gboolean
ephy_embed_event_has_property (EphyEmbedEvent *event,
const char *name)
{
gpointer tmp;
tmp = g_hash_table_lookup (event->priv->props,
name);
return tmp != NULL;
}
|