Commit 18127438 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Added new backend ->depends() vfunc to determine toplevel dependancies


	* 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


svn path=/trunk/; revision=2032
parent fa51f128
......@@ -7,7 +7,13 @@
* src/glade-window.c: Update glade-app accel group.
* gladeui/glade-project.[ch], gladeui/glade-app.c: Remove accel group notion from projects
* 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], gladeui/glade-app.c:
- Remove accel group notion from projects
- Sort dependancies using glade_widget_adaptor_depends()
* gladeui/glade-base-editor.c:
- Use global accel group (with keypress editor hijack in place)
......@@ -23,7 +29,9 @@
- Added "widget" property
- added glade_editor_dialog_for_widget()
* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Added "Edit Separately" action
* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c:
- Added "Edit Separately" action
- Added ->depends() func for GtkWidget and GtkSizeGroup
2008-11-12 Tristan Van Berkom <tvb@gnome.org>
......
......@@ -2302,7 +2302,21 @@ glade_project_set_widget_name (GladeProject *project,
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_project_add_object (GladeProject *project,
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],
......
......@@ -845,6 +845,14 @@ glade_widget_adaptor_object_child_action_activate (GladeWidgetAdaptor *adaptor,
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 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass *adaptor_class)
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 @@ gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass *klass,
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,
......@@ -3377,6 +3391,30 @@ glade_widget_adaptor_action_submenu (GladeWidgetAdaptor *adaptor,
return NULL;
}
/**
* 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
......
......@@ -417,6 +417,22 @@ typedef GtkWidget *(* GladeActionSubmenuFunc) (GladeWidgetAdaptor *adaptor,
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 @@ struct _GladeWidgetAdaptorClass
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 @@ GtkWidget *glade_widget_adaptor_action_submenu (GladeWidgetAdap
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,
......
......@@ -131,6 +131,7 @@ typedef enum {
#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"
......
......@@ -224,6 +224,17 @@ glade_gtk_init (const gchar *name)
}
/* ----------------------------- 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 @@ glade_gtk_message_dialog_get_property (GladeWidgetAdaptor *adaptor,
}
/*--------------------------- 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"
......
......@@ -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 @@ embedded in another object</_tooltip>
<!-- 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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment