/pidgin/main: d1cc97d667a2: Box PidginSmiley and PidginWebViewSm...
Ankit Vani
a at nevitus.org
Mon Mar 31 05:01:20 EDT 2014
Changeset: d1cc97d667a23fa0f23a1c7740a3b5f5d088ee3a
Author: Ankit Vani <a at nevitus.org>
Date: 2014-03-31 14:22 +0530
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/d1cc97d667a2
Description:
Box PidginSmiley and PidginWebViewSmiley
diffstat:
pidgin/gtksmiley.c | 35 +++++++++++++++++++++++++++++++++++
pidgin/gtksmiley.h | 9 +++++++++
pidgin/gtkwebview.c | 39 +++++++++++++++++++++++++++++++++++++++
pidgin/gtkwebview.h | 13 ++++++++++---
4 files changed, 93 insertions(+), 3 deletions(-)
diffs (166 lines):
diff --git a/pidgin/gtksmiley.c b/pidgin/gtksmiley.c
--- a/pidgin/gtksmiley.c
+++ b/pidgin/gtksmiley.c
@@ -39,6 +39,7 @@
struct _PidginSmiley
{
+ gint box_count;
PurpleSmiley *smiley;
GtkWidget *parent;
GtkWidget *smile;
@@ -82,6 +83,40 @@ pidgin_smiley_destroy(PidginSmiley *smil
g_free(smiley);
}
+static PidginSmiley *
+pidgin_smiley_ref(PidginSmiley *smiley)
+{
+ g_return_val_if_fail(smiley != NULL, NULL);
+
+ smiley->box_count++;
+
+ return smiley;
+}
+
+static void
+pidgin_smiley_unref(PidginSmiley *smiley)
+{
+ g_return_if_fail(smiley != NULL);
+ g_return_if_fail(smiley->box_count >= 0);
+
+ if (!smiley->box_count--)
+ pidgin_smiley_destroy(smiley);
+}
+
+GType
+pidgin_smiley_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("PidginSmiley",
+ (GBoxedCopyFunc)pidgin_smiley_ref,
+ (GBoxedFreeFunc)pidgin_smiley_unref);
+ }
+
+ return type;
+}
+
/******************************************************************************
* PidginWebViewSmileys stuff
*****************************************************************************/
diff --git a/pidgin/gtksmiley.h b/pidgin/gtksmiley.h
--- a/pidgin/gtksmiley.h
+++ b/pidgin/gtksmiley.h
@@ -30,11 +30,20 @@
#include "smiley.h"
+#define PIDGIN_TYPE_SMILEY (pidgin_smiley_get_type())
+
typedef struct _PidginSmiley PidginSmiley;
G_BEGIN_DECLS
/**
+ * pidgin_smiley_get_type:
+ *
+ * Returns: The #GType for the #PidginSmiley boxed structure.
+ */
+GType pidgin_smiley_get_type(void);
+
+/**
* pidgin_smiley_add_to_list:
* @smiley: The smiley to be added.
*
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -86,6 +86,7 @@ typedef struct {
} PidginWebViewProtocol;
struct _PidginWebViewSmiley {
+ gint box_count;
gchar *smile;
gchar *file;
GdkPixbufAnimation *icon;
@@ -674,6 +675,44 @@ pidgin_webview_insert_smiley(PidginWebVi
g_free(unescaped);
}
+/**************************************************************************
+ * PidginWebViewSmiley GBoxed code
+ **************************************************************************/
+
+static PidginWebViewSmiley *
+pidgin_webview_smiley_ref(PidginWebViewSmiley *smiley)
+{
+ g_return_val_if_fail(smiley != NULL, NULL);
+
+ smiley->box_count++;
+
+ return smiley;
+}
+
+static void
+pidgin_webview_smiley_unref(PidginWebViewSmiley *smiley)
+{
+ g_return_if_fail(smiley != NULL);
+ g_return_if_fail(smiley->box_count >= 0);
+
+ if (!smiley->box_count--)
+ pidgin_webview_smiley_destroy(smiley);
+}
+
+GType
+pidgin_webview_smiley_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("PidginWebViewSmiley",
+ (GBoxedCopyFunc)pidgin_webview_smiley_ref,
+ (GBoxedFreeFunc)pidgin_webview_smiley_unref);
+ }
+
+ return type;
+}
+
/******************************************************************************
* Helpers
*****************************************************************************/
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
--- a/pidgin/gtkwebview.h
+++ b/pidgin/gtkwebview.h
@@ -42,6 +42,8 @@
#define PIDGIN_IS_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PIDGIN_TYPE_WEBVIEW))
#define PIDGIN_WEBVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PIDGIN_TYPE_WEBVIEW, PidginWebViewClass))
+#define PIDGIN_TYPE_WEBVIEW_SMILEY (pidgin_webview_smiley_get_type())
+
typedef enum {
PIDGIN_WEBVIEW_BOLD = 1 << 0,
PIDGIN_WEBVIEW_ITALIC = 1 << 1,
@@ -114,13 +116,18 @@ G_BEGIN_DECLS
/**
* pidgin_webview_get_type:
*
- * Returns the GType for a PidginWebView widget
- *
- * Returns: The GType for PidginWebView widget
+ * Returns: The #GType for #PidginWebView widget
*/
GType pidgin_webview_get_type(void);
/**
+ * pidgin_webview_smiley_get_type:
+ *
+ * Returns: The #GType for the #PidginWebViewSmiley boxed structure.
+ */
+GType pidgin_webview_smiley_get_type(void);
+
+/**
* pidgin_webview_new:
* @editable: Whether this PidginWebView will be user-editable
*
More information about the Commits
mailing list