pidgin: 0b4ee8e5: Make the current variant a property.

qulogic at pidgin.im qulogic at pidgin.im
Sat Sep 24 17:30:23 EDT 2011


----------------------------------------------------------------------
Revision: 0b4ee8e53b350e4c56a4ec88755eaef374c7256c
Parent:   461ff5d0b22ae38e586cce796e74bb9cf56abcfe
Author:   qulogic at pidgin.im
Date:     09/24/11 17:15:29
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0b4ee8e53b350e4c56a4ec88755eaef374c7256c

Changelog: 

Make the current variant a property.

Changes against parent 461ff5d0b22ae38e586cce796e74bb9cf56abcfe

  patched  pidgin/gtkconv-theme.c

-------------- next part --------------
============================================================
--- pidgin/gtkconv-theme.c	50cff656f86238a21c9b709124ea3a23244f1a29
+++ pidgin/gtkconv-theme.c	a4283a2c9da01c55d09ec8f273e4742029935e03
@@ -37,6 +37,8 @@
 #define PIDGIN_CONV_THEME_GET_PRIVATE(Gobject) \
 	(G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_CONV_THEME, PidginConvThemePrivate))
 
+static void _set_variant(PidginConvTheme *theme, const char *variant);
+
 /******************************************************************************
  * Structs
  *****************************************************************************/
@@ -68,21 +70,24 @@ typedef struct {
 } PidginConvThemePrivate;
 
 /******************************************************************************
- * Globals
- *****************************************************************************/
-
-static GObjectClass *parent_class = NULL;
-
-/******************************************************************************
  * Enums
  *****************************************************************************/
 
 enum {
 	PROP_ZERO = 0,
 	PROP_INFO,
+	PROP_VARIANT,
+	PROP_LAST
 };
 
 /******************************************************************************
+ * Globals
+ *****************************************************************************/
+
+static GObjectClass *parent_class = NULL;
+static GParamSpec *properties[PROP_LAST];
+
+/******************************************************************************
  * GObject Stuff
  *****************************************************************************/
 
@@ -96,6 +101,11 @@ pidgin_conv_theme_get_property(GObject *
 		case PROP_INFO:
 			g_value_set_boxed(value, (gpointer)pidgin_conversation_theme_get_info(theme));
 			break;
+
+		case PROP_VARIANT:
+			g_value_set_string(value, pidgin_conversation_theme_get_variant(theme));
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
 			break;
@@ -112,6 +122,11 @@ pidgin_conv_theme_set_property(GObject *
 		case PROP_INFO:
 			pidgin_conversation_theme_set_info(theme, g_value_get_boxed(value));
 			break;
+
+		case PROP_VARIANT:
+			_set_variant(theme, g_value_get_string(value));
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
 			break;
@@ -176,7 +191,15 @@ pidgin_conv_theme_class_init(PidginConvT
 			G_TYPE_HASH_TABLE,
 			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 	g_object_class_install_property(obj_class, PROP_INFO, pspec);
+	properties[PROP_INFO] = pspec;
 
+	/* VARIANT */
+	pspec = g_param_spec_string("variant", "Variant",
+			"The current variant for this theme",
+			NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+	g_object_class_install_property(obj_class, PROP_VARIANT, pspec);
+	properties[PROP_VARIANT] = pspec;
+
 }
 
 GType
@@ -490,6 +513,28 @@ get_outgoing_next_context_html(PidginCon
 	return priv->outgoing_next_context_html;
 }
 
+static void
+_set_variant(PidginConvTheme *theme, const char *variant)
+{
+	PidginConvThemePrivate *priv;
+	const GValue *val;
+	char *prefname;
+
+	g_return_if_fail(theme != NULL);
+	g_return_if_fail(variant != NULL);
+
+	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
+
+	g_free(priv->variant);
+	priv->variant = g_strdup(variant);
+
+	val = get_key(priv, "CFBundleIdentifier", FALSE);
+	prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversations/themes/%s/variant",
+	                           g_value_get_string(val));
+	purple_prefs_set_string(prefname, variant);
+	g_free(prefname);
+}
+
 /*****************************************************************************
  * Public API functions
  *****************************************************************************/
@@ -628,23 +673,8 @@ pidgin_conversation_theme_set_variant(Pi
 void
 pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant)
 {
-	PidginConvThemePrivate *priv;
-	const GValue *val;
-	char *prefname;
-
-	g_return_if_fail(theme != NULL);
-	g_return_if_fail(variant != NULL);
-
-	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
-
-	g_free(priv->variant);
-	priv->variant = g_strdup(variant);
-
-	val = get_key(priv, "CFBundleIdentifier", FALSE);
-	prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversations/themes/%s/variant",
-	                           g_value_get_string(val));
-	purple_prefs_set_string(prefname, variant);
-	g_free(prefname);
+	_set_variant(theme, variant);
+	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_VARIANT]);
 }
 
 const GList *


More information about the Commits mailing list