/dev/tomkiewicz/new-smileys: 7bc9ddd6f6af: Smiley: make generic ...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Sat Mar 29 11:49:16 EDT 2014
Changeset: 7bc9ddd6f6afc92054ca39c8e1097e127e6e9480
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-03-29 16:49 +0100
Branch: default
URL: https://hg.pidgin.im/dev/tomkiewicz/new-smileys/rev/7bc9ddd6f6af
Description:
Smiley: make generic implementation a bit more complete
diffstat:
libpurple/smiley.c | 27 ++++++++++++++++++---------
libpurple/smiley.h | 14 ++++++++------
2 files changed, 26 insertions(+), 15 deletions(-)
diffs (79 lines):
diff --git a/libpurple/smiley.c b/libpurple/smiley.c
--- a/libpurple/smiley.c
+++ b/libpurple/smiley.c
@@ -60,16 +60,17 @@ static GParamSpec *properties[PROP_LAST]
* API implementation
******************************************************************************/
-void
-purple_smiley_set_shortcut(PurpleSmiley *smiley, const gchar *shortcut)
+PurpleSmiley *
+purple_smiley_new(const gchar *shortcut, const gchar *path)
{
- PurpleSmileyPrivate *priv = PURPLE_SMILEY_GET_PRIVATE(smiley);
+ g_return_val_if_fail(shortcut != NULL, NULL);
+ g_return_val_if_fail(path != NULL, NULL);
- g_return_if_fail(priv != NULL);
-
- g_free(priv->shortcut);
- priv->shortcut = g_strdup(shortcut);
- g_object_notify_by_pspec(G_OBJECT(smiley), properties[PROP_SHORTCUT]);
+ return g_object_new(PURPLE_TYPE_SMILEY,
+ "shortcut", shortcut,
+ "is-ready", TRUE,
+ "path", path,
+ NULL);
}
const gchar *
@@ -178,6 +179,14 @@ purple_smiley_class_init(PurpleSmileyCla
"The text-shortcut for the smiley", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_IS_READY] = g_param_spec_boolean("is-ready", "Is ready",
+ "The full path to the smiley image file", TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_PATH] = g_param_spec_string("path", "Path",
+ "The full path to the smiley image file", NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties(gobj_class, PROP_LAST, properties);
signals[SIG_READY] = g_signal_new("ready", G_OBJECT_CLASS_TYPE(klass),
@@ -199,7 +208,7 @@ purple_smiley_get_type(void)
};
type = g_type_register_static(G_TYPE_OBJECT,
- "PurpleSmiley", &info, G_TYPE_FLAG_ABSTRACT);
+ "PurpleSmiley", &info, 0);
}
return type;
diff --git a/libpurple/smiley.h b/libpurple/smiley.h
--- a/libpurple/smiley.h
+++ b/libpurple/smiley.h
@@ -82,14 +82,16 @@ purple_smiley_get_type(void);
/**************************************************************************/
/**
- * purple_smiley_set_shortcut:
- * @smiley: The smiley.
- * @shortcut: The new shortcut. Should be unique within a smiley set.
+ * purple_smiley_new:
+ * @shortcut: The smiley shortcut.
+ * @path: The image file path.
*
- * Changes the smiley's shortcut.
+ * Creates new shortcut, which is ready to display.
+ *
+ * Returns: The shortcut.
*/
-void
-purple_smiley_set_shortcut(PurpleSmiley *smiley, const gchar *shortcut);
+PurpleSmiley *
+purple_smiley_new(const gchar *shortcut, const gchar *path);
/**
* purple_smiley_get_shortcut:
More information about the Commits
mailing list