[glade3/signal-tree-model: 52/53] gladeui: Fix changes due to member sealing



commit e00304af2cffa0dda812312b32d5e71f5e8b62c0
Author: Johannes Schmid <jhs gnome org>
Date:   Wed Jan 5 11:13:56 2011 +0100

    gladeui: Fix changes due to member sealing

 gladeui/glade-app.c           |   12 -----
 gladeui/glade-signal-editor.c |   17 +++---
 gladeui/glade-signal-model.c  |  110 +++++++++++++++++++++++++---------------
 gladeui/glade-signal-model.h  |    4 +-
 gladeui/glade-signal.c        |    2 +-
 gladeui/glade-signal.h        |    6 +-
 gladeui/glade-widget.c        |   17 +++---
 7 files changed, 92 insertions(+), 76 deletions(-)
---
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index f02bdf3..02956b9 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -312,18 +312,6 @@ glade_app_class_init (GladeAppClass * klass)
 	object_class->constructor  = glade_app_constructor;
 	object_class->dispose      = glade_app_dispose;
 	object_class->finalize     = glade_app_finalize;
-	object_class->get_property = glade_app_get_property;
-	object_class->set_property = glade_app_set_property;
-
-	klass->update_ui_signal = glade_app_update_ui_default;
-	klass->show_properties  = NULL;
-	klass->hide_properties  = NULL;
-
-  g_object_class_install_property
-      (object_class, PROP_ACTIVE_PROJECT,
-       g_param_spec_object
-       ("active-project", _("Active Project"),
-        _("The active project"), GLADE_TYPE_PROJECT, G_PARAM_READWRITE));
 
   object_class->constructor = glade_app_constructor;
   object_class->dispose = glade_app_dispose;
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index 60f8737..0284f8f 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2001 Ximian, Inc.
  *
@@ -108,8 +107,7 @@ on_handler_edited (GtkCellRendererText* renderer,
 				new_signal = glade_signal_clone (old_signal);
 
 				/* Change the new signal handler */
-				g_free (new_signal->handler);
-				new_signal->handler = g_strdup(handler);
+				glade_signal_set_handler (new_signal, handler);
 
 				glade_command_change_signal (self->priv->widget, old_signal, new_signal);
 
@@ -193,8 +191,7 @@ on_userdata_edited (GtkCellRendererText* renderer,
 		new_signal = glade_signal_clone (old_signal);
 
 		/* Change the new signal handler */
-		g_free (new_signal->userdata);
-		new_signal->userdata = g_strdup(new_userdata);
+		glade_signal_set_userdata (new_signal, new_userdata);
 
 		glade_command_change_signal (self->priv->widget, old_signal, new_signal);
 
@@ -229,7 +226,8 @@ on_swap_toggled (GtkCellRendererToggle* renderer,
 	new_signal = glade_signal_clone (old_signal);
 
 	/* Change the new signal handler */
-	new_signal->swapped = !gtk_cell_renderer_toggle_get_active (renderer);
+	glade_signal_set_swapped (new_signal,
+	                          !gtk_cell_renderer_toggle_get_active (renderer));
 
 	glade_command_change_signal (self->priv->widget, old_signal, new_signal);
 
@@ -263,7 +261,8 @@ on_after_toggled (GtkCellRendererToggle* renderer,
 	new_signal = glade_signal_clone (old_signal);
 
 	/* Change the new signal handler */
-	new_signal->after = !gtk_cell_renderer_toggle_get_active (renderer);
+	glade_signal_set_after (new_signal, 
+	                        !gtk_cell_renderer_toggle_get_active (renderer));
 
 	glade_command_change_signal (self->priv->widget, old_signal, new_signal);
 
@@ -305,7 +304,7 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
 	if (priv->widget != widget)
 	{	
 		priv->widget = widget;
-		priv->adaptor = widget ? widget->adaptor : NULL;
+		priv->adaptor = widget ? glade_widget_get_adaptor (widget) : NULL;
 		
 		if (priv->widget)
 		{
@@ -322,7 +321,7 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
 
 	priv->model = glade_widget_get_signal_model (widget);
 	gtk_tree_view_set_model (GTK_TREE_VIEW (priv->signal_tree), priv->model);
-	g_object_set (priv->renderer_userdata, "model", glade_app_get_project (), NULL);
+	g_object_set (priv->renderer_userdata, "model", glade_widget_get_project (widget), NULL);
 }
 
 /**
diff --git a/gladeui/glade-signal-model.c b/gladeui/glade-signal-model.c
index 832bd2a..deb0cde 100644
--- a/gladeui/glade-signal-model.c
+++ b/gladeui/glade-signal-model.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 /*
  * glade3
  * Copyright (C) Johannes Schmid 2010 <jhs gnome org>
@@ -35,12 +34,14 @@ struct _GladeSignalModelPrivate
 	gint stamp;
 
 	GHashTable* dummy_signals;
+	GHashTable* signals; /* signals of the widget */
 };
 
 enum
 {
 	PROP_0,
-	PROP_WIDGET
+	PROP_WIDGET,
+	PROP_SIGNALS
 };
 
 static void gtk_tree_model_iface_init (GtkTreeModelIface* iface);
@@ -74,14 +75,16 @@ glade_signal_model_init (GladeSignalModel *object)
 static void
 glade_signal_model_create_widget_list (GladeSignalModel* sig_model)
 {
-	GList* list;
-	for (list = sig_model->priv->widget->adaptor->signals;
+	const GList* list;
+	GladeWidget *widget = sig_model->priv->widget;
+	GladeWidgetAdaptor *adaptor = glade_widget_get_adaptor (widget);
+	for (list = glade_widget_adaptor_get_signals (adaptor);
 	     list != NULL; list = g_list_next (list))
 	{
 		GladeSignalClass *signal = (GladeSignalClass *) list->data;
-		if (!g_list_find_custom (sig_model->priv->widgets, signal->type, (GCompareFunc) strcmp))
+		if (!g_list_find_custom (sig_model->priv->widgets, (gpointer) glade_signal_class_get_type (signal), (GCompareFunc) strcmp))
 		{
-			sig_model->priv->widgets = g_list_prepend (sig_model->priv->widgets, (gpointer) signal->type);
+			sig_model->priv->widgets = g_list_prepend (sig_model->priv->widgets, (gpointer) glade_signal_class_get_type (signal));
 		}
 	}
 	sig_model->priv->widgets = g_list_reverse (sig_model->priv->widgets);
@@ -118,6 +121,9 @@ glade_signal_model_set_property (GObject *object, guint prop_id, const GValue *v
 		                  "change-signal-handler",
 		                  G_CALLBACK (on_glade_signal_model_changed), sig_model);			
 		break;
+	case PROP_SIGNALS:
+		sig_model->priv->signals = g_value_get_pointer (value);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -136,6 +142,9 @@ glade_signal_model_get_property (GObject *object, guint prop_id, GValue *value,
 	case PROP_WIDGET:
 		g_value_set_object (value, sig_model->priv->widget);
 		break;
+	case PROP_SIGNALS:
+		g_value_set_pointer (value, sig_model->priv->signals);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -160,21 +169,30 @@ glade_signal_model_class_init (GladeSignalModelClass *klass)
 	                                                      "The GladeWidget used to query the signals",
 	                                                      GLADE_TYPE_WIDGET,
 	                                                      G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+	g_object_class_install_property (object_class,
+	                                 PROP_SIGNALS,
+	                                 g_param_spec_pointer ("signals",
+	                                                      "A GHashTable containing the widget signals",
+	                                                      "Use to query signals",
+	                                                      G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
 }
 
 /*
  * glade_signal_model_new:
  * @widget: The GladeWidget the signals belong to
+ * @signals: The signals of the #GladeWidget
  *
  * Creates a new GladeSignalModel object to show and edit the
  * signals of a widgets in a GtkTreeView
  */
 
 GtkTreeModel*
-glade_signal_model_new (GladeWidget *widget)
+glade_signal_model_new (GladeWidget *widget,
+                        GHashTable *signals)
 {
 	GObject* object = g_object_new (GLADE_TYPE_SIGNAL_MODEL,
-	                                "widget", widget, NULL);
+	                                "widget", widget, 
+	                                "signals", signals, NULL);
 	return GTK_TREE_MODEL (object);
 }
 
@@ -234,16 +252,19 @@ glade_signal_model_get_dummy_handler (GladeSignalModel* model, GladeSignalClass*
 {
 	GladeSignal* signal;
 
-	signal = g_hash_table_lookup (model->priv->dummy_signals, sig_class->name);
+	signal = g_hash_table_lookup (model->priv->dummy_signals, 
+	                              glade_signal_class_get_name (sig_class));
 
 	if (!signal)
 	{
-		signal = glade_signal_new (sig_class->name,
+		signal = glade_signal_new (glade_signal_class_get_name (sig_class),
 		                           HANDLER_DEFAULT,
 		                           USERDATA_DEFAULT,
 		                           FALSE,
 		                           FALSE);
-		g_hash_table_insert (model->priv->dummy_signals, (gpointer) sig_class->name, signal);
+		g_hash_table_insert (model->priv->dummy_signals, 
+		                     (gpointer) glade_signal_class_get_name (sig_class), 
+		                     signal);
 	}
 	return signal;
 }
@@ -296,15 +317,18 @@ glade_signal_model_create_signal_iter (GladeSignalModel* sig_model,
 }
 
 static GList* glade_signal_model_create_signal_list (GladeSignalModel* sig_model,
-                                                     const gchar* widget)
+                                                     const gchar* widget_type)
 {
 	GList* widget_signals = NULL;
-	GList* signals;
-	for (signals = sig_model->priv->widget->adaptor->signals; signals != NULL;
+	const GList* signals;
+	GladeWidget *widget = sig_model->priv->widget;
+	GladeWidgetAdaptor *adaptor = glade_widget_get_adaptor (widget);
+	for (signals = glade_widget_adaptor_get_signals (adaptor);
+	     signals != NULL;
 	     signals = g_list_next (signals))
 	{
 		GladeSignalClass* sig_class = signals->data;
-		if (g_str_equal (sig_class->type, widget))
+		if (g_str_equal (glade_signal_class_get_type (sig_class), widget_type))
 		{
 			widget_signals = g_list_append (widget_signals, sig_class);
 		}
@@ -324,8 +348,8 @@ glade_signal_model_has_handlers (GladeSignalModel* model, GtkTreeIter* iter)
 
 	if (sig_class)
 	{
-		GPtrArray* handlers = g_hash_table_lookup (model->priv->widget->signals,
-		                                           sig_class->name);
+		GPtrArray* handlers = g_hash_table_lookup (model->priv->signals,
+		                                           glade_signal_class_get_name (sig_class));
 		if (handlers && handlers->len > 0)
 			return TRUE;
 	}
@@ -336,8 +360,8 @@ glade_signal_model_has_handlers (GladeSignalModel* model, GtkTreeIter* iter)
 		for (class_iter = signals; class_iter != NULL; class_iter = g_list_next (class_iter))
 		{
 			sig_class = class_iter->data;
-			GPtrArray* handlers = g_hash_table_lookup (model->priv->widget->signals,
-			                                           sig_class->name);
+			GPtrArray* handlers = g_hash_table_lookup (model->priv->signals,
+			                                           glade_signal_class_get_name (sig_class));
 			if (handlers && handlers->len > 0)
 			{
 				g_list_free (signals);
@@ -352,16 +376,18 @@ glade_signal_model_has_handlers (GladeSignalModel* model, GtkTreeIter* iter)
 static gboolean
 glade_signal_model_iter_for_signal (GladeSignalModel* model, const GladeSignal* signal, GtkTreeIter* iter)
 {
-	GList* list;
-	
-	for (list = model->priv->widget->adaptor->signals;
+	const GList* list;
+	GladeWidget *widget = model->priv->widget;
+	GladeWidgetAdaptor *adaptor = glade_widget_get_adaptor (widget);
+	for (list = glade_widget_adaptor_get_signals (adaptor);
 	     list != NULL; list = g_list_next (list))
 	{
 		GladeSignalClass *sig_class = (GladeSignalClass *) list->data;
-		if (g_str_equal (signal->name, sig_class->name))
+		if (g_str_equal (glade_signal_get_name (signal), 
+		                 glade_signal_class_get_name (sig_class)))
 		{
 			glade_signal_model_create_handler_iter (model,
-			                                        sig_class->type,
+			                                        glade_signal_class_get_type (sig_class),
 			                                        sig_class,
 			                                        signal,
 			                                        iter);
@@ -505,8 +531,8 @@ glade_signal_model_get_iter (GtkTreeModel* model,
 			if (signals)
 			{
 				GladeSignalClass* signal = g_list_nth_data (signals, indices[ITER_SIGNAL]);
-				handlers = g_hash_table_lookup (sig_model->priv->widget->signals,
-					                            signal->name);
+				handlers = g_hash_table_lookup (sig_model->priv->signals,
+					                            glade_signal_class_get_name (signal));
 				if (handlers && indices[ITER_HANDLER] < handlers->len)
 				{
 					GladeSignal* handler =
@@ -568,8 +594,8 @@ glade_signal_model_get_path (GtkTreeModel* model,
 		                       widget);
 		index1 = g_list_index (signals, sig_class);
 
-		handlers = g_hash_table_lookup (sig_model->priv->widget->signals,
-			                            sig_class->name);
+		handlers = g_hash_table_lookup (sig_model->priv->signals,
+			                            glade_signal_class_get_name (sig_class));
 
 		if (handler == glade_signal_model_get_dummy_handler (sig_model,
 		                                                     sig_class))
@@ -638,7 +664,7 @@ glade_signal_model_get_value (GtkTreeModel* model,
 				                           "");
 			else if (widget && sig_class)
 				g_value_set_static_string (value,
-				                           sig_class->name);
+				                           glade_signal_class_get_name (sig_class));
 			else if (widget)
 				g_value_set_static_string (value,
 				                           widget);
@@ -646,7 +672,7 @@ glade_signal_model_get_value (GtkTreeModel* model,
 		case GLADE_SIGNAL_COLUMN_HANDLER:
 			if (widget && sig_class && handler)
 				g_value_set_static_string (value,
-				                           handler->handler);
+				                           glade_signal_get_handler (handler));
 			else 
 				g_value_set_static_string (value,
 				                           "");
@@ -654,9 +680,10 @@ glade_signal_model_get_value (GtkTreeModel* model,
 		case GLADE_SIGNAL_COLUMN_OBJECT:
 			if (widget && sig_class && handler)
 			{
-				if (handler->userdata && strlen (handler->userdata))
+				const gchar* userdata = glade_signal_get_userdata (handler);
+				if (userdata && strlen (userdata))
 					g_value_set_static_string (value,
-					                           handler->userdata);
+					                           userdata);
 				else
 					g_value_set_static_string (value,
 					                           USERDATA_DEFAULT);
@@ -668,7 +695,7 @@ glade_signal_model_get_value (GtkTreeModel* model,
 		case GLADE_SIGNAL_COLUMN_SWAP:
 			if (widget && sig_class && handler)
 				g_value_set_boolean (value,
-				                     handler->swapped);
+				                     glade_signal_get_swapped (handler));
 			else 
 				g_value_set_boolean (value,
 				                     FALSE);
@@ -676,7 +703,7 @@ glade_signal_model_get_value (GtkTreeModel* model,
 		case GLADE_SIGNAL_COLUMN_AFTER:
 			if (widget && sig_class && handler)
 				g_value_set_boolean (value,
-				                     handler->after);
+				                     glade_signal_get_after (handler));
 			else 
 				g_value_set_boolean (value,
 				                     FALSE);
@@ -721,8 +748,8 @@ glade_signal_model_iter_next (GtkTreeModel* model,
 	
 	if (handler)
 	{
-		GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->widget->signals,
-		                                           sig_class->name);
+		GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->signals,
+		                                           glade_signal_class_get_name (sig_class));
 		GladeSignal* dummy = glade_signal_model_get_dummy_handler (sig_model,
 		                                                           sig_class);
 		if (handler == dummy)
@@ -789,8 +816,8 @@ glade_signal_model_iter_n_children (GtkTreeModel* model,
 	else if (sig_class)
 	{
 		gint children = 0;
-		GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->widget->signals,
-		                                           sig_class->name);
+		GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->signals,
+		                                           glade_signal_class_get_name (sig_class));
 		if (handlers)
 			children = handlers->len;
 		return children + 1;
@@ -837,8 +864,8 @@ glade_signal_model_iter_nth_child (GtkTreeModel* model,
 	}
 	else if (sig_class)
 	{
-		GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->widget->signals,
-		                                           sig_class->name);
+		GPtrArray* handlers = g_hash_table_lookup (sig_model->priv->signals,
+		                                           glade_signal_class_get_name (sig_class));
 
 		if (handlers)
 		{
@@ -973,7 +1000,8 @@ glade_signal_model_drag_data_get (GtkTreeDragSource* model,
 		gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
 		                    GLADE_SIGNAL_COLUMN_SIGNAL, &signal, -1);
 
-		dnd_text = g_strdup_printf ("%s:%s:%s", widget, signal->name, signal->handler);
+		dnd_text = g_strdup_printf ("%s:%s:%s", widget, glade_signal_get_name (signal),
+		                            glade_signal_get_handler (signal));
 		g_message ("Sent: %s", dnd_text);
 		gtk_selection_data_set (data,
 		                        gdk_atom_intern_static_string ("application/x-glade-signal"),
diff --git a/gladeui/glade-signal-model.h b/gladeui/glade-signal-model.h
index 504157d..98b2e51 100644
--- a/gladeui/glade-signal-model.h
+++ b/gladeui/glade-signal-model.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 /*
  * glade3
  * Copyright (C) Johannes Schmid 2010 <jhs gnome org>
@@ -64,7 +63,8 @@ struct _GladeSignalModel
 };
 
 GType glade_signal_model_get_type (void) G_GNUC_CONST;
-GtkTreeModel *glade_signal_model_new (GladeWidget *widget);
+GtkTreeModel *glade_signal_model_new (GladeWidget *widget,
+                                      GHashTable *signals);
 
 G_END_DECLS
 
diff --git a/gladeui/glade-signal.c b/gladeui/glade-signal.c
index e580707..a7fdee1 100644
--- a/gladeui/glade-signal.c
+++ b/gladeui/glade-signal.c
@@ -250,7 +250,7 @@ glade_signal_set_name (GladeSignal *signal,
 }
 
 G_CONST_RETURN gchar *
-glade_signal_get_name (GladeSignal *signal)
+glade_signal_get_name (const GladeSignal *signal)
 {
   g_return_val_if_fail (GLADE_IS_SIGNAL (signal), NULL);
 
diff --git a/gladeui/glade-signal.h b/gladeui/glade-signal.h
index 9296e67..bc753cd 100644
--- a/gladeui/glade-signal.h
+++ b/gladeui/glade-signal.h
@@ -17,8 +17,8 @@ GladeSignal          *glade_signal_new                 (const gchar        *name
 							gboolean            swapped);
 GladeSignal          *glade_signal_clone               (const GladeSignal  *signal);
 void                  glade_signal_free                (GladeSignal        *signal);
-gboolean              glade_signal_equal               (GladeSignal        *sig1, 
-							GladeSignal        *sig2);
+gboolean              glade_signal_equal               (const GladeSignal        *sig1, 
+							const GladeSignal        *sig2);
 GladeSignal          *glade_signal_read                (GladeXmlNode       *node);
 void                  glade_signal_write               (GladeSignal        *signal,
 							GladeXmlContext    *context,
@@ -26,7 +26,7 @@ void                  glade_signal_write               (GladeSignal        *sign
 
 void                  glade_signal_set_name            (GladeSignal        *signal,
 							const gchar        *name);
-G_CONST_RETURN gchar *glade_signal_get_name            (GladeSignal        *signal);
+G_CONST_RETURN gchar *glade_signal_get_name            (const GladeSignal        *signal);
 void                  glade_signal_set_handler         (GladeSignal        *signal,
 							const gchar        *handler);
 G_CONST_RETURN gchar *glade_signal_get_handler         (GladeSignal        *signal);
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 7b8e7dd..e3be5f8 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -370,7 +370,7 @@ glade_widget_remove_signal_handler (GladeWidget * widget,
 			g_ptr_array_remove_index (signals, i);
 			if (signals->len == 0)
 			{
-				g_hash_table_remove (widget->signals, tmp_signal_handler->name);
+				g_hash_table_remove (widget->priv->signals, glade_signal_get_name (tmp_signal_handler));
 			}
 			else
 			{
@@ -390,9 +390,9 @@ glade_widget_remove_signal_handler (GladeWidget * widget,
  * Changes a #GladeSignal on @widget 
  */
 void
-glade_widget_change_signal_handler_impl (GladeWidget * widget,
-                                         GladeSignal * old_signal_handler,
-                                         GladeSignal * new_signal_handler)
+glade_widget_change_signal_handler (GladeWidget * widget,
+                                    const GladeSignal * old_signal_handler,
+                                    const GladeSignal * new_signal_handler)
 {
   GPtrArray *signals;
   GladeSignal *signal_handler_iter;
@@ -1024,10 +1024,10 @@ glade_widget_dispose (GObject * object)
       widget->priv->packing_actions = NULL;
     }
 
-  if (widget->signal_model)
+  if (widget->priv->signal_model)
     {
-      g_object_unref (widget->signal_model);
-      widget->signal_model = NULL;
+      g_object_unref (widget->priv->signal_model);
+      widget->priv->signal_model = NULL;
     }
 
   glade_widget_pop_superuser ();
@@ -4464,7 +4464,8 @@ glade_widget_get_signal_model (GladeWidget *widget)
 {
 	if (!widget->priv->signal_model)
 	{
-		widget->priv->signal_model = glade_signal_model_new (widget);
+		widget->priv->signal_model = glade_signal_model_new (widget, 
+                                                         widget->priv->signals);
 	}
 	return widget->priv->signal_model;
 }



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