Updated Spanish translation
[evolution.git] / e-util / e-emoticon.c
blobcc2fd419ff22ca03c4db50728779cf1ae00da45c
1 /*
2 * e-emoticon.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 #include "e-emoticon.h"
24 #include <gtk/gtk.h>
26 static EEmoticon *
27 emoticon_copy (EEmoticon *emoticon)
29 EEmoticon *copy;
31 copy = g_slice_new (EEmoticon);
32 copy->label = g_strdup (emoticon->label);
33 copy->icon_name = g_strdup (emoticon->icon_name);
34 copy->unicode_character = g_strdup (emoticon->unicode_character);
35 copy->text_face = g_strdup (emoticon->text_face);
37 return copy;
40 static void
41 emoticon_free (EEmoticon *emoticon)
43 g_free (emoticon->label);
44 g_free (emoticon->icon_name);
45 g_free (emoticon->unicode_character);
46 g_free (emoticon->text_face);
47 g_slice_free (EEmoticon, emoticon);
50 GType
51 e_emoticon_get_type (void)
53 static GType type = 0;
55 if (G_UNLIKELY (type == 0))
56 type = g_boxed_type_register_static (
57 "EEmoticon",
58 (GBoxedCopyFunc) emoticon_copy,
59 (GBoxedFreeFunc) emoticon_free);
61 return type;
64 gboolean
65 e_emoticon_equal (EEmoticon *emoticon_a,
66 EEmoticon *emoticon_b)
68 if (((emoticon_a == NULL) && (emoticon_b != NULL)) ||
69 ((emoticon_a != NULL) && (emoticon_b == NULL)))
70 return FALSE;
72 if (emoticon_a == emoticon_b)
73 return TRUE;
75 if (g_strcmp0 (emoticon_a->label, emoticon_b->label) != 0)
76 return FALSE;
78 if (g_strcmp0 (emoticon_a->icon_name, emoticon_b->icon_name) != 0)
79 return FALSE;
81 if (g_strcmp0 (emoticon_a->unicode_character, emoticon_b->unicode_character) != 0)
82 return FALSE;
84 if (g_strcmp0 (emoticon_a->text_face, emoticon_b->text_face) != 0)
85 return FALSE;
87 return TRUE;
90 EEmoticon *
91 e_emoticon_copy (EEmoticon *emoticon)
93 return g_boxed_copy (E_TYPE_EMOTICON, emoticon);
96 void
97 e_emoticon_free (EEmoticon *emoticon)
99 g_boxed_free (E_TYPE_EMOTICON, emoticon);
102 gchar *
103 e_emoticon_get_uri (EEmoticon *emoticon)
105 GtkIconInfo *icon_info;
106 GtkIconTheme *icon_theme;
107 const gchar *filename;
108 gchar *uri = NULL;
110 icon_theme = gtk_icon_theme_get_default ();
111 icon_info = gtk_icon_theme_lookup_icon (
112 icon_theme, emoticon->icon_name, 16, 0);
113 g_return_val_if_fail (icon_info != NULL, NULL);
115 filename = gtk_icon_info_get_filename (icon_info);
116 if (filename != NULL) {
117 uri = g_filename_to_uri (filename, NULL, NULL);
119 gtk_icon_info_free (icon_info);
120 g_return_val_if_fail (uri != NULL, NULL);
122 return uri;