summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tvb@src.gnome.org>2008-04-06 00:31:29 +0000
committerTristan Van Berkom <tvb@src.gnome.org>2008-04-06 00:31:29 +0000
commit3b86d7f0e17da3b4590a0572523a638daf479f29 (patch)
tree610e274269c6444e43585622f42cada647dd86f2
parent7b9f3bf947fbd6249a969c31c67268c0d4102c4a (diff)
downloadglade-3b86d7f0e17da3b4590a0572523a638daf479f29.tar.gz
Added basic builder support, format can be chosen via a radiomenuitem in
* gladeui/glade-widget.[ch], gladeui/glade-widget-adaptor.c gladeui/glade-xml-utils.[ch], gladeui/glade-project.c, gladeui/glade-property.c, gladeui/glade-signal.c, plugins/gtk+/glade-gtk.c, src/glade-window.c: Added basic builder support, format can be chosen via a radiomenuitem in the "Edit" menu, currently supports different names for the interface and widget tags, and saves special child widgets accordingly (i.e. notebook tabs and frame labels). svn path=/trunk/; revision=1771
-rw-r--r--ChangeLog9
-rw-r--r--gladeui/glade-project.c32
-rw-r--r--gladeui/glade-property.c9
-rw-r--r--gladeui/glade-signal.c5
-rw-r--r--gladeui/glade-widget-adaptor.c8
-rw-r--r--gladeui/glade-widget.c156
-rw-r--r--gladeui/glade-widget.h2
-rw-r--r--gladeui/glade-xml-utils.c30
-rw-r--r--gladeui/glade-xml-utils.h20
-rw-r--r--plugins/gtk+/glade-gtk.c6
-rw-r--r--src/glade-window.c83
11 files changed, 263 insertions, 97 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c436362..d6408cde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,15 @@
but can also be used to parse/write packing stuff (i.e. the
<child> tag) in custom ways).
+ * gladeui/glade-widget.[ch], gladeui/glade-widget-adaptor.c
+ gladeui/glade-xml-utils.[ch], gladeui/glade-project.c,
+ gladeui/glade-property.c, gladeui/glade-signal.c,
+ plugins/gtk+/glade-gtk.c, src/glade-window.c:
+ Added basic builder support, format can be chosen via a
+ radiomenuitem in the "Edit" menu, currently supports different
+ names for the interface and widget tags, and saves special
+ child widgets accordingly (i.e. notebook tabs and frame labels).
+
2008-04-04 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-project.c: Resurected <requires> code and
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 61fb136e..a4163d5d 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -846,6 +846,15 @@ loadable_interface (GladeXmlNode *root_node, const gchar *path)
return loadable;
}
+static void
+glade_project_read_comment (GladeProject *project, GladeXmlDoc *doc)
+{
+ /* TODO Write me !! Find out how to extract root level comments
+ * with libxml2 !!!
+ */
+}
+
+
gboolean
glade_project_load_from_file (GladeProject *project, const gchar *path)
{
@@ -865,7 +874,7 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
if (!(context =
glade_xml_context_new_from_path (path,
NULL,
- GLADE_XML_TAG_PROJECT)))
+ NULL)))
{
g_warning ("Couldn't open glade file [%s].", path);
return FALSE;
@@ -874,18 +883,22 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
doc = glade_xml_context_get_doc (context);
root = glade_xml_doc_get_root (doc);
- /* XXX Need to load project->priv->comment ! */
-
- if (loadable_interface (root, path) == FALSE)
+ if (glade_xml_node_verify_silent (root, GLADE_XML_TAG_LIBGLADE_PROJECT))
+ project->priv->format = GLADE_PROJECT_FORMAT_LIBGLADE;
+ else if (glade_xml_node_verify_silent (root, GLADE_XML_TAG_BUILDER_PROJECT))
+ project->priv->format = GLADE_PROJECT_FORMAT_GTKBUILDER;
+ else
{
+ g_warning ("Couldnt determine project format, skipping %s", path);
glade_xml_context_free (context);
return FALSE;
}
- if (!glade_xml_node_verify (root, GLADE_XML_TAG_PROJECT))
+ /* XXX Need to load project->priv->comment ! */
+ glade_project_read_comment (project, doc);
+
+ if (loadable_interface (root, path) == FALSE)
{
- g_warning ("Glade file root node is not '%s', skipping %s",
- GLADE_XML_TAG_PROJECT, path);
glade_xml_context_free (context);
return FALSE;
}
@@ -894,7 +907,8 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
node; node = glade_xml_node_next (node))
{
/* Skip "requires" tags */
- if (!glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET))
+ if (!glade_xml_node_verify_silent
+ (node, GLADE_XML_TAG_WIDGET (project->priv->format)))
continue;
if ((widget = glade_widget_read (project, NULL, node, NULL)) != NULL)
@@ -1658,7 +1672,7 @@ glade_project_write (GladeProject *project)
doc = glade_xml_doc_new ();
context = glade_xml_context_new (doc, NULL);
- root = glade_xml_node_new (context, GLADE_XML_TAG_PROJECT);
+ root = glade_xml_node_new (context, GLADE_XML_TAG_PROJECT (project->priv->format));
glade_xml_doc_set_root (doc, root);
glade_project_update_comment (project);
diff --git a/gladeui/glade-property.c b/gladeui/glade-property.c
index ea285c5f..92d3e451 100644
--- a/gladeui/glade-property.c
+++ b/gladeui/glade-property.c
@@ -928,7 +928,8 @@ glade_property_read (GladeProperty *property,
/* This code should work the same for <packing> and <widget> */
if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_PACKING) ||
- glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET)))
+ glade_xml_node_verify_silent
+ (node, GLADE_XML_TAG_WIDGET (glade_project_get_format (project)))))
return;
for (prop = glade_xml_node_get_children (node);
@@ -1032,14 +1033,18 @@ glade_property_write (GladeProperty *property,
GladeXmlNode *node)
{
GladeXmlNode *prop_node;
+ GladeProject *project;
gchar *name, *value, *tmp;
g_return_if_fail (GLADE_IS_PROPERTY (property));
g_return_if_fail (node != NULL);
+ project = property->widget->project;
+
/* This code should work the same for <packing> and <widget> */
if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_PACKING) ||
- glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET)))
+ glade_xml_node_verify_silent
+ (node, GLADE_XML_TAG_WIDGET (glade_project_get_format(project)))))
return;
if (!property->klass->save || !property->enabled)
diff --git a/gladeui/glade-signal.c b/gladeui/glade-signal.c
index 3e5e522c..7b6837c2 100644
--- a/gladeui/glade-signal.c
+++ b/gladeui/glade-signal.c
@@ -133,8 +133,9 @@ glade_signal_write (GladeSignal *signal,
GladeXmlNode *signal_node;
gchar *name;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ /* Should assert GLADE_XML_TAG_WIDGET tag here, but no
+ * access to project, so not really seriosly needed
+ */
name = g_strdup (signal->name);
glade_util_replace (name, '-', '_');
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 054c4f7d..79fcf80b 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -877,7 +877,7 @@ glade_widget_adaptor_object_read_child (GladeWidgetAdaptor *adaptor,
if ((widget_node =
glade_xml_search_child
- (node, GLADE_XML_TAG_WIDGET)) != NULL)
+ (node, GLADE_XML_TAG_WIDGET(glade_project_get_format(widget->project)))) != NULL)
{
child_widget =
glade_widget_read (widget->project,
@@ -889,7 +889,7 @@ glade_widget_adaptor_object_read_child (GladeWidgetAdaptor *adaptor,
{
if (!internal_name) {
glade_widget_set_child_type_from_node
- (adaptor, child_widget->object, node);
+ (widget, child_widget->object, node);
glade_widget_add_child (widget, child_widget, FALSE);
}
@@ -913,7 +913,7 @@ glade_widget_adaptor_object_read_child (GladeWidgetAdaptor *adaptor,
} else {
GObject *palaceholder =
G_OBJECT (glade_placeholder_new ());
- glade_widget_set_child_type_from_node (adaptor, palaceholder, node);
+ glade_widget_set_child_type_from_node (widget, palaceholder, node);
glade_widget_adaptor_add (adaptor, widget->object, palaceholder);
}
@@ -952,7 +952,7 @@ glade_widget_adaptor_object_write_child (GladeWidgetAdaptor *adaptor,
glade_widget_write_special_child_prop (widget->parent,
widget->object,
- context, packing_node);
+ context, child_node);
/* Default packing properties and such are not saved,
* so lets check afterwords if there was anything saved
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 6aa5edd8..1f014481 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -3289,11 +3289,53 @@ glade_widget_replace (GladeWidget *parent, GObject *old_object, GObject *new_obj
/*******************************************************************************
* Xml Parsing code *
*******************************************************************************/
+/* XXX Doc me !*/
+void
+glade_widget_write_special_child_prop (GladeWidget *parent,
+ GObject *object,
+ GladeXmlContext *context,
+ GladeXmlNode *node)
+{
+ GladeXmlNode *prop_node, *packing_node;
+ gchar *buff, *special_child_type;
+
+ buff = g_object_get_data (object, "special-child-type");
+ g_object_get (parent->adaptor, "special-child-type", &special_child_type, NULL);
+
+ packing_node = glade_xml_search_child (node, GLADE_XML_TAG_PACKING);
+
+ if (special_child_type && buff)
+ {
+ switch (glade_project_get_format (parent->project))
+ {
+ case GLADE_PROJECT_FORMAT_LIBGLADE:
+ prop_node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
+ glade_xml_node_append_child (packing_node, prop_node);
+
+ /* Name and value */
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_XML_TAG_NAME,
+ special_child_type);
+ glade_xml_set_content (prop_node, buff);
+ break;
+ case GLADE_PROJECT_FORMAT_GTKBUILDER:
+ glade_xml_node_set_property_string (node,
+ GLADE_XML_TAG_TYPE,
+ buff);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ }
+ g_free (special_child_type);
+}
+
/* XXX Doc me ! */
void
-glade_widget_set_child_type_from_node (GladeWidgetAdaptor *parent_adaptor,
- GObject *child,
- GladeXmlNode *node)
+glade_widget_set_child_type_from_node (GladeWidget *parent,
+ GObject *child,
+ GladeXmlNode *node)
{
GladeXmlNode *packing_node, *prop;
gchar *special_child_type, *name, *value;
@@ -3301,42 +3343,59 @@ glade_widget_set_child_type_from_node (GladeWidgetAdaptor *parent_adaptor,
if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
return;
- g_object_get (parent_adaptor, "special-child-type", &special_child_type, NULL);
+ g_object_get (parent->adaptor, "special-child-type", &special_child_type, NULL);
if (!special_child_type)
return;
-
- if ((packing_node =
- glade_xml_search_child (node, GLADE_XML_TAG_PACKING)) != NULL)
+
+ switch (glade_project_get_format (parent->project))
{
- for (prop = glade_xml_node_get_children (packing_node);
- prop; prop = glade_xml_node_next (prop))
+ case GLADE_PROJECT_FORMAT_LIBGLADE:
+ if ((packing_node =
+ glade_xml_search_child (node, GLADE_XML_TAG_PACKING)) != NULL)
{
- if (!(name =
- glade_xml_get_property_string_required (prop,
- GLADE_XML_TAG_NAME,
- NULL)))
- continue;
-
- if (!(value = glade_xml_get_content (prop)))
+ for (prop = glade_xml_node_get_children (packing_node);
+ prop; prop = glade_xml_node_next (prop))
{
- /* XXX should be glade_xml_get_content_required()... */
- g_free (name);
- continue;
- }
+ if (!(name =
+ glade_xml_get_property_string_required
+ (prop, GLADE_XML_TAG_NAME, NULL)))
+ continue;
- if (!strcmp (name, special_child_type))
- {
- g_object_set_data_full (child,
- "special-child-type",
- g_strdup (value),
- g_free);
+ if (!(value = glade_xml_get_content (prop)))
+ {
+ /* XXX should be glade_xml_get_content_required()... */
+ g_free (name);
+ continue;
+ }
+
+ if (!strcmp (name, special_child_type))
+ {
+ g_object_set_data_full (child,
+ "special-child-type",
+ g_strdup (value),
+ g_free);
+ g_free (name);
+ g_free (value);
+ break;
+ }
g_free (name);
g_free (value);
- break;
}
- g_free (name);
- g_free (value);
}
+ break;
+ case GLADE_PROJECT_FORMAT_GTKBUILDER:
+ /* all child types here are depicted by the "type" property */
+ if ((value =
+ glade_xml_get_property_string (node, GLADE_XML_TAG_TYPE)))
+ {
+ g_object_set_data_full (child,
+ "special-child-type",
+ value,
+ g_free);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
g_free (special_child_type);
}
@@ -3376,7 +3435,8 @@ glade_widget_read (GladeProject *project,
glade_widget_push_superuser ();
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ if (!glade_xml_node_verify
+ (node, GLADE_XML_TAG_WIDGET (glade_project_get_format (project))))
return NULL;
if ((klass =
@@ -3442,36 +3502,6 @@ glade_widget_read (GladeProject *project,
return widget;
}
-/* XXX Doc me !*/
-void
-glade_widget_write_special_child_prop (GladeWidget *parent,
- GObject *object,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- GladeXmlNode *prop_node;
- gchar *buff, *special_child_type;
-
- buff = g_object_get_data (object, "special-child-type");
- g_object_get (parent->adaptor, "special-child-type", &special_child_type, NULL);
-
- if (special_child_type && buff)
- {
-
- prop_node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
- glade_xml_node_append_child (node, prop_node);
-
- /* Name and value */
- glade_xml_node_set_property_string (prop_node,
- GLADE_XML_TAG_NAME,
- special_child_type);
- glade_xml_set_content (prop_node, buff);
-
- }
- g_free (special_child_type);
-}
-
-
/**
* glade_widget_write_child:
@@ -3520,7 +3550,7 @@ glade_widget_write_placeholder (GladeWidget *parent,
glade_xml_node_append_child (child_node, packing_node);
glade_widget_write_special_child_prop (parent, object,
- context, packing_node);
+ context, child_node);
if (!glade_xml_node_get_children (packing_node))
{
@@ -3545,7 +3575,9 @@ glade_widget_write (GladeWidget *widget,
{
GladeXmlNode *widget_node;
- widget_node = glade_xml_node_new (context, GLADE_XML_TAG_WIDGET);
+ widget_node =
+ glade_xml_node_new
+ (context, GLADE_XML_TAG_WIDGET (glade_project_get_format (widget->project)));
glade_xml_node_append_child (node, widget_node);
/* Set class and id */
diff --git a/gladeui/glade-widget.h b/gladeui/glade-widget.h
index 16194ebd..8c261c25 100644
--- a/gladeui/glade-widget.h
+++ b/gladeui/glade-widget.h
@@ -239,7 +239,7 @@ void glade_widget_write_special_child_prop (GladeWidget *
GladeXmlContext *context,
GladeXmlNode *node);
-void glade_widget_set_child_type_from_node (GladeWidgetAdaptor *parent_adaptor,
+void glade_widget_set_child_type_from_node (GladeWidget *parent,
GObject *child,
GladeXmlNode *node);
diff --git a/gladeui/glade-xml-utils.c b/gladeui/glade-xml-utils.c
index 85719196..ff72a46f 100644
--- a/gladeui/glade-xml-utils.c
+++ b/gladeui/glade-xml-utils.c
@@ -587,7 +587,8 @@ glade_xml_context_new_from_path (const gchar *full_path,
}
root = xmlDocGetRootElement(doc);
- if ((root->name == NULL) || (xmlStrcmp (root->name, BAD_CAST(root_name)) !=0 ))
+ if (root_name != NULL &&
+ ((root->name == NULL) || (xmlStrcmp (root->name, BAD_CAST(root_name)) != 0)))
{
g_warning ("The file did not contain the expected root name\n"
"Expected \"%s\", actual : \"%s\" [%s]",
@@ -672,8 +673,10 @@ glade_xml_context_get_doc (GladeXmlContext *context)
return context->doc;
}
-static gboolean
-glade_libxml_node_is_comment (xmlNodePtr node) {
+gboolean
+glade_xml_node_is_comment (GladeXmlNode *node_in)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
if (node == NULL)
return FALSE;
if ((xmlStrcmp ( node->name, BAD_CAST("text")) == 0) ||
@@ -689,24 +692,41 @@ glade_xml_node_get_children (GladeXmlNode *node_in)
xmlNodePtr children;
children = node->children;
- while (glade_libxml_node_is_comment (children))
+ while (glade_xml_node_is_comment ((GladeXmlNode *)children))
children = children->next;
return (GladeXmlNode *)children;
}
GladeXmlNode *
+glade_xml_node_get_children_with_comments (GladeXmlNode *node_in)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
+
+ return (GladeXmlNode *)node->children;
+}
+
+GladeXmlNode *
glade_xml_node_next (GladeXmlNode *node_in)
{
xmlNodePtr node = (xmlNodePtr) node_in;
node = node->next;
- while (glade_libxml_node_is_comment (node))
+ while (glade_xml_node_is_comment ((GladeXmlNode *)node))
node = node->next;
return (GladeXmlNode *)node;
}
+GladeXmlNode *
+glade_xml_node_next_with_comments (GladeXmlNode *node_in)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
+
+ return (GladeXmlNode *)node->next;
+}
+
+
const gchar *
glade_xml_node_get_name (GladeXmlNode *node_in)
{
diff --git a/gladeui/glade-xml-utils.h b/gladeui/glade-xml-utils.h
index d9ac7496..919e03ce 100644
--- a/gladeui/glade-xml-utils.h
+++ b/gladeui/glade-xml-utils.h
@@ -19,11 +19,23 @@ typedef struct _GladeXmlContext GladeXmlContext;
typedef struct _GladeXmlNode GladeXmlNode;
typedef struct _GladeXmlDoc GladeXmlDoc;
+
+#define GLADE_XML_TAG_PROJECT(type) \
+ ((type == GLADE_PROJECT_FORMAT_LIBGLADE) ? \
+ GLADE_XML_TAG_LIBGLADE_PROJECT : GLADE_XML_TAG_BUILDER_PROJECT)
+
+#define GLADE_XML_TAG_WIDGET(type) \
+ ((type == GLADE_PROJECT_FORMAT_LIBGLADE) ? \
+ GLADE_XML_TAG_LIBGLADE_WIDGET : GLADE_XML_TAG_BUILDER_WIDGET)
+
/* Used for catalog tags and attributes */
-#define GLADE_XML_TAG_PROJECT "glade-interface"
+#define GLADE_XML_TAG_LIBGLADE_PROJECT "glade-interface"
+#define GLADE_XML_TAG_BUILDER_PROJECT "interface"
+#define GLADE_XML_TAG_LIBGLADE_WIDGET "widget"
+#define GLADE_XML_TAG_BUILDER_WIDGET "object"
+
#define GLADE_XML_TAG_REQUIRES "requires"
#define GLADE_XML_TAG_LIB "lib"
-#define GLADE_XML_TAG_WIDGET "widget"
#define GLADE_XML_TAG_PROPERTY "property"
#define GLADE_XML_TAG_CLASS "class"
#define GLADE_XML_TAG_ID "id"
@@ -38,6 +50,7 @@ typedef struct _GladeXmlDoc GladeXmlDoc;
#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_TYPE "type"
#define GLADE_TAG_GLADE_CATALOG "glade-catalog"
#define GLADE_TAG_GLADE_WIDGET_CLASSES "glade-widget-classes"
@@ -179,6 +192,9 @@ gboolean glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar
const gchar * glade_xml_node_get_name (GladeXmlNode *node_in);
void glade_xml_node_append_child (GladeXmlNode * node, GladeXmlNode * child);
void glade_xml_node_remove (GladeXmlNode *node_in);
+gboolean glade_xml_node_is_comment (GladeXmlNode *node_in);
+GladeXmlNode * glade_xml_node_next_with_comments (GladeXmlNode *node_in);
+GladeXmlNode * glade_xml_node_get_children_with_comments (GladeXmlNode *node);
/* Document Operatons */
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 4e48f84c..4859e634 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -571,7 +571,8 @@ glade_gtk_widget_read_widget (GladeWidgetAdaptor *adaptor,
GladeWidget *widget,
GladeXmlNode *node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ if (!glade_xml_node_verify
+ (node, GLADE_XML_TAG_WIDGET (glade_project_get_format (widget->project))))
return;
/* First chain up and read in all the normal properties.. */
@@ -889,7 +890,8 @@ glade_gtk_widget_write_widget (GladeWidgetAdaptor *adaptor,
GladeXmlContext *context,
GladeXmlNode *node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ if (!glade_xml_node_verify
+ (node, GLADE_XML_TAG_WIDGET (glade_project_get_format (widget->project))))
return;
/* First chain up and read in all the normal properties.. */
diff --git a/src/glade-window.c b/src/glade-window.c
index 0f2b5e93..86f4327c 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -1691,7 +1691,12 @@ notebook_switch_page_cb (GtkNotebook *notebook,
refresh_title (window);
set_sensitivity_according_to_project (window, project);
-
+
+ /* Set project format here */
+ action = gtk_action_group_get_action (window->priv->static_actions, "LibgladeFormat");
+ gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action),
+ glade_project_get_format (project));
+
/* switch to the project's inspector */
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), page_num);
@@ -1718,6 +1723,7 @@ notebook_tab_added_cb (GtkNotebook *notebook,
{
GladeProject *project;
GtkWidget *inspector;
+ GtkAction *action;
++window->priv->num_tabs;
@@ -1768,6 +1774,7 @@ notebook_tab_removed_cb (GtkNotebook *notebook,
{
GladeProject *project;
GladeInspector *inspector;
+ GtkAction *action;
--window->priv->num_tabs;
@@ -1797,9 +1804,24 @@ notebook_tab_removed_cb (GtkNotebook *notebook,
project_selection_changed_cb (glade_app_get_project (), window);
if (window->priv->active_view)
- set_sensitivity_according_to_project (window, glade_design_view_get_project (window->priv->active_view));
+ {
+ set_sensitivity_according_to_project
+ (window, glade_design_view_get_project (window->priv->active_view));
+ action = gtk_action_group_get_action
+ (window->priv->static_actions, "LibgladeFormat");
+ gtk_radio_action_set_current_value
+ (GTK_RADIO_ACTION (action), glade_project_get_format
+ (glade_design_view_get_project (window->priv->active_view)));
+
+ }
else
+ {
+ action = gtk_action_group_get_action
+ (window->priv->static_actions, "ProjectFormat");
+ gtk_action_set_sensitive (action, FALSE);
+
gtk_action_group_set_sensitive (window->priv->project_actions, FALSE);
+ }
}
@@ -1827,8 +1849,8 @@ recent_chooser_item_activated_cb (GtkRecentChooser *chooser, GladeWindow *window
static void
palette_appearance_change_cb (GtkRadioAction *action,
- GtkRadioAction *current,
- GladeWindow *window)
+ GtkRadioAction *current,
+ GladeWindow *window)
{
gint value;
@@ -1838,6 +1860,24 @@ palette_appearance_change_cb (GtkRadioAction *action,
}
+
+static void
+format_change_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ GladeWindow *window)
+{
+ gint value;
+ GladeProject *project;
+
+ value = gtk_radio_action_get_current_value (action);
+
+ if (window->priv->active_view)
+ {
+ project = glade_design_view_get_project (window->priv->active_view);
+ glade_project_set_format (project, value);
+ }
+}
+
static void
palette_toggle_small_icons_cb (GtkAction *action, GladeWindow *window)
{
@@ -2151,6 +2191,11 @@ static const gchar ui_info[] =
" <menuitem action='Copy'/>"
" <menuitem action='Paste'/>"
" <menuitem action='Delete'/>"
+" <separator/>"
+" <menu action='ProjectFormat'>"
+" <menuitem action='LibgladeFormat'/>"
+" <menuitem action='BuilderFormat'/>"
+" </menu>"
" </menu>"
" <menu action='ViewMenu'>"
" <menuitem action='Clipboard'/>"
@@ -2213,6 +2258,9 @@ static GtkActionEntry static_entries[] = {
{ "Quit", GTK_STOCK_QUIT, NULL, "<control>Q",
N_("Quit the program"), G_CALLBACK (quit_cb) },
+ /* Edit Menu */
+ { "ProjectFormat", NULL, N_("_Project Format") },
+
/* ViewMenu */
{ "PaletteAppearance", NULL, N_("Palette _Appearance") },
@@ -2302,7 +2350,7 @@ static GtkToggleActionEntry view_entries[] = {
};
static guint n_view_entries = G_N_ELEMENTS (view_entries);
-static GtkRadioActionEntry radio_entries[] = {
+static GtkRadioActionEntry palette_radio_entries[] = {
{ "IconsAndLabels", NULL, N_("Text beside icons"), NULL,
N_("Display items as text beside icons"), GLADE_ITEM_ICON_AND_LABEL },
@@ -2312,8 +2360,21 @@ static GtkRadioActionEntry radio_entries[] = {
{ "LabelsOnly", NULL, N_("_Text only"), NULL,
N_("Display items as text only"), GLADE_ITEM_LABEL_ONLY },
+
};
-static guint n_radio_entries = G_N_ELEMENTS (radio_entries);
+static guint n_palette_radio_entries = G_N_ELEMENTS (palette_radio_entries);
+
+
+static GtkRadioActionEntry format_radio_entries[] = {
+
+ { "LibgladeFormat", NULL, N_("Libglade"), NULL,
+ N_("Set libglade readable file format"), GLADE_PROJECT_FORMAT_LIBGLADE },
+
+ { "BuilderFormat", NULL, N_("Gtk Builder"), NULL,
+ N_("Set Gtk Builder file format"), GLADE_PROJECT_FORMAT_GTKBUILDER },
+
+};
+static guint n_format_radio_entries = G_N_ELEMENTS (format_radio_entries);
static void
menu_item_selected_cb (GtkWidget *item, GladeWindow *window)
@@ -2384,10 +2445,16 @@ construct_menu (GladeWindow *window)
view_entries,
n_view_entries,
window);
- gtk_action_group_add_radio_actions (window->priv->static_actions, radio_entries,
- n_radio_entries, GLADE_ITEM_ICON_ONLY,
+
+ gtk_action_group_add_radio_actions (window->priv->static_actions, palette_radio_entries,
+ n_palette_radio_entries, GLADE_ITEM_ICON_ONLY,
G_CALLBACK (palette_appearance_change_cb), window);
+ gtk_action_group_add_radio_actions (window->priv->static_actions, format_radio_entries,
+ n_format_radio_entries,
+ GLADE_PROJECT_FORMAT_GTKBUILDER,
+ G_CALLBACK (format_change_cb), window);
+
window->priv->project_actions = gtk_action_group_new (ACTION_GROUP_PROJECT);
gtk_action_group_set_translation_domain (window->priv->project_actions, GETTEXT_PACKAGE);