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.
26 #include "e-emoticon-chooser.h"
28 #include <glib/gi18n-lib.h>
30 /* Constant version of EEMoticon. */
33 const gchar
*icon_name
;
34 const gchar
*unicode_character
;
35 const gchar
*text_face
;
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", "π΅", ":-(|)" }
88 static guint signals
[LAST_SIGNAL
];
96 e_emoticon_chooser_default_init (EEmoticonChooserInterface
*interface
)
98 g_object_interface_install_property (
103 "Currently selected emoticon",
107 signals
[ITEM_ACTIVATED
] = g_signal_new (
109 G_TYPE_FROM_INTERFACE (interface
),
111 G_STRUCT_OFFSET (EEmoticonChooserInterface
, item_activated
),
113 g_cclosure_marshal_VOID__VOID
,
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
);
131 e_emoticon_chooser_set_current_emoticon (EEmoticonChooser
*chooser
,
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
);
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);
153 e_emoticon_chooser_get_items (void)
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
);
165 e_emoticon_chooser_lookup_emoticon (const gchar
*icon_name
)
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
];