/pidgin/main: a0d221323be1: Box PidginBuddyList, PidginThemeFont...

Ankit Vani a at nevitus.org
Mon Feb 24 04:38:08 EST 2014


Changeset: a0d221323be15fb13d6a5743739472f23a37c87e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2014-02-24 13:51 +0530
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/a0d221323be1

Description:

Box PidginBuddyList, PidginThemeFont, PidginBlistLayout

diffstat:

 pidgin/gtkblist-theme.c |  50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 pidgin/gtkblist-theme.h |  27 +++++++++++++++++--------
 pidgin/gtkblist.c       |  48 +++++++++++++++++++++++++++++++++++++++++++++++
 pidgin/gtkblist.h       |   9 ++++++++
 4 files changed, 124 insertions(+), 10 deletions(-)

diffs (216 lines):

diff --git a/pidgin/gtkblist-theme.c b/pidgin/gtkblist-theme.c
--- a/pidgin/gtkblist-theme.c
+++ b/pidgin/gtkblist-theme.c
@@ -475,6 +475,54 @@ pidgin_blist_theme_get_type (void)
 	return type;
 }
 
+/**************************************************************************
+ * GBoxed Stuff
+ **************************************************************************/
+
+static PidginThemeFont *
+pidgin_theme_font_copy(PidginThemeFont *font)
+{
+	g_return_val_if_fail(font != NULL, NULL);
+
+	return pidgin_theme_font_new(font->font, font->gdkcolor);
+}
+
+GType
+pidgin_theme_font_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PidginThemeFont",
+				(GBoxedCopyFunc)pidgin_theme_font_copy,
+				(GBoxedFreeFunc)pidgin_theme_font_free);
+	}
+
+	return type;
+}
+
+static PidginBlistLayout *
+pidgin_blist_layout_copy(const PidginBlistLayout *layout)
+{
+	g_return_val_if_fail(layout != NULL, NULL);
+
+	return g_memdup(layout, sizeof(PidginBlistLayout));
+}
+
+GType
+pidgin_blist_layout_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PidginBlistLayout",
+				(GBoxedCopyFunc)pidgin_blist_layout_copy,
+				(GBoxedFreeFunc)g_free);
+	}
+
+	return type;
+}
+
 
 /*****************************************************************************
  * Public API functions
@@ -715,7 +763,7 @@ pidgin_blist_theme_set_layout(PidginBlis
 	priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
 
 	g_free(priv->layout);
-	priv->layout = g_memdup(layout, sizeof(PidginBlistLayout));
+	priv->layout = pidgin_blist_layout_copy(layout);
 
 	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_LAYOUT]);
 }
diff --git a/pidgin/gtkblist-theme.h b/pidgin/gtkblist-theme.h
--- a/pidgin/gtkblist-theme.h
+++ b/pidgin/gtkblist-theme.h
@@ -44,6 +44,10 @@ typedef struct _PidginBlistThemeClass   
 #define PIDGIN_IS_BLIST_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIDGIN_TYPE_BLIST_THEME))
 #define PIDGIN_BLIST_THEME_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIDGIN_TYPE_BLIST_THEME, PidginBlistThemeClass))
 
+#define PIDGIN_TYPE_THEME_FONT             (pidgin_theme_font_get_type())
+
+#define PIDGIN_TYPE_BLIST_LAYOUT           (pidgin_blist_layout_get_type())
+
 /**
  * PidginBlistTheme:
  *
@@ -62,15 +66,6 @@ struct _PidginBlistThemeClass
 	PurpleThemeClass parent_class;
 };
 
-#if 0
-typedef struct _PidginThemeFont PidginThemeFont;
-struct _PidginThemeFont
-{
-	const gchar *font;
-	const gchar *color;
-
-};
-#endif
 typedef struct _PidginThemeFont PidginThemeFont;
 
 typedef struct _PidginBlistLayout PidginBlistLayout;
@@ -93,6 +88,13 @@ G_BEGIN_DECLS
 /**************************************************************************/
 
 /**
+ * pidgin_theme_font_get_type:
+ *
+ * Returns: The #GType for the #PidginThemeFont boxed structure.
+ */
+GType pidgin_theme_font_get_type(void);
+
+/**
  * pidgin_theme_font_new:
  * @face:  The font face
  * @color: The color of the font
@@ -170,6 +172,13 @@ const gchar * pidgin_theme_font_get_colo
  */
 GType pidgin_blist_theme_get_type(void);
 
+/**
+ * pidgin_blist_layout_get_type:
+ *
+ * Returns: The #GType for the #PidginBlistLayout boxed structure.
+ */
+GType pidgin_blist_layout_get_type(void);
+
 /* get methods */
 
 /**
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -105,6 +105,9 @@ typedef struct
 
 typedef struct
 {
+	/* GBoxed reference count */
+	int box_count;
+
 	/* Used to hold error minidialogs.  Gets packed
 	 * inside PidginBuddyList.error_buttons
 	 */
@@ -4881,6 +4884,51 @@ conversation_created_cb(PurpleConversati
 	}
 }
 
+/**************************************************************************
+ * GTK Buddy list GBoxed code
+ **************************************************************************/
+static PidginBuddyList *
+pidgin_buddy_list_ref(PidginBuddyList *gtkblist)
+{
+	PidginBuddyListPrivate *priv;
+
+	g_return_val_if_fail(gtkblist != NULL, NULL);
+
+	priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist);
+	priv->box_count++;
+
+	return gtkblist;
+}
+
+static void
+pidgin_buddy_list_unref(PidginBuddyList *gtkblist)
+{
+	PidginBuddyListPrivate *priv;
+
+	g_return_if_fail(gtkblist != NULL);
+
+	priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist);
+
+	g_return_if_fail(priv->box_count >= 0);
+
+	if (!priv->box_count--)
+		purple_core_quit();
+}
+
+GType
+pidgin_buddy_list_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PidginBuddyList",
+				(GBoxedCopyFunc)pidgin_buddy_list_ref,
+				(GBoxedFreeFunc)pidgin_buddy_list_unref);
+	}
+
+	return type;
+}
+
 /**********************************************************************************
  * Public API Functions                                                           *
  **********************************************************************************/
diff --git a/pidgin/gtkblist.h b/pidgin/gtkblist.h
--- a/pidgin/gtkblist.h
+++ b/pidgin/gtkblist.h
@@ -29,6 +29,8 @@
  * @see_also: <link linkend="chapter-signals-gtkblist">Buddy List signals</link>
  */
 
+#define PIDGIN_TYPE_BUDDY_LIST (pidgin_buddy_list_get_type())
+
 typedef struct _PidginBuddyList PidginBuddyList;
 
 enum {
@@ -157,6 +159,13 @@ G_BEGIN_DECLS
  **************************************************************************/
 
 /**
+ * pidgin_buddy_list_get_type:
+ *
+ * Returns: The #GType for the #PidginBuddyList boxed structure.
+ */
+GType pidgin_buddy_list_get_type(void);
+
+/**
  * pidgin_blist_get_handle:
  *
  * Get the handle for the GTK+ blist system.



More information about the Commits mailing list