* Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * 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 General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * A generic smiley. It can either be a theme smiley, or a custom smiley. static GParamSpec *properties[PROP_LAST]; G_DEFINE_TYPE_WITH_PRIVATE(PurpleSmiley, purple_smiley, PURPLE_TYPE_IMAGE); /******************************************************************************* ******************************************************************************/ _purple_smiley_set_shortcut(PurpleSmiley *smiley, const gchar *shortcut) { PurpleSmileyPrivate *priv = purple_smiley_get_instance_private(smiley); priv->shortcut = g_strdup(shortcut); g_object_notify(G_OBJECT(smiley), "shortcut"); /******************************************************************************* ******************************************************************************/ purple_smiley_init(PurpleSmiley *smiley) { purple_smiley_finalize(GObject *obj) { PurpleSmiley *smiley = PURPLE_SMILEY(obj); PurpleSmileyPrivate *priv = purple_smiley_get_instance_private(smiley); G_OBJECT_CLASS(purple_smiley_parent_class)->finalize(obj); purple_smiley_get_property(GObject *obj, guint param_id, GValue *value, PurpleSmiley *smiley = PURPLE_SMILEY(obj); g_value_set_string(value, purple_smiley_get_shortcut(smiley)); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); purple_smiley_set_property(GObject *obj, guint param_id, const GValue *value, PurpleSmiley *smiley = PURPLE_SMILEY(obj); _purple_smiley_set_shortcut(smiley, g_value_get_string(value)); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); purple_smiley_class_init(PurpleSmileyClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS(klass); obj_class->get_property = purple_smiley_get_property; obj_class->set_property = purple_smiley_set_property; obj_class->finalize = purple_smiley_finalize; properties[PROP_SHORTCUT] = g_param_spec_string( "A non-escaped textual representation of a smiley.", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS g_object_class_install_properties(obj_class, PROP_LAST, properties); /******************************************************************************* ******************************************************************************/ purple_smiley_new(const gchar *shortcut, const gchar *path) PurpleSmiley *smiley = NULL; g_return_val_if_fail(shortcut != NULL, NULL); g_return_val_if_fail(path != NULL, NULL); if(!g_file_get_contents(path, &contents, &length, NULL)) { bytes = g_bytes_new_take(contents, length); purple_smiley_new_from_data(const gchar *shortcut, PurpleSmiley *smiley = NULL; g_return_val_if_fail(shortcut != NULL, NULL); bytes = g_bytes_new(data, length); purple_smiley_new_remote(const gchar *shortcut) { g_return_val_if_fail(shortcut != NULL, NULL); purple_smiley_get_shortcut(PurpleSmiley *smiley) PurpleSmileyPrivate *priv = NULL; g_return_val_if_fail(PURPLE_IS_SMILEY(smiley), NULL); priv = purple_smiley_get_instance_private(smiley);