* Pidgin 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
void purple_theme_set_type_string(PurpleTheme *theme, const gchar *type);
/******************************************************************************
*****************************************************************************/
/******************************************************************************
*****************************************************************************/
/******************************************************************************
*****************************************************************************/
static GParamSpec *properties[PROP_LAST];
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(PurpleTheme, purple_theme, G_TYPE_OBJECT);
/******************************************************************************
*****************************************************************************/
purple_theme_get_property(GObject *obj, guint param_id, GValue *value,
PurpleTheme *theme = PURPLE_THEME(obj);
g_value_set_string(value, purple_theme_get_name(theme));
g_value_set_string(value, purple_theme_get_description(theme));
g_value_set_string(value, purple_theme_get_author(theme));
g_value_set_string(value, purple_theme_get_type_string(theme));
g_value_set_string(value, purple_theme_get_dir(theme));
g_value_set_string(value, purple_theme_get_image(theme));
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
purple_theme_set_property(GObject *obj, guint param_id, const GValue *value,
PurpleTheme *theme = PURPLE_THEME(obj);
purple_theme_set_name(theme, g_value_get_string(value));
purple_theme_set_description(theme, g_value_get_string(value));
purple_theme_set_author(theme, g_value_get_string(value));
purple_theme_set_type_string(theme, g_value_get_string(value));
purple_theme_set_dir(theme, g_value_get_string(value));
purple_theme_set_image(theme, g_value_get_string(value));
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
purple_theme_init(PurpleTheme *theme)
purple_theme_finalize(GObject *obj)
PurpleTheme *theme = PURPLE_THEME(obj);
PurpleThemePrivate *priv = purple_theme_get_instance_private(theme);
g_free(priv->description);
G_OBJECT_CLASS(purple_theme_parent_class)->finalize(obj);
purple_theme_class_init(PurpleThemeClass *klass)
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
obj_class->get_property = purple_theme_get_property;
obj_class->set_property = purple_theme_set_property;
obj_class->finalize = purple_theme_finalize;
properties[PROP_NAME] = g_param_spec_string("name", "Name",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
properties[PROP_DESCRIPTION] = g_param_spec_string("description",
"The description of the theme",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
properties[PROP_AUTHOR] = g_param_spec_string("author", "Author",
"The author of the theme",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
/* TYPE STRING (read only) */
properties[PROP_TYPE] = g_param_spec_string("type", "Type",
"The string representing the type of the theme",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
properties[PROP_DIR] = g_param_spec_string("directory", "Directory",
"The directory that contains the theme and all its files",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
properties[PROP_IMAGE] = g_param_spec_string("image", "Image",
"A preview image of the theme",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties(obj_class, PROP_LAST, properties);
/******************************************************************************
*****************************************************************************/
theme_clean_text(const gchar *text)
gchar *clean_text = NULL;
clean_text = g_markup_escape_text(text, -1);
g_strdelimit(clean_text, "\n", ' ');
purple_str_strip_char(clean_text, '\r');
/*****************************************************************************
*****************************************************************************/
purple_theme_get_name(PurpleTheme *theme)
PurpleThemePrivate *priv;
g_return_val_if_fail(PURPLE_IS_THEME(theme), NULL);
priv = purple_theme_get_instance_private(theme);
purple_theme_set_name(PurpleTheme *theme, const gchar *name)
PurpleThemePrivate *priv;
g_return_if_fail(PURPLE_IS_THEME(theme));
priv = purple_theme_get_instance_private(theme);
priv->name = theme_clean_text(name);
g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_NAME]);
purple_theme_get_description(PurpleTheme *theme)
PurpleThemePrivate *priv;
g_return_val_if_fail(PURPLE_IS_THEME(theme), NULL);
priv = purple_theme_get_instance_private(theme);
return priv->description;
purple_theme_set_description(PurpleTheme *theme, const gchar *description)
PurpleThemePrivate *priv;
g_return_if_fail(PURPLE_IS_THEME(theme));
priv = purple_theme_get_instance_private(theme);
g_free(priv->description);
priv->description = theme_clean_text(description);
g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_DESCRIPTION]);
purple_theme_get_author(PurpleTheme *theme)
PurpleThemePrivate *priv;
g_return_val_if_fail(PURPLE_IS_THEME(theme), NULL);
priv = purple_theme_get_instance_private(theme);
purple_theme_set_author(PurpleTheme *theme, const gchar *author)
PurpleThemePrivate *priv;
g_return_if_fail(PURPLE_IS_THEME(theme));
priv = purple_theme_get_instance_private(theme);
priv->author = theme_clean_text(author);
g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_AUTHOR]);
purple_theme_get_type_string(PurpleTheme *theme)
PurpleThemePrivate *priv;
g_return_val_if_fail(PURPLE_IS_THEME(theme), NULL);
priv = purple_theme_get_instance_private(theme);
purple_theme_set_type_string(PurpleTheme *theme, const gchar *type)
PurpleThemePrivate *priv;
g_return_if_fail(PURPLE_IS_THEME(theme));
priv = purple_theme_get_instance_private(theme);
priv->type = g_strdup(type);
g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_TYPE]);
purple_theme_get_dir(PurpleTheme *theme)
PurpleThemePrivate *priv;
g_return_val_if_fail(PURPLE_IS_THEME(theme), NULL);
priv = purple_theme_get_instance_private(theme);
purple_theme_set_dir(PurpleTheme *theme, const gchar *dir)
PurpleThemePrivate *priv;
g_return_if_fail(PURPLE_IS_THEME(theme));
priv = purple_theme_get_instance_private(theme);
priv->dir = g_strdup(dir);
g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_DIR]);
purple_theme_get_image(PurpleTheme *theme)
PurpleThemePrivate *priv;
g_return_val_if_fail(PURPLE_IS_THEME(theme), NULL);
priv = purple_theme_get_instance_private(theme);
purple_theme_get_image_full(PurpleTheme *theme)
const gchar *filename = purple_theme_get_image(theme);
return g_build_filename(purple_theme_get_dir(PURPLE_THEME(theme)), filename, NULL);
purple_theme_set_image(PurpleTheme *theme, const gchar *img)
PurpleThemePrivate *priv;
g_return_if_fail(PURPLE_IS_THEME(theme));
priv = purple_theme_get_instance_private(theme);
priv->img = g_strdup(img);
g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_IMAGE]);