Updated Spanish translation
[evolution.git] / e-util / e-emoticon-chooser.c
blob428e116f6777449f4573f65934be8dff7b2377c6
1 /*
2 * e-emoticon-chooser.c
4 * Copyright (C) 2008 Novell, Inc.
5 * Copyright (C) 2012 Dan VrΓ‘til <dvratil@redhat.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of version 2 of the GNU Lesser General Public
9 * License as published by the Free Software Foundation.
11 * This program 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 * General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 #include "e-emoticon-chooser.h"
28 #include <glib/gi18n-lib.h>
30 /* Constant version of EEMoticon. */
31 typedef struct {
32 const gchar *label;
33 const gchar *icon_name;
34 const gchar *unicode_character;
35 const gchar *text_face;
36 } ConstantEmoticon;
38 static ConstantEmoticon available_emoticons[] = {
39 /* Translators: :-) */
40 { N_("_Smile"), "face-smile", "☺", ":-)" },
41 /* Translators: :-( */
42 { N_("S_ad"), "face-sad", "☹", ":-(" },
43 /* Translators: ;-) */
44 { N_("_Wink"), "face-wink", "πŸ˜‰", ";-)" },
45 /* Translators: :-P */
46 { N_("Ton_gue"), "face-raspberry", "πŸ˜›", ":-P" },
47 /* Translators: :-)) */
48 { N_("Laug_h"), "face-laugh", "πŸ˜ƒ", ":-D" },
49 /* Translators: :-| */
50 { N_("_Plain"), "face-plain", "πŸ˜”", ":-|" },
51 /* Translators: :-! */
52 { N_("Smi_rk"), "face-smirk", "😏", ":-!" },
53 /* Translators: :"-) */
54 { N_("_Embarrassed"), "face-embarrassed", "😯", ":\"-)" },
55 /* Translators: :-D */
56 { N_("_Big Smile"), "face-smile-big", "πŸ˜„", ":-D" },
57 /* Translators: :-/ */
58 { N_("Uncer_tain"), "face-uncertain", "πŸ˜•", ":-/" },
59 /* Translators: :-O */
60 { N_("S_urprise"), "face-surprise", "😲", ":-O" },
61 /* Translators: :-S */
62 { N_("W_orried"), "face-worried", "😟", ":-S" },
63 /* Translators: :-* */
64 { N_("_Kiss"), "face-kiss", "πŸ˜—", ":-*" },
65 /* Translators: X-( */
66 { N_("A_ngry"), "face-angry", "😠", "X-(" },
67 /* Translators: B-) */
68 { N_("_Cool"), "face-cool", "😎", "B-)" },
69 /* Translators: O:-) */
70 { N_("Ange_l"), "face-angel", "πŸ˜‡", "O:-)" },
71 /* Translators: :'( */
72 { N_("Cr_ying"), "face-crying", "😒", ":'(" },
73 /* Translators: :-Q */
74 { N_("S_ick"), "face-sick", "😨", ":-Q" },
75 /* Translators: |-) */
76 { N_("Tire_d"), "face-tired", "😫", "|-)" },
77 /* Translators: >:-) */
78 { N_("De_vilish"), "face-devilish", "😈", ">:-)" },
79 /* Translators: :-(|) */
80 { N_("_Monkey"), "face-monkey", "🐡", ":-(|)" }
83 enum {
84 ITEM_ACTIVATED,
85 LAST_SIGNAL
88 static guint signals[LAST_SIGNAL];
90 G_DEFINE_INTERFACE (
91 EEmoticonChooser,
92 e_emoticon_chooser,
93 G_TYPE_OBJECT)
95 static void
96 e_emoticon_chooser_default_init (EEmoticonChooserInterface *interface)
98 g_object_interface_install_property (
99 interface,
100 g_param_spec_boxed (
101 "current-emoticon",
102 "Current Emoticon",
103 "Currently selected emoticon",
104 E_TYPE_EMOTICON,
105 G_PARAM_READWRITE));
107 signals[ITEM_ACTIVATED] = g_signal_new (
108 "item-activated",
109 G_TYPE_FROM_INTERFACE (interface),
110 G_SIGNAL_RUN_LAST,
111 G_STRUCT_OFFSET (EEmoticonChooserInterface, item_activated),
112 NULL, NULL,
113 g_cclosure_marshal_VOID__VOID,
114 G_TYPE_NONE, 0);
117 EEmoticon *
118 e_emoticon_chooser_get_current_emoticon (EEmoticonChooser *chooser)
120 EEmoticonChooserInterface *interface;
122 g_return_val_if_fail (E_IS_EMOTICON_CHOOSER (chooser), NULL);
124 interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
125 g_return_val_if_fail (interface->get_current_emoticon != NULL, NULL);
127 return interface->get_current_emoticon (chooser);
130 void
131 e_emoticon_chooser_set_current_emoticon (EEmoticonChooser *chooser,
132 EEmoticon *emoticon)
134 EEmoticonChooserInterface *interface;
136 g_return_if_fail (E_IS_EMOTICON_CHOOSER (chooser));
138 interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
139 g_return_if_fail (interface->set_current_emoticon != NULL);
141 interface->set_current_emoticon (chooser, emoticon);
144 void
145 e_emoticon_chooser_item_activated (EEmoticonChooser *chooser)
147 g_return_if_fail (E_IS_EMOTICON_CHOOSER (chooser));
149 g_signal_emit (chooser, signals[ITEM_ACTIVATED], 0);
152 GList *
153 e_emoticon_chooser_get_items (void)
155 GList *list = NULL;
156 gint ii;
158 for (ii = 0; ii < G_N_ELEMENTS (available_emoticons); ii++)
159 list = g_list_prepend (list, &available_emoticons[ii]);
161 return g_list_reverse (list);
164 const EEmoticon *
165 e_emoticon_chooser_lookup_emoticon (const gchar *icon_name)
167 gint ii;
169 g_return_val_if_fail (icon_name && *icon_name, NULL);
171 for (ii = 0; ii < G_N_ELEMENTS (available_emoticons); ii++) {
172 if (strcmp (available_emoticons[ii].icon_name, icon_name) == 0) {
173 return (const EEmoticon *) &available_emoticons[ii];
177 return NULL;