libpurple/smiley-theme.c

Wed, 20 Jun 2018 02:13:44 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Wed, 20 Jun 2018 02:13:44 -0400
changeset 39181
f0cd633d86d4
parent 35778
8ea15abd8688
permissions
-rw-r--r--

prefs: Add binding versions of pref widget functions.

These just bind settings to existing widgets and copy the saved value to
the widget, except for combos which are produced from runtime lists.
Those are populated in a similar way as before.

There are some extra _bind_ words that will probably be dropped once the
other functions are unused.

/* purple
 *
 * 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
 * source distribution.
 *
 * 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
 */

#include "smiley-theme.h"

static PurpleSmileyTheme *current = NULL;

/*******************************************************************************
 * API implementation
 ******************************************************************************/

PurpleSmileyList *
purple_smiley_theme_get_smileys(PurpleSmileyTheme *theme, gpointer ui_data)
{
	PurpleSmileyThemeClass *klass;

	g_return_val_if_fail(PURPLE_IS_SMILEY_THEME(theme), NULL);
	klass = PURPLE_SMILEY_THEME_GET_CLASS(theme);
	g_return_val_if_fail(klass != NULL, NULL);
	g_return_val_if_fail(klass->get_smileys != NULL, NULL);

	return klass->get_smileys(theme, ui_data);
}

void
purple_smiley_theme_set_current(PurpleSmileyTheme *theme)
{
	PurpleSmileyThemeClass *klass;

	g_return_if_fail(theme == NULL || PURPLE_IS_SMILEY_THEME(theme));

	if (theme)
		g_object_ref(theme);
	if (current)
		g_object_unref(current);
	current = theme;

	if (!theme)
		return;
	klass = PURPLE_SMILEY_THEME_GET_CLASS(theme);
	g_return_if_fail(klass != NULL);
	if (klass->activate)
		klass->activate(theme);
}

PurpleSmileyTheme *
purple_smiley_theme_get_current(void)
{
	return current;
}

void
_purple_smiley_theme_uninit(void)
{
	purple_smiley_theme_set_current(NULL);
}


/*******************************************************************************
 * Object stuff
 ******************************************************************************/

GType
purple_smiley_theme_get_type(void)
{
	static GType type = 0;

	if (G_UNLIKELY(type == 0)) {
		static const GTypeInfo info = {
			.class_size = sizeof(PurpleSmileyThemeClass),
			.instance_size = sizeof(PurpleSmileyTheme),
		};

		type = g_type_register_static(G_TYPE_OBJECT,
			"PurpleSmileyTheme", &info, G_TYPE_FLAG_ABSTRACT);
	}

	return type;
}

mercurial