glade3 r1800 - in trunk: . gladeui



Author: jpu
Date: Thu Apr 17 21:29:33 2008
New Revision: 1800
URL: http://svn.gnome.org/viewvc/glade3?rev=1800&view=rev

Log:
* gladeui/glade-property-class.[ch]: added glade_property_class_compare()
	
* gladeui/glade-editor-property.c: use new compare function in
  glade_editor_property_commit() instead of g_param_values_cmp()
  since GBoxed comparison is not well defined.
  Fixes bug #528511.


Modified:
   trunk/ChangeLog
   trunk/gladeui/glade-editor-property.c
   trunk/gladeui/glade-property-class.c
   trunk/gladeui/glade-property-class.h

Modified: trunk/gladeui/glade-editor-property.c
==============================================================================
--- trunk/gladeui/glade-editor-property.c	(original)
+++ trunk/gladeui/glade-editor-property.c	Thu Apr 17 21:29:33 2008
@@ -101,8 +101,8 @@
 	/* If the value was denied by a verify function, we'll have to
 	 * reload the real value.
 	 */
-	if (g_param_values_cmp (eprop->property->klass->pspec,
-				eprop->property->value, value) != 0)
+	if (glade_property_class_compare (eprop->property->klass,
+					  eprop->property->value, value) != 0)
 		GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->load (eprop, eprop->property);
 }
 

Modified: trunk/gladeui/glade-property-class.c
==============================================================================
--- trunk/gladeui/glade-property-class.c	(original)
+++ trunk/gladeui/glade-property-class.c	Thu Apr 17 21:29:33 2008
@@ -1578,3 +1578,45 @@
 
 	return FALSE;
 }
+
+/**
+ * glade_property_class_compare:
+ * @klass: a #GladePropertyClass
+ * @value1: a GValue of correct type for @klass
+ * @value2: a GValue of correct type for @klass
+ *
+ * Compares value1 with value2 according to @klass.
+ *
+ * Returns: -1, 0 or +1, if value1 is found to be less than,
+ * equal to or greater than value2, respectively.
+ */
+gint
+glade_property_class_compare (GladePropertyClass *klass,
+			      GValue             *value1,
+			      GValue             *value2)
+{
+	gint retval;
+	
+	g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), -1);
+	
+	/* GLib does not know how to compare a boxed real value */
+	if (G_PARAM_SPEC_BOXED (klass->pspec))
+	{
+		gchar *val1, *val2;
+		
+		val1 = glade_property_class_make_string_from_gvalue (klass, value1),
+		val2 = glade_property_class_make_string_from_gvalue (klass, value2);
+
+		if (val1 && val2)
+			retval = strcmp (val1, val2);
+		else
+			retval = val1 - val2;
+		
+		g_free (val1);
+		g_free (val2);
+	}
+	else
+		retval = g_param_values_cmp (klass->pspec, value1, value2);
+	
+	return retval;
+}

Modified: trunk/gladeui/glade-property-class.h
==============================================================================
--- trunk/gladeui/glade-property-class.h	(original)
+++ trunk/gladeui/glade-property-class.h	Thu Apr 17 21:29:33 2008
@@ -214,6 +214,9 @@
 gboolean            glade_property_class_void_value              (GladePropertyClass *klass,
 								  GValue             *value);
 
+gint                glade_property_class_compare                 (GladePropertyClass *klass,
+								  GValue             *value1,
+								  GValue             *value2);
 G_END_DECLS
 
 #endif /* __GLADE_PROPERTY_CLASS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]