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
|
/*
* e-emoticon-chooser.c
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2012 Dan Vrátil <dvratil@redhat.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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 Lesser 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "e-emoticon-chooser.h"
#include <glib/gi18n-lib.h>
/* Constant version of EEMoticon. */
typedef struct {
const gchar *label;
const gchar *icon_name;
const gchar *text_face;
} ConstantEmoticon;
static ConstantEmoticon available_emoticons[] = {
/* Translators: :-) */
{ N_("_Smile"), "face-smile", ":-)" },
/* Translators: :-( */
{ N_("S_ad"), "face-sad", ":-(" },
/* Translators: ;-) */
{ N_("_Wink"), "face-wink", ";-)" },
/* Translators: :-P */
{ N_("Ton_gue"), "face-raspberry", ":-P" },
/* Translators: :-)) */
{ N_("Laug_h"), "face-laugh", ":-))" },
/* Translators: :-| */
{ N_("_Plain"), "face-plain", ":-|" },
/* Translators: :-! */
{ N_("Smi_rk"), "face-smirk", ":-!" },
/* Translators: :"-) */
{ N_("_Embarrassed"), "face-embarrassed", ":\"-)" },
/* Translators: :-D */
{ N_("_Big Smile"), "face-smile-big", ":-D" },
/* Translators: :-/ */
{ N_("Uncer_tain"), "face-uncertain", ":-/" },
/* Translators: :-O */
{ N_("S_urprise"), "face-surprise", ":-O" },
/* Translators: :-S */
{ N_("W_orried"), "face-worried", ":-S" },
/* Translators: :-* */
{ N_("_Kiss"), "face-kiss", ":-*" },
/* Translators: X-( */
{ N_("A_ngry"), "face-angry", "X-(" },
/* Translators: B-) */
{ N_("_Cool"), "face-cool", "B-)" },
/* Translators: O:-) */
{ N_("Ange_l"), "face-angel", "O:-)" },
/* Translators: :'( */
{ N_("Cr_ying"), "face-crying", ":'(" },
/* Translators: :-Q */
{ N_("S_ick"), "face-sick", ":-Q" },
/* Translators: |-) */
{ N_("Tire_d"), "face-tired", "|-)" },
/* Translators: >:-) */
{ N_("De_vilish"), "face-devilish", ">:-)" },
/* Translators: :-(|) */
{ N_("_Monkey"), "face-monkey", ":-(|)" }
};
enum {
ITEM_ACTIVATED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_INTERFACE (
EEmoticonChooser,
e_emoticon_chooser,
G_TYPE_OBJECT)
static void
e_emoticon_chooser_default_init (EEmoticonChooserInterface *interface)
{
g_object_interface_install_property (
interface,
g_param_spec_boxed (
"current-emoticon",
"Current Emoticon",
"Currently selected emoticon",
E_TYPE_EMOTICON,
G_PARAM_READWRITE));
signals[ITEM_ACTIVATED] = g_signal_new (
"item-activated",
G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EEmoticonChooserInterface, item_activated),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
EEmoticon *
e_emoticon_chooser_get_current_emoticon (EEmoticonChooser *chooser)
{
EEmoticonChooserInterface *interface;
g_return_val_if_fail (E_IS_EMOTICON_CHOOSER (chooser), NULL);
interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
g_return_val_if_fail (interface->get_current_emoticon != NULL, NULL);
return interface->get_current_emoticon (chooser);
}
void
e_emoticon_chooser_set_current_emoticon (EEmoticonChooser *chooser,
EEmoticon *emoticon)
{
EEmoticonChooserInterface *interface;
g_return_if_fail (E_IS_EMOTICON_CHOOSER (chooser));
interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
g_return_if_fail (interface->set_current_emoticon != NULL);
interface->set_current_emoticon (chooser, emoticon);
}
void
e_emoticon_chooser_item_activated (EEmoticonChooser *chooser)
{
g_return_if_fail (E_IS_EMOTICON_CHOOSER (chooser));
g_signal_emit (chooser, signals[ITEM_ACTIVATED], 0);
}
GList *
e_emoticon_chooser_get_items (void)
{
GList *list = NULL;
gint ii;
for (ii = 0; ii < G_N_ELEMENTS (available_emoticons); ii++)
list = g_list_prepend (list, &available_emoticons[ii]);
return g_list_reverse (list);
}
const EEmoticon *
e_emoticon_chooser_lookup_emoticon (const gchar *icon_name)
{
gint ii;
g_return_val_if_fail (icon_name && *icon_name, NULL);
for (ii = 0; ii < G_N_ELEMENTS (available_emoticons); ii++) {
if (strcmp (available_emoticons[ii].icon_name, icon_name) == 0) {
return (const EEmoticon *) &available_emoticons[ii];
}
}
return NULL;
}
|