1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* gtkhtml-face-chooser.c
4 * Copyright (C) 2008 Novell, Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU Lesser General Public
8 * License as published by the Free Software Foundation.
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 GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include "gtkhtml-face-chooser.h"
23 #include <glib/gi18n-lib.h>
25 /* Constant version of GtkhtmlFace. */
28 const gchar
*icon_name
;
29 const gchar
*text_face
;
32 static ConstantFace available_faces
[] = {
33 /* Translators: :-) */
34 { N_("_Smile"), "face-smile", ":-)" },
35 /* Translators: :-( */
36 { N_("S_ad"), "face-sad", ":-(" },
37 /* Translators: ;-) */
38 { N_("_Wink"), "face-wink", ";-)" },
39 /* Translators: :-P */
40 { N_("Ton_gue"), "face-raspberry", ":-P" },
41 /* Translators: :-)) */
42 { N_("Laug_h"), "face-laugh", ":-))" },
43 /* Translators: :-| */
44 { N_("_Plain"), "face-plain", ":-|" },
45 /* Translators: :-! */
46 { N_("Smi_rk"), "face-smirk", ":-!" },
47 /* Translators: :"-) */
48 { N_("_Embarrassed"), "face-embarrassed", ":\"-)" },
49 /* Translators: :-D */
50 { N_("_Big Smile"), "face-smile-big", ":-D" },
51 /* Translators: :-/ */
52 { N_("Uncer_tain"), "face-uncertain", ":-/" },
53 /* Translators: :-O */
54 { N_("S_urprise"), "face-surprise", ":-O" },
55 /* Translators: :-S */
56 { N_("W_orried"), "face-worried", ":-S" },
57 /* Translators: :-* */
58 { N_("_Kiss"), "face-kiss", ":-*" },
59 /* Translators: X-( */
60 { N_("A_ngry"), "face-angry", "X-(" },
61 /* Translators: B-) */
62 { N_("_Cool"), "face-cool", "B-)" },
63 /* Translators: O:-) */
64 { N_("Ange_l"), "face-angel", "O:-)" },
65 /* Translators: :'( */
66 { N_("Cr_ying"), "face-crying", ":'(" },
67 /* Translators: :-Q */
68 { N_("S_ick"), "face-sick", ":-Q" },
69 /* Translators: |-) */
70 { N_("Tire_d"), "face-tired", "|-)" },
71 /* Translators: >:-) */
72 { N_("De_vilish"), "face-devilish", ">:-)" },
73 /* Translators: :-(|) */
74 { N_("_Monkey"), "face-monkey", ":-(|)" }
82 static guint signals
[LAST_SIGNAL
];
85 face_chooser_class_init (GtkhtmlFaceChooserIface
*iface
)
87 g_object_interface_install_property (
92 "Currently selected face",
96 signals
[ITEM_ACTIVATED
] = g_signal_new (
98 G_TYPE_FROM_INTERFACE (iface
),
100 G_STRUCT_OFFSET (GtkhtmlFaceChooserIface
, item_activated
),
102 g_cclosure_marshal_VOID__VOID
,
107 gtkhtml_face_chooser_get_type (void)
109 static GType type
= 0;
111 if (G_UNLIKELY (type
== 0)) {
112 static const GTypeInfo type_info
= {
113 sizeof (GtkhtmlFaceChooserIface
),
114 (GBaseInitFunc
) NULL
,
115 (GBaseFinalizeFunc
) NULL
,
116 (GClassInitFunc
) face_chooser_class_init
,
117 (GClassFinalizeFunc
) NULL
,
118 NULL
, /* class_data */
119 0, /* instance_size */
121 NULL
, /* instance_init */
122 NULL
/* value_table */
125 type
= g_type_register_static (
126 G_TYPE_INTERFACE
, "GtkhtmlFaceChooser", &type_info
, 0);
128 g_type_interface_add_prerequisite (type
, G_TYPE_OBJECT
);
135 gtkhtml_face_chooser_get_current_face (GtkhtmlFaceChooser
*chooser
)
137 GtkhtmlFaceChooserIface
*iface
;
139 g_return_val_if_fail (GTKHTML_IS_FACE_CHOOSER (chooser
), NULL
);
141 iface
= GTKHTML_FACE_CHOOSER_GET_IFACE (chooser
);
142 g_return_val_if_fail (iface
->get_current_face
!= NULL
, NULL
);
144 return iface
->get_current_face (chooser
);
148 gtkhtml_face_chooser_set_current_face (GtkhtmlFaceChooser
*chooser
,
151 GtkhtmlFaceChooserIface
*iface
;
153 g_return_if_fail (GTKHTML_IS_FACE_CHOOSER (chooser
));
155 iface
= GTKHTML_FACE_CHOOSER_GET_IFACE (chooser
);
156 g_return_if_fail (iface
->set_current_face
!= NULL
);
158 iface
->set_current_face (chooser
, face
);
162 gtkhtml_face_chooser_item_activated (GtkhtmlFaceChooser
*chooser
)
164 g_return_if_fail (GTKHTML_IS_FACE_CHOOSER (chooser
));
166 g_signal_emit (chooser
, signals
[ITEM_ACTIVATED
], 0);
170 gtkhtml_face_chooser_get_items (GtkhtmlFaceChooser
*chooser
)
175 for (ii
= 0; ii
< G_N_ELEMENTS (available_faces
); ii
++)
176 list
= g_list_prepend (list
, &available_faces
[ii
]);
178 return g_list_reverse (list
);