/dev/tomkiewicz/new-smileys: 238e0042049a: PurpleSmileyTheme: ab...

Tomasz Wasilczyk twasilczyk at pidgin.im
Mon Mar 31 07:05:52 EDT 2014


Changeset: 238e0042049a26dcf3496659d75eb06f783c2775
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-03-31 13:05 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/tomkiewicz/new-smileys/rev/238e0042049a

Description:

PurpleSmileyTheme: abstract implementation

diffstat:

 libpurple/Makefile.am    |   2 +
 libpurple/core.c         |   6 +--
 libpurple/smiley-theme.c |  91 ++++++++++++++++++++++++++++++++++++++++++++++++
 libpurple/smiley-theme.h |  90 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 185 insertions(+), 4 deletions(-)

diffs (233 lines):

diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -102,6 +102,7 @@ purple_coresources = \
 	server.c \
 	signals.c \
 	smiley-list.c \
+	smiley-theme.c \
 	smiley.c \
 	dnsquery.c \
 	dnssrv.c\
@@ -178,6 +179,7 @@ purple_coreheaders = \
 	server.h \
 	signals.h \
 	smiley-list.h \
+	smiley-theme.h \
 	smiley.h \
 	dnsquery.h \
 	dnssrv.h \
diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -41,7 +41,7 @@
 #include "proxy.h"
 #include "savedstatuses.h"
 #include "signals.h"
-#include "smiley.h"
+#include "smiley-theme.h"
 #include "sound.h"
 #include "sound-theme-loader.h"
 #include "sslconn.h"
@@ -256,9 +256,7 @@ purple_core_quit(void)
 	purple_plugins_unload(PURPLE_PLUGIN_STANDARD);
 
 	/* Save .xml files, remove signals, etc. */
-#if 0
-	purple_smileys_uninit();
-#endif
+	purple_smiley_theme_uninit();
 	purple_http_uninit();
 	purple_idle_uninit();
 	purple_pounces_uninit();
diff --git a/libpurple/smiley-theme.c b/libpurple/smiley-theme.c
new file mode 100644
--- /dev/null
+++ b/libpurple/smiley-theme.c
@@ -0,0 +1,91 @@
+/* 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"
+
+#include "dbus-maybe.h"
+#include "debug.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)
+{
+	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;
+}
+
+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;
+}
diff --git a/libpurple/smiley-theme.h b/libpurple/smiley-theme.h
new file mode 100644
--- /dev/null
+++ b/libpurple/smiley-theme.h
@@ -0,0 +1,90 @@
+/* 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
+ */
+
+#ifndef _PURPLE_SMILEY_THEME_H_
+#define _PURPLE_SMILEY_THEME_H_
+
+#include <glib-object.h>
+
+#include "smiley.h"
+#include "smiley-list.h"
+
+typedef struct _PurpleSmileyTheme PurpleSmileyTheme;
+typedef struct _PurpleSmileyThemeClass PurpleSmileyThemeClass;
+
+#define PURPLE_TYPE_SMILEY_THEME            (purple_smiley_theme_get_type())
+#define PURPLE_SMILEY_THEME(smiley)         (G_TYPE_CHECK_INSTANCE_CAST((smiley), PURPLE_TYPE_SMILEY_THEME, PurpleSmileyTheme))
+#define PURPLE_SMILEY_THEME_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_SMILEY_THEME, PurpleSmileyThemeClass))
+#define PURPLE_IS_SMILEY_THEME(smiley)      (G_TYPE_CHECK_INSTANCE_TYPE((smiley), PURPLE_TYPE_SMILEY_THEME))
+#define PURPLE_IS_SMILEY_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_SMILEY_THEME))
+#define PURPLE_SMILEY_THEME_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_SMILEY_THEME, PurpleSmileyThemeClass))
+
+/**
+ * PurpleSmileyTheme:
+ *
+ * A list of smileys.
+ */
+struct _PurpleSmileyTheme
+{
+	/*< private >*/
+	GObject parent;
+};
+
+struct _PurpleSmileyThemeClass
+{
+	/*< private >*/
+	GObjectClass parent_class;
+
+	PurpleSmileyList * (*get_smileys)(PurpleSmileyTheme *theme,
+		gpointer ui_data);
+
+	void (*purple_reserved1)(void);
+	void (*purple_reserved2)(void);
+	void (*purple_reserved3)(void);
+	void (*purple_reserved4)(void);
+};
+
+G_BEGIN_DECLS
+
+/**
+ * purple_smiley_theme_get_type:
+ *
+ * Returns: The #GType for a smiley list.
+ */
+GType
+purple_smiley_theme_get_type(void);
+
+PurpleSmileyList *
+purple_smiley_theme_get_smileys(PurpleSmileyTheme *theme, gpointer ui_data);
+
+void
+purple_smiley_theme_set_current(PurpleSmileyTheme *theme);
+
+PurpleSmileyTheme *
+purple_smiley_theme_get_current(void);
+
+void
+purple_smiley_theme_uninit(void);
+
+G_END_DECLS
+
+#endif /* _PURPLE_SMILEY_H_ */
+



More information about the Commits mailing list