[glade3] * gladeui/glade-xml-utils.h: Added "swapped" attribute definition



commit 5def911c59d18adb6fcb333c23112edd99689ab2
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Mar 28 19:17:46 2010 -0400

    	* gladeui/glade-xml-utils.h: Added "swapped" attribute definition
    
    	* gladeui/glade-signal.c: Added "swapped" attribute and read/write from xml, swapped attribute is
    	always saved, if its missing on load and user_data (object) is set, we assume a swapped default.
    
    	* gladeui/glade-signal-editor.c: Allow toggling "swapped" flag of a signal if user data is set.
    
    	* gladeui/glade-widget.c: Account for new signal "swapped" flag when modifying local signals.

 ChangeLog                     |    9 ++
 gladeui/glade-signal-editor.c |  224 +++++++++++++++--------------------------
 gladeui/glade-signal-editor.h |    4 +-
 gladeui/glade-signal.c        |   30 +++++-
 gladeui/glade-signal.h        |    7 +-
 gladeui/glade-widget.c        |   25 +++--
 gladeui/glade-xml-utils.h     |    2 +
 7 files changed, 137 insertions(+), 164 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fc007a6..8a101b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,15 @@
 	Consult glade_util_check_and_warn_scrollable() before executing commands that introduce objects
 	to the project.
 
+	* gladeui/glade-xml-utils.h: Added "swapped" attribute definition
+	
+	* gladeui/glade-signal.c: Added "swapped" attribute and read/write from xml, swapped attribute is 
+	always saved, if its missing on load and user_data (object) is set, we assume a swapped default.
+
+	* gladeui/glade-signal-editor.c: Allow toggling "swapped" flag of a signal if user data is set.
+
+	* gladeui/glade-widget.c: Account for new signal "swapped" flag when modifying local signals.
+
 2010-03-27  Tristan Van Berkom <tvb gnome org>
 
 	* gladeui/glade-marshallers.list, gladeui/glade-placeholder.c: 
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index 2919aad..2dec3cf 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -93,9 +93,9 @@ is_void_userdata (const gchar *user_data)
 }
 
 static void
-glade_signal_editor_after_toggled (GtkCellRendererToggle *cell,
-				   gchar                 *path_str,
-				   gpointer               data)
+glade_signal_editor_after_swapped_toggled (GtkCellRendererToggle *cell,
+					   gchar                 *path_str,
+					   gpointer               data)
 {
 	GladeSignalEditor *editor = (GladeSignalEditor*) data;
 	GtkTreeModel *model = GTK_TREE_MODEL (editor->model);
@@ -107,8 +107,8 @@ glade_signal_editor_after_toggled (GtkCellRendererToggle *cell,
 	gchar     *signal_name;
 	gchar     *handler;
 	gchar     *userdata;
-	gboolean   lookup;
-	gboolean   after;
+	gboolean   swapped, new_swapped;
+	gboolean   after, new_after;
 
 	/* get toggled iter */
 	gtk_tree_model_get_iter (model, &iter, path);
@@ -116,8 +116,9 @@ glade_signal_editor_after_toggled (GtkCellRendererToggle *cell,
 			    GSE_COLUMN_SIGNAL,  &signal_name,
 			    GSE_COLUMN_HANDLER, &handler,
 			    GSE_COLUMN_USERDATA,&userdata,
-			    GSE_COLUMN_LOOKUP,  &lookup,
+			    GSE_COLUMN_SWAPPED, &swapped,
 			    GSE_COLUMN_AFTER,   &after, -1);
+
 	if (signal_name == NULL)
 	{
 		if (!gtk_tree_model_iter_parent (model, &iter_parent, &iter))
@@ -132,74 +133,23 @@ glade_signal_editor_after_toggled (GtkCellRendererToggle *cell,
 		g_free (userdata);
 		userdata = NULL;
 	}
-	
-	old_signal = glade_signal_new (signal_name, handler, userdata, after);
-	new_signal = glade_signal_new (signal_name, handler, userdata, !after);
-
-	glade_command_change_signal (editor->widget, old_signal, new_signal);
-	gtk_tree_store_set (GTK_TREE_STORE (model), &iter, GSE_COLUMN_AFTER, !after, -1);
-
-	glade_signal_free (old_signal);
-	glade_signal_free (new_signal);
-	gtk_tree_path_free (path);
-	g_free (signal_name);
-	g_free (handler);
-	g_free (userdata);
-}
-
-/*
-  glade files do not support symbol names as signal handler user_data arguments
-  yet, so we disabled the lookup column.
-*/
-#define LOOKUP_COLUMN 0
-
-#if LOOKUP_COLUMN
-static void
-glade_signal_editor_lookup_toggled (GtkCellRendererToggle *cell,
-				    gchar                 *path_str,
-				    gpointer               data)
-{
-	GladeSignalEditor *editor = (GladeSignalEditor*) data;
-	GtkTreeModel *model = GTK_TREE_MODEL (editor->model);
-	GtkTreeIter  iter;
-	GtkTreeIter iter_parent;
-	GladeSignal *old_signal;
-	GladeSignal *new_signal;
-	GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
-	gchar     *signal_name;
-	gchar     *handler;
-	gchar     *userdata;
-	gboolean   lookup;
-	gboolean   after;
 
-	/* get toggled iter */
-	gtk_tree_model_get_iter (model, &iter, path);
-	gtk_tree_model_get (model, &iter,
-			    GSE_COLUMN_SIGNAL,  &signal_name,
-			    GSE_COLUMN_HANDLER, &handler,
-			    GSE_COLUMN_USERDATA,&userdata,
-			    GSE_COLUMN_LOOKUP,  &lookup,
-			    GSE_COLUMN_AFTER,   &after, -1);
-	if (signal_name == NULL)
-	{
-		if (!gtk_tree_model_iter_parent (model, &iter_parent, &iter))
-			g_assert (FALSE);
-
-		gtk_tree_model_get (model, &iter_parent, GSE_COLUMN_SIGNAL, &signal_name, -1);
-		g_assert (signal_name != NULL);
-	}
+	new_after = after;
+	new_swapped = swapped;
+	if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "signal-after-cell")))
+		new_after = !after;
+	else
+		new_swapped = !swapped;
 
-	if (is_void_userdata (userdata))
-	{
-		g_free (userdata);
-		userdata = NULL;
-	}
-	
-	old_signal = glade_signal_new (signal_name, handler, userdata, lookup, after);
-	new_signal = glade_signal_new (signal_name, handler, userdata, !lookup, after);
+	old_signal = glade_signal_new (signal_name, handler, userdata, after, swapped);
+	new_signal = glade_signal_new (signal_name, handler, userdata, new_after, new_swapped);
 
 	glade_command_change_signal (editor->widget, old_signal, new_signal);
-	gtk_tree_store_set (GTK_TREE_STORE (model), &iter, GSE_COLUMN_LOOKUP, !lookup, -1);
+
+	gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 
+			    GSE_COLUMN_AFTER, new_after, 
+			    GSE_COLUMN_SWAPPED, new_swapped, 
+			    -1);
 
 	glade_signal_free (old_signal);
 	glade_signal_free (new_signal);
@@ -209,27 +159,6 @@ glade_signal_editor_lookup_toggled (GtkCellRendererToggle *cell,
 	g_free (userdata);
 }
 
-
-static gboolean
-glade_signal_editor_is_valid_identifier (const char *text)
-{
-	char ch;
-
-	if (text == NULL)
-		return FALSE;
-
-	ch = *text++;
-	if (!(ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')))
-		return FALSE;
-
-	while ((ch = *text++) != 0)
-		if (!(ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')))
-			return FALSE;
-
-	return TRUE;
-}
-#endif
-
 static void
 append_slot (GtkTreeModel *model, GtkTreeIter *iter_signal)
 {
@@ -240,8 +169,8 @@ append_slot (GtkTreeModel *model, GtkTreeIter *iter_signal)
 	gtk_tree_store_set (GTK_TREE_STORE (model), &iter_new_slot,
 			    GSE_COLUMN_HANDLER,          _(HANDLER_DEFAULT),
 			    GSE_COLUMN_USERDATA,         _(USERDATA_DEFAULT),
-			    GSE_COLUMN_LOOKUP,           FALSE,
-			    GSE_COLUMN_LOOKUP_VISIBLE,   FALSE,
+			    GSE_COLUMN_SWAPPED,          FALSE,
+			    GSE_COLUMN_SWAPPED_VISIBLE,  FALSE,
 			    GSE_COLUMN_HANDLER_EDITABLE, TRUE,
 			    GSE_COLUMN_USERDATA_EDITABLE,FALSE,
 			    GSE_COLUMN_AFTER,            FALSE,
@@ -267,8 +196,8 @@ move_row (GtkTreeModel *model, GtkTreeIter *from, GtkTreeIter *to)
 	gboolean userdata_slot;
 	gboolean handler_editable;
 	gboolean userdata_editable;
-	gboolean lookup;
-	gboolean lookup_visible;
+	gboolean swapped;
+	gboolean swapped_visible;
 	gboolean bold;
 
 	gtk_tree_model_get (model,                     from,
@@ -280,8 +209,8 @@ move_row (GtkTreeModel *model, GtkTreeIter *from, GtkTreeIter *to)
 			    GSE_COLUMN_HANDLER_EDITABLE,  &handler_editable,
 			    GSE_COLUMN_USERDATA_EDITABLE, &userdata_editable,
 			    GSE_COLUMN_USERDATA_SLOT,     &userdata_slot,
-			    GSE_COLUMN_LOOKUP,            &lookup,
-			    GSE_COLUMN_LOOKUP_VISIBLE,    &lookup_visible,
+			    GSE_COLUMN_SWAPPED,           &swapped,
+			    GSE_COLUMN_SWAPPED_VISIBLE,   &swapped_visible,
 			    GSE_COLUMN_BOLD,              &bold,
 			    -1);
 
@@ -294,8 +223,8 @@ move_row (GtkTreeModel *model, GtkTreeIter *from, GtkTreeIter *to)
 			    GSE_COLUMN_HANDLER_EDITABLE,  handler_editable,
 			    GSE_COLUMN_USERDATA_EDITABLE, userdata_editable,
 			    GSE_COLUMN_USERDATA_SLOT,     userdata_slot,
-			    GSE_COLUMN_LOOKUP,            lookup,
-			    GSE_COLUMN_LOOKUP_VISIBLE,    lookup_visible,
+			    GSE_COLUMN_SWAPPED,           swapped,
+			    GSE_COLUMN_SWAPPED_VISIBLE,   swapped_visible,
 			    GSE_COLUMN_BOLD,              &bold,
 			    -1);
 	g_free (handler);
@@ -343,13 +272,15 @@ glade_signal_editor_handler_editing_done_impl  (GladeSignalEditor *self,
 	gchar *tmp_signal_name;
 	gchar *userdata;
 	GtkTreeIter iter_signal;
-	gboolean  after;
+	gboolean  after, swapped;
 	gboolean is_top_handler;
 
-	gtk_tree_model_get (model,           iter,
+	gtk_tree_model_get (model,               iter,
 			    GSE_COLUMN_SIGNAL,   &tmp_signal_name,
 			    GSE_COLUMN_USERDATA, &userdata,
-			    GSE_COLUMN_AFTER,    &after, -1);
+			    GSE_COLUMN_AFTER,    &after,
+			    GSE_COLUMN_SWAPPED,  &swapped,
+			    -1);
 
 	if (self->is_void_userdata (userdata))
 	{
@@ -373,7 +304,7 @@ glade_signal_editor_handler_editing_done_impl  (GladeSignalEditor *self,
 	if (old_handler == NULL && new_handler)
 	{
 		GladeSignal *new_signal = glade_signal_new (signal_name, new_handler,
-							    NULL, FALSE);
+							    NULL, FALSE, FALSE);
 		glade_command_add_signal (glade_widget, new_signal);
 		glade_signal_free (new_signal);
 		gtk_tree_store_set (GTK_TREE_STORE (model), iter,
@@ -393,7 +324,8 @@ glade_signal_editor_handler_editing_done_impl  (GladeSignalEditor *self,
 			glade_signal_new (signal_name,
 					  old_handler,
 					  userdata, 
-					  after);
+					  after, 
+					  swapped);
 		glade_command_remove_signal (glade_widget, old_signal);
 		glade_signal_free (old_signal);
 
@@ -402,8 +334,8 @@ glade_signal_editor_handler_editing_done_impl  (GladeSignalEditor *self,
 				 GSE_COLUMN_HANDLER,          _(HANDLER_DEFAULT),
 				 GSE_COLUMN_AFTER,            FALSE,
 				 GSE_COLUMN_USERDATA,         _(USERDATA_DEFAULT),
-				 GSE_COLUMN_LOOKUP,           FALSE,
-				 GSE_COLUMN_LOOKUP_VISIBLE,   FALSE,
+				 GSE_COLUMN_SWAPPED,          FALSE,
+				 GSE_COLUMN_SWAPPED_VISIBLE,  FALSE,
 				 GSE_COLUMN_HANDLER_EDITABLE, TRUE,
 				 GSE_COLUMN_USERDATA_EDITABLE,FALSE,
 				 GSE_COLUMN_AFTER_VISIBLE,    FALSE,
@@ -422,13 +354,15 @@ glade_signal_editor_handler_editing_done_impl  (GladeSignalEditor *self,
 			(signal_name,
 			 old_handler,
 			 userdata,
-			 after);
+			 after,
+			 swapped);
 		GladeSignal *new_signal =
 			glade_signal_new
 			(signal_name,
 			 new_handler,
 			 userdata,
-			 after);
+			 after, 
+			 swapped);
 
 		if (glade_signal_equal (old_signal, new_signal) == FALSE)
 			glade_command_change_signal (glade_widget, old_signal, new_signal);
@@ -458,34 +392,36 @@ glade_signal_editor_userdata_editing_done_impl (GladeSignalEditor *self,
 	GtkTreeModel *model = GTK_TREE_MODEL (self->model);
 	GladeWidget  *glade_widget = self->widget;
 	gchar *handler;
-	gboolean after;
+	gboolean after, swapped;
 	GladeSignal *old_signal, *new_signal;
 
-	gtk_tree_model_get (model,           iter,
+	gtk_tree_model_get (model,               iter,
 			    GSE_COLUMN_HANDLER,  &handler,
-			    GSE_COLUMN_AFTER,    &after, -1);
+			    GSE_COLUMN_AFTER,    &after, 
+			    GSE_COLUMN_SWAPPED,  &swapped, 
+			    -1);
 
 	/* We are removing userdata */
 	if (new_userdata == NULL)
 	{
 		gtk_tree_store_set (GTK_TREE_STORE (model), iter,
-				    GSE_COLUMN_USERDATA_SLOT,  TRUE,
-				    GSE_COLUMN_USERDATA,       _(USERDATA_DEFAULT),
-				    GSE_COLUMN_LOOKUP,         FALSE,
-				    GSE_COLUMN_LOOKUP_VISIBLE, FALSE, -1);
+				    GSE_COLUMN_USERDATA_SLOT,   TRUE,
+				    GSE_COLUMN_USERDATA,        _(USERDATA_DEFAULT),
+				    GSE_COLUMN_SWAPPED,         FALSE,
+				    GSE_COLUMN_SWAPPED_VISIBLE, FALSE, -1);
 	}
 	else
 	{
 		gtk_tree_store_set (GTK_TREE_STORE (model), iter,
-			    GSE_COLUMN_USERDATA_SLOT,  FALSE,
-			    GSE_COLUMN_USERDATA,       new_userdata,
-			    GSE_COLUMN_LOOKUP_VISIBLE, TRUE,
-			    -1);
+				    GSE_COLUMN_USERDATA_SLOT,   FALSE,
+				    GSE_COLUMN_USERDATA,        new_userdata,
+				    GSE_COLUMN_SWAPPED_VISIBLE, TRUE,
+				    -1);
 	}
 
-	old_signal = glade_signal_new (signal_name, handler, old_userdata, after);
+	old_signal = glade_signal_new (signal_name, handler, old_userdata, after, swapped);
 
-	new_signal = glade_signal_new (signal_name, handler, new_userdata, after);
+	new_signal = glade_signal_new (signal_name, handler, new_userdata, after, swapped);
 
 	if (glade_signal_equal (old_signal, new_signal) == FALSE)
 		glade_command_change_signal (glade_widget, old_signal, new_signal);
@@ -700,11 +636,10 @@ glade_signal_editor_construct_signals_list (GladeSignalEditor *editor)
 		 G_TYPE_STRING,   /* Handler value      */
 		 G_TYPE_BOOLEAN,  /* After   value      */
 		 G_TYPE_STRING,   /* User data value    */
-		 G_TYPE_BOOLEAN,  /* module lookup string for
-				   * user data */
+		 G_TYPE_BOOLEAN,  /* Swapped value */
 		 G_TYPE_BOOLEAN,  /* Whether userdata is a slot */
-		 G_TYPE_BOOLEAN,  /* Lookup visibility  */
-		 G_TYPE_BOOLEAN,  /* After   visibility */
+		 G_TYPE_BOOLEAN,  /* Swapped visibility  */
+		 G_TYPE_BOOLEAN,  /* After visibility */
 		 G_TYPE_BOOLEAN,  /* Handler editable   */
 		 G_TYPE_BOOLEAN,  /* Userdata editable  */
 		 G_TYPE_BOOLEAN,  /* New slot           */
@@ -761,6 +696,7 @@ glade_signal_editor_construct_signals_list (GladeSignalEditor *editor)
 							 NULL, NULL);
 	}
 
+ 	gtk_tree_view_column_set_expand (editor->handler_column, TRUE);
  	gtk_tree_view_append_column (view, editor->handler_column);
 
 	/************************ userdata column ************************/
@@ -783,7 +719,7 @@ glade_signal_editor_construct_signals_list (GladeSignalEditor *editor)
 	{
 		editor->userdata_column =
 			gtk_tree_view_column_new_with_attributes
-				(_("User data"), editor->userdata_renderer,
+				(_("Object"), editor->userdata_renderer,
 				 "text",           GSE_COLUMN_USERDATA,
 				 "editable",       GSE_COLUMN_USERDATA_EDITABLE, NULL);
 
@@ -792,30 +728,34 @@ glade_signal_editor_construct_signals_list (GladeSignalEditor *editor)
 							 NULL, NULL);
 	}
 
+ 	gtk_tree_view_column_set_expand (editor->userdata_column, TRUE);
  	gtk_tree_view_append_column (view, editor->userdata_column);
 
-#if LOOKUP_COLUMN
-	/************************ lookup column ************************/
+	/************************ swapped column ************************/
  	renderer = gtk_cell_renderer_toggle_new ();
 	g_signal_connect (renderer, "toggled",
-			  G_CALLBACK (glade_signal_editor_lookup_toggled), editor);
+			  G_CALLBACK (glade_signal_editor_after_swapped_toggled), editor);
 	column = gtk_tree_view_column_new_with_attributes
-		(_("Lookup"), renderer,
-		 "active",  GSE_COLUMN_LOOKUP,
-		 "visible", GSE_COLUMN_LOOKUP_VISIBLE, NULL);
+		(_("Swapped"), renderer,
+		 "active",  GSE_COLUMN_SWAPPED,
+		 "visible", GSE_COLUMN_SWAPPED_VISIBLE, NULL);
 
  	gtk_tree_view_append_column (view, column);
-#endif
+
 	/************************ after column ************************/
 	renderer = gtk_cell_renderer_toggle_new ();
 	g_signal_connect (renderer, "toggled",
-			  G_CALLBACK (glade_signal_editor_after_toggled), editor);
+			  G_CALLBACK (glade_signal_editor_after_swapped_toggled), editor);
  	column = gtk_tree_view_column_new_with_attributes
 		(_("After"), renderer,
 		 "active",  GSE_COLUMN_AFTER,
 		 "visible", GSE_COLUMN_AFTER_VISIBLE, NULL);
  	gtk_tree_view_append_column (view, column);
 
+	g_object_set_data (G_OBJECT (renderer), "signal-after-cell",
+			       GINT_TO_POINTER (TRUE));
+
+
 	editor->signals_list = view_widget;
 }
 
@@ -950,8 +890,8 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
 				 GSE_COLUMN_HANDLER,          _(HANDLER_DEFAULT),
 				 GSE_COLUMN_AFTER,            FALSE,
 				 GSE_COLUMN_USERDATA,         _(USERDATA_DEFAULT),
-				 GSE_COLUMN_LOOKUP,           FALSE,
-				 GSE_COLUMN_LOOKUP_VISIBLE,   FALSE,
+				 GSE_COLUMN_SWAPPED,          FALSE,
+				 GSE_COLUMN_SWAPPED_VISIBLE,  FALSE,
 				 GSE_COLUMN_HANDLER_EDITABLE, TRUE,
 				 GSE_COLUMN_USERDATA_EDITABLE,FALSE,
 				 GSE_COLUMN_AFTER_VISIBLE,    FALSE,
@@ -984,8 +924,8 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
 				 GSE_COLUMN_USERDATA,
 				 widget_signal->userdata ?
 				 widget_signal->userdata : _(USERDATA_DEFAULT),
-				 GSE_COLUMN_LOOKUP,             FALSE/* widget_signal->lookup */,
-				 GSE_COLUMN_LOOKUP_VISIBLE,
+				 GSE_COLUMN_SWAPPED,            widget_signal->swapped,
+				 GSE_COLUMN_SWAPPED_VISIBLE,
 				 widget_signal->userdata ?  TRUE : FALSE,
 				 GSE_COLUMN_AFTER_VISIBLE,      TRUE,
 				 GSE_COLUMN_HANDLER_EDITABLE,   TRUE,
@@ -1007,8 +947,8 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
 					 GSE_COLUMN_USERDATA,
 					 widget_signal->userdata  ?
 					 widget_signal->userdata : _(USERDATA_DEFAULT),
-					 GSE_COLUMN_LOOKUP,         FALSE/* widget_signal->lookup */,
-					 GSE_COLUMN_LOOKUP_VISIBLE,
+					 GSE_COLUMN_SWAPPED,            widget_signal->swapped,
+					 GSE_COLUMN_SWAPPED_VISIBLE,
 					 widget_signal->userdata  ? TRUE : FALSE,
 					 GSE_COLUMN_AFTER_VISIBLE,      TRUE,
 					 GSE_COLUMN_HANDLER_EDITABLE,   TRUE,
@@ -1026,8 +966,8 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
 				 GSE_COLUMN_HANDLER,          _(HANDLER_DEFAULT),
 				 GSE_COLUMN_AFTER,            FALSE,
 				 GSE_COLUMN_USERDATA,         _(USERDATA_DEFAULT),
-				 GSE_COLUMN_LOOKUP,           FALSE,
-				 GSE_COLUMN_LOOKUP_VISIBLE,   FALSE,
+				 GSE_COLUMN_SWAPPED,          FALSE,
+				 GSE_COLUMN_SWAPPED_VISIBLE,  FALSE,
 				 GSE_COLUMN_HANDLER_EDITABLE, TRUE,
 				 GSE_COLUMN_USERDATA_EDITABLE,FALSE,
 				 GSE_COLUMN_AFTER_VISIBLE,    FALSE,
diff --git a/gladeui/glade-signal-editor.h b/gladeui/glade-signal-editor.h
index 9cb6b0f..e3c0e7e 100644
--- a/gladeui/glade-signal-editor.h
+++ b/gladeui/glade-signal-editor.h
@@ -24,10 +24,10 @@ enum
 	GSE_COLUMN_HANDLER,
 	GSE_COLUMN_AFTER,
 	GSE_COLUMN_USERDATA,
-	GSE_COLUMN_LOOKUP,
+	GSE_COLUMN_SWAPPED,
 
 	GSE_COLUMN_USERDATA_SLOT,
-	GSE_COLUMN_LOOKUP_VISIBLE,
+	GSE_COLUMN_SWAPPED_VISIBLE,
 	GSE_COLUMN_AFTER_VISIBLE,
 	GSE_COLUMN_HANDLER_EDITABLE,
 	GSE_COLUMN_USERDATA_EDITABLE,
diff --git a/gladeui/glade-signal.c b/gladeui/glade-signal.c
index fa46689..30d758e 100644
--- a/gladeui/glade-signal.c
+++ b/gladeui/glade-signal.c
@@ -35,8 +35,8 @@
  * glade_signal_new:
  * @name: a name for the signal
  * @handler: a handler function for the signal
- * @after: #gboolean indicating whether this handler should be called after
- *         the default handler
+ * @after: whether this handler should be called after the default emission phase
+ * @swapped: whether the handler's user data should be swapped with the emitter instance.
  *
  * Creates a new #GladeSignal with the given parameters.
  *
@@ -45,7 +45,8 @@
 GladeSignal *glade_signal_new (const gchar *name,
 			       const gchar *handler,
 			       const gchar *userdata,
-			       gboolean     after)
+			       gboolean     after,
+			       gboolean     swapped)
 {
 	GladeSignal *signal = g_new0 (GladeSignal, 1);
 
@@ -53,6 +54,7 @@ GladeSignal *glade_signal_new (const gchar *name,
 	signal->handler  = g_strdup (handler);
 	signal->userdata = userdata ? g_strdup (userdata) : NULL;
 	signal->after    = after;
+	signal->swapped  = swapped;
 
 	return signal;
 }
@@ -70,7 +72,7 @@ glade_signal_free (GladeSignal *signal)
 
 	g_free (signal->name);
 	g_free (signal->handler);
-	if (signal->userdata) g_free (signal->userdata);
+	g_free (signal->userdata);
 	g_free (signal);
 }
 
@@ -90,7 +92,8 @@ glade_signal_equal (GladeSignal *sig1, GladeSignal *sig2)
 	
 	if (!strcmp (sig1->name, sig2->name)        &&
 	    !strcmp (sig1->handler, sig2->handler)  &&
-	    sig1->after  == sig2->after)
+	    sig1->after   == sig2->after            &&
+	    sig1->swapped == sig2->swapped)
 	{
 		if ((sig1->userdata == NULL && sig2->userdata == NULL) ||
 		    (sig1->userdata != NULL && sig2->userdata != NULL  &&
@@ -110,10 +113,13 @@ glade_signal_equal (GladeSignal *sig1, GladeSignal *sig2)
 GladeSignal *
 glade_signal_clone (const GladeSignal *signal)
 {
+	g_return_val_if_fail (signal != NULL, NULL);
+
 	return glade_signal_new (signal->name,
 				 signal->handler,
 				 signal->userdata,
-				 signal->after);
+				 signal->after,
+				 signal->swapped);
 
 }
 
@@ -161,6 +167,14 @@ glade_signal_write (GladeSignal       *signal,
 						    GLADE_XML_TAG_AFTER, 
 						    GLADE_XML_TAG_SIGNAL_TRUE);
 
+	/* Always serialize swapped regardless of format (libglade should not complain about this
+	 * and we prefer to not lose data in conversions).
+	 */
+	glade_xml_node_set_property_string (signal_node, 
+					    GLADE_XML_TAG_SWAPPED,
+					    signal->swapped ? 
+					    GLADE_XML_TAG_SIGNAL_TRUE : GLADE_XML_TAG_SIGNAL_FALSE);
+
 	g_free (name);
 }
 
@@ -199,6 +213,10 @@ glade_signal_read (GladeXmlNode *node)
 	signal->handler  = handler;
 	signal->after    = glade_xml_get_property_boolean (node, GLADE_XML_TAG_AFTER, FALSE);
 	signal->userdata = glade_xml_get_property_string (node, GLADE_XML_TAG_OBJECT);
+	signal->swapped  = glade_xml_get_property_boolean (node, GLADE_XML_TAG_SWAPPED, 
+							   /* If a signal specifies an object, its swapped
+							    * by default behaviour in GtkBuilder */
+							   signal->userdata != NULL);
 
 	return signal;
 }
diff --git a/gladeui/glade-signal.h b/gladeui/glade-signal.h
index 4b15c5b..42dd5eb 100644
--- a/gladeui/glade-signal.h
+++ b/gladeui/glade-signal.h
@@ -17,14 +17,17 @@ struct _GladeSignal
 	gchar    *name;         /* Signal name eg "clicked"            */
 	gchar    *handler;      /* Handler function eg "gtk_main_quit" */
 	gchar    *userdata;     /* User data signal handler argument   */
-	gboolean  after;        /* Connect after TRUE or FALSE         */
+	guint8    after : 1;    /* Connect after TRUE or FALSE         */
+	guint8    swapped : 1;  /* Connect swapped TRUE or FALSE (GtkBuilder only) */
 };
 
 
 GladeSignal *glade_signal_new   (const gchar *name,
 				 const gchar *handler,
 				 const gchar *userdata,
-				 gboolean     after);
+				 gboolean     after,
+				 gboolean     swapped);
+
 GladeSignal *glade_signal_clone (const GladeSignal *signal);
 void         glade_signal_free  (GladeSignal *signal);
 
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index dd52762..61b8e77 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -247,7 +247,7 @@ glade_widget_change_signal_handler_impl (GladeWidget *widget,
 					 GladeSignal *new_signal_handler)
 {
 	GPtrArray   *signals;
-	GladeSignal *tmp_signal_handler;
+	GladeSignal *signal_handler_iter;
 	guint        i;
 	
 	g_return_if_fail (GLADE_IS_WIDGET (widget));
@@ -262,30 +262,31 @@ glade_widget_change_signal_handler_impl (GladeWidget *widget,
 
 	for (i = 0; i < signals->len; i++)
 	{
-		tmp_signal_handler = g_ptr_array_index (signals, i);
-		if (glade_signal_equal (tmp_signal_handler, old_signal_handler))
+		signal_handler_iter = g_ptr_array_index (signals, i);
+		if (glade_signal_equal (signal_handler_iter, old_signal_handler))
 		{
 			if (strcmp (old_signal_handler->handler,
 				    new_signal_handler->handler) != 0)
 			{
-				g_free (tmp_signal_handler->handler);
-				tmp_signal_handler->handler =
+				g_free (signal_handler_iter->handler);
+				signal_handler_iter->handler =
 					g_strdup (new_signal_handler->handler);
 			}
 
 			/* Handler */
-			if (tmp_signal_handler->handler)
-				g_free (tmp_signal_handler->handler);
-			tmp_signal_handler->handler =
+			if (signal_handler_iter->handler)
+				g_free (signal_handler_iter->handler);
+			signal_handler_iter->handler =
 				g_strdup (new_signal_handler->handler);
 			
 			/* Object */
-			if (tmp_signal_handler->userdata)
-				g_free (tmp_signal_handler->userdata);
-			tmp_signal_handler->userdata = 
+			if (signal_handler_iter->userdata)
+				g_free (signal_handler_iter->userdata);
+			signal_handler_iter->userdata = 
 				g_strdup (new_signal_handler->userdata);
 			
-			tmp_signal_handler->after  = new_signal_handler->after;
+			signal_handler_iter->after    = new_signal_handler->after;
+			signal_handler_iter->swapped  = new_signal_handler->swapped;
 			break;
 		}
 	}
diff --git a/gladeui/glade-xml-utils.h b/gladeui/glade-xml-utils.h
index 6e890e7..df12ba8 100644
--- a/gladeui/glade-xml-utils.h
+++ b/gladeui/glade-xml-utils.h
@@ -72,6 +72,7 @@ typedef enum {
 #define GLADE_XML_TAG_SIGNAL                      "signal"
 #define GLADE_XML_TAG_HANDLER                     "handler"
 #define GLADE_XML_TAG_AFTER                       "after"
+#define GLADE_XML_TAG_SWAPPED                     "swapped"
 #define GLADE_XML_TAG_OBJECT                      "object"
 #define GLADE_XML_TAG_NAME                        "name"
 #define GLADE_XML_TAG_CHILD                       "child"
@@ -80,6 +81,7 @@ typedef enum {
 #define GLADE_XML_TAG_INTERNAL_CHILD              "internal-child"
 #define GLADE_XML_TAG_I18N_TRUE                   "yes"
 #define GLADE_XML_TAG_SIGNAL_TRUE                 "yes"
+#define GLADE_XML_TAG_SIGNAL_FALSE                "no"
 #define GLADE_XML_TAG_TYPE                        "type"
 #define GLADE_XML_TAG_SOURCES                     "sources"
 #define GLADE_XML_TAG_SOURCE                      "source"



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