glade3 r2032 - in trunk: . gladeui plugins/gtk+
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r2032 - in trunk: . gladeui plugins/gtk+
- Date: Sat, 15 Nov 2008 22:38:48 +0000 (UTC)
Author: tvb
Date: Sat Nov 15 22:38:48 2008
New Revision: 2032
URL: http://svn.gnome.org/viewvc/glade3?rev=2032&view=rev
Log:
* gladeui/glade-widget-adaptor.[ch], gladeui/glade-xml-utils.h: Added
new backend ->depends() vfunc to determine toplevel dependancies (for
glade file output ordering).
* gladeui/glade-project.[ch]:
- Sort dependancies using glade_widget_adaptor_depends()
* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c:
- Added ->depends() func for GtkWidget and GtkSizeGroup
Modified:
trunk/ChangeLog
trunk/gladeui/glade-project.c
trunk/gladeui/glade-widget-adaptor.c
trunk/gladeui/glade-widget-adaptor.h
trunk/gladeui/glade-xml-utils.h
trunk/plugins/gtk+/glade-gtk.c
trunk/plugins/gtk+/gtk+.xml.in
Modified: trunk/gladeui/glade-project.c
==============================================================================
--- trunk/gladeui/glade-project.c (original)
+++ trunk/gladeui/glade-project.c Sat Nov 15 22:38:48 2008
@@ -2302,7 +2302,21 @@
g_free (new_name);
}
+static gint
+sort_project_dependancies (GObject *a, GObject *b)
+{
+ GladeWidget *ga, *gb;
+
+ ga = glade_widget_get_from_gobject (a);
+ gb = glade_widget_get_from_gobject (b);
+ if (glade_widget_adaptor_depends (ga->adaptor, ga, gb))
+ return 1;
+ else if (glade_widget_adaptor_depends (gb->adaptor, gb, ga))
+ return -1;
+ else
+ return 1;
+}
/**
* glade_project_add_object:
@@ -2376,7 +2390,11 @@
glade_widget_set_project (gwidget, (gpointer)project);
- project->priv->objects = g_list_append (project->priv->objects, g_object_ref (object));
+ if (!gwidget->parent)
+ project->priv->objects = g_list_insert_sorted (project->priv->objects, g_object_ref (object),
+ (GCompareFunc)sort_project_dependancies);
+ else
+ project->priv->objects = g_list_append (project->priv->objects, g_object_ref (object));
g_signal_emit (G_OBJECT (project),
glade_project_signals [ADD_WIDGET],
Modified: trunk/gladeui/glade-widget-adaptor.c
==============================================================================
--- trunk/gladeui/glade-widget-adaptor.c (original)
+++ trunk/gladeui/glade-widget-adaptor.c Sat Nov 15 22:38:48 2008
@@ -845,6 +845,14 @@
adaptor->name, action_id);
}
+static gboolean
+glade_widget_adaptor_object_depends (GladeWidgetAdaptor *adaptor,
+ GladeWidget *widget,
+ GladeWidget *another)
+{
+ return FALSE;
+}
+
static void
glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor *adaptor,
GladeWidget *widget,
@@ -1179,6 +1187,7 @@
adaptor_class->action_activate = glade_widget_adaptor_object_action_activate;
adaptor_class->child_action_activate= glade_widget_adaptor_object_child_action_activate;
adaptor_class->action_submenu = NULL;
+ adaptor_class->depends = glade_widget_adaptor_object_depends;
adaptor_class->read_widget = glade_widget_adaptor_object_read_widget;
adaptor_class->write_widget = glade_widget_adaptor_object_write_widget;
adaptor_class->read_child = glade_widget_adaptor_object_read_child;
@@ -1436,6 +1445,11 @@
GLADE_TAG_ACTION_SUBMENU_FUNCTION,
&symbol))
klass->action_submenu = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_DEPENDS_FUNCTION,
+ &symbol))
+ klass->depends = symbol;
if (glade_xml_load_sym_from_node (node, module,
GLADE_TAG_READ_WIDGET_FUNCTION,
@@ -3378,6 +3392,30 @@
}
/**
+ * glade_widget_adaptor_depends:
+ * @adaptor: A #GladeWidgetAdaptor
+ * @widget: A #GladeWidget of the adaptor
+ * @another: another #GladeWidget
+ *
+ * Checks whether @widget depends on @another to be placed earlier in
+ * the glade file.
+ *
+ * Returns: whether @widget depends on @another being parsed first in
+ * the resulting glade file.
+ */
+gboolean
+glade_widget_adaptor_depends (GladeWidgetAdaptor *adaptor,
+ GladeWidget *widget,
+ GladeWidget *another)
+{
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (another), FALSE);
+
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->depends (adaptor, widget, another);
+}
+
+/**
* glade_widget_adaptor_read_widget:
* @adaptor: A #GladeWidgetAdaptor
* @widget: The #GladeWidget
Modified: trunk/gladeui/glade-widget-adaptor.h
==============================================================================
--- trunk/gladeui/glade-widget-adaptor.h (original)
+++ trunk/gladeui/glade-widget-adaptor.h Sat Nov 15 22:38:48 2008
@@ -417,6 +417,22 @@
const gchar *action_path);
+/**
+ * GladeDependsFunc:
+ * @adaptor: A #GladeWidgetAdaptor
+ * @widget: A #GladeWidget of the adaptor
+ * @another: another #GladeWidget
+ *
+ * Checks whether @widget depends on @another to be placed earlier in
+ * the glade file.
+ *
+ * Returns: whether @widget depends on @another being parsed first in
+ * the resulting glade file.
+ */
+typedef gboolean (* GladeDependsFunc) (GladeWidgetAdaptor *adaptor,
+ GladeWidget *widget,
+ GladeWidget *another);
+
/**
@@ -669,6 +685,8 @@
GladeActionSubmenuFunc action_submenu; /* Delagate function to create dynamic submenus */
/* in action menus. */
+
+ GladeDependsFunc depends; /* Periodically sort widgets in the project */
GladeReadWidgetFunc read_widget; /* Reads widget attributes from xml */
@@ -841,6 +859,10 @@
GObject *object,
const gchar *action_path);
+gboolean glade_widget_adaptor_depends (GladeWidgetAdaptor *adaptor,
+ GladeWidget *widget,
+ GladeWidget *another);
+
void glade_widget_adaptor_read_widget (GladeWidgetAdaptor *adaptor,
GladeWidget *widget,
Modified: trunk/gladeui/glade-xml-utils.h
==============================================================================
--- trunk/gladeui/glade-xml-utils.h (original)
+++ trunk/gladeui/glade-xml-utils.h Sat Nov 15 22:38:48 2008
@@ -131,6 +131,7 @@
#define GLADE_TAG_ACTION_ACTIVATE_FUNCTION "action-activate-function"
#define GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION "child-action-activate-function"
#define GLADE_TAG_ACTION_SUBMENU_FUNCTION "action-submenu-function"
+#define GLADE_TAG_DEPENDS_FUNCTION "depends-function"
#define GLADE_TAG_READ_WIDGET_FUNCTION "read-widget-function"
#define GLADE_TAG_WRITE_WIDGET_FUNCTION "write-widget-function"
#define GLADE_TAG_READ_CHILD_FUNCTION "read-child-function"
Modified: trunk/plugins/gtk+/glade-gtk.c
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.c (original)
+++ trunk/plugins/gtk+/glade-gtk.c Sat Nov 15 22:38:48 2008
@@ -224,6 +224,17 @@
}
/* ----------------------------- GtkWidget ------------------------------ */
+gboolean
+glade_gtk_widget_depends (GladeWidgetAdaptor *adaptor,
+ GladeWidget *widget,
+ GladeWidget *another)
+{
+ if (GTK_IS_ICON_FACTORY (another->object))
+ return TRUE;
+
+ return GWA_GET_CLASS (G_TYPE_OBJECT)->depends (adaptor, widget, another);
+}
+
#define GLADE_TAG_ACCEL "accelerator"
#define GLADE_TAG_ACCEL_KEY "key"
#define GLADE_TAG_ACCEL_MODIFIERS "modifiers"
@@ -8628,6 +8639,17 @@
}
/*--------------------------- GtkSizeGroup ---------------------------------*/
+gboolean
+glade_gtk_size_group_depends (GladeWidgetAdaptor *adaptor,
+ GladeWidget *widget,
+ GladeWidget *another)
+{
+ if (GTK_IS_WIDGET (another->object))
+ return TRUE;
+
+ return GWA_GET_CLASS (G_TYPE_OBJECT)->depends (adaptor, widget, another);
+}
+
#define GLADE_TAG_SIZEGROUP_WIDGETS "widgets"
#define GLADE_TAG_SIZEGROUP_WIDGET "widget"
Modified: trunk/plugins/gtk+/gtk+.xml.in
==============================================================================
--- trunk/plugins/gtk+/gtk+.xml.in (original)
+++ trunk/plugins/gtk+/gtk+.xml.in Sat Nov 15 22:38:48 2008
@@ -16,6 +16,7 @@
<get-property-function>glade_gtk_widget_get_property</get-property-function>
<action-activate-function>glade_gtk_widget_action_activate</action-activate-function>
<action-submenu-function>glade_gtk_widget_action_submenu</action-submenu-function>
+ <depends-function>glade_gtk_widget_depends</depends-function>
<read-widget-function>glade_gtk_widget_read_widget</read-widget-function>
<write-widget-function>glade_gtk_widget_write_widget</write-widget-function>
<create-editor-property-function>glade_gtk_widget_create_eprop</create-editor-property-function>
@@ -1707,6 +1708,7 @@
<!-- Objects -->
<glade-widget-class name="GtkSizeGroup" generic-name="sizegroup" _title="Size Group" libglade-unsupported="True" toplevel="True">
+ <depends-function>glade_gtk_size_group_depends</depends-function>
<read-widget-function>glade_gtk_size_group_read_widget</read-widget-function>
<write-widget-function>glade_gtk_size_group_write_widget</write-widget-function>
<set-property-function>glade_gtk_size_group_set_property</set-property-function>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]