Use gssize for length, not gsize.

2003-08-26  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkuimanager.[hc] (gtk_ui_manager_add_ui_from_string): Use gssize
	for length, not gsize.

	* gtk/gtkuimanager.c: Refactor the XML format a bit: rename <Root> to
	<ui> and make it optional in strings. Rename verb to action, <dockitem>
	to <toolbar>, <menu> to <menubar>, <submenu> to <menu>.

	* demos/gtk-demo/appwindow.c:
	* tests/testactions.c:
	* tests/testmerge.c:
	* tests/merge-1.ui:
	* tests/merge-2.ui:
	* tests/merge-3.ui: Adjust to the new XML format.
This commit is contained in:
Matthias Clasen 2003-08-26 00:13:59 +00:00 committed by Matthias Clasen
parent 2be259b24a
commit 720bdb8daf
13 changed files with 346 additions and 221 deletions

View File

@ -1,3 +1,19 @@
2003-08-26 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.[hc] (gtk_ui_manager_add_ui_from_string): Use gssize
for length, not gsize.
* gtk/gtkuimanager.c: Refactor the XML format a bit: rename <Root> to
<ui> and make it optional in strings. Rename verb to action, <dockitem>
to <toolbar>, <menu> to <menubar>, <submenu> to <menu>.
* demos/gtk-demo/appwindow.c:
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-1.ui:
* tests/merge-2.ui:
* tests/merge-3.ui: Adjust to the new XML format.
Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_update_layout_width): * gtk/gtktextview.c (gtk_text_view_update_layout_width):
@ -21,10 +37,12 @@ Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtk.h: * gtk/gtk.h:
* tests/testmerge.c: * tests/testmerge.c:
* tests/testactions.c: * tests/testactions.c:
* demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by GtkUIManager. * demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by
GtkUIManager.
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating: add comments to * demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
entries array, remove newlines from ui definition. Don't use the ::add_widget signal. add comments to entries array, remove newlines from ui definition. Don't
use the ::add_widget signal.
Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,19 @@
2003-08-26 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.[hc] (gtk_ui_manager_add_ui_from_string): Use gssize
for length, not gsize.
* gtk/gtkuimanager.c: Refactor the XML format a bit: rename <Root> to
<ui> and make it optional in strings. Rename verb to action, <dockitem>
to <toolbar>, <menu> to <menubar>, <submenu> to <menu>.
* demos/gtk-demo/appwindow.c:
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-1.ui:
* tests/merge-2.ui:
* tests/merge-3.ui: Adjust to the new XML format.
Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_update_layout_width): * gtk/gtktextview.c (gtk_text_view_update_layout_width):
@ -21,10 +37,12 @@ Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtk.h: * gtk/gtk.h:
* tests/testmerge.c: * tests/testmerge.c:
* tests/testactions.c: * tests/testactions.c:
* demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by GtkUIManager. * demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by
GtkUIManager.
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating: add comments to * demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
entries array, remove newlines from ui definition. Don't use the ::add_widget signal. add comments to entries array, remove newlines from ui definition. Don't
use the ::add_widget signal.
Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,19 @@
2003-08-26 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.[hc] (gtk_ui_manager_add_ui_from_string): Use gssize
for length, not gsize.
* gtk/gtkuimanager.c: Refactor the XML format a bit: rename <Root> to
<ui> and make it optional in strings. Rename verb to action, <dockitem>
to <toolbar>, <menu> to <menubar>, <submenu> to <menu>.
* demos/gtk-demo/appwindow.c:
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-1.ui:
* tests/merge-2.ui:
* tests/merge-3.ui: Adjust to the new XML format.
Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_update_layout_width): * gtk/gtktextview.c (gtk_text_view_update_layout_width):
@ -21,10 +37,12 @@ Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtk.h: * gtk/gtk.h:
* tests/testmerge.c: * tests/testmerge.c:
* tests/testactions.c: * tests/testactions.c:
* demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by GtkUIManager. * demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by
GtkUIManager.
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating: add comments to * demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
entries array, remove newlines from ui definition. Don't use the ::add_widget signal. add comments to entries array, remove newlines from ui definition. Don't
use the ::add_widget signal.
Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,19 @@
2003-08-26 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.[hc] (gtk_ui_manager_add_ui_from_string): Use gssize
for length, not gsize.
* gtk/gtkuimanager.c: Refactor the XML format a bit: rename <Root> to
<ui> and make it optional in strings. Rename verb to action, <dockitem>
to <toolbar>, <menu> to <menubar>, <submenu> to <menu>.
* demos/gtk-demo/appwindow.c:
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-1.ui:
* tests/merge-2.ui:
* tests/merge-3.ui: Adjust to the new XML format.
Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_update_layout_width): * gtk/gtktextview.c (gtk_text_view_update_layout_width):
@ -21,10 +37,12 @@ Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtk.h: * gtk/gtk.h:
* tests/testmerge.c: * tests/testmerge.c:
* tests/testactions.c: * tests/testactions.c:
* demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by GtkUIManager. * demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by
GtkUIManager.
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating: add comments to * demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
entries array, remove newlines from ui definition. Don't use the ::add_widget signal. add comments to entries array, remove newlines from ui definition. Don't
use the ::add_widget signal.
Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,19 @@
2003-08-26 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.[hc] (gtk_ui_manager_add_ui_from_string): Use gssize
for length, not gsize.
* gtk/gtkuimanager.c: Refactor the XML format a bit: rename <Root> to
<ui> and make it optional in strings. Rename verb to action, <dockitem>
to <toolbar>, <menu> to <menubar>, <submenu> to <menu>.
* demos/gtk-demo/appwindow.c:
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-1.ui:
* tests/merge-2.ui:
* tests/merge-3.ui: Adjust to the new XML format.
Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_update_layout_width): * gtk/gtktextview.c (gtk_text_view_update_layout_width):
@ -21,10 +37,12 @@ Mon Aug 25 19:55:55 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtk.h: * gtk/gtk.h:
* tests/testmerge.c: * tests/testmerge.c:
* tests/testactions.c: * tests/testactions.c:
* demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by GtkUIManager. * demos/gtk-demo/appwindow.c: Replace all uses of GtkMenuMerge by
GtkUIManager.
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating: add comments to * demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
entries array, remove newlines from ui definition. Don't use the ::add_widget signal. add comments to entries array, remove newlines from ui definition. Don't
use the ::add_widget signal.
Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 25 17:28:04 2003 Owen Taylor <otaylor@redhat.com>

View File

@ -101,39 +101,39 @@ static GtkActionGroupEntry entries[] = {
static guint n_entries = G_N_ELEMENTS (entries); static guint n_entries = G_N_ELEMENTS (entries);
static const gchar *ui_info = static const gchar *ui_info =
"<Root>" "<ui>"
" <menu name='MenuBar'>" " <menubar name='MenuBar'>"
" <submenu name='FileMenu'>" " <menu name='FileMenu'>"
" <menuitem name='New'/>" " <menuitem name='New'/>"
" <menuitem name='Open'/>" " <menuitem name='Open'/>"
" <menuitem name='Save'/>" " <menuitem name='Save'/>"
" <menuitem name='SaveAs'/>" " <menuitem name='SaveAs'/>"
" <separator name='Sep1'/>" " <separator name='Sep1'/>"
" <menuitem name='Quit'/>" " <menuitem name='Quit'/>"
" </submenu>" " </menu>"
" <submenu name='PreferencesMenu'>" " <menu name='PreferencesMenu'>"
" <submenu name='ColorMenu'>" " <menu name='ColorMenu'>"
" <menuitem name='Red'/>" " <menuitem name='Red'/>"
" <menuitem name='Green'/>" " <menuitem name='Green'/>"
" <menuitem name='Blue'/>" " <menuitem name='Blue'/>"
" </submenu>" " </menu>"
" <submenu name='ShapeMenu'>" " <menu name='ShapeMenu'>"
" <menuitem name='Square'/>" " <menuitem name='Square'/>"
" <menuitem name='Rectangle'/>" " <menuitem name='Rectangle'/>"
" <menuitem name='Oval'/>" " <menuitem name='Oval'/>"
" </submenu>" " </menu>"
" </submenu>" " </menu>"
" <submenu name='HelpMenu'>" " <menu name='HelpMenu'>"
" <menuitem name='About'/>" " <menuitem name='About'/>"
" </submenu>" " </menu>"
" </menu>" " </menubar>"
" <dockitem name='ToolBar'>" " <toolbar name='ToolBar'>"
" <toolitem name='Open'/>" " <toolitem name='Open'/>"
" <toolitem name='Quit'/>" " <toolitem name='Quit'/>"
" <separator name='Sep1'/>" " <separator name='Sep1'/>"
" <toolitem name='Logo'/>" " <toolitem name='Logo'/>"
" </dockitem>" " </toolbar>"
"</Root>"; "</ui>";

View File

@ -428,7 +428,7 @@ gtk_action_sync_property (GtkAction *action,
property = g_param_spec_get_name (pspec); property = g_param_spec_get_name (pspec);
g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_object_get_property (G_OBJECT (action), property, &value); g_object_get_property (G_OBJECT (action), property, &value);
g_object_set_property (G_OBJECT (proxy), property, &value); g_object_set_property (G_OBJECT (proxy), property, &value);

View File

@ -212,7 +212,7 @@ gtk_ui_manager_init (GtkUIManager *self)
merge_id = gtk_ui_manager_next_merge_id (self); merge_id = gtk_ui_manager_next_merge_id (self);
node = get_child_node (self, NULL, "Root", 4, node = get_child_node (self, NULL, "ui", 4,
GTK_UI_MANAGER_ROOT, TRUE, FALSE); GTK_UI_MANAGER_ROOT, TRUE, FALSE);
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), merge_id, 0); gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), merge_id, 0);
node = get_child_node (self, self->private_data->root_node, "popups", 6, node = get_child_node (self, self->private_data->root_node, "popups", 6,
@ -567,7 +567,7 @@ start_element_handler (GMarkupParseContext *context,
gint i; gint i;
const gchar *node_name; const gchar *node_name;
GQuark verb_quark; GQuark action_quark;
gboolean top; gboolean top;
gboolean raise_error = TRUE; gboolean raise_error = TRUE;
@ -576,7 +576,7 @@ start_element_handler (GMarkupParseContext *context,
/* work out a name for this node. Either the name attribute, or /* work out a name for this node. Either the name attribute, or
* element name */ * element name */
node_name = element_name; node_name = element_name;
verb_quark = 0; action_quark = 0;
top = FALSE; top = FALSE;
for (i = 0; attribute_names[i] != NULL; i++) for (i = 0; attribute_names[i] != NULL; i++)
{ {
@ -584,34 +584,34 @@ start_element_handler (GMarkupParseContext *context,
{ {
node_name = attribute_values[i]; node_name = attribute_values[i];
} }
else if (!strcmp (attribute_names[i], "verb")) else if (!strcmp (attribute_names[i], "action"))
{ {
verb_quark = g_quark_from_string (attribute_values[i]); action_quark = g_quark_from_string (attribute_values[i]);
} }
else if (!strcmp (attribute_names[i], "pos")) else if (!strcmp (attribute_names[i], "pos"))
{ {
top = !strcmp (attribute_values[i], "top"); top = !strcmp (attribute_values[i], "top");
} }
} }
/* if no verb, then set it to the node's name */ /* if no action, then set it to the node's name */
if (verb_quark == 0) if (action_quark == 0)
verb_quark = g_quark_from_string (node_name); action_quark = g_quark_from_string (node_name);
switch (element_name[0]) switch (element_name[0])
{ {
case 'R': case 'u':
if (ctx->state == STATE_START && !strcmp (element_name, "Root")) if (ctx->state == STATE_START && !strcmp (element_name, "ui"))
{ {
ctx->state = STATE_ROOT; ctx->state = STATE_ROOT;
ctx->current = self->private_data->root_node; ctx->current = self->private_data->root_node;
raise_error = FALSE; raise_error = FALSE;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
} }
break; break;
case 'm': case 'm':
if (ctx->state == STATE_ROOT && !strcmp (element_name, "menu")) if (ctx->state == STATE_ROOT && !strcmp (element_name, "menubar"))
{ {
ctx->state = STATE_MENU; ctx->state = STATE_MENU;
ctx->current = get_child_node (self, ctx->current, ctx->current = get_child_node (self, ctx->current,
@ -619,12 +619,28 @@ start_element_handler (GMarkupParseContext *context,
GTK_UI_MANAGER_MENUBAR, GTK_UI_MANAGER_MENUBAR,
TRUE, FALSE); TRUE, FALSE);
if (NODE_INFO (ctx->current)->action_name == 0) if (NODE_INFO (ctx->current)->action_name == 0)
NODE_INFO (ctx->current)->action_name = verb_quark; NODE_INFO (ctx->current)->action_name = action_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
NODE_INFO (ctx->current)->dirty = TRUE; NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE;
}
else if (ctx->state == STATE_MENU && !strcmp (element_name, "menu"))
{
ctx->state = STATE_MENU;
ctx->current = get_child_node (self, ctx->current,
node_name, strlen (node_name),
GTK_UI_MANAGER_MENU,
TRUE, top);
if (NODE_INFO (ctx->current)->action_name == 0)
NODE_INFO (ctx->current)->action_name = action_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, action_quark);
NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE; raise_error = FALSE;
} }
else if (ctx->state == STATE_MENU && !strcmp (element_name, "menuitem")) else if (ctx->state == STATE_MENU && !strcmp (element_name, "menuitem"))
@ -637,30 +653,12 @@ start_element_handler (GMarkupParseContext *context,
GTK_UI_MANAGER_MENUITEM, GTK_UI_MANAGER_MENUITEM,
TRUE, top); TRUE, top);
if (NODE_INFO (node)->action_name == 0) if (NODE_INFO (node)->action_name == 0)
NODE_INFO (node)->action_name = verb_quark; NODE_INFO (node)->action_name = action_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
NODE_INFO (node)->dirty = TRUE; NODE_INFO (node)->dirty = TRUE;
raise_error = FALSE;
}
break;
case 'd':
if (ctx->state == STATE_ROOT && !strcmp (element_name, "dockitem"))
{
ctx->state = STATE_TOOLBAR;
ctx->current = get_child_node (self, ctx->current,
node_name, strlen (node_name),
GTK_UI_MANAGER_TOOLBAR,
TRUE, FALSE);
if (NODE_INFO (ctx->current)->action_name == 0)
NODE_INFO (ctx->current)->action_name = verb_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE; raise_error = FALSE;
} }
break; break;
@ -674,7 +672,7 @@ start_element_handler (GMarkupParseContext *context,
TRUE, FALSE); TRUE, FALSE);
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
NODE_INFO (ctx->current)->dirty = TRUE; NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE; raise_error = FALSE;
@ -687,10 +685,10 @@ start_element_handler (GMarkupParseContext *context,
GTK_UI_MANAGER_MENU, GTK_UI_MANAGER_MENU,
TRUE, FALSE); TRUE, FALSE);
if (NODE_INFO (ctx->current)->action_name == 0) if (NODE_INFO (ctx->current)->action_name == 0)
NODE_INFO (ctx->current)->action_name = verb_quark; NODE_INFO (ctx->current)->action_name = action_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
NODE_INFO (ctx->current)->dirty = TRUE; NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE; raise_error = FALSE;
@ -710,30 +708,14 @@ start_element_handler (GMarkupParseContext *context,
TRUE, top); TRUE, top);
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
NODE_INFO (ctx->current)->dirty = TRUE; NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE; raise_error = FALSE;
} }
break; break;
case 's': case 's':
if (ctx->state == STATE_MENU && !strcmp (element_name, "submenu")) if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
{
ctx->state = STATE_MENU;
ctx->current = get_child_node (self, ctx->current,
node_name, strlen (node_name),
GTK_UI_MANAGER_MENU,
TRUE, top);
if (NODE_INFO (ctx->current)->action_name == 0)
NODE_INFO (ctx->current)->action_name = verb_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE;
}
else if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
!strcmp (element_name, "separator")) !strcmp (element_name, "separator"))
{ {
GNode *node; GNode *node;
@ -747,17 +729,33 @@ start_element_handler (GMarkupParseContext *context,
GTK_UI_MANAGER_SEPARATOR, GTK_UI_MANAGER_SEPARATOR,
TRUE, top); TRUE, top);
if (NODE_INFO (node)->action_name == 0) if (NODE_INFO (node)->action_name == 0)
NODE_INFO (node)->action_name = verb_quark; NODE_INFO (node)->action_name = action_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
NODE_INFO (node)->dirty = TRUE; NODE_INFO (node)->dirty = TRUE;
raise_error = FALSE; raise_error = FALSE;
} }
break; break;
case 't': case 't':
if (ctx->state == STATE_TOOLBAR && !strcmp (element_name, "toolitem")) if (ctx->state == STATE_ROOT && !strcmp (element_name, "toolbar"))
{
ctx->state = STATE_TOOLBAR;
ctx->current = get_child_node (self, ctx->current,
node_name, strlen (node_name),
GTK_UI_MANAGER_TOOLBAR,
TRUE, FALSE);
if (NODE_INFO (ctx->current)->action_name == 0)
NODE_INFO (ctx->current)->action_name = action_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, action_quark);
NODE_INFO (ctx->current)->dirty = TRUE;
raise_error = FALSE;
}
else if (ctx->state == STATE_TOOLBAR && !strcmp (element_name, "toolitem"))
{ {
GNode *node; GNode *node;
@ -767,10 +765,10 @@ start_element_handler (GMarkupParseContext *context,
GTK_UI_MANAGER_TOOLITEM, GTK_UI_MANAGER_TOOLITEM,
TRUE, top); TRUE, top);
if (NODE_INFO (node)->action_name == 0) if (NODE_INFO (node)->action_name == 0)
NODE_INFO (node)->action_name = verb_quark; NODE_INFO (node)->action_name = action_quark;
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark); ctx->merge_id, action_quark);
NODE_INFO (node)->dirty = TRUE; NODE_INFO (node)->dirty = TRUE;
raise_error = FALSE; raise_error = FALSE;
@ -880,6 +878,56 @@ static GMarkupParser ui_parser = {
}; };
static gboolean
xml_isspace (char c)
{
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
static guint
add_ui_from_string (GtkUIManager *self,
const gchar *buffer,
gssize length,
gboolean needs_root,
GError **error)
{
ParseContext ctx = { 0 };
GMarkupParseContext *context;
ctx.state = STATE_START;
ctx.self = self;
ctx.current = NULL;
ctx.merge_id = gtk_ui_manager_next_merge_id (self);
context = g_markup_parse_context_new (&ui_parser, 0, &ctx, NULL);
if (needs_root)
if (!g_markup_parse_context_parse (context, "<ui>", -1, error))
goto error;
if (!g_markup_parse_context_parse (context, buffer, length, error))
goto error;
if (needs_root)
if (!g_markup_parse_context_parse (context, "</ui>", -1, error))
goto error;
if (!g_markup_parse_context_end_parse (context, error))
goto error;
g_markup_parse_context_free (context);
gtk_ui_manager_queue_update (self);
return ctx.merge_id;
error:
g_markup_parse_context_free (context);
return 0;
}
/** /**
* gtk_ui_manager_add_ui_from_string: * gtk_ui_manager_add_ui_from_string:
* @self: a #GtkUIManager object * @self: a #GtkUIManager object
@ -899,41 +947,28 @@ static GMarkupParser ui_parser = {
guint guint
gtk_ui_manager_add_ui_from_string (GtkUIManager *self, gtk_ui_manager_add_ui_from_string (GtkUIManager *self,
const gchar *buffer, const gchar *buffer,
gsize length, gssize length,
GError **error) GError **error)
{ {
ParseContext ctx = { 0 }; gboolean needs_root = TRUE;
GMarkupParseContext *context; const gchar *p;
gboolean res = TRUE; const gchar *end;
g_return_val_if_fail (GTK_IS_UI_MANAGER (self), FALSE); g_return_val_if_fail (GTK_IS_UI_MANAGER (self), FALSE);
g_return_val_if_fail (buffer != NULL, FALSE); g_return_val_if_fail (buffer != NULL, FALSE);
ctx.state = STATE_START;
ctx.self = self;
ctx.current = NULL;
ctx.merge_id = gtk_ui_manager_next_merge_id (self);
context = g_markup_parse_context_new (&ui_parser, 0, &ctx, NULL);
if (length < 0) if (length < 0)
length = strlen (buffer); length = strlen (buffer);
if (g_markup_parse_context_parse (context, buffer, length, error)) p = buffer;
{ end = buffer + length;
if (!g_markup_parse_context_end_parse (context, error)) while (p != end && xml_isspace (*p))
res = FALSE; ++p;
}
else
res = FALSE;
g_markup_parse_context_free (context); if (end - p >= 4 && strncmp (p, "<ui>", 4) == 0)
needs_root = FALSE;
gtk_ui_manager_queue_update (self);
return add_ui_from_string (self, buffer, length, needs_root, error);
if (res)
return ctx.merge_id;
return 0;
} }
/** /**
@ -963,7 +998,7 @@ gtk_ui_manager_add_ui_from_file (GtkUIManager *self,
if (!g_file_get_contents (filename, &buffer, &length, error)) if (!g_file_get_contents (filename, &buffer, &length, error))
return 0; return 0;
res = gtk_ui_manager_add_ui_from_string (self, buffer, length, error); res = add_ui_from_string (self, buffer, length, FALSE, error);
g_free (buffer); g_free (buffer);
return res; return res;
@ -1572,25 +1607,25 @@ gtk_ui_manager_dirty_all (GtkUIManager *self)
static const gchar *open_tag_format[] = { static const gchar *open_tag_format[] = {
"%*s<UNDECIDED>\n", "%*s<UNDECIDED>\n",
"%*s<Root>\n", "%*s<ui>\n",
"%*s<menu name=\"%s\">\n", "%*s<menubar name=\"%s\">\n",
"%*s<submenu name=\"%s\" verb=\"%s\">\n", "%*s<menu name=\"%s\" action=\"%s\">\n",
"%*s<dockitem name=\"%s\">\n", "%*s<toolbar name=\"%s\">\n",
"%*s<placeholder name=\"%s\">\n", "%*s<placeholder name=\"%s\">\n",
"%*s<placeholder name=\"%s\">\n", "%*s<placeholder name=\"%s\">\n",
"%*s<popups>\n", "%*s<popups>\n",
"%*s<menuitem name=\"%s\" verb=\"%s\"/>\n", "%*s<menuitem name=\"%s\" action=\"%s\"/>\n",
"%*s<toolitem name=\"%s\" verb=\"%s\"/>\n", "%*s<toolitem name=\"%s\" action=\"%s\"/>\n",
"%*s<separator/>\n", "%*s<separator/>\n",
"%*s<popup name=\"%s\">\n" "%*s<popup name=\"%s\">\n"
}; };
static const gchar *close_tag_format[] = { static const gchar *close_tag_format[] = {
"%*s</UNDECIDED>\n", "%*s</UNDECIDED>\n",
"%*s</Root>\n", "%*s</ui>\n",
"%*s</menubar>\n",
"%*s</menu>\n", "%*s</menu>\n",
"%*s</submenu>\n", "%*s</toolbar>\n",
"%*s</dockitem>\n",
"%*s</placeholder>\n", "%*s</placeholder>\n",
"%*s</placeholder>\n", "%*s</placeholder>\n",
"%*s</popups>\n", "%*s</popups>\n",

View File

@ -95,7 +95,7 @@ GtkWidget *gtk_ui_manager_get_widget (GtkUIManager *self,
* interface */ * interface */
guint gtk_ui_manager_add_ui_from_string (GtkUIManager *self, guint gtk_ui_manager_add_ui_from_string (GtkUIManager *self,
const gchar *buffer, const gchar *buffer,
gsize length, gssize length,
GError **error); GError **error);
guint gtk_ui_manager_add_ui_from_file (GtkUIManager *self, guint gtk_ui_manager_add_ui_from_file (GtkUIManager *self,
const gchar *filename, const gchar *filename,

View File

@ -1,20 +1,22 @@
<!--*- xml -*--> <!--*- xml -*-->
<Root> <ui>
<menu> <menubar>
<submenu name="FileMenu" verb="StockFileMenuAction"> <menu name="FileMenu" action="StockFileMenuAction">
<menuitem name="Open" verb="OpenAction" /> <menuitem name="Open" action="OpenAction" />
</submenu> </menu>
<submenu name="EditMenu" verb="StockEditMenuAction"> <menu name="EditMenu" action="StockEditMenuAction">
<menuitem name="Cut" verb="CutAction" /> <menuitem name="Cut" action="CutAction" />
</submenu> </menu>
<placeholder name="TestPlaceholder" /> <placeholder name="TestPlaceholder" />
</menu> </menubar>
<dockitem name="toolbar1"> <toolbar name="toolbar1">
<placeholder name="ToolbarPlaceholder" /> <placeholder name="ToolbarPlaceholder">
<toolitem name="NewButton" verb="NewAction" /> <toolitem name="nb2" action="NewAction" />
<toolitem name="CutButton" verb="CutAction" /> </placeholder>
<toolitem name="CopyButton" verb="CopyAction" /> <toolitem name="NewButton" action="NewAction" />
<toolitem name="PasteButton" verb="PasteAction" /> <toolitem name="CutButton" action="CutAction" />
<toolitem name="CopyButton" action="CopyAction" />
<toolitem name="PasteButton" action="PasteAction" />
<placeholder name="JustifyToolItems"/> <placeholder name="JustifyToolItems"/>
</dockitem> </toolbar>
</Root> </ui>

View File

@ -1,27 +1,27 @@
<!--*- xml -*--> <!--*- xml -*-->
<Root> <ui>
<menu> <menubar>
<submenu name="FileMenu" verb="StockFileMenuAction"> <menu name="FileMenu" action="StockFileMenuAction">
<menuitem name="New" verb="NewAction" pos="top" /> <menuitem name="New" action="NewAction" pos="top" />
<separator /> <separator />
<menuitem name="Quit" verb="QuitAction" /> <menuitem name="Quit" action="QuitAction" />
</submenu> </menu>
<submenu name="HelpMenu" verb="StockHelpMenuAction"> <menu name="HelpMenu" action="StockHelpMenuAction">
<menuitem name="About" verb="AboutAction" /> <menuitem name="About" action="AboutAction" />
</submenu> </menu>
</menu> </menubar>
<dockitem name="toolbar1"> <toolbar name="toolbar1">
<placeholder name="ToolbarPlaceholder"> <placeholder name="ToolbarPlaceholder">
<toolitem name="Quit" verb="QuitAction" /> <toolitem name="Quit" action="QuitAction" />
<separator /> <separator />
</placeholder> </placeholder>
</dockitem> </toolbar>
<popups> <popups>
<popup name="FileMenu" verb="StockFileMenuAction"> <popup name="FileMenu" action="StockFileMenuAction">
<menuitem name="New" verb="NewAction" pos="top" /> <menuitem name="New" action="NewAction" pos="top" />
<submenu name="HelpMenu" verb="StockHelpMenuAction"> <menu name="HelpMenu" action="StockHelpMenuAction">
<menuitem name="About" verb="AboutAction" /> <menuitem name="About" action="AboutAction" />
</submenu> </menu>
</popup> </popup>
</popups> </popups>
</Root> </ui>

View File

@ -1,23 +1,23 @@
<!--*- xml -*--> <!--*- xml -*-->
<Root> <ui>
<menu> <menubar>
<submenu name="FileMenu" verb="StockFileMenuAction"> <menu name="FileMenu" action="StockFileMenuAction">
<menuitem name="New" verb="New2Action" /> <menuitem name="New" action="New2Action" />
</submenu> </menu>
<placeholder name="TestPlaceholder"> <placeholder name="TestPlaceholder">
<submenu name="Test"> <menu name="Test">
<menuitem name="Cut" verb="CutAction" /> <menuitem name="Cut" action="CutAction" />
</submenu> </menu>
</placeholder> </placeholder>
</menu> </menubar>
<dockitem name="toolbar1"> <toolbar name="toolbar1">
<placeholder name="JustifyToolItems"> <placeholder name="JustifyToolItems">
<separator name="first-sep"/> <separator name="first-sep"/>
<toolitem name="Left" verb="justify-left"/> <toolitem name="Left" action="justify-left"/>
<toolitem name="Centre" verb="justify-center"/> <toolitem name="Centre" action="justify-center"/>
<toolitem name="Right" verb="justify-right"/> <toolitem name="Right" action="justify-right"/>
<toolitem name="Fill" verb="justify-fill"/> <toolitem name="Fill" action="justify-fill"/>
<separator name="second-sep" /> <separator name="second-sep" />
</placeholder> </placeholder>
</dockitem> </toolbar>
</Root> </ui>

View File

@ -141,58 +141,56 @@ static guint n_entries = G_N_ELEMENTS (entries);
/* XML description of the menus for the test app. The parser understands /* XML description of the menus for the test app. The parser understands
* a subset of the Bonobo UI XML format, and uses GMarkup for parsing */ * a subset of the Bonobo UI XML format, and uses GMarkup for parsing */
static const gchar *ui_info = static const gchar *ui_info =
"<Root>\n" " <menubar>\n"
" <menu>\n" " <menu name=\"Menu _1\" action=\"Menu1Action\">\n"
" <submenu name=\"Menu _1\" verb=\"Menu1Action\">\n" " <menuitem name=\"cut\" action=\"cut\" />\n"
" <menuitem name=\"cut\" verb=\"cut\" />\n" " <menuitem name=\"copy\" action=\"copy\" />\n"
" <menuitem name=\"copy\" verb=\"copy\" />\n" " <menuitem name=\"paste\" action=\"paste\" />\n"
" <menuitem name=\"paste\" verb=\"paste\" />\n"
" <separator name=\"sep1\" />\n" " <separator name=\"sep1\" />\n"
" <menuitem name=\"bold1\" verb=\"bold\" />\n" " <menuitem name=\"bold1\" action=\"bold\" />\n"
" <menuitem name=\"bold2\" verb=\"bold\" />\n" " <menuitem name=\"bold2\" action=\"bold\" />\n"
" <separator name=\"sep2\" />\n" " <separator name=\"sep2\" />\n"
" <menuitem name=\"toggle-cnp\" verb=\"toggle-cnp\" />\n" " <menuitem name=\"toggle-cnp\" action=\"toggle-cnp\" />\n"
" <separator name=\"sep3\" />\n" " <separator name=\"sep3\" />\n"
" <menuitem name=\"quit\" verb=\"quit\" />\n" " <menuitem name=\"quit\" action=\"quit\" />\n"
" </submenu>\n" " </menu>\n"
" <submenu name=\"Menu _2\" verb=\"Menu2Action\">\n" " <menu name=\"Menu _2\" action=\"Menu2Action\">\n"
" <menuitem name=\"cut\" verb=\"cut\" />\n" " <menuitem name=\"cut\" action=\"cut\" />\n"
" <menuitem name=\"copy\" verb=\"copy\" />\n" " <menuitem name=\"copy\" action=\"copy\" />\n"
" <menuitem name=\"paste\" verb=\"paste\" />\n" " <menuitem name=\"paste\" action=\"paste\" />\n"
" <separator name=\"sep4\"/>\n" " <separator name=\"sep4\"/>\n"
" <menuitem name=\"bold\" verb=\"bold\" />\n" " <menuitem name=\"bold\" action=\"bold\" />\n"
" <separator name=\"sep5\"/>\n" " <separator name=\"sep5\"/>\n"
" <menuitem name=\"justify-left\" verb=\"justify-left\" />\n" " <menuitem name=\"justify-left\" action=\"justify-left\" />\n"
" <menuitem name=\"justify-center\" verb=\"justify-center\" />\n" " <menuitem name=\"justify-center\" action=\"justify-center\" />\n"
" <menuitem name=\"justify-right\" verb=\"justify-right\" />\n" " <menuitem name=\"justify-right\" action=\"justify-right\" />\n"
" <menuitem name=\"justify-fill\" verb=\"justify-fill\" />\n" " <menuitem name=\"justify-fill\" action=\"justify-fill\" />\n"
" <separator name=\"sep6\"/>\n" " <separator name=\"sep6\"/>\n"
" <menuitem name=\"customise-accels\" verb=\"customise-accels\" />\n" " <menuitem name=\"customise-accels\" action=\"customise-accels\" />\n"
" <separator name=\"sep7\"/>\n" " <separator name=\"sep7\"/>\n"
" <menuitem verb=\"toolbar-icons\" />\n" " <menuitem action=\"toolbar-icons\" />\n"
" <menuitem verb=\"toolbar-text\" />\n" " <menuitem action=\"toolbar-text\" />\n"
" <menuitem verb=\"toolbar-both\" />\n" " <menuitem action=\"toolbar-both\" />\n"
" <menuitem verb=\"toolbar-both-horiz\" />\n" " <menuitem action=\"toolbar-both-horiz\" />\n"
" <separator name=\"sep8\"/>\n" " <separator name=\"sep8\"/>\n"
" <menuitem verb=\"toolbar-small-icons\" />\n" " <menuitem action=\"toolbar-small-icons\" />\n"
" <menuitem verb=\"toolbar-large-icons\" />\n" " <menuitem action=\"toolbar-large-icons\" />\n"
" </submenu>\n" " </menu>\n"
" </menu>\n" " </menubar>\n"
" <dockitem name=\"toolbar\">\n" " <toolbar name=\"toolbar\">\n"
" <toolitem name=\"cut\" verb=\"cut\" />\n" " <toolitem name=\"cut\" action=\"cut\" />\n"
" <toolitem name=\"copy\" verb=\"copy\" />\n" " <toolitem name=\"copy\" action=\"copy\" />\n"
" <toolitem name=\"paste\" verb=\"paste\" />\n" " <toolitem name=\"paste\" action=\"paste\" />\n"
" <separator name=\"sep9\" />\n" " <separator name=\"sep9\" />\n"
" <toolitem name=\"bold\" verb=\"bold\" />\n" " <toolitem name=\"bold\" action=\"bold\" />\n"
" <separator name=\"sep10\" />\n" " <separator name=\"sep10\" />\n"
" <toolitem name=\"justify-left\" verb=\"justify-left\" />\n" " <toolitem name=\"justify-left\" action=\"justify-left\" />\n"
" <toolitem name=\"justify-center\" verb=\"justify-center\" />\n" " <toolitem name=\"justify-center\" action=\"justify-center\" />\n"
" <toolitem name=\"justify-right\" verb=\"justify-right\" />\n" " <toolitem name=\"justify-right\" action=\"justify-right\" />\n"
" <toolitem name=\"justify-fill\" verb=\"justify-fill\" />\n" " <toolitem name=\"justify-fill\" action=\"justify-fill\" />\n"
" <separator name=\"sep11\"/>\n" " <separator name=\"sep11\"/>\n"
" <toolitem name=\"quit\" verb=\"quit\" />\n" " <toolitem name=\"quit\" action=\"quit\" />\n"
" </dockitem>\n" " </toolbar>\n";
"</Root>\n";
static void static void
add_widget (GtkUIManager *merge, add_widget (GtkUIManager *merge,