mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-23 20:30:15 +00:00
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:
parent
2be259b24a
commit
720bdb8daf
24
ChangeLog
24
ChangeLog
@ -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>
|
||||
|
||||
* 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:
|
||||
* tests/testmerge.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
|
||||
entries array, remove newlines from ui definition. Don't use the ::add_widget signal.
|
||||
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
|
||||
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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
* 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:
|
||||
* tests/testmerge.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
|
||||
entries array, remove newlines from ui definition. Don't use the ::add_widget signal.
|
||||
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
|
||||
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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
* 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:
|
||||
* tests/testmerge.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
|
||||
entries array, remove newlines from ui definition. Don't use the ::add_widget signal.
|
||||
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
|
||||
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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
* 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:
|
||||
* tests/testmerge.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
|
||||
entries array, remove newlines from ui definition. Don't use the ::add_widget signal.
|
||||
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
|
||||
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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
* 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:
|
||||
* tests/testmerge.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
|
||||
entries array, remove newlines from ui definition. Don't use the ::add_widget signal.
|
||||
* demos/gtk-demo/appwindow.c: Make GtkMenuMerge demo less intimidating:
|
||||
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>
|
||||
|
||||
|
@ -101,39 +101,39 @@ static GtkActionGroupEntry entries[] = {
|
||||
static guint n_entries = G_N_ELEMENTS (entries);
|
||||
|
||||
static const gchar *ui_info =
|
||||
"<Root>"
|
||||
" <menu name='MenuBar'>"
|
||||
" <submenu name='FileMenu'>"
|
||||
"<ui>"
|
||||
" <menubar name='MenuBar'>"
|
||||
" <menu name='FileMenu'>"
|
||||
" <menuitem name='New'/>"
|
||||
" <menuitem name='Open'/>"
|
||||
" <menuitem name='Save'/>"
|
||||
" <menuitem name='SaveAs'/>"
|
||||
" <separator name='Sep1'/>"
|
||||
" <menuitem name='Quit'/>"
|
||||
" </submenu>"
|
||||
" <submenu name='PreferencesMenu'>"
|
||||
" <submenu name='ColorMenu'>"
|
||||
" </menu>"
|
||||
" <menu name='PreferencesMenu'>"
|
||||
" <menu name='ColorMenu'>"
|
||||
" <menuitem name='Red'/>"
|
||||
" <menuitem name='Green'/>"
|
||||
" <menuitem name='Blue'/>"
|
||||
" </submenu>"
|
||||
" <submenu name='ShapeMenu'>"
|
||||
" </menu>"
|
||||
" <menu name='ShapeMenu'>"
|
||||
" <menuitem name='Square'/>"
|
||||
" <menuitem name='Rectangle'/>"
|
||||
" <menuitem name='Oval'/>"
|
||||
" </submenu>"
|
||||
" </submenu>"
|
||||
" <submenu name='HelpMenu'>"
|
||||
" </menu>"
|
||||
" </menu>"
|
||||
" <menu name='HelpMenu'>"
|
||||
" <menuitem name='About'/>"
|
||||
" </submenu>"
|
||||
" </menu>"
|
||||
" <dockitem name='ToolBar'>"
|
||||
" </menu>"
|
||||
" </menubar>"
|
||||
" <toolbar name='ToolBar'>"
|
||||
" <toolitem name='Open'/>"
|
||||
" <toolitem name='Quit'/>"
|
||||
" <separator name='Sep1'/>"
|
||||
" <toolitem name='Logo'/>"
|
||||
" </dockitem>"
|
||||
"</Root>";
|
||||
" </toolbar>"
|
||||
"</ui>";
|
||||
|
||||
|
||||
|
||||
|
@ -428,7 +428,7 @@ gtk_action_sync_property (GtkAction *action,
|
||||
|
||||
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_set_property (G_OBJECT (proxy), property, &value);
|
||||
|
@ -212,7 +212,7 @@ gtk_ui_manager_init (GtkUIManager *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_node_prepend_ui_reference (NODE_INFO (node), merge_id, 0);
|
||||
node = get_child_node (self, self->private_data->root_node, "popups", 6,
|
||||
@ -567,7 +567,7 @@ start_element_handler (GMarkupParseContext *context,
|
||||
|
||||
gint i;
|
||||
const gchar *node_name;
|
||||
GQuark verb_quark;
|
||||
GQuark action_quark;
|
||||
gboolean top;
|
||||
|
||||
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
|
||||
* element name */
|
||||
node_name = element_name;
|
||||
verb_quark = 0;
|
||||
action_quark = 0;
|
||||
top = FALSE;
|
||||
for (i = 0; attribute_names[i] != NULL; i++)
|
||||
{
|
||||
@ -584,34 +584,34 @@ start_element_handler (GMarkupParseContext *context,
|
||||
{
|
||||
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"))
|
||||
{
|
||||
top = !strcmp (attribute_values[i], "top");
|
||||
}
|
||||
}
|
||||
/* if no verb, then set it to the node's name */
|
||||
if (verb_quark == 0)
|
||||
verb_quark = g_quark_from_string (node_name);
|
||||
/* if no action, then set it to the node's name */
|
||||
if (action_quark == 0)
|
||||
action_quark = g_quark_from_string (node_name);
|
||||
|
||||
switch (element_name[0])
|
||||
{
|
||||
case 'R':
|
||||
if (ctx->state == STATE_START && !strcmp (element_name, "Root"))
|
||||
case 'u':
|
||||
if (ctx->state == STATE_START && !strcmp (element_name, "ui"))
|
||||
{
|
||||
ctx->state = STATE_ROOT;
|
||||
ctx->current = self->private_data->root_node;
|
||||
raise_error = FALSE;
|
||||
|
||||
gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current),
|
||||
ctx->merge_id, verb_quark);
|
||||
ctx->merge_id, action_quark);
|
||||
}
|
||||
break;
|
||||
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->current = get_child_node (self, ctx->current,
|
||||
@ -619,12 +619,28 @@ start_element_handler (GMarkupParseContext *context,
|
||||
GTK_UI_MANAGER_MENUBAR,
|
||||
TRUE, FALSE);
|
||||
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),
|
||||
ctx->merge_id, verb_quark);
|
||||
ctx->merge_id, action_quark);
|
||||
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;
|
||||
}
|
||||
else if (ctx->state == STATE_MENU && !strcmp (element_name, "menuitem"))
|
||||
@ -637,30 +653,12 @@ start_element_handler (GMarkupParseContext *context,
|
||||
GTK_UI_MANAGER_MENUITEM,
|
||||
TRUE, top);
|
||||
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),
|
||||
ctx->merge_id, verb_quark);
|
||||
ctx->merge_id, action_quark);
|
||||
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;
|
||||
}
|
||||
break;
|
||||
@ -674,7 +672,7 @@ start_element_handler (GMarkupParseContext *context,
|
||||
TRUE, FALSE);
|
||||
|
||||
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;
|
||||
|
||||
raise_error = FALSE;
|
||||
@ -687,10 +685,10 @@ start_element_handler (GMarkupParseContext *context,
|
||||
GTK_UI_MANAGER_MENU,
|
||||
TRUE, FALSE);
|
||||
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),
|
||||
ctx->merge_id, verb_quark);
|
||||
ctx->merge_id, action_quark);
|
||||
NODE_INFO (ctx->current)->dirty = TRUE;
|
||||
|
||||
raise_error = FALSE;
|
||||
@ -710,30 +708,14 @@ start_element_handler (GMarkupParseContext *context,
|
||||
TRUE, top);
|
||||
|
||||
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;
|
||||
|
||||
raise_error = FALSE;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if (ctx->state == STATE_MENU && !strcmp (element_name, "submenu"))
|
||||
{
|
||||
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) &&
|
||||
if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
|
||||
!strcmp (element_name, "separator"))
|
||||
{
|
||||
GNode *node;
|
||||
@ -747,17 +729,33 @@ start_element_handler (GMarkupParseContext *context,
|
||||
GTK_UI_MANAGER_SEPARATOR,
|
||||
TRUE, top);
|
||||
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),
|
||||
ctx->merge_id, verb_quark);
|
||||
ctx->merge_id, action_quark);
|
||||
NODE_INFO (node)->dirty = TRUE;
|
||||
|
||||
raise_error = FALSE;
|
||||
}
|
||||
break;
|
||||
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;
|
||||
|
||||
@ -767,10 +765,10 @@ start_element_handler (GMarkupParseContext *context,
|
||||
GTK_UI_MANAGER_TOOLITEM,
|
||||
TRUE, top);
|
||||
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),
|
||||
ctx->merge_id, verb_quark);
|
||||
ctx->merge_id, action_quark);
|
||||
NODE_INFO (node)->dirty = TRUE;
|
||||
|
||||
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:
|
||||
* @self: a #GtkUIManager object
|
||||
@ -899,41 +947,28 @@ static GMarkupParser ui_parser = {
|
||||
guint
|
||||
gtk_ui_manager_add_ui_from_string (GtkUIManager *self,
|
||||
const gchar *buffer,
|
||||
gsize length,
|
||||
gssize length,
|
||||
GError **error)
|
||||
{
|
||||
ParseContext ctx = { 0 };
|
||||
GMarkupParseContext *context;
|
||||
gboolean res = TRUE;
|
||||
gboolean needs_root = TRUE;
|
||||
const gchar *p;
|
||||
const gchar *end;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_UI_MANAGER (self), 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)
|
||||
length = strlen (buffer);
|
||||
|
||||
if (g_markup_parse_context_parse (context, buffer, length, error))
|
||||
{
|
||||
if (!g_markup_parse_context_end_parse (context, error))
|
||||
res = FALSE;
|
||||
}
|
||||
else
|
||||
res = FALSE;
|
||||
p = buffer;
|
||||
end = buffer + length;
|
||||
while (p != end && xml_isspace (*p))
|
||||
++p;
|
||||
|
||||
g_markup_parse_context_free (context);
|
||||
|
||||
gtk_ui_manager_queue_update (self);
|
||||
|
||||
if (res)
|
||||
return ctx.merge_id;
|
||||
|
||||
return 0;
|
||||
if (end - p >= 4 && strncmp (p, "<ui>", 4) == 0)
|
||||
needs_root = FALSE;
|
||||
|
||||
return add_ui_from_string (self, buffer, length, needs_root, error);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -963,7 +998,7 @@ gtk_ui_manager_add_ui_from_file (GtkUIManager *self,
|
||||
if (!g_file_get_contents (filename, &buffer, &length, error))
|
||||
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);
|
||||
|
||||
return res;
|
||||
@ -1572,25 +1607,25 @@ gtk_ui_manager_dirty_all (GtkUIManager *self)
|
||||
|
||||
static const gchar *open_tag_format[] = {
|
||||
"%*s<UNDECIDED>\n",
|
||||
"%*s<Root>\n",
|
||||
"%*s<menu name=\"%s\">\n",
|
||||
"%*s<submenu name=\"%s\" verb=\"%s\">\n",
|
||||
"%*s<dockitem name=\"%s\">\n",
|
||||
"%*s<ui>\n",
|
||||
"%*s<menubar name=\"%s\">\n",
|
||||
"%*s<menu name=\"%s\" action=\"%s\">\n",
|
||||
"%*s<toolbar name=\"%s\">\n",
|
||||
"%*s<placeholder name=\"%s\">\n",
|
||||
"%*s<placeholder name=\"%s\">\n",
|
||||
"%*s<popups>\n",
|
||||
"%*s<menuitem name=\"%s\" verb=\"%s\"/>\n",
|
||||
"%*s<toolitem name=\"%s\" verb=\"%s\"/>\n",
|
||||
"%*s<menuitem name=\"%s\" action=\"%s\"/>\n",
|
||||
"%*s<toolitem name=\"%s\" action=\"%s\"/>\n",
|
||||
"%*s<separator/>\n",
|
||||
"%*s<popup name=\"%s\">\n"
|
||||
};
|
||||
|
||||
static const gchar *close_tag_format[] = {
|
||||
"%*s</UNDECIDED>\n",
|
||||
"%*s</Root>\n",
|
||||
"%*s</ui>\n",
|
||||
"%*s</menubar>\n",
|
||||
"%*s</menu>\n",
|
||||
"%*s</submenu>\n",
|
||||
"%*s</dockitem>\n",
|
||||
"%*s</toolbar>\n",
|
||||
"%*s</placeholder>\n",
|
||||
"%*s</placeholder>\n",
|
||||
"%*s</popups>\n",
|
||||
|
@ -95,7 +95,7 @@ GtkWidget *gtk_ui_manager_get_widget (GtkUIManager *self,
|
||||
* interface */
|
||||
guint gtk_ui_manager_add_ui_from_string (GtkUIManager *self,
|
||||
const gchar *buffer,
|
||||
gsize length,
|
||||
gssize length,
|
||||
GError **error);
|
||||
guint gtk_ui_manager_add_ui_from_file (GtkUIManager *self,
|
||||
const gchar *filename,
|
||||
|
@ -1,20 +1,22 @@
|
||||
<!--*- xml -*-->
|
||||
<Root>
|
||||
<menu>
|
||||
<submenu name="FileMenu" verb="StockFileMenuAction">
|
||||
<menuitem name="Open" verb="OpenAction" />
|
||||
</submenu>
|
||||
<submenu name="EditMenu" verb="StockEditMenuAction">
|
||||
<menuitem name="Cut" verb="CutAction" />
|
||||
</submenu>
|
||||
<ui>
|
||||
<menubar>
|
||||
<menu name="FileMenu" action="StockFileMenuAction">
|
||||
<menuitem name="Open" action="OpenAction" />
|
||||
</menu>
|
||||
<menu name="EditMenu" action="StockEditMenuAction">
|
||||
<menuitem name="Cut" action="CutAction" />
|
||||
</menu>
|
||||
<placeholder name="TestPlaceholder" />
|
||||
</menu>
|
||||
<dockitem name="toolbar1">
|
||||
<placeholder name="ToolbarPlaceholder" />
|
||||
<toolitem name="NewButton" verb="NewAction" />
|
||||
<toolitem name="CutButton" verb="CutAction" />
|
||||
<toolitem name="CopyButton" verb="CopyAction" />
|
||||
<toolitem name="PasteButton" verb="PasteAction" />
|
||||
</menubar>
|
||||
<toolbar name="toolbar1">
|
||||
<placeholder name="ToolbarPlaceholder">
|
||||
<toolitem name="nb2" action="NewAction" />
|
||||
</placeholder>
|
||||
<toolitem name="NewButton" action="NewAction" />
|
||||
<toolitem name="CutButton" action="CutAction" />
|
||||
<toolitem name="CopyButton" action="CopyAction" />
|
||||
<toolitem name="PasteButton" action="PasteAction" />
|
||||
<placeholder name="JustifyToolItems"/>
|
||||
</dockitem>
|
||||
</Root>
|
||||
</toolbar>
|
||||
</ui>
|
||||
|
@ -1,27 +1,27 @@
|
||||
<!--*- xml -*-->
|
||||
<Root>
|
||||
<menu>
|
||||
<submenu name="FileMenu" verb="StockFileMenuAction">
|
||||
<menuitem name="New" verb="NewAction" pos="top" />
|
||||
<ui>
|
||||
<menubar>
|
||||
<menu name="FileMenu" action="StockFileMenuAction">
|
||||
<menuitem name="New" action="NewAction" pos="top" />
|
||||
<separator />
|
||||
<menuitem name="Quit" verb="QuitAction" />
|
||||
</submenu>
|
||||
<submenu name="HelpMenu" verb="StockHelpMenuAction">
|
||||
<menuitem name="About" verb="AboutAction" />
|
||||
</submenu>
|
||||
</menu>
|
||||
<dockitem name="toolbar1">
|
||||
<menuitem name="Quit" action="QuitAction" />
|
||||
</menu>
|
||||
<menu name="HelpMenu" action="StockHelpMenuAction">
|
||||
<menuitem name="About" action="AboutAction" />
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="toolbar1">
|
||||
<placeholder name="ToolbarPlaceholder">
|
||||
<toolitem name="Quit" verb="QuitAction" />
|
||||
<toolitem name="Quit" action="QuitAction" />
|
||||
<separator />
|
||||
</placeholder>
|
||||
</dockitem>
|
||||
</toolbar>
|
||||
<popups>
|
||||
<popup name="FileMenu" verb="StockFileMenuAction">
|
||||
<menuitem name="New" verb="NewAction" pos="top" />
|
||||
<submenu name="HelpMenu" verb="StockHelpMenuAction">
|
||||
<menuitem name="About" verb="AboutAction" />
|
||||
</submenu>
|
||||
<popup name="FileMenu" action="StockFileMenuAction">
|
||||
<menuitem name="New" action="NewAction" pos="top" />
|
||||
<menu name="HelpMenu" action="StockHelpMenuAction">
|
||||
<menuitem name="About" action="AboutAction" />
|
||||
</menu>
|
||||
</popup>
|
||||
</popups>
|
||||
</Root>
|
||||
</ui>
|
||||
|
@ -1,23 +1,23 @@
|
||||
<!--*- xml -*-->
|
||||
<Root>
|
||||
<menu>
|
||||
<submenu name="FileMenu" verb="StockFileMenuAction">
|
||||
<menuitem name="New" verb="New2Action" />
|
||||
</submenu>
|
||||
<ui>
|
||||
<menubar>
|
||||
<menu name="FileMenu" action="StockFileMenuAction">
|
||||
<menuitem name="New" action="New2Action" />
|
||||
</menu>
|
||||
<placeholder name="TestPlaceholder">
|
||||
<submenu name="Test">
|
||||
<menuitem name="Cut" verb="CutAction" />
|
||||
</submenu>
|
||||
<menu name="Test">
|
||||
<menuitem name="Cut" action="CutAction" />
|
||||
</menu>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<dockitem name="toolbar1">
|
||||
</menubar>
|
||||
<toolbar name="toolbar1">
|
||||
<placeholder name="JustifyToolItems">
|
||||
<separator name="first-sep"/>
|
||||
<toolitem name="Left" verb="justify-left"/>
|
||||
<toolitem name="Centre" verb="justify-center"/>
|
||||
<toolitem name="Right" verb="justify-right"/>
|
||||
<toolitem name="Fill" verb="justify-fill"/>
|
||||
<toolitem name="Left" action="justify-left"/>
|
||||
<toolitem name="Centre" action="justify-center"/>
|
||||
<toolitem name="Right" action="justify-right"/>
|
||||
<toolitem name="Fill" action="justify-fill"/>
|
||||
<separator name="second-sep" />
|
||||
</placeholder>
|
||||
</dockitem>
|
||||
</Root>
|
||||
</toolbar>
|
||||
</ui>
|
||||
|
@ -141,58 +141,56 @@ static guint n_entries = G_N_ELEMENTS (entries);
|
||||
/* 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 */
|
||||
static const gchar *ui_info =
|
||||
"<Root>\n"
|
||||
" <menu>\n"
|
||||
" <submenu name=\"Menu _1\" verb=\"Menu1Action\">\n"
|
||||
" <menuitem name=\"cut\" verb=\"cut\" />\n"
|
||||
" <menuitem name=\"copy\" verb=\"copy\" />\n"
|
||||
" <menuitem name=\"paste\" verb=\"paste\" />\n"
|
||||
" <menubar>\n"
|
||||
" <menu name=\"Menu _1\" action=\"Menu1Action\">\n"
|
||||
" <menuitem name=\"cut\" action=\"cut\" />\n"
|
||||
" <menuitem name=\"copy\" action=\"copy\" />\n"
|
||||
" <menuitem name=\"paste\" action=\"paste\" />\n"
|
||||
" <separator name=\"sep1\" />\n"
|
||||
" <menuitem name=\"bold1\" verb=\"bold\" />\n"
|
||||
" <menuitem name=\"bold2\" verb=\"bold\" />\n"
|
||||
" <menuitem name=\"bold1\" action=\"bold\" />\n"
|
||||
" <menuitem name=\"bold2\" action=\"bold\" />\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"
|
||||
" <menuitem name=\"quit\" verb=\"quit\" />\n"
|
||||
" </submenu>\n"
|
||||
" <submenu name=\"Menu _2\" verb=\"Menu2Action\">\n"
|
||||
" <menuitem name=\"cut\" verb=\"cut\" />\n"
|
||||
" <menuitem name=\"copy\" verb=\"copy\" />\n"
|
||||
" <menuitem name=\"paste\" verb=\"paste\" />\n"
|
||||
" <menuitem name=\"quit\" action=\"quit\" />\n"
|
||||
" </menu>\n"
|
||||
" <menu name=\"Menu _2\" action=\"Menu2Action\">\n"
|
||||
" <menuitem name=\"cut\" action=\"cut\" />\n"
|
||||
" <menuitem name=\"copy\" action=\"copy\" />\n"
|
||||
" <menuitem name=\"paste\" action=\"paste\" />\n"
|
||||
" <separator name=\"sep4\"/>\n"
|
||||
" <menuitem name=\"bold\" verb=\"bold\" />\n"
|
||||
" <menuitem name=\"bold\" action=\"bold\" />\n"
|
||||
" <separator name=\"sep5\"/>\n"
|
||||
" <menuitem name=\"justify-left\" verb=\"justify-left\" />\n"
|
||||
" <menuitem name=\"justify-center\" verb=\"justify-center\" />\n"
|
||||
" <menuitem name=\"justify-right\" verb=\"justify-right\" />\n"
|
||||
" <menuitem name=\"justify-fill\" verb=\"justify-fill\" />\n"
|
||||
" <menuitem name=\"justify-left\" action=\"justify-left\" />\n"
|
||||
" <menuitem name=\"justify-center\" action=\"justify-center\" />\n"
|
||||
" <menuitem name=\"justify-right\" action=\"justify-right\" />\n"
|
||||
" <menuitem name=\"justify-fill\" action=\"justify-fill\" />\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"
|
||||
" <menuitem verb=\"toolbar-icons\" />\n"
|
||||
" <menuitem verb=\"toolbar-text\" />\n"
|
||||
" <menuitem verb=\"toolbar-both\" />\n"
|
||||
" <menuitem verb=\"toolbar-both-horiz\" />\n"
|
||||
" <menuitem action=\"toolbar-icons\" />\n"
|
||||
" <menuitem action=\"toolbar-text\" />\n"
|
||||
" <menuitem action=\"toolbar-both\" />\n"
|
||||
" <menuitem action=\"toolbar-both-horiz\" />\n"
|
||||
" <separator name=\"sep8\"/>\n"
|
||||
" <menuitem verb=\"toolbar-small-icons\" />\n"
|
||||
" <menuitem verb=\"toolbar-large-icons\" />\n"
|
||||
" </submenu>\n"
|
||||
" </menu>\n"
|
||||
" <dockitem name=\"toolbar\">\n"
|
||||
" <toolitem name=\"cut\" verb=\"cut\" />\n"
|
||||
" <toolitem name=\"copy\" verb=\"copy\" />\n"
|
||||
" <toolitem name=\"paste\" verb=\"paste\" />\n"
|
||||
" <menuitem action=\"toolbar-small-icons\" />\n"
|
||||
" <menuitem action=\"toolbar-large-icons\" />\n"
|
||||
" </menu>\n"
|
||||
" </menubar>\n"
|
||||
" <toolbar name=\"toolbar\">\n"
|
||||
" <toolitem name=\"cut\" action=\"cut\" />\n"
|
||||
" <toolitem name=\"copy\" action=\"copy\" />\n"
|
||||
" <toolitem name=\"paste\" action=\"paste\" />\n"
|
||||
" <separator name=\"sep9\" />\n"
|
||||
" <toolitem name=\"bold\" verb=\"bold\" />\n"
|
||||
" <toolitem name=\"bold\" action=\"bold\" />\n"
|
||||
" <separator name=\"sep10\" />\n"
|
||||
" <toolitem name=\"justify-left\" verb=\"justify-left\" />\n"
|
||||
" <toolitem name=\"justify-center\" verb=\"justify-center\" />\n"
|
||||
" <toolitem name=\"justify-right\" verb=\"justify-right\" />\n"
|
||||
" <toolitem name=\"justify-fill\" verb=\"justify-fill\" />\n"
|
||||
" <toolitem name=\"justify-left\" action=\"justify-left\" />\n"
|
||||
" <toolitem name=\"justify-center\" action=\"justify-center\" />\n"
|
||||
" <toolitem name=\"justify-right\" action=\"justify-right\" />\n"
|
||||
" <toolitem name=\"justify-fill\" action=\"justify-fill\" />\n"
|
||||
" <separator name=\"sep11\"/>\n"
|
||||
" <toolitem name=\"quit\" verb=\"quit\" />\n"
|
||||
" </dockitem>\n"
|
||||
"</Root>\n";
|
||||
" <toolitem name=\"quit\" action=\"quit\" />\n"
|
||||
" </toolbar>\n";
|
||||
|
||||
static void
|
||||
add_widget (GtkUIManager *merge,
|
||||
|
Loading…
Reference in New Issue
Block a user