[glade3] * gladeui/Makefile.am, gladeui/glade-signal-class.[ch], gladeui/glade-widget-adaptor.c, gladeui/gl



commit a3877e63e4cc1ea16ee58fc276af658bdff5992b
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Wed Jan 5 16:09:54 2011 +0900

    	* gladeui/Makefile.am, gladeui/glade-signal-class.[ch], gladeui/glade-widget-adaptor.c,
    	gladeui/glade-signal-editor.c, plugins/gtk+/glade-accels.c:
    
    	Added glade-signal-class.[ch] as an opaque type.

 ChangeLog                      |    7 ++
 gladeui/Makefile.am            |   39 +++++-----
 gladeui/glade-project.c        |   49 +++++++------
 gladeui/glade-property-class.c |    3 -
 gladeui/glade-property-class.h |    1 -
 gladeui/glade-signal-class.c   |  153 ++++++++++++++++++++++++++++++++++++++++
 gladeui/glade-signal-class.h   |   73 +++++++++++++++++++
 gladeui/glade-signal-editor.c  |   30 ++++----
 gladeui/glade-widget-adaptor.c |  110 ++++++++++++-----------------
 gladeui/glade-widget-adaptor.h |   46 +-----------
 gladeui/glade.h                |    2 +
 plugins/gtk+/glade-accels.c    |   28 ++++----
 12 files changed, 359 insertions(+), 182 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a8edea3..408c3fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-01-05  Tristan Van Berkom <tristanvb openismus com>
+
+	* gladeui/Makefile.am, gladeui/glade-signal-class.[ch], gladeui/glade-widget-adaptor.c,
+	gladeui/glade-signal-editor.c, plugins/gtk+/glade-accels.c:
+
+	Added glade-signal-class.[ch] as an opaque type.
+
 2011-01-04  Johannes Schmid <jhs gnome org>
 
 	* data/gladeui-2.0.pc.in: Fix include paths and library name
diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am
index 484b9aa..dde2b92 100644
--- a/gladeui/Makefile.am
+++ b/gladeui/Makefile.am
@@ -48,45 +48,46 @@ EXTRA_DIST = glade-marshallers.list gladeui.rc.in icon-naming-spec.c glade-previ
 
 # The glade core library
 libgladeui_2_la_SOURCES = \
-	glade-widget-adaptor.c \
 	glade-debug.c \
-	glade-project.c \
-	glade-placeholder.c \
-	glade-inspector.c \
 	glade-xml-utils.c \
+	glade-catalog.c \
+	glade-widget-adaptor.c \
+	glade-widget.c \
+	glade-property-class.c \
+	glade-property.c \
+	glade-signal-class.c \
+	glade-signal.c \
+	glade-editable.c \
+	glade-editor-table.c \
+	glade-editor-property.c \
+	glade-editor.c \
+	glade-base-editor.c \
+	glade-signal-editor.c \
 	glade-palette.c \
+	glade-inspector.c \
 	glade-design-layout.c \
 	glade-design-view.c \
+	glade-id-allocator.c \
+	glade-id-allocator.h \
+	glade-project.c \
+	glade-cursor.c \
+	glade-placeholder.c \
 	glade-named-icon-chooser-dialog.c \
 	glade-named-icon-chooser-dialog.h \
-	glade-cursor.c \
-	glade-catalog.c \
-	glade-property.c \
-	glade-property-class.c \
 	glade-popup.c \
-	glade-widget.c \
-	glade-editor-property.c \
-	glade-editor.c \
 	glade-utils.c \
-	glade-signal.c \
-	glade-signal-editor.c \
-	glade-clipboard.c \
 	glade-command.c \
-	glade-id-allocator.c \
-	glade-id-allocator.h \
 	glade-marshallers.c \
 	glade-accumulators.c \
 	glade-builtins.c \
 	glade-app.c \
-	glade-base-editor.c \
+	glade-clipboard.c \
 	glade-popup.h \
 	glade-marshallers.h \
 	glade-accumulators.h \
 	glade-widget-action.c \
 	glade-name-context.c \
 	glade-displayable-values.c \
-	glade-editable.c \
-	glade-editor-table.c \
 	glade-cell-renderer-icon.c
 
 libgladeui_2_la_CPPFLAGS =  \
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 77774e7..d9dc42e 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -1387,9 +1387,10 @@ static void
 glade_project_introspect_signal_versions (GladeSignal *signal,
                                           VersionData *data)
 {
-  GladeSignalClass *signal_class;
-  gchar *catalog = NULL;
-  gboolean is_gtk_adaptor = FALSE;
+  GladeSignalClass   *signal_class;
+  GladeWidgetAdaptor *adaptor;
+  gchar              *catalog = NULL;
+  gboolean            is_gtk_adaptor = FALSE;
 
   signal_class =
     glade_widget_adaptor_get_signal_class (glade_widget_get_adaptor (data->widget), signal->name);
@@ -1397,22 +1398,20 @@ glade_project_introspect_signal_versions (GladeSignal *signal,
   /*  unknown signal... can it happen ? */
   if (!signal_class) 
     return;
-  g_assert (signal_class->adaptor);
+
+  adaptor = glade_signal_class_get_adaptor (signal_class);
 
   /* Check if the signal comes from a GTK+ widget class */
-  g_object_get (signal_class->adaptor, "catalog", &catalog, NULL);
+  g_object_get (adaptor, "catalog", &catalog, NULL);
   if (strcmp (catalog, "gtk+") == 0)
     is_gtk_adaptor = TRUE;
   g_free (catalog);
 
-  /* Check GTK+ version that signal was introduced */
-  if (is_gtk_adaptor &&
-      (data->major < signal_class->version_since_major ||
-       (data->major == signal_class->version_since_major &&
-	data->minor < signal_class->version_since_minor)))
+  if (is_gtk_adaptor && 
+      !GSC_VERSION_CHECK (signal_class, data->major, data->minor))
     {
-      data->major = signal_class->version_since_major;
-      data->minor = signal_class->version_since_minor;
+      data->major = glade_signal_class_since_major (signal_class);
+      data->minor = glade_signal_class_since_minor (signal_class);
     }
 }
 
@@ -2247,20 +2246,22 @@ glade_project_verify_signal_internal (GladeWidget * widget,
 				      const gchar * path_name,
 				      GString * string, gboolean forwidget)
 {
-  GladeSignalClass *signal_class;
-  gint target_major, target_minor;
-  gchar *catalog;
+  GladeSignalClass   *signal_class;
+  GladeWidgetAdaptor *adaptor;
+  gint                target_major, target_minor;
+  gchar              *catalog;
 
   signal_class =
       glade_widget_adaptor_get_signal_class (glade_widget_get_adaptor (widget), signal->name);
-  //* Cannot verify unknown signal */
+
   if (!signal_class)
     return;
-  g_assert (signal_class->adaptor);
 
-  g_object_get (signal_class->adaptor, "catalog", &catalog, NULL);
+  adaptor = glade_signal_class_get_adaptor (signal_class);
+
+  g_object_get (adaptor, "catalog", &catalog, NULL);
   glade_project_target_version_for_adaptor (glade_widget_get_project (widget),
-                                            signal_class->adaptor,
+                                            adaptor,
                                             &target_major, &target_minor);
 
   if (!GSC_VERSION_CHECK (signal_class, target_major, target_minor))
@@ -2271,8 +2272,8 @@ glade_project_verify_signal_internal (GladeWidget * widget,
 
           warning = g_strdup_printf (SIGNAL_VERSION_CONFLICT_MSGFMT,
                                      catalog,
-                                     signal_class->version_since_major,
-                                     signal_class->version_since_minor,
+				     glade_signal_class_since_major (signal_class),
+				     glade_signal_class_since_minor (signal_class),
                                      catalog, target_major, target_minor);
           glade_signal_set_support_warning (signal, warning);
           g_free (warning);
@@ -2282,10 +2283,10 @@ glade_project_verify_signal_internal (GladeWidget * widget,
                                 SIGNAL_VERSION_CONFLICT_FMT,
                                 path_name,
                                 signal->name,
-                                glade_widget_adaptor_get_title (signal_class->adaptor),
+                                glade_widget_adaptor_get_title (adaptor),
                                 catalog,
-                                signal_class->version_since_major,
-                                signal_class->version_since_minor);
+				glade_signal_class_since_major (signal_class),
+				glade_signal_class_since_minor (signal_class));
     }
   else if (forwidget)
     glade_signal_set_support_warning (signal, NULL);
diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c
index 337a8ad..ba12d56 100644
--- a/gladeui/glade-property-class.c
+++ b/gladeui/glade-property-class.c
@@ -37,7 +37,6 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <gmodule.h>
 #include <glib/gi18n-lib.h>
 
 #include "glade.h"
@@ -1846,7 +1845,6 @@ glade_property_class_parse_specifications (GladePropertyClass * klass,
 /**
  * glade_property_class_update_from_node:
  * @node: the property node
- * @module: a #GModule to lookup symbols from the plugin
  * @object_type: the #GType of the owning object
  * @property_class: a pointer to the property class
  * @domain: the domain to translate catalog strings from
@@ -1859,7 +1857,6 @@ glade_property_class_parse_specifications (GladePropertyClass * klass,
  */
 gboolean
 glade_property_class_update_from_node (GladeXmlNode * node,
-                                       GModule * module,
                                        GType object_type,
                                        GladePropertyClass ** property_class,
                                        const gchar * domain)
diff --git a/gladeui/glade-property-class.h b/gladeui/glade-property-class.h
index 515798d..d592f20 100644
--- a/gladeui/glade-property-class.h
+++ b/gladeui/glade-property-class.h
@@ -142,7 +142,6 @@ void                glade_property_class_get_from_gvalue         (GladePropertyC
 								  ...);
 
 gboolean            glade_property_class_update_from_node        (GladeXmlNode        *node,
-								  GModule             *module,
 								  GType                object_type,
 								  GladePropertyClass **property_class,
 								  const gchar         *domain);
diff --git a/gladeui/glade-signal-class.c b/gladeui/glade-signal-class.c
new file mode 100644
index 0000000..5c3e011
--- /dev/null
+++ b/gladeui/glade-signal-class.c
@@ -0,0 +1,153 @@
+/* glade-signal-class.c
+ *
+ * Copyright (C) 2011 Openismus GmbH
+ *
+ * Authors:
+ *      Tristan Van Berkom <tristanvb openismus com>
+ *
+ * This library is free software; you can redistribute it and/or it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public 
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include <config.h>
+#include "glade-signal-class.h"
+#include "glade-widget-adaptor.h"
+
+struct _GladeSignalClass
+{
+  GladeWidgetAdaptor *adaptor; /* The adaptor that originated this signal.
+				*/
+  GSignalQuery        query;
+
+  guint16             version_since_major; /* Version in which this signal was */
+  guint16             version_since_minor; /* introduced
+					    */
+
+  const gchar        *name;                /* Name of the signal, eg clicked */
+  const gchar        *type;                /* Name of the object class that this signal 
+					    * belongs to eg GtkButton */
+};
+
+GladeSignalClass *
+glade_signal_class_new  (GladeWidgetAdaptor *adaptor,
+			 GType               for_type,
+			 guint               signal_id)
+{
+  GladeSignalClass *class;
+
+  class = g_slice_new0 (GladeSignalClass);
+
+  class->adaptor = adaptor;
+
+  /* Since glib gave us this signal id... it should
+   * exist no matter what.
+   */
+  g_signal_query (signal_id, &(class->query));
+  if (class->query.signal_id != 0)
+    {
+      g_critical ("glade_signal_class_new() called with an invalid signal id");
+
+      glade_signal_class_free (class);
+      return NULL;
+    }
+
+  class->name = (class->query.signal_name);
+  class->type = g_type_name (for_type);
+
+  /* Initialize signal versions to adaptor version */
+  class->version_since_major = GWA_VERSION_SINCE_MAJOR (adaptor);
+  class->version_since_minor = GWA_VERSION_SINCE_MINOR (adaptor);
+
+  return class;
+}
+
+void
+glade_signal_class_free (GladeSignalClass *signal_class)
+{
+  g_slice_free (GladeSignalClass, signal_class);
+}
+
+void
+glade_signal_class_update_from_node (GladeSignalClass   *signal_class,
+				     GladeXmlNode       *node,
+				     const gchar        *domain)
+{
+  g_return_if_fail (signal_class != NULL);
+  g_return_if_fail (node != NULL);
+
+  glade_xml_get_property_version (node, GLADE_TAG_VERSION_SINCE,
+				  &signal_class->version_since_major, 
+				  &signal_class->version_since_minor);
+}
+
+GladeWidgetAdaptor *
+glade_signal_class_get_adaptor (GladeSignalClass *signal_class)
+{
+  g_return_val_if_fail (signal_class != NULL, NULL);
+
+  return signal_class->adaptor;
+}
+
+G_CONST_RETURN gchar *
+glade_signal_class_get_name (GladeSignalClass  *signal_class)
+{
+  g_return_val_if_fail (signal_class != NULL, NULL);
+
+  return signal_class->name;
+}
+
+G_CONST_RETURN gchar *
+glade_signal_class_get_type (GladeSignalClass  *signal_class)
+{
+  g_return_val_if_fail (signal_class != NULL, NULL);
+
+  return signal_class->type;
+}
+
+GSignalFlags
+glade_signal_class_get_flags (GladeSignalClass *signal_class)
+{
+  g_return_val_if_fail (signal_class != NULL, 0);
+
+  return signal_class->query.signal_flags;
+}
+
+void
+glade_signal_class_set_since (GladeSignalClass   *signal_class,
+			      guint16             since_major,
+			      guint16             since_minor)
+{
+  g_return_if_fail (signal_class != NULL);
+
+  signal_class->version_since_major = since_major;
+  signal_class->version_since_minor = since_minor;
+}
+
+guint16
+glade_signal_class_since_major (GladeSignalClass   *signal_class)
+{
+  g_return_val_if_fail (signal_class != NULL, 0);
+
+  return signal_class->version_since_major;
+}
+
+guint16
+glade_signal_class_since_minor (GladeSignalClass   *signal_class)
+{
+  g_return_val_if_fail (signal_class != NULL, 0);
+
+  return signal_class->version_since_minor;
+}
+
diff --git a/gladeui/glade-signal-class.h b/gladeui/glade-signal-class.h
new file mode 100644
index 0000000..ee2b6a9
--- /dev/null
+++ b/gladeui/glade-signal-class.h
@@ -0,0 +1,73 @@
+/* glade-signal-class.h
+ *
+ * Copyright (C) 2011 Openismus GmbH
+ *
+ * Authors:
+ *      Tristan Van Berkom <tristanvb openismus com>
+ *
+ * This library is free software; you can redistribute it and/or it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public 
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _GLADE_SIGNAL_CLASS_H_
+#define _GLADE_SIGNAL_CLASS_H_
+
+#include <glib-object.h>
+#include <gladeui/glade-xml-utils.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GSC_VERSION_CHECK:
+ * @klass: A #GladeSignalClass
+ * @major_version: The major version to check
+ * @minor_version: The minor version to check
+ *
+ * Evaluates to %TRUE if @klass is available in its owning library version- major_verion @minor_version.
+ *
+ */
+#define GSC_VERSION_CHECK(klass, major_version, minor_version)	\
+  ((glade_signal_class_since_major (GLADE_SIGNAL_CLASS (klass)) == major_version) ? \
+   (glade_signal_class_since_minor (GLADE_SIGNAL_CLASS (klass)) <= minor_version) : \
+   (glade_signal_class_since_major (GLADE_SIGNAL_CLASS (klass)) <= major_version))
+
+
+#define GLADE_SIGNAL_CLASS(klass) ((GladeSignalClass *)(klass))
+
+typedef struct _GladeSignalClass GladeSignalClass;
+
+GladeSignalClass     *glade_signal_class_new                      (GladeWidgetAdaptor *adaptor,
+								   GType               for_type,
+								   guint               signal_id);
+void                  glade_signal_class_free                     (GladeSignalClass   *signal_class);
+void                  glade_signal_class_update_from_node         (GladeSignalClass   *signal_class,
+								   GladeXmlNode       *node,
+								   const gchar        *domain);
+
+GladeWidgetAdaptor   *glade_signal_class_get_adaptor              (GladeSignalClass   *signal_class);
+G_CONST_RETURN gchar *glade_signal_class_get_name                 (GladeSignalClass   *signal_class);
+G_CONST_RETURN gchar *glade_signal_class_get_type                 (GladeSignalClass   *signal_class);
+GSignalFlags          glade_signal_class_get_flags                (GladeSignalClass   *signal_class);
+
+void                  glade_signal_class_set_since                (GladeSignalClass   *signal_class,
+								   guint16             since_major,
+								   guint16             since_minor);
+guint16               glade_signal_class_since_major              (GladeSignalClass   *signal_class);
+guint16               glade_signal_class_since_minor              (GladeSignalClass   *signal_class);
+
+
+
+G_END_DECLS
+
+#endif /* _GLADE_SIGNAL_CLASS_H_ */
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index cb019aa..3a1f47e 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -715,11 +715,12 @@ glade_signal_editor_devhelp_cb (GtkCellRenderer * cell,
                                 GladeSignalEditor * editor)
 {
   GladeSignalEditorPrivate *priv = editor->priv;
-  GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
-  GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
-  GtkTreeIter iter;
-  GladeSignalClass *signal_class;
-  gchar *signal, *search, *book = NULL;
+  GladeWidgetAdaptor       *adaptor;
+  GtkTreePath              *path = gtk_tree_path_new_from_string (path_str);
+  GtkTreeModel             *model = GTK_TREE_MODEL (priv->model);
+  GtkTreeIter               iter;
+  GladeSignalClass         *signal_class;
+  gchar                    *signal, *search, *book = NULL;
 
   g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
   gtk_tree_path_free (path);
@@ -731,9 +732,10 @@ glade_signal_editor_devhelp_cb (GtkCellRenderer * cell,
     glade_widget_adaptor_get_signal_class (glade_widget_get_adaptor (priv->widget), signal);
   g_assert (signal_class);
 
-  g_object_get (signal_class->adaptor, "book", &book, NULL);
+  adaptor = glade_signal_class_get_adaptor (signal_class);
+  g_object_get (adaptor, "book", &book, NULL);
 
-  glade_app_search_docs (book, glade_widget_adaptor_get_name (signal_class->adaptor), search);
+  glade_app_search_docs (book, glade_widget_adaptor_get_name (adaptor), search);
 
   g_free (search);
   g_free (book);
@@ -1208,36 +1210,36 @@ glade_signal_editor_load_widget (GladeSignalEditor * editor,
     {
       GladeSignalClass *signal = (GladeSignalClass *) list->data;
       GladeSignal *sig =
-          glade_signal_new (signal->name, NULL, NULL, FALSE, FALSE);
+	glade_signal_new (glade_signal_class_get_name (signal), NULL, NULL, FALSE, FALSE);
 
       /* Check versioning here with a virtual signal */
       glade_project_verify_signal (priv->widget, sig);
 
       /* Add class name that this signal belongs to.
        */
-      if (strcmp (last_type, signal->type))
+      if (strcmp (last_type, glade_signal_class_get_type (signal)))
         {
           gtk_tree_store_append (priv->model, &parent_class, NULL);
           gtk_tree_store_set (priv->model, &parent_class,
-                              GSE_COLUMN_SIGNAL, signal->type,
+                              GSE_COLUMN_SIGNAL, glade_signal_class_get_type (signal),
                               GSE_COLUMN_AFTER_VISIBLE, FALSE,
                               GSE_COLUMN_HANDLER_EDITABLE, FALSE,
                               GSE_COLUMN_USERDATA_EDITABLE, FALSE,
                               GSE_COLUMN_SLOT, FALSE,
                               GSE_COLUMN_BOLD, FALSE,
                               GSE_COLUMN_CONTENT, FALSE, -1);
-          last_type = signal->type;
+          last_type = glade_signal_class_get_type (signal);
         }
 
       gtk_tree_store_append (priv->model, &parent_signal, &parent_class);
-      signals = glade_widget_list_signal_handlers (widget, signal->name);
+      signals = glade_widget_list_signal_handlers (widget, glade_signal_class_get_name (signal));
 
       if (!signals || signals->len == 0)
         {
 
           gtk_tree_store_set
               (priv->model, &parent_signal,
-               GSE_COLUMN_SIGNAL, signal->name,
+               GSE_COLUMN_SIGNAL, glade_signal_class_get_name (signal),
                GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
                GSE_COLUMN_AFTER, FALSE,
                GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
@@ -1272,7 +1274,7 @@ glade_signal_editor_load_widget (GladeSignalEditor * editor,
 
           gtk_tree_store_set
               (priv->model, &parent_signal,
-               GSE_COLUMN_SIGNAL, signal->name,
+               GSE_COLUMN_SIGNAL, glade_signal_class_get_name (signal),
                GSE_COLUMN_HANDLER, widget_signal->handler,
                GSE_COLUMN_AFTER, widget_signal->after,
                GSE_COLUMN_USERDATA,
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index ca2da28..933a688 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -278,63 +278,46 @@ glade_widget_adaptor_get_parent_adaptor (GladeWidgetAdaptor * adaptor)
 }
 
 static gint
-gwa_signal_comp (gconstpointer a, gconstpointer b)
+gwa_signal_comp (gpointer a, gpointer b)
 {
-  const GladeSignalClass *signal_a = a, *signal_b = b;
-  return strcmp (signal_b->query.signal_name, signal_a->query.signal_name);
+  GladeSignalClass *signal_a = a, *signal_b = b;
+
+  return strcmp (glade_signal_class_get_name (signal_b), 
+		 glade_signal_class_get_name (signal_a));
 }
 
 static gint
-gwa_signal_find_comp (gconstpointer a, gconstpointer b)
+gwa_signal_find_comp (gpointer a, gpointer b)
 {
-  const GladeSignalClass *signal = a;
-  const gchar *name = b;
-  return strcmp (name, signal->query.signal_name);
+  GladeSignalClass *signal = a;
+  gchar *name = b;
+  return strcmp (name, glade_signal_class_get_name (signal));
 }
 
 static void
 gwa_add_signals (GladeWidgetAdaptor * adaptor, GList ** signals, GType type)
 {
-  guint count, *sig_ids, num_signals;
+  guint               count, *sig_ids, num_signals;
   GladeWidgetAdaptor *type_adaptor;
-  GladeSignalClass *cur;
-  GList *list = NULL;
+  GladeSignalClass   *signal;
+  GList              *list = NULL;
 
   type_adaptor = glade_widget_adaptor_get_by_type (type);
 
-  if (G_TYPE_IS_INSTANTIATABLE (type) || G_TYPE_IS_INTERFACE (type))
-    {
-      sig_ids = g_signal_list_ids (type, &num_signals);
-
-      for (count = 0; count < num_signals; count++)
-        {
-          cur = g_new0 (GladeSignalClass, 1);
-
-          g_signal_query (sig_ids[count], &(cur->query));
-
-          /* Since glib gave us this signal id... it should
-           * exist no matter what.
-           */
-          g_assert (cur->query.signal_id != 0);
-
-          /* When creating this type, this type is not registered yet,
-           * but we still get the right value here.
-           */
-          cur->adaptor = type_adaptor ? type_adaptor : adaptor;
-          cur->name = (cur->query.signal_name);
-          cur->type = (gchar *) g_type_name (type);
-
-          /* Initialize signal versions to adaptor version */
-          cur->version_since_major = GWA_VERSION_SINCE_MAJOR (cur->adaptor);
-          cur->version_since_minor = GWA_VERSION_SINCE_MINOR (cur->adaptor);
+  sig_ids = g_signal_list_ids (type, &num_signals);
 
-          list = g_list_prepend (list, cur);
-        }
-      g_free (sig_ids);
+  for (count = 0; count < num_signals; count++)
+    {
+      signal = glade_signal_class_new (type_adaptor ? 
+				       type_adaptor : adaptor,
+				       type, sig_ids[count]);
 
-      list = g_list_sort (list, gwa_signal_comp);
-      *signals = g_list_concat (list, *signals);
+      list = g_list_prepend (list, signal);
     }
+  g_free (sig_ids);
+
+  list = g_list_sort (list, (GCompareFunc)gwa_signal_comp);
+  *signals = g_list_concat (list, *signals);
 }
 
 static GList *
@@ -523,23 +506,20 @@ gwa_inherit_signals (GladeWidgetAdaptor * adaptor)
         {
           signal = list->data;
 
-          if ((node = g_list_find_custom
-               (parent_adaptor->priv->signals, signal->name,
-                (GCompareFunc) gwa_signal_find_comp)) != NULL)
+          if ((node = g_list_find_custom (parent_adaptor->priv->signals, 
+					  glade_signal_class_get_name (signal),
+					  (GCompareFunc) gwa_signal_find_comp)) != NULL)
             {
               parent_signal = node->data;
 
               /* Reset versioning in derived catalogs just once */
               if (strcmp (adaptor->priv->catalog,
                           parent_adaptor->priv->catalog))
-                signal->version_since_major = 0;
+		glade_signal_class_set_since (signal, 0, 0);
               else
-                {
-                  signal->version_since_major =
-                      parent_signal->version_since_major;
-                  signal->version_since_minor =
-                      parent_signal->version_since_minor;
-                }
+		glade_signal_class_set_since (signal, 
+					      glade_signal_class_since_major (parent_signal),
+					      glade_signal_class_since_minor (parent_signal));
             }
         }
     }
@@ -1876,8 +1856,10 @@ gwa_update_properties_from_node (GladeWidgetAdaptor * adaptor,
           list = g_list_last (*properties);
         }
 
-      if ((updated = glade_property_class_update_from_node
-           (child, module, adaptor->priv->type, &property_class, domain)) == FALSE)
+      if ((updated = glade_property_class_update_from_node (child, 
+							    adaptor->priv->type, 
+							    &property_class, 
+							    domain)) == FALSE)
         {
           g_warning ("failed to update %s property of %s from xml",
                      id, adaptor->priv->name);
@@ -2145,12 +2127,14 @@ gwa_action_update_from_node (GladeWidgetAdaptor * adaptor,
 }
 
 static void
-gwa_set_signals_from_node (GladeWidgetAdaptor * adaptor, GladeXmlNode * node)
+gwa_set_signals_from_node (GladeWidgetAdaptor *adaptor, 
+			   GladeXmlNode       *node,
+			   const gchar        *domain)
 {
-  GladeXmlNode *child;
+  GladeXmlNode     *child;
   GladeSignalClass *signal;
-  GList *list;
-  gchar *id;
+  GList            *list;
+  gchar            *id;
 
   for (child = glade_xml_node_get_children (node);
        child; child = glade_xml_node_next (child))
@@ -2158,9 +2142,7 @@ gwa_set_signals_from_node (GladeWidgetAdaptor * adaptor, GladeXmlNode * node)
       if (!glade_xml_node_verify (child, GLADE_TAG_SIGNAL))
         continue;
 
-      if (!
-          (id =
-           glade_xml_get_property_string_required (child, GLADE_TAG_ID, NULL)))
+      if (!(id = glade_xml_get_property_string_required (child, GLADE_TAG_ID, NULL)))
         continue;
 
       if ((list =
@@ -2168,15 +2150,13 @@ gwa_set_signals_from_node (GladeWidgetAdaptor * adaptor, GladeXmlNode * node)
                                (GCompareFunc) gwa_signal_find_comp)) != NULL)
         {
           signal = list->data;
-          glade_xml_get_property_version
-              (child, GLADE_TAG_VERSION_SINCE,
-               &signal->version_since_major, &signal->version_since_minor);
+
+	  glade_signal_class_update_from_node (signal, child, domain);
         }
       g_free (id);
     }
 }
 
-
 static gboolean
 gwa_extend_with_node (GladeWidgetAdaptor * adaptor,
                       GladeXmlNode * node,
@@ -2205,7 +2185,7 @@ gwa_extend_with_node (GladeWidgetAdaptor * adaptor,
     gwa_set_packing_defaults_from_node (adaptor, child);
 
   if ((child = glade_xml_search_child (node, GLADE_TAG_SIGNALS)) != NULL)
-    gwa_set_signals_from_node (adaptor, child);
+    gwa_set_signals_from_node (adaptor, child, domain);
 
   if ((child = glade_xml_search_child (node, GLADE_TAG_ACTIONS)) != NULL)
     gwa_action_update_from_node (adaptor, FALSE, child, domain, NULL);
@@ -3976,7 +3956,7 @@ glade_widget_adaptor_get_signal_class (GladeWidgetAdaptor * adaptor,
   for (list = adaptor->priv->signals; list; list = list->next)
     {
       signal = list->data;
-      if (!strcmp (signal->name, name))
+      if (!strcmp (glade_signal_class_get_name (signal), name))
         return signal;
     }
 
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index 20589cc..b08ec66 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -1,9 +1,10 @@
-#ifndef __GLADE_WIDGET_ADAPTOR_H__
-#define __GLADE_WIDGET_ADAPTOR_H__
+#ifndef _GLADE_WIDGET_ADAPTOR_H_
+#define _GLADE_WIDGET_ADAPTOR_H_
 
 #include <gladeui/glade-xml-utils.h>
 #include <gladeui/glade-property-class.h>
 #include <gladeui/glade-editor-property.h>
+#include <gladeui/glade-signal-class.h>
 #include <gladeui/glade-catalog.h>
 #include <gladeui/glade-editable.h>
 #include <glib-object.h>
@@ -139,23 +140,6 @@ typedef struct _GladeWidgetAdaptorClass   GladeWidgetAdaptorClass;
 #define GWA_GET_OCLASS(type) ((GObjectClass*)GWA_GET_CLASS(type))
 
 
-#define GLADE_SIGNAL_CLASS(klass) ((GladeSignalClass *)(klass))
-
-/**
- * GSC_VERSION_CHECK:
- * @klass: A #GladeSignalClass
- * @major_version: The major version to check
- * @minor_version: The minor version to check
- *
- * Evaluates to %TRUE if @klass is available in its owning library version- major_verion @minor_version.
- *
- */
-#define GSC_VERSION_CHECK(klass, major_version, minor_version)	\
-  ((GLADE_SIGNAL_CLASS (klass)->version_since_major == major_version) ? \
-   (GLADE_SIGNAL_CLASS (klass)->version_since_minor <= minor_version) : \
-   (GLADE_SIGNAL_CLASS (klass)->version_since_major <= major_version))
-
-
 #define GLADE_VALID_CREATE_REASON(reason) (reason >= 0 && reason < GLADE_CREATE_REASONS)
 
 /**
@@ -542,28 +526,6 @@ typedef GladeEditable *(* GladeCreateEditableFunc) (GladeWidgetAdaptor   *adapto
 						    GladeEditorPageType   type);
 
 
-/* GladeSignalClass contains all the info we need for a given signal, such as
- * the signal name, and maybe more in the future 
- */
-typedef struct _GladeSignalClass GladeSignalClass; 
-struct _GladeSignalClass
-{
-  GladeWidgetAdaptor *adaptor; /* The adaptor that originated this signal.
-				*/
-
-  GSignalQuery query;
-
-  guint16      version_since_major; /* Version in which this signal was
-				     * introduced
-				     */
-  guint16      version_since_minor;
-
-  const gchar *name;         /* Name of the signal, eg clicked */
-  const gchar *type;         /* Name of the object class that this signal belongs to
-			      * eg GtkButton */
-
-};
-
 /* Note that everything that must be processed at the creation of
  * every instance is managed on the instance structure, and everywhere
  * that we want to take advantage of inheritance is handled in the class
@@ -851,4 +813,4 @@ GladeWidgetAdaptor   *glade_widget_adaptor_get_parent_adaptor (GladeWidgetAdapto
 
 G_END_DECLS
 
-#endif /* __GLADE_WIDGET_ADAPTOR_H__ */
+#endif /* _GLADE_WIDGET_ADAPTOR_H_ */
diff --git a/gladeui/glade.h b/gladeui/glade.h
index a62e07b..7566546 100644
--- a/gladeui/glade.h
+++ b/gladeui/glade.h
@@ -26,6 +26,8 @@
 #include <gladeui/glade-widget.h>
 #include <gladeui/glade-property-class.h>
 #include <gladeui/glade-property.h>
+#include <gladeui/glade-signal-class.h>
+#include <gladeui/glade-signal.h>
 #include <gladeui/glade-project.h>
 #include <gladeui/glade-app.h>
 #include <gladeui/glade-base-editor.h>
diff --git a/plugins/gtk+/glade-accels.c b/plugins/gtk+/glade-accels.c
index 59f32d6..cd2c69f 100644
--- a/plugins/gtk+/glade-accels.c
+++ b/plugins/gtk+/glade-accels.c
@@ -225,26 +225,26 @@ glade_eprop_accel_populate_view (GladeEditorProperty * eprop,
       if (glade_widget_adaptor_get_object_type (adaptor) == GTK_TYPE_ACTION ||
           g_type_is_a (glade_widget_adaptor_get_object_type (adaptor), GTK_TYPE_ACTION))
         {
-          if (g_strcmp0 (sclass->type, "GtkAction") != 0 ||
-              g_strcmp0 (sclass->name, "activate") != 0)
+          if (g_strcmp0 (glade_signal_class_get_type (sclass), "GtkAction") != 0 ||
+              g_strcmp0 (glade_signal_class_get_name (sclass), "activate") != 0)
             continue;
         }
       /* Only action signals have accelerators. */
-      else if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
+      else if ((glade_signal_class_get_flags (sclass) & G_SIGNAL_ACTION) == 0)
         continue;
 
       if (g_list_find_custom (eprop_accel->parent_iters,
-                              sclass->type,
+                              glade_signal_class_get_type (sclass),
                               (GCompareFunc) eprop_find_iter) == NULL)
         {
           gtk_tree_store_append (model, &iter, NULL);
           gtk_tree_store_set (model, &iter,
-                              ACCEL_COLUMN_SIGNAL, sclass->type,
+                              ACCEL_COLUMN_SIGNAL, glade_signal_class_get_type (sclass),
                               ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
                               ACCEL_COLUMN_VISIBLE, FALSE, -1);
 
           parent_tab = g_new0 (GladeEpropIterTab, 1);
-          parent_tab->name = sclass->type;
+          parent_tab->name = glade_signal_class_get_type (sclass);
           parent_tab->iter = gtk_tree_iter_copy (&iter);
 
           eprop_accel->parent_iters =
@@ -262,20 +262,20 @@ glade_eprop_accel_populate_view (GladeEditorProperty * eprop,
       if (glade_widget_adaptor_get_object_type (adaptor) == GTK_TYPE_ACTION ||
           g_type_is_a (glade_widget_adaptor_get_object_type (adaptor), GTK_TYPE_ACTION))
         {
-          if (g_strcmp0 (sclass->type, "GtkAction") != 0 ||
-              g_strcmp0 (sclass->name, "activate") != 0)
+          if (g_strcmp0 (glade_signal_class_get_type (sclass), "GtkAction") != 0 ||
+              g_strcmp0 (glade_signal_class_get_name (sclass), "activate") != 0)
             continue;
         }
       /* Only action signals have accelerators. */
-      else if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
+      else if ((glade_signal_class_get_flags (sclass) & G_SIGNAL_ACTION) == 0)
         continue;
 
       if ((found = g_list_find_custom (eprop_accel->parent_iters,
-                                       sclass->type,
+                                       glade_signal_class_get_type (sclass),
                                        (GCompareFunc) eprop_find_iter)) != NULL)
         {
           parent_tab = found->data;
-          name = g_strdup_printf ("    %s", sclass->name);
+          name = g_strdup_printf ("    %s", glade_signal_class_get_name (sclass));
 
           /* Populate from accelerator list
            */
@@ -283,7 +283,7 @@ glade_eprop_accel_populate_view (GladeEditorProperty * eprop,
             {
               info = l->data;
 
-              if (strcmp (info->signal, sclass->name))
+              if (strcmp (info->signal, glade_signal_class_get_name (sclass)))
                 continue;
 
               accel_text = gtk_accelerator_name (info->key, info->modifiers);
@@ -292,7 +292,7 @@ glade_eprop_accel_populate_view (GladeEditorProperty * eprop,
               gtk_tree_store_set
                   (model, &iter,
                    ACCEL_COLUMN_SIGNAL, name,
-                   ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
+                   ACCEL_COLUMN_REAL_SIGNAL, glade_signal_class_get_name (sclass),
                    ACCEL_COLUMN_TEXT, accel_text,
                    ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
                    ACCEL_COLUMN_STYLE, PANGO_STYLE_NORMAL,
@@ -316,7 +316,7 @@ glade_eprop_accel_populate_view (GladeEditorProperty * eprop,
           gtk_tree_store_set
               (model, &iter,
                ACCEL_COLUMN_SIGNAL, name,
-               ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
+               ACCEL_COLUMN_REAL_SIGNAL, glade_signal_class_get_name (sclass),
                ACCEL_COLUMN_TEXT, _("<choose a key>"),
                ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
                ACCEL_COLUMN_STYLE, PANGO_STYLE_ITALIC,



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