diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2003-08-25 23:13:47 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2003-08-25 23:13:47 +0000 |
commit | 77af2d637c944f1e61d290ede8ae61be95c5abb7 (patch) | |
tree | 1b75baadf5c443edc0ae00fde5a963cb03c2e8e8 | |
parent | 3cb958de19162d57df4c04d383f7fd52e4d818a1 (diff) | |
download | gtk+-77af2d637c944f1e61d290ede8ae61be95c5abb7.tar.gz |
Rename GtkMenuMerge to GtkUIManager.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 16 | ||||
-rw-r--r-- | demos/gtk-demo/appwindow.c | 215 | ||||
-rw-r--r-- | gtk/Makefile.am | 4 | ||||
-rw-r--r-- | gtk/gtk.h | 2 | ||||
-rw-r--r-- | gtk/gtkmenumerge.h | 109 | ||||
-rw-r--r-- | gtk/gtkuimanager.c (renamed from gtk/gtkmenumerge.c) | 396 | ||||
-rw-r--r-- | gtk/gtkuimanager.h | 109 | ||||
-rw-r--r-- | tests/testactions.c | 12 | ||||
-rw-r--r-- | tests/testmerge.c | 28 |
13 files changed, 532 insertions, 423 deletions
@@ -1,3 +1,19 @@ +2003-08-26 Matthias Clasen <maclas@gmx.de> + + Rename GtkMenuMerge to GtkUIManager. + + * gtk/gtkuimanager.[hc]: New files. + * gtk/gtkmenumerge.[hc]: Removed. + + * gtk/Makefile.am: + * 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: 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> * gtk/gtknotebook.c (gtk_notebook_forall): Don't diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 91a9358f01..78ea6e6746 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,19 @@ +2003-08-26 Matthias Clasen <maclas@gmx.de> + + Rename GtkMenuMerge to GtkUIManager. + + * gtk/gtkuimanager.[hc]: New files. + * gtk/gtkmenumerge.[hc]: Removed. + + * gtk/Makefile.am: + * 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: 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> * gtk/gtknotebook.c (gtk_notebook_forall): Don't diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 91a9358f01..78ea6e6746 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,19 @@ +2003-08-26 Matthias Clasen <maclas@gmx.de> + + Rename GtkMenuMerge to GtkUIManager. + + * gtk/gtkuimanager.[hc]: New files. + * gtk/gtkmenumerge.[hc]: Removed. + + * gtk/Makefile.am: + * 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: 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> * gtk/gtknotebook.c (gtk_notebook_forall): Don't diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 91a9358f01..78ea6e6746 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,19 @@ +2003-08-26 Matthias Clasen <maclas@gmx.de> + + Rename GtkMenuMerge to GtkUIManager. + + * gtk/gtkuimanager.[hc]: New files. + * gtk/gtkmenumerge.[hc]: Removed. + + * gtk/Makefile.am: + * 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: 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> * gtk/gtknotebook.c (gtk_notebook_forall): Don't diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 91a9358f01..78ea6e6746 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,19 @@ +2003-08-26 Matthias Clasen <maclas@gmx.de> + + Rename GtkMenuMerge to GtkUIManager. + + * gtk/gtkuimanager.[hc]: New files. + * gtk/gtkmenumerge.[hc]: Removed. + + * gtk/Makefile.am: + * 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: 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> * gtk/gtknotebook.c (gtk_notebook_forall): Don't diff --git a/demos/gtk-demo/appwindow.c b/demos/gtk-demo/appwindow.c index 88742cc13b..916f1ae444 100644 --- a/demos/gtk-demo/appwindow.c +++ b/demos/gtk-demo/appwindow.c @@ -33,69 +33,107 @@ activate_action (GtkAction *action) } -#ifndef N_ -#define N_(String) String -#endif - static GtkActionGroupEntry entries[] = { - { "FileMenu", N_("_File"), NULL, NULL, NULL, NULL, NULL }, - { "PreferencesMenu", N_("_Preferences"), NULL, NULL, NULL, NULL, NULL }, - { "ColorMenu", N_("_Color"), NULL, NULL, NULL, NULL, NULL }, - { "ShapeMenu", N_("_Shape"), NULL, NULL, NULL, NULL, NULL }, - { "HelpMenu", N_("_Help"), NULL, NULL, NULL, NULL, NULL }, - - { "New", N_("_New"), GTK_STOCK_NEW, "<control>N", N_("Create a new file"), G_CALLBACK (activate_action), NULL }, - { "Open", N_("_Open"), GTK_STOCK_OPEN, "<control>O", N_("Open a file"), G_CALLBACK (activate_action), NULL }, - { "Save", N_("_Save"), GTK_STOCK_SAVE, "<control>S", N_("Save current file"), G_CALLBACK (activate_action), NULL }, - { "SaveAs", N_("Save _As..."), GTK_STOCK_SAVE, NULL, N_("Save to a file"), G_CALLBACK (activate_action), NULL }, - { "Quit", N_("_Quit"), GTK_STOCK_QUIT, "<control>Q", N_("Quit"), G_CALLBACK (activate_action), NULL }, - - { "Red", N_("_Red"), NULL, "<control>R", N_("Blood"), G_CALLBACK (activate_action), NULL, GTK_ACTION_RADIO }, - { "Green", N_("_Green"), NULL, "<control>G", N_("Grass"), G_CALLBACK (activate_action), NULL, GTK_ACTION_RADIO, "Red" }, - { "Blue", N_("_Blue"), NULL, "<control>B", N_("Sky"), G_CALLBACK (activate_action), NULL, GTK_ACTION_RADIO, "Red" }, - - { "Square", N_("_Square"), NULL, "<control>S", N_("Square"), G_CALLBACK (activate_action), NULL, GTK_ACTION_RADIO }, - { "Rectangle", N_("_Rectangle"), NULL, "<control>R", N_("Rectangle"), G_CALLBACK (activate_action), NULL, GTK_ACTION_RADIO, "Square" }, - { "Oval", N_("_Oval"), NULL, "<control>O", N_("Egg"), G_CALLBACK (activate_action), NULL, GTK_ACTION_RADIO, "Square" }, - { "About", N_("_About"), NULL, "<control>A", N_("About"), G_CALLBACK (activate_action), NULL }, - { "Logo", NULL, "demo-gtk-logo", NULL, N_("GTK+"), G_CALLBACK (activate_action), NULL }, + { "FileMenu", "_File" }, /* name, label */ + { "PreferencesMenu", "_Preferences" }, /* name, label */ + { "ColorMenu", "_Color" }, /* name, label */ + { "ShapeMenu", "_Shape" }, /* name, label */ + { "HelpMenu", "_Help" }, /* name, label */ + { "New", "_New", /* name, label */ + GTK_STOCK_NEW, "<control>N", /* stock_id, accelerator */ + "Create a new file", /* tooltip */ + G_CALLBACK (activate_action) }, + { "Open", "_Open", /* name, label */ + GTK_STOCK_OPEN, "<control>O", /* stock_id, accelerator */ + "Open a file", /* tooltip */ + G_CALLBACK (activate_action) }, + { "Save", "_Save", /* name, label */ + GTK_STOCK_SAVE, "<control>S", /* stock_id, accelerator */ + "Save current file", /* tooltip */ + G_CALLBACK (activate_action) }, + { "SaveAs", "Save _As...", /* name, label */ + GTK_STOCK_SAVE, NULL, /* stock_id, accelerator */ + "Save to a file", /* tooltip */ + G_CALLBACK (activate_action) }, + { "Quit", "_Quit", /* name, label */ + GTK_STOCK_QUIT, "<control>Q", /* stock_id, accelerator */ + "Quit", /* tooltip */ + G_CALLBACK (activate_action) }, + { "Red", "_Red", /* name, label */ + NULL, "<control>R", /* stock_id, accelerator */ + "Blood", /* tooltip */ + G_CALLBACK (activate_action), NULL, + GTK_ACTION_RADIO }, /* entry type */ + { "Green", "_Green", /* name, label */ + NULL, "<control>G", /* stock_id, accelerator */ + "Grass", /* tooltip */ + G_CALLBACK (activate_action), NULL, + GTK_ACTION_RADIO, "Red" }, /* entry type, radio group */ + { "Blue", "_Blue", /* name, label */ + NULL, "<control>B", /* stock_id, accelerator */ + "Sky", /* tooltip */ + G_CALLBACK (activate_action), NULL, + GTK_ACTION_RADIO, "Red" }, /* entry type, radio group */ + { "Square", "_Square", /* name, label */ + NULL, "<control>S", /* stock_id, accelerator */ + "Square", /* tooltip */ + G_CALLBACK (activate_action), NULL, + GTK_ACTION_RADIO }, /* entry type */ + { "Rectangle", "_Rectangle", /* name, label */ + NULL, "<control>R", /* stock_id, accelerator */ + "Rectangle", /* tooltip */ + G_CALLBACK (activate_action), NULL, + GTK_ACTION_RADIO, "Square" }, /* entry type, radio group */ + { "Oval", "_Oval", /* name, label */ + NULL, "<control>O", /* stock_id, accelerator */ + "Egg", /* tooltip */ + G_CALLBACK (activate_action), NULL, + GTK_ACTION_RADIO, "Square" }, /* entry type, radio group */ + { "About", "_About", /* name, label */ + NULL, "<control>A", /* stock_id, accelerator */ + "About", /* tooltip */ + G_CALLBACK (activate_action) }, + { "Logo", NULL, /* name, label */ + "demo-gtk-logo", NULL, /* stock_id, accelerator */ + "GTK+", /* tooltip */ + G_CALLBACK (activate_action) }, }; static guint n_entries = G_N_ELEMENTS (entries); static const gchar *ui_info = -"<Root>\n" -" <menu>\n" -" <submenu name='FileMenu'>\n" -" <menuitem name='New'/>\n" -" <menuitem name='Open'/>\n" -" <menuitem name='Save'/>\n" -" <menuitem name='SaveAs'/>\n" -" <separator name='Sep1'/>\n" -" <menuitem name='Quit'/>\n" -" </submenu>\n" -" <submenu name='PreferencesMenu'>\n" -" <submenu name='ColorMenu'>\n" -" <menuitem name='Red'/>\n" -" <menuitem name='Green'/>\n" -" <menuitem name='Blue'/>\n" -" </submenu>\n" -" <submenu name='ShapeMenu'>\n" -" <menuitem name='Square'/>\n" -" <menuitem name='Rectangle'/>\n" -" <menuitem name='Oval'/>\n" -" </submenu>\n" -" </submenu>\n" -" <submenu name='HelpMenu'>\n" -" <menuitem name='About'/>\n" -" </submenu>\n" -" </menu>\n" -" <dockitem>\n" -" <toolitem name='Open'/>\n" -" <toolitem name='Quit'/>\n" -" <separator name='Sep1'/>\n" -" <toolitem name='Logo'/>\n" -" </dockitem>\n" -"</Root>\n"; +"<Root>" +" <menu name='MenuBar'>" +" <submenu 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'>" +" <menuitem name='Red'/>" +" <menuitem name='Green'/>" +" <menuitem name='Blue'/>" +" </submenu>" +" <submenu name='ShapeMenu'>" +" <menuitem name='Square'/>" +" <menuitem name='Rectangle'/>" +" <menuitem name='Oval'/>" +" </submenu>" +" </submenu>" +" <submenu name='HelpMenu'>" +" <menuitem name='About'/>" +" </submenu>" +" </menu>" +" <dockitem name='ToolBar'>" +" <toolitem name='Open'/>" +" <toolitem name='Quit'/>" +" <separator name='Sep1'/>" +" <toolitem name='Logo'/>" +" </dockitem>" +"</Root>"; @@ -213,33 +251,6 @@ update_resize_grip (GtkWidget *widget, } -static void -add_widget (GtkMenuMerge *merge, - GtkWidget *widget, - GtkTable *table) -{ - if (GTK_IS_MENU_BAR (widget)) - { - gtk_table_attach (GTK_TABLE (table), - widget, - /* X direction */ /* Y direction */ - 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, 0, - 0, 0); - } - else if (GTK_IS_TOOLBAR (widget)) - { - gtk_table_attach (GTK_TABLE (table), - widget, - /* X direction */ /* Y direction */ - 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, 0, - 0, 0); - } - - gtk_widget_show (widget); -} - GtkWidget * do_appwindow (void) { @@ -249,10 +260,11 @@ do_appwindow (void) GtkWidget *statusbar; GtkWidget *contents; GtkWidget *sw; + GtkWidget *bar; GtkTextBuffer *buffer; GtkActionGroup *action_group; GtkAction *action; - GtkMenuMerge *merge; + GtkUIManager *merge; GError *error = NULL; register_stock_icons (); @@ -278,23 +290,40 @@ do_appwindow (void) action_group = gtk_action_group_new ("AppWindowActions"); gtk_action_group_add_actions (action_group, entries, n_entries); - action = gtk_action_group_get_action (action_group, "red"); + action = gtk_action_group_get_action (action_group, "Red"); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); - action = gtk_action_group_get_action (action_group, "square"); + action = gtk_action_group_get_action (action_group, "Square"); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); - merge = gtk_menu_merge_new (); - gtk_menu_merge_insert_action_group (merge, action_group, 0); - g_signal_connect (merge, "add_widget", G_CALLBACK (add_widget), table); + merge = gtk_ui_manager_new (); + gtk_ui_manager_insert_action_group (merge, action_group, 0); gtk_window_add_accel_group (GTK_WINDOW (window), - gtk_menu_merge_get_accel_group (merge)); + gtk_ui_manager_get_accel_group (merge)); - if (!gtk_menu_merge_add_ui_from_string (merge, ui_info, -1, &error)) + if (!gtk_ui_manager_add_ui_from_string (merge, ui_info, -1, &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); } + bar = gtk_ui_manager_get_widget (merge, "/MenuBar"); + gtk_widget_show (bar); + gtk_table_attach (GTK_TABLE (table), + bar, + /* X direction */ /* Y direction */ + 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL, 0, + 0, 0); + + bar = gtk_ui_manager_get_widget (merge, "/ToolBar"); + gtk_widget_show (bar); + gtk_table_attach (GTK_TABLE (table), + bar, + /* X direction */ /* Y direction */ + 0, 1, 1, 2, + GTK_EXPAND | GTK_FILL, 0, + 0, 0); + /* Create document */ diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 9ca5c77236..c0319342b8 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -167,7 +167,6 @@ gtk_public_h_sources = \ gtkmenu.h \ gtkmenubar.h \ gtkmenuitem.h \ - gtkmenumerge.h \ gtkmenushell.h \ gtkmessagedialog.h \ gtkmisc.h \ @@ -236,6 +235,7 @@ gtk_public_h_sources = \ gtktreeview.h \ gtktreeviewcolumn.h \ gtktypeutils.h \ + gtkuimanager.h \ gtkvbbox.h \ gtkvbox.h \ gtkviewport.h \ @@ -358,7 +358,6 @@ gtk_c_sources = \ gtkmarshalers.c \ gtkmarshal.c \ gtkmenu.c \ - gtkmenumerge.c \ gtkmenubar.c \ gtkmenuitem.c \ gtkmenushell.c \ @@ -429,6 +428,7 @@ gtk_c_sources = \ gtktreeviewcolumn.c \ gtktypebuiltins.c \ gtktypeutils.c \ + gtkuimanager.c \ gtkvbbox.c \ gtkvbox.c \ gtkviewport.c \ @@ -105,7 +105,6 @@ #include <gtk/gtkmenu.h> #include <gtk/gtkmenubar.h> #include <gtk/gtkmenuitem.h> -#include <gtk/gtkmenumerge.h> #include <gtk/gtkmenushell.h> #include <gtk/gtkmessagedialog.h> #include <gtk/gtkmisc.h> @@ -166,6 +165,7 @@ #include <gtk/gtktreeview.h> #include <gtk/gtktreeviewcolumn.h> #include <gtk/gtktypeutils.h> +#include <gtk/gtkuimanager.h> #include <gtk/gtkvbbox.h> #include <gtk/gtkvbox.h> #include <gtk/gtkversion.h> diff --git a/gtk/gtkmenumerge.h b/gtk/gtkmenumerge.h deleted file mode 100644 index e4db4dc7d9..0000000000 --- a/gtk/gtkmenumerge.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * GTK - The GIMP Toolkit - * Copyright (C) 1998, 1999 Red Hat, Inc. - * All rights reserved. - * - * This Library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This Library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Author: James Henstridge <james@daa.com.au> - * - * Modified by the GTK+ Team and others 2003. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ -#ifndef __GTK_MENU_MERGE_H__ -#define __GTK_MENU_MERGE_H__ - - -#include <glib.h> -#include <glib-object.h> -#include <gtk/gtkaccelgroup.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtkaction.h> -#include <gtk/gtkactiongroup.h> - -#define GTK_TYPE_MENU_MERGE (gtk_menu_merge_get_type ()) -#define GTK_MENU_MERGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_MERGE, GtkMenuMerge)) -#define GTK_MENU_MERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_MERGE, GtkMenuMergeClass)) -#define GTK_IS_MENU_MERGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_MERGE)) -#define GTK_IS_MENU_MERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_MENU_MERGE)) -#define GTK_MENU_MERGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_MENU_MERGE, GtkMenuMergeClass)) - -typedef struct _GtkMenuMerge GtkMenuMerge; -typedef struct _GtkMenuMergeClass GtkMenuMergeClass; -typedef struct _GtkMenuMergePrivate GtkMenuMergePrivate; - - -struct _GtkMenuMerge { - GObject parent; - - /*< private >*/ - - GtkMenuMergePrivate *private_data; -}; - -struct _GtkMenuMergeClass { - GObjectClass parent_class; - - void (* add_widget) (GtkMenuMerge *merge, - GtkWidget *widget); - void (* remove_widget) (GtkMenuMerge *merge, - GtkWidget *widget); - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - -GType gtk_menu_merge_get_type (void); -GtkMenuMerge *gtk_menu_merge_new (void); - -/* these two functions will dirty all merge nodes, as they may need to - * be connected up to different actions */ -void gtk_menu_merge_insert_action_group (GtkMenuMerge *self, - GtkActionGroup *action_group, - gint pos); -void gtk_menu_merge_remove_action_group (GtkMenuMerge *self, - GtkActionGroup *action_group); -GList *gtk_menu_merge_get_action_groups (GtkMenuMerge *self); -GtkAccelGroup *gtk_menu_merge_get_accel_group (GtkMenuMerge *self); - - - -GtkWidget *gtk_menu_merge_get_widget (GtkMenuMerge *self, - const gchar *path); - -/* these two functions are for adding UI elements to the merged user - * interface */ -guint gtk_menu_merge_add_ui_from_string (GtkMenuMerge *self, - const gchar *buffer, - gsize length, - GError **error); -guint gtk_menu_merge_add_ui_from_file (GtkMenuMerge *self, - const gchar *filename, - GError **error); -void gtk_menu_merge_remove_ui (GtkMenuMerge *self, - guint merge_id); - -gchar *gtk_menu_merge_get_ui (GtkMenuMerge *self); - - -#endif /* __GTK_MENU_MERGE_H__ */ diff --git a/gtk/gtkmenumerge.c b/gtk/gtkuimanager.c index 2e8320ba85..5f7b3e78ea 100644 --- a/gtk/gtkmenumerge.c +++ b/gtk/gtkuimanager.c @@ -31,7 +31,7 @@ #include <config.h> #include <string.h> -#include "gtkmenumerge.h" +#include "gtkuimanager.h" #include "gtktoolbar.h" #include "gtkseparatortoolitem.h" #include "gtkmenushell.h" @@ -40,28 +40,28 @@ #include "gtkseparatormenuitem.h" #include "gtkintl.h" -#undef DEBUG_MENU_MERGE +#undef DEBUG_UI_MANAGER typedef enum { - GTK_MENU_MERGE_UNDECIDED, - GTK_MENU_MERGE_ROOT, - GTK_MENU_MERGE_MENUBAR, - GTK_MENU_MERGE_MENU, - GTK_MENU_MERGE_TOOLBAR, - GTK_MENU_MERGE_MENU_PLACEHOLDER, - GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER, - GTK_MENU_MERGE_POPUPS, - GTK_MENU_MERGE_MENUITEM, - GTK_MENU_MERGE_TOOLITEM, - GTK_MENU_MERGE_SEPARATOR, -} GtkMenuMergeNodeType; + GTK_UI_MANAGER_UNDECIDED, + GTK_UI_MANAGER_ROOT, + GTK_UI_MANAGER_MENUBAR, + GTK_UI_MANAGER_MENU, + GTK_UI_MANAGER_TOOLBAR, + GTK_UI_MANAGER_MENU_PLACEHOLDER, + GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER, + GTK_UI_MANAGER_POPUPS, + GTK_UI_MANAGER_MENUITEM, + GTK_UI_MANAGER_TOOLITEM, + GTK_UI_MANAGER_SEPARATOR, +} GtkUIManagerNodeType; -typedef struct _GtkMenuMergeNode GtkMenuMergeNode; +typedef struct _GtkUIManagerNode GtkUIManagerNode; -struct _GtkMenuMergeNode { - GtkMenuMergeNodeType type; +struct _GtkUIManagerNode { + GtkUIManagerNodeType type; const gchar *name; @@ -75,9 +75,9 @@ struct _GtkMenuMergeNode { guint dirty : 1; }; -#define GTK_MENU_MERGE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_MENU_MERGE, GtkMenuMergePrivate)) +#define GTK_UI_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_UI_MANAGER, GtkUIManagerPrivate)) -struct _GtkMenuMergePrivate +struct _GtkUIManagerPrivate { GtkAccelGroup *accel_group; @@ -89,7 +89,7 @@ struct _GtkMenuMergePrivate guint update_tag; }; -#define NODE_INFO(node) ((GtkMenuMergeNode *)node->data) +#define NODE_INFO(node) ((GtkUIManagerNode *)node->data) typedef struct _NodeUIReference NodeUIReference; @@ -99,29 +99,29 @@ struct _NodeUIReference GQuark action_quark; }; -static void gtk_menu_merge_class_init (GtkMenuMergeClass *class); -static void gtk_menu_merge_init (GtkMenuMerge *merge); +static void gtk_ui_manager_class_init (GtkUIManagerClass *class); +static void gtk_ui_manager_init (GtkUIManager *merge); -static void gtk_menu_merge_queue_update (GtkMenuMerge *self); -static void gtk_menu_merge_dirty_all (GtkMenuMerge *self); +static void gtk_ui_manager_queue_update (GtkUIManager *self); +static void gtk_ui_manager_dirty_all (GtkUIManager *self); -static GNode *get_child_node (GtkMenuMerge *self, GNode *parent, +static GNode *get_child_node (GtkUIManager *self, GNode *parent, const gchar *childname, gint childname_length, - GtkMenuMergeNodeType node_type, + GtkUIManagerNodeType node_type, gboolean create, gboolean top); -static GNode *gtk_menu_merge_get_node (GtkMenuMerge *self, +static GNode *gtk_ui_manager_get_node (GtkUIManager *self, const gchar *path, - GtkMenuMergeNodeType node_type, + GtkUIManagerNodeType node_type, gboolean create); -static guint gtk_menu_merge_next_merge_id (GtkMenuMerge *self); +static guint gtk_ui_manager_next_merge_id (GtkUIManager *self); -static void gtk_menu_merge_node_prepend_ui_reference (GtkMenuMergeNode *node, +static void gtk_ui_manager_node_prepend_ui_reference (GtkUIManagerNode *node, guint merge_id, GQuark action_quark); -static void gtk_menu_merge_node_remove_ui_reference (GtkMenuMergeNode *node, +static void gtk_ui_manager_node_remove_ui_reference (GtkUIManagerNode *node, guint merge_id); -static void gtk_menu_merge_ensure_update (GtkMenuMerge *self); +static void gtk_ui_manager_ensure_update (GtkUIManager *self); enum @@ -136,7 +136,7 @@ static guint merge_signals[LAST_SIGNAL] = { 0 }; static GMemChunk *merge_node_chunk = NULL; GType -gtk_menu_merge_get_type (void) +gtk_ui_manager_get_type (void) { static GtkType type = 0; @@ -144,41 +144,41 @@ gtk_menu_merge_get_type (void) { static const GTypeInfo type_info = { - sizeof (GtkMenuMergeClass), + sizeof (GtkUIManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_menu_merge_class_init, + (GClassInitFunc) gtk_ui_manager_class_init, (GClassFinalizeFunc) NULL, NULL, - sizeof (GtkMenuMerge), + sizeof (GtkUIManager), 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_menu_merge_init, + (GInstanceInitFunc) gtk_ui_manager_init, }; type = g_type_register_static (G_TYPE_OBJECT, - "GtkMenuMerge", + "GtkUIManager", &type_info, 0); } return type; } static void -gtk_menu_merge_class_init (GtkMenuMergeClass *klass) +gtk_ui_manager_class_init (GtkUIManagerClass *klass) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); if (!merge_node_chunk) - merge_node_chunk = g_mem_chunk_create (GtkMenuMergeNode, 64, + merge_node_chunk = g_mem_chunk_create (GtkUIManagerNode, 64, G_ALLOC_AND_FREE); merge_signals[ADD_WIDGET] = g_signal_new ("add_widget", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GtkMenuMergeClass, add_widget), NULL, NULL, + G_STRUCT_OFFSET (GtkUIManagerClass, add_widget), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_WIDGET); @@ -186,22 +186,22 @@ gtk_menu_merge_class_init (GtkMenuMergeClass *klass) g_signal_new ("remove_widget", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GtkMenuMergeClass, remove_widget), NULL, NULL, + G_STRUCT_OFFSET (GtkUIManagerClass, remove_widget), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_WIDGET); - g_type_class_add_private (gobject_class, sizeof (GtkMenuMergePrivate)); + g_type_class_add_private (gobject_class, sizeof (GtkUIManagerPrivate)); } static void -gtk_menu_merge_init (GtkMenuMerge *self) +gtk_ui_manager_init (GtkUIManager *self) { guint merge_id; GNode *node; - self->private_data = GTK_MENU_MERGE_GET_PRIVATE (self); + self->private_data = GTK_UI_MANAGER_GET_PRIVATE (self); self->private_data->accel_group = gtk_accel_group_new (); @@ -211,18 +211,18 @@ gtk_menu_merge_init (GtkMenuMerge *self) self->private_data->last_merge_id = 0; - merge_id = gtk_menu_merge_next_merge_id (self); + merge_id = gtk_ui_manager_next_merge_id (self); node = get_child_node (self, NULL, "Root", 4, - GTK_MENU_MERGE_ROOT, TRUE, FALSE); - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (node), merge_id, 0); + 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, - GTK_MENU_MERGE_POPUPS, TRUE, FALSE); - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (node), merge_id, 0); + GTK_UI_MANAGER_POPUPS, TRUE, FALSE); + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), merge_id, 0); } /** - * gtk_menu_merge_new: + * gtk_ui_manager_new: * * Creates a new menu merge object. * @@ -230,16 +230,16 @@ gtk_menu_merge_init (GtkMenuMerge *self) * * Since: 2.4 **/ -GtkMenuMerge* -gtk_menu_merge_new (void) +GtkUIManager* +gtk_ui_manager_new (void) { - return g_object_new (GTK_TYPE_MENU_MERGE, NULL); + return g_object_new (GTK_TYPE_UI_MANAGER, NULL); } /** - * gtk_menu_merge_insert_action_group: - * @self: a #GtkMenuMerge object + * gtk_ui_manager_insert_action_group: + * @self: a #GtkUIManager object * @action_group: the action group to be inserted * @pos: the position at which the group will be inserted * @@ -248,11 +248,11 @@ gtk_menu_merge_new (void) * Since: 2.4 **/ void -gtk_menu_merge_insert_action_group (GtkMenuMerge *self, +gtk_ui_manager_insert_action_group (GtkUIManager *self, GtkActionGroup *action_group, gint pos) { - g_return_if_fail (GTK_IS_MENU_MERGE (self)); + g_return_if_fail (GTK_IS_UI_MANAGER (self)); g_return_if_fail (GTK_IS_ACTION_GROUP (action_group)); g_return_if_fail (g_list_find (self->private_data->action_groups, action_group) == NULL); @@ -260,12 +260,12 @@ gtk_menu_merge_insert_action_group (GtkMenuMerge *self, self->private_data->action_groups = g_list_insert (self->private_data->action_groups, action_group, pos); /* dirty all nodes, as action bindings may change */ - gtk_menu_merge_dirty_all (self); + gtk_ui_manager_dirty_all (self); } /** - * gtk_menu_merge_remove_action_group: - * @self: a #GtkMenuMerge object + * gtk_ui_manager_remove_action_group: + * @self: a #GtkUIManager object * @action_group: the action group to be removed * * Removes an action group from the list of action groups associated with @self. @@ -273,10 +273,10 @@ gtk_menu_merge_insert_action_group (GtkMenuMerge *self, * Since: 2.4 **/ void -gtk_menu_merge_remove_action_group (GtkMenuMerge *self, +gtk_ui_manager_remove_action_group (GtkUIManager *self, GtkActionGroup *action_group) { - g_return_if_fail (GTK_IS_MENU_MERGE (self)); + g_return_if_fail (GTK_IS_UI_MANAGER (self)); g_return_if_fail (GTK_IS_ACTION_GROUP (action_group)); g_return_if_fail (g_list_find (self->private_data->action_groups, action_group) != NULL); @@ -286,12 +286,12 @@ gtk_menu_merge_remove_action_group (GtkMenuMerge *self, g_object_unref (action_group); /* dirty all nodes, as action bindings may change */ - gtk_menu_merge_dirty_all (self); + gtk_ui_manager_dirty_all (self); } /** - * gtk_menu_merge_get_action_groups: - * @self: a #GtkMenuMerge object + * gtk_ui_manager_get_action_groups: + * @self: a #GtkUIManager object * * Returns the list of action groups associated with @self. * @@ -301,16 +301,16 @@ gtk_menu_merge_remove_action_group (GtkMenuMerge *self, * Since: 2.4 **/ GList * -gtk_menu_merge_get_action_groups (GtkMenuMerge *self) +gtk_ui_manager_get_action_groups (GtkUIManager *self) { - g_return_val_if_fail (GTK_IS_MENU_MERGE (self), NULL); + g_return_val_if_fail (GTK_IS_UI_MANAGER (self), NULL); return self->private_data->action_groups; } /** - * gtk_menu_merge_get_accel_group: - * @self: a #GtkMenuMerge object + * gtk_ui_manager_get_accel_group: + * @self: a #GtkUIManager object * * Returns the #GtkAccelGroup associated with @self. * @@ -319,16 +319,16 @@ gtk_menu_merge_get_action_groups (GtkMenuMerge *self) * Since: 2.4 **/ GtkAccelGroup * -gtk_menu_merge_get_accel_group (GtkMenuMerge *self) +gtk_ui_manager_get_accel_group (GtkUIManager *self) { - g_return_val_if_fail (GTK_IS_MENU_MERGE (self), NULL); + g_return_val_if_fail (GTK_IS_UI_MANAGER (self), NULL); return self->private_data->accel_group; } /** - * gtk_menu_merge_get_widget: - * @self: a #GtkMenuMerge + * gtk_ui_manager_get_widget: + * @self: a #GtkUIManager * @path: a path * * Looks up a widget by following a path. The path consists of the names specified @@ -342,16 +342,16 @@ gtk_menu_merge_get_accel_group (GtkMenuMerge *self) * Since: 2.4 **/ GtkWidget * -gtk_menu_merge_get_widget (GtkMenuMerge *self, +gtk_ui_manager_get_widget (GtkUIManager *self, const gchar *path) { GNode *node; /* ensure that there are no pending updates before we get the * widget */ - gtk_menu_merge_ensure_update (self); + gtk_ui_manager_ensure_update (self); - node = gtk_menu_merge_get_node (self, path, GTK_MENU_MERGE_UNDECIDED, FALSE); + node = gtk_ui_manager_get_node (self, path, GTK_UI_MANAGER_UNDECIDED, FALSE); if (node == NULL) return NULL; @@ -360,19 +360,19 @@ gtk_menu_merge_get_widget (GtkMenuMerge *self, } static GNode * -get_child_node (GtkMenuMerge *self, +get_child_node (GtkUIManager *self, GNode *parent, const gchar *childname, gint childname_length, - GtkMenuMergeNodeType node_type, + GtkUIManagerNodeType node_type, gboolean create, gboolean top) { GNode *child = NULL; g_return_val_if_fail (parent == NULL || - (NODE_INFO (parent)->type != GTK_MENU_MERGE_MENUITEM && - NODE_INFO (parent)->type != GTK_MENU_MERGE_TOOLITEM), + (NODE_INFO (parent)->type != GTK_UI_MANAGER_MENUITEM && + NODE_INFO (parent)->type != GTK_UI_MANAGER_TOOLITEM), NULL); if (parent) @@ -385,12 +385,12 @@ get_child_node (GtkMenuMerge *self, !strncmp (NODE_INFO (child)->name, childname, childname_length)) { /* if undecided about node type, set it */ - if (NODE_INFO (child)->type == GTK_MENU_MERGE_UNDECIDED) + if (NODE_INFO (child)->type == GTK_UI_MANAGER_UNDECIDED) NODE_INFO (child)->type = node_type; /* warn about type mismatch */ - if (NODE_INFO (child)->type != GTK_MENU_MERGE_UNDECIDED && - node_type != GTK_MENU_MERGE_UNDECIDED && + if (NODE_INFO (child)->type != GTK_UI_MANAGER_UNDECIDED && + node_type != GTK_UI_MANAGER_UNDECIDED && NODE_INFO (child)->type != node_type) g_warning ("node type doesn't match %d (%s is type %d)", node_type, @@ -403,9 +403,9 @@ get_child_node (GtkMenuMerge *self, } if (!child && create) { - GtkMenuMergeNode *mnode; + GtkUIManagerNode *mnode; - mnode = g_chunk_new0 (GtkMenuMergeNode, merge_node_chunk); + mnode = g_chunk_new0 (GtkUIManagerNode, merge_node_chunk); mnode->type = node_type; mnode->name = g_strndup (childname, childname_length); mnode->dirty = TRUE; @@ -425,14 +425,14 @@ get_child_node (GtkMenuMerge *self, if (strncmp (NODE_INFO (child)->name, childname, childname_length) != 0) g_warning ("root node name '%s' doesn't match '%s'", childname, NODE_INFO (child)->name); - if (NODE_INFO (child)->type != GTK_MENU_MERGE_ROOT) + if (NODE_INFO (child)->type != GTK_UI_MANAGER_ROOT) g_warning ("base element must be of type ROOT"); } else if (create) { - GtkMenuMergeNode *mnode; + GtkUIManagerNode *mnode; - mnode = g_chunk_new0 (GtkMenuMergeNode, merge_node_chunk); + mnode = g_chunk_new0 (GtkUIManagerNode, merge_node_chunk); mnode->type = node_type; mnode->name = g_strndup (childname, childname_length); mnode->dirty = TRUE; @@ -445,9 +445,9 @@ get_child_node (GtkMenuMerge *self, } static GNode * -gtk_menu_merge_get_node (GtkMenuMerge *self, +gtk_ui_manager_get_node (GtkUIManager *self, const gchar *path, - GtkMenuMergeNodeType node_type, + GtkUIManagerNodeType node_type, gboolean create) { const gchar *pos, *end; @@ -467,7 +467,7 @@ gtk_menu_merge_get_node (GtkMenuMerge *self, else length = strlen (pos); - node = get_child_node (self, parent, pos, length, GTK_MENU_MERGE_UNDECIDED, + node = get_child_node (self, parent, pos, length, GTK_UI_MANAGER_UNDECIDED, create, FALSE); if (!node) return NULL; @@ -476,13 +476,13 @@ gtk_menu_merge_get_node (GtkMenuMerge *self, parent = node; } - if (NODE_INFO (node)->type == GTK_MENU_MERGE_UNDECIDED) + if (NODE_INFO (node)->type == GTK_UI_MANAGER_UNDECIDED) NODE_INFO (node)->type = node_type; return node; } static guint -gtk_menu_merge_next_merge_id (GtkMenuMerge *self) +gtk_ui_manager_next_merge_id (GtkUIManager *self) { self->private_data->last_merge_id++; @@ -490,7 +490,7 @@ gtk_menu_merge_next_merge_id (GtkMenuMerge *self) } static void -gtk_menu_merge_node_prepend_ui_reference (GtkMenuMergeNode *node, +gtk_ui_manager_node_prepend_ui_reference (GtkUIManagerNode *node, guint merge_id, GQuark action_quark) { @@ -507,7 +507,7 @@ gtk_menu_merge_node_prepend_ui_reference (GtkMenuMergeNode *node, } static void -gtk_menu_merge_node_remove_ui_reference (GtkMenuMergeNode *node, +gtk_ui_manager_node_remove_ui_reference (GtkUIManagerNode *node, guint merge_id) { GList *p; @@ -547,7 +547,7 @@ struct _ParseContext ParseState state; ParseState prev_state; - GtkMenuMerge *self; + GtkUIManager *self; GNode *current; @@ -563,7 +563,7 @@ start_element_handler (GMarkupParseContext *context, GError **error) { ParseContext *ctx = user_data; - GtkMenuMerge *self = ctx->self; + GtkUIManager *self = ctx->self; gint i; const gchar *node_name; @@ -606,7 +606,7 @@ start_element_handler (GMarkupParseContext *context, ctx->current = self->private_data->root_node; raise_error = FALSE; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), ctx->merge_id, verb_quark); } break; @@ -616,12 +616,12 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_MENU; ctx->current = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_MENUBAR, + GTK_UI_MANAGER_MENUBAR, TRUE, FALSE); if (NODE_INFO (ctx->current)->action_name == 0) NODE_INFO (ctx->current)->action_name = verb_quark; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), ctx->merge_id, verb_quark); NODE_INFO (ctx->current)->dirty = TRUE; @@ -634,12 +634,12 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_MENUITEM; node = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_MENUITEM, + GTK_UI_MANAGER_MENUITEM, TRUE, top); if (NODE_INFO (node)->action_name == 0) NODE_INFO (node)->action_name = verb_quark; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (node), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), ctx->merge_id, verb_quark); NODE_INFO (node)->dirty = TRUE; @@ -652,12 +652,12 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_TOOLBAR; ctx->current = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_TOOLBAR, + GTK_UI_MANAGER_TOOLBAR, TRUE, FALSE); if (NODE_INFO (ctx->current)->action_name == 0) NODE_INFO (ctx->current)->action_name = verb_quark; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), ctx->merge_id, verb_quark); NODE_INFO (ctx->current)->dirty = TRUE; @@ -670,10 +670,10 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_POPUPS; ctx->current = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_POPUPS, + GTK_UI_MANAGER_POPUPS, TRUE, FALSE); - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), ctx->merge_id, verb_quark); NODE_INFO (ctx->current)->dirty = TRUE; @@ -684,12 +684,12 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_MENU; ctx->current = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_MENU, + GTK_UI_MANAGER_MENU, TRUE, FALSE); if (NODE_INFO (ctx->current)->action_name == 0) NODE_INFO (ctx->current)->action_name = verb_quark; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), ctx->merge_id, verb_quark); NODE_INFO (ctx->current)->dirty = TRUE; @@ -701,15 +701,15 @@ start_element_handler (GMarkupParseContext *context, if (ctx->state == STATE_MENU) ctx->current = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_MENU_PLACEHOLDER, + GTK_UI_MANAGER_MENU_PLACEHOLDER, TRUE, top); else ctx->current = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER, + GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER, TRUE, top); - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), ctx->merge_id, verb_quark); NODE_INFO (ctx->current)->dirty = TRUE; @@ -722,12 +722,12 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_MENU; ctx->current = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_MENU, + GTK_UI_MANAGER_MENU, TRUE, top); if (NODE_INFO (ctx->current)->action_name == 0) NODE_INFO (ctx->current)->action_name = verb_quark; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (ctx->current), ctx->merge_id, verb_quark); NODE_INFO (ctx->current)->dirty = TRUE; @@ -744,12 +744,12 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_TOOLITEM; node = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_SEPARATOR, + GTK_UI_MANAGER_SEPARATOR, TRUE, top); if (NODE_INFO (node)->action_name == 0) NODE_INFO (node)->action_name = verb_quark; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (node), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), ctx->merge_id, verb_quark); NODE_INFO (node)->dirty = TRUE; @@ -764,12 +764,12 @@ start_element_handler (GMarkupParseContext *context, ctx->state = STATE_TOOLITEM; node = get_child_node (self, ctx->current, node_name, strlen (node_name), - GTK_MENU_MERGE_TOOLITEM, + GTK_UI_MANAGER_TOOLITEM, TRUE, top); if (NODE_INFO (node)->action_name == 0) NODE_INFO (node)->action_name = verb_quark; - gtk_menu_merge_node_prepend_ui_reference (NODE_INFO (node), + gtk_ui_manager_node_prepend_ui_reference (NODE_INFO (node), ctx->merge_id, verb_quark); NODE_INFO (node)->dirty = TRUE; @@ -809,7 +809,7 @@ end_element_handler (GMarkupParseContext *context, GError **error) { ParseContext *ctx = user_data; - GtkMenuMerge *self = ctx->self; + GtkUIManager *self = ctx->self; switch (ctx->state) { @@ -825,9 +825,9 @@ end_element_handler (GMarkupParseContext *context, break; case STATE_MENU: ctx->current = ctx->current->parent; - if (NODE_INFO (ctx->current)->type == GTK_MENU_MERGE_ROOT) /* menubar */ + if (NODE_INFO (ctx->current)->type == GTK_UI_MANAGER_ROOT) /* menubar */ ctx->state = STATE_ROOT; - else if (NODE_INFO (ctx->current)->type == GTK_MENU_MERGE_POPUPS) /* popup */ + else if (NODE_INFO (ctx->current)->type == GTK_UI_MANAGER_POPUPS) /* popup */ ctx->state = STATE_POPUPS; /* else, stay in STATE_MENU state */ break; @@ -835,7 +835,7 @@ end_element_handler (GMarkupParseContext *context, ctx->current = ctx->current->parent; /* we conditionalise this test, in case we are closing off a * placeholder */ - if (NODE_INFO (ctx->current)->type == GTK_MENU_MERGE_ROOT) + if (NODE_INFO (ctx->current)->type == GTK_UI_MANAGER_ROOT) ctx->state = STATE_ROOT; /* else, stay in STATE_TOOLBAR state */ break; @@ -862,13 +862,13 @@ cleanup (GMarkupParseContext *context, gpointer user_data) { ParseContext *ctx = user_data; - GtkMenuMerge *self = ctx->self; + GtkUIManager *self = ctx->self; ctx->current = NULL; /* should also walk through the tree and get rid of nodes related to * this UI file's tag */ - gtk_menu_merge_remove_ui (self, ctx->merge_id); + gtk_ui_manager_remove_ui (self, ctx->merge_id); } static GMarkupParser ui_parser = { @@ -881,8 +881,8 @@ static GMarkupParser ui_parser = { /** - * gtk_menu_merge_add_ui_from_string: - * @self: a #GtkMenuMerge object + * gtk_ui_manager_add_ui_from_string: + * @self: a #GtkUIManager object * @buffer: the string to parse * @length: the length of @buffer (may be -1 if @buffer is nul-terminated) * @error: return location for an error @@ -891,13 +891,13 @@ static GMarkupParser ui_parser = { * contents of @self. FIXME: describe the XML format. * * Return value: The merge id for the merged UI. The merge id can be used - * to unmerge the UI with gtk_menu_merge_remove_ui(). If an error occurred, + * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, * the return value is 0. * * Since: 2.4 **/ guint -gtk_menu_merge_add_ui_from_string (GtkMenuMerge *self, +gtk_ui_manager_add_ui_from_string (GtkUIManager *self, const gchar *buffer, gsize length, GError **error) @@ -906,13 +906,13 @@ gtk_menu_merge_add_ui_from_string (GtkMenuMerge *self, GMarkupParseContext *context; gboolean res = TRUE; - g_return_val_if_fail (GTK_IS_MENU_MERGE (self), FALSE); + 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_menu_merge_next_merge_id (self); + ctx.merge_id = gtk_ui_manager_next_merge_id (self); context = g_markup_parse_context_new (&ui_parser, 0, &ctx, NULL); if (length < 0) @@ -928,7 +928,7 @@ gtk_menu_merge_add_ui_from_string (GtkMenuMerge *self, g_markup_parse_context_free (context); - gtk_menu_merge_queue_update (self); + gtk_ui_manager_queue_update (self); if (res) return ctx.merge_id; @@ -937,22 +937,22 @@ gtk_menu_merge_add_ui_from_string (GtkMenuMerge *self, } /** - * gtk_menu_merge_add_ui_from_file: - * @self: a #GtkMenuMerge object + * gtk_ui_manager_add_ui_from_file: + * @self: a #GtkUIManager object * @filename: the name of the file to parse * @error: return location for an error * * Parses a file containing a UI description and merge it with the current - * contents of @self. See gtk_menu_merge_add_ui_from_file(). + * contents of @self. See gtk_ui_manager_add_ui_from_file(). * * Return value: The merge id for the merged UI. The merge id can be used - * to unmerge the UI with gtk_menu_merge_remove_ui(). If an error occurred, + * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, * the return value is 0. * * Since: 2.4 **/ guint -gtk_menu_merge_add_ui_from_file (GtkMenuMerge *self, +gtk_ui_manager_add_ui_from_file (GtkUIManager *self, const gchar *filename, GError **error) { @@ -963,7 +963,7 @@ gtk_menu_merge_add_ui_from_file (GtkMenuMerge *self, if (!g_file_get_contents (filename, &buffer, &length, error)) return 0; - res = gtk_menu_merge_add_ui_from_string (self, buffer, length, error); + res = gtk_ui_manager_add_ui_from_string (self, buffer, length, error); g_free (buffer); return res; @@ -975,35 +975,35 @@ remove_ui (GNode *node, { guint merge_id = GPOINTER_TO_UINT (user_data); - gtk_menu_merge_node_remove_ui_reference (NODE_INFO (node), merge_id); + gtk_ui_manager_node_remove_ui_reference (NODE_INFO (node), merge_id); return FALSE; /* continue */ } /** - * gtk_menu_merge_remove_ui: - * @self: a #GtkMenuMerge object - * @merge_id: a merge id as returned by gtk_menu_merge_add_ui_from_string() + * gtk_ui_manager_remove_ui: + * @self: a #GtkUIManager object + * @merge_id: a merge id as returned by gtk_ui_manager_add_ui_from_string() * * Unmerges the part of @self<!-- -->s content identified by @merge_id. * * Since: 2.4 **/ void -gtk_menu_merge_remove_ui (GtkMenuMerge *self, +gtk_ui_manager_remove_ui (GtkUIManager *self, guint merge_id) { g_node_traverse (self->private_data->root_node, G_POST_ORDER, G_TRAVERSE_ALL, -1, remove_ui, GUINT_TO_POINTER (merge_id)); - gtk_menu_merge_queue_update (self); + gtk_ui_manager_queue_update (self); } /* -------------------- Updates -------------------- */ static GtkAction * -get_action_by_name (GtkMenuMerge *merge, +get_action_by_name (GtkUIManager *merge, const char *action_name) { GList *tmp; @@ -1035,10 +1035,10 @@ find_menu_position (GNode *node, gint pos; g_return_val_if_fail (node != NULL, FALSE); - g_return_val_if_fail (NODE_INFO (node)->type == GTK_MENU_MERGE_MENU || - NODE_INFO (node)->type == GTK_MENU_MERGE_MENU_PLACEHOLDER || - NODE_INFO (node)->type == GTK_MENU_MERGE_MENUITEM || - NODE_INFO (node)->type == GTK_MENU_MERGE_SEPARATOR, + g_return_val_if_fail (NODE_INFO (node)->type == GTK_UI_MANAGER_MENU || + NODE_INFO (node)->type == GTK_UI_MANAGER_MENU_PLACEHOLDER || + NODE_INFO (node)->type == GTK_UI_MANAGER_MENUITEM || + NODE_INFO (node)->type == GTK_UI_MANAGER_SEPARATOR, FALSE); /* first sibling -- look at parent */ @@ -1049,17 +1049,17 @@ find_menu_position (GNode *node, parent = node->parent; switch (NODE_INFO (parent)->type) { - case GTK_MENU_MERGE_MENUBAR: + case GTK_UI_MANAGER_MENUBAR: menushell = NODE_INFO (parent)->proxy; pos = 0; break; - case GTK_MENU_MERGE_MENU: + case GTK_UI_MANAGER_MENU: menushell = NODE_INFO (parent)->proxy; if (GTK_IS_MENU_ITEM (menushell)) menushell = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menushell)); pos = 0; break; - case GTK_MENU_MERGE_MENU_PLACEHOLDER: + case GTK_UI_MANAGER_MENU_PLACEHOLDER: menushell = gtk_widget_get_parent (NODE_INFO (parent)->proxy); g_return_val_if_fail (GTK_IS_MENU_SHELL (menushell), FALSE); pos = g_list_index (GTK_MENU_SHELL (menushell)->children, @@ -1077,7 +1077,7 @@ find_menu_position (GNode *node, GNode *sibling; sibling = node->prev; - if (NODE_INFO (sibling)->type == GTK_MENU_MERGE_MENU_PLACEHOLDER) + if (NODE_INFO (sibling)->type == GTK_UI_MANAGER_MENU_PLACEHOLDER) prev_child = NODE_INFO (sibling)->extra; /* second Separator */ else prev_child = NODE_INFO (sibling)->proxy; @@ -1106,10 +1106,10 @@ find_toolbar_position (GNode *node, gint pos; g_return_val_if_fail (node != NULL, FALSE); - g_return_val_if_fail (NODE_INFO (node)->type == GTK_MENU_MERGE_TOOLBAR || - NODE_INFO (node)->type == GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER || - NODE_INFO (node)->type == GTK_MENU_MERGE_TOOLITEM || - NODE_INFO (node)->type == GTK_MENU_MERGE_SEPARATOR, + g_return_val_if_fail (NODE_INFO (node)->type == GTK_UI_MANAGER_TOOLBAR || + NODE_INFO (node)->type == GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER || + NODE_INFO (node)->type == GTK_UI_MANAGER_TOOLITEM || + NODE_INFO (node)->type == GTK_UI_MANAGER_SEPARATOR, FALSE); /* first sibling -- look at parent */ @@ -1120,11 +1120,11 @@ find_toolbar_position (GNode *node, parent = node->parent; switch (NODE_INFO (parent)->type) { - case GTK_MENU_MERGE_TOOLBAR: + case GTK_UI_MANAGER_TOOLBAR: toolbar = NODE_INFO (parent)->proxy; pos = 0; break; - case GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER: + case GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER: toolbar = gtk_widget_get_parent (NODE_INFO (parent)->proxy); g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), FALSE); pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolbar), @@ -1142,7 +1142,7 @@ find_toolbar_position (GNode *node, GNode *sibling; sibling = node->prev; - if (NODE_INFO (sibling)->type == GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER) + if (NODE_INFO (sibling)->type == GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER) prev_child = NODE_INFO (sibling)->extra; /* second Separator */ else prev_child = NODE_INFO (sibling)->proxy; @@ -1164,13 +1164,13 @@ find_toolbar_position (GNode *node, } static void -update_node (GtkMenuMerge *self, +update_node (GtkUIManager *self, GNode *node) { - GtkMenuMergeNode *info; + GtkUIManagerNode *info; GNode *child; GtkAction *action; -#ifdef DEBUG_MENU_MERGE +#ifdef DEBUG_UI_MANAGER GList *tmp; #endif @@ -1179,7 +1179,7 @@ update_node (GtkMenuMerge *self, info = NODE_INFO (node); -#ifdef DEBUG_MENU_MERGE +#ifdef DEBUG_UI_MANAGER g_print ("update_node name=%s dirty=%d (", info->name, info->dirty); for (tmp = info->uifiles; tmp != NULL; tmp = tmp->next) { @@ -1211,11 +1211,11 @@ update_node (GtkMenuMerge *self, /* Check if the node doesn't have an action and must have an action */ if (action == NULL && - info->type != GTK_MENU_MERGE_MENUBAR && - info->type != GTK_MENU_MERGE_TOOLBAR && - info->type != GTK_MENU_MERGE_SEPARATOR && - info->type != GTK_MENU_MERGE_MENU_PLACEHOLDER && - info->type != GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER) + info->type != GTK_UI_MANAGER_MENUBAR && + info->type != GTK_UI_MANAGER_TOOLBAR && + info->type != GTK_UI_MANAGER_SEPARATOR && + info->type != GTK_UI_MANAGER_MENU_PLACEHOLDER && + info->type != GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER) { /* FIXME: Should we warn here? */ goto recurse_children; @@ -1238,7 +1238,7 @@ update_node (GtkMenuMerge *self, switch (info->type) { - case GTK_MENU_MERGE_MENUBAR: + case GTK_UI_MANAGER_MENUBAR: if (info->proxy == NULL) { info->proxy = gtk_menu_bar_new (); @@ -1246,8 +1246,8 @@ update_node (GtkMenuMerge *self, g_signal_emit (self, merge_signals[ADD_WIDGET], 0, info->proxy); } break; - case GTK_MENU_MERGE_MENU: - if (NODE_INFO (node->parent)->type == GTK_MENU_MERGE_POPUPS) + case GTK_UI_MANAGER_MENU: + if (NODE_INFO (node->parent)->type == GTK_UI_MANAGER_POPUPS) { if (info->proxy == NULL) { @@ -1302,12 +1302,12 @@ update_node (GtkMenuMerge *self, } } break; - case GTK_MENU_MERGE_UNDECIDED: + case GTK_UI_MANAGER_UNDECIDED: g_warning ("found 'undecided node!"); break; - case GTK_MENU_MERGE_ROOT: + case GTK_UI_MANAGER_ROOT: break; - case GTK_MENU_MERGE_TOOLBAR: + case GTK_UI_MANAGER_TOOLBAR: if (info->proxy == NULL) { info->proxy = gtk_toolbar_new (); @@ -1315,7 +1315,7 @@ update_node (GtkMenuMerge *self, g_signal_emit (self, merge_signals[ADD_WIDGET], 0, info->proxy); } break; - case GTK_MENU_MERGE_MENU_PLACEHOLDER: + case GTK_UI_MANAGER_MENU_PLACEHOLDER: /* create menu items for placeholders if necessary ... */ if (!GTK_IS_SEPARATOR_MENU_ITEM (info->proxy) || !GTK_IS_SEPARATOR_MENU_ITEM (info->extra)) @@ -1346,7 +1346,7 @@ update_node (GtkMenuMerge *self, } } break; - case GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER: + case GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER: /* create toolbar items for placeholders if necessary ... */ if (!GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy) || !GTK_IS_SEPARATOR_TOOL_ITEM (info->extra)) @@ -1379,9 +1379,9 @@ update_node (GtkMenuMerge *self, } } break; - case GTK_MENU_MERGE_POPUPS: + case GTK_UI_MANAGER_POPUPS: break; - case GTK_MENU_MERGE_MENUITEM: + case GTK_UI_MANAGER_MENUITEM: /* remove the proxy if it is of the wrong type ... */ if (info->proxy && G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (info->action)->menu_item_type) @@ -1410,7 +1410,7 @@ update_node (GtkMenuMerge *self, gtk_action_connect_proxy (info->action, info->proxy); } break; - case GTK_MENU_MERGE_TOOLITEM: + case GTK_UI_MANAGER_TOOLITEM: /* remove the proxy if it is of the wrong type ... */ if (info->proxy && G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (info->action)->toolbar_item_type) @@ -1438,9 +1438,9 @@ update_node (GtkMenuMerge *self, gtk_action_connect_proxy (info->action, info->proxy); } break; - case GTK_MENU_MERGE_SEPARATOR: - if (NODE_INFO (node->parent)->type == GTK_MENU_MERGE_TOOLBAR || - NODE_INFO (node->parent)->type == GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER) + case GTK_UI_MANAGER_SEPARATOR: + if (NODE_INFO (node->parent)->type == GTK_UI_MANAGER_TOOLBAR || + NODE_INFO (node->parent)->type == GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER) { GtkWidget *toolbar; gint pos; @@ -1503,8 +1503,8 @@ update_node (GtkMenuMerge *self, { if (NODE_INFO (node)->proxy) gtk_widget_destroy (NODE_INFO (node)->proxy); - if ((NODE_INFO (node)->type == GTK_MENU_MERGE_MENU_PLACEHOLDER || - NODE_INFO (node)->type == GTK_MENU_MERGE_TOOLBAR_PLACEHOLDER) && + if ((NODE_INFO (node)->type == GTK_UI_MANAGER_MENU_PLACEHOLDER || + NODE_INFO (node)->type == GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER) && NODE_INFO (node)->extra) gtk_widget_destroy (NODE_INFO (node)->extra); g_chunk_free (NODE_INFO (node), merge_node_chunk); @@ -1513,7 +1513,7 @@ update_node (GtkMenuMerge *self, } static gboolean -do_updates (GtkMenuMerge *self) +do_updates (GtkUIManager *self) { /* this function needs to check through the tree for dirty nodes. * For such nodes, it needs to do the following: @@ -1536,7 +1536,7 @@ do_updates (GtkMenuMerge *self) } static void -gtk_menu_merge_queue_update (GtkMenuMerge *self) +gtk_ui_manager_queue_update (GtkUIManager *self) { if (self->private_data->update_tag != 0) return; @@ -1545,7 +1545,7 @@ gtk_menu_merge_queue_update (GtkMenuMerge *self) } static void -gtk_menu_merge_ensure_update (GtkMenuMerge *self) +gtk_ui_manager_ensure_update (GtkUIManager *self) { if (self->private_data->update_tag != 0) { @@ -1563,11 +1563,11 @@ dirty_traverse_func (GNode *node, } static void -gtk_menu_merge_dirty_all (GtkMenuMerge *self) +gtk_ui_manager_dirty_all (GtkUIManager *self) { g_node_traverse (self->private_data->root_node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, dirty_traverse_func, NULL); - gtk_menu_merge_queue_update (self); + gtk_ui_manager_queue_update (self); } static const gchar *open_tag_format[] = { @@ -1601,19 +1601,19 @@ static const gchar *close_tag_format[] = { }; static void -print_node (GtkMenuMerge *self, +print_node (GtkUIManager *self, GNode *node, gint indent_level, GString *buffer) { - GtkMenuMergeNode *mnode; + GtkUIManagerNode *mnode; GNode *child; guint type; mnode = node->data; - if (mnode->type == GTK_MENU_MERGE_MENU && - NODE_INFO (node->parent)->type == GTK_MENU_MERGE_POPUPS) - type = GTK_MENU_MERGE_SEPARATOR + 1; + if (mnode->type == GTK_UI_MANAGER_MENU && + NODE_INFO (node->parent)->type == GTK_UI_MANAGER_POPUPS) + type = GTK_UI_MANAGER_SEPARATOR + 1; else type = mnode->type; @@ -1631,8 +1631,8 @@ print_node (GtkMenuMerge *self, } /** - * gtk_menu_merge_get_ui: - * @self: a #GtkMenuMerge + * gtk_ui_manager_get_ui: + * @self: a #GtkUIManager * * Creates an XML representation of the merged ui. * @@ -1642,13 +1642,13 @@ print_node (GtkMenuMerge *self, * Since: 2.4 **/ gchar* -gtk_menu_merge_get_ui (GtkMenuMerge *self) +gtk_ui_manager_get_ui (GtkUIManager *self) { GString *buffer; buffer = g_string_new (NULL); - gtk_menu_merge_ensure_update (self); + gtk_ui_manager_ensure_update (self); print_node (self, self->private_data->root_node, 0, buffer); diff --git a/gtk/gtkuimanager.h b/gtk/gtkuimanager.h new file mode 100644 index 0000000000..90e4e52191 --- /dev/null +++ b/gtk/gtkuimanager.h @@ -0,0 +1,109 @@ +/* + * GTK - The GIMP Toolkit + * Copyright (C) 1998, 1999 Red Hat, Inc. + * All rights reserved. + * + * This Library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with the Gnome Library; see the file COPYING.LIB. If not, + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Author: James Henstridge <james@daa.com.au> + * + * Modified by the GTK+ Team and others 2003. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ +#ifndef __GTK_UI_MANAGER_H__ +#define __GTK_UI_MANAGER_H__ + + +#include <glib.h> +#include <glib-object.h> +#include <gtk/gtkaccelgroup.h> +#include <gtk/gtkwidget.h> +#include <gtk/gtkaction.h> +#include <gtk/gtkactiongroup.h> + +#define GTK_TYPE_UI_MANAGER (gtk_ui_manager_get_type ()) +#define GTK_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_UI_MANAGER, GtkMenuMerge)) +#define GTK_UI_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_UI_MANAGER, GtkUIManagerClass)) +#define GTK_IS_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_UI_MANAGER)) +#define GTK_IS_UI_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_UI_MANAGER)) +#define GTK_UI_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_UI_MANAGER, GtkUIManagerClass)) + +typedef struct _GtkUIManager GtkUIManager; +typedef struct _GtkUIManagerClass GtkUIManagerClass; +typedef struct _GtkUIManagerPrivate GtkUIManagerPrivate; + + +struct _GtkUIManager { + GObject parent; + + /*< private >*/ + + GtkUIManagerPrivate *private_data; +}; + +struct _GtkUIManagerClass { + GObjectClass parent_class; + + void (* add_widget) (GtkUIManager *merge, + GtkWidget *widget); + void (* remove_widget) (GtkUIManager *merge, + GtkWidget *widget); + + /* Padding for future expansion */ + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); + void (*_gtk_reserved4) (void); +}; + +GType gtk_ui_manager_get_type (void); +GtkUIManager *gtk_ui_manager_new (void); + +/* these two functions will dirty all merge nodes, as they may need to + * be connected up to different actions */ +void gtk_ui_manager_insert_action_group (GtkUIManager *self, + GtkActionGroup *action_group, + gint pos); +void gtk_ui_manager_remove_action_group (GtkUIManager *self, + GtkActionGroup *action_group); +GList *gtk_ui_manager_get_action_groups (GtkUIManager *self); +GtkAccelGroup *gtk_ui_manager_get_accel_group (GtkUIManager *self); + + + +GtkWidget *gtk_ui_manager_get_widget (GtkUIManager *self, + const gchar *path); + +/* these two functions are for adding UI elements to the merged user + * interface */ +guint gtk_ui_manager_add_ui_from_string (GtkUIManager *self, + const gchar *buffer, + gsize length, + GError **error); +guint gtk_ui_manager_add_ui_from_file (GtkUIManager *self, + const gchar *filename, + GError **error); +void gtk_ui_manager_remove_ui (GtkUIManager *self, + guint merge_id); + +gchar *gtk_ui_manager_get_ui (GtkUIManager *self); + + +#endif /* __GTK_UI_MANAGER_H__ */ diff --git a/tests/testactions.c b/tests/testactions.c index d2d1be33a1..131d0ccd20 100644 --- a/tests/testactions.c +++ b/tests/testactions.c @@ -195,7 +195,7 @@ static const gchar *ui_info = "</Root>\n"; static void -add_widget (GtkMenuMerge *merge, +add_widget (GtkUIManager *merge, GtkWidget *widget, GtkContainer *container) { @@ -213,7 +213,7 @@ add_widget (GtkMenuMerge *merge, static void create_window (GtkActionGroup *action_group) { - GtkMenuMerge *merge; + GtkUIManager *merge; GtkWidget *window; GtkWidget *box; GError *error = NULL; @@ -227,14 +227,14 @@ create_window (GtkActionGroup *action_group) gtk_container_add (GTK_CONTAINER (window), box); gtk_widget_show (box); - merge = gtk_menu_merge_new (); - gtk_menu_merge_insert_action_group (merge, action_group, 0); + merge = gtk_ui_manager_new (); + gtk_ui_manager_insert_action_group (merge, action_group, 0); g_signal_connect (merge, "add_widget", G_CALLBACK (add_widget), box); gtk_window_add_accel_group (GTK_WINDOW (window), - gtk_menu_merge_get_accel_group (merge)); + gtk_ui_manager_get_accel_group (merge)); - if (!gtk_menu_merge_add_ui_from_string (merge, ui_info, -1, &error)) + if (!gtk_ui_manager_add_ui_from_string (merge, ui_info, -1, &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); diff --git a/tests/testmerge.c b/tests/testmerge.c index a352f3866a..2bfd78601b 100644 --- a/tests/testmerge.c +++ b/tests/testmerge.c @@ -15,11 +15,11 @@ struct { const gchar *filename; guint merge_id; } merge_ids[] = { static void dump_tree (GtkWidget *button, - GtkMenuMerge *merge) + GtkUIManager *merge) { gchar *dump; - dump = gtk_menu_merge_get_ui (merge); + dump = gtk_ui_manager_get_ui (merge); g_message (dump); g_free (dump); } @@ -82,7 +82,7 @@ static GtkActionGroupEntry entries[] = { static guint n_entries = G_N_ELEMENTS (entries); static void -add_widget (GtkMenuMerge *merge, +add_widget (GtkUIManager *merge, GtkWidget *widget, GtkBox *box) { @@ -92,7 +92,7 @@ add_widget (GtkMenuMerge *merge, static void toggle_merge (GtkWidget *button, - GtkMenuMerge *merge) + GtkUIManager *merge) { gint mergenum; @@ -104,7 +104,7 @@ toggle_merge (GtkWidget *button, g_message ("merging %s", merge_ids[mergenum].filename); merge_ids[mergenum].merge_id = - gtk_menu_merge_add_ui_from_file (merge, merge_ids[mergenum].filename, &err); + gtk_ui_manager_add_ui_from_file (merge, merge_ids[mergenum].filename, &err); if (err != NULL) { GtkWidget *dialog; @@ -124,7 +124,7 @@ toggle_merge (GtkWidget *button, { g_message ("unmerging %s (merge_id=%u)", merge_ids[mergenum].filename, merge_ids[mergenum].merge_id); - gtk_menu_merge_remove_ui (merge, merge_ids[mergenum].merge_id); + gtk_ui_manager_remove_ui (merge, merge_ids[mergenum].merge_id); } } @@ -252,7 +252,7 @@ iter_compare_func (GtkTreeModel *model, } static GtkWidget * -create_tree_view (GtkMenuMerge *merge) +create_tree_view (GtkUIManager *merge) { GtkWidget *tree_view, *sw; GtkListStore *store; @@ -265,7 +265,7 @@ create_tree_view (GtkMenuMerge *merge) gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 0, GTK_SORT_ASCENDING); - for (p = gtk_menu_merge_get_action_groups (merge); p; p = p->next) + for (p = gtk_ui_manager_get_action_groups (merge); p; p = p->next) { GList *actions, *l; @@ -315,14 +315,14 @@ create_tree_view (GtkMenuMerge *merge) static gboolean area_press (GtkWidget *drawing_area, GdkEventButton *event, - GtkMenuMerge *merge) + GtkUIManager *merge) { gtk_widget_grab_focus (drawing_area); if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { - GtkWidget *menu = gtk_menu_merge_get_widget (merge, "/popups/FileMenu"); + GtkWidget *menu = gtk_ui_manager_get_widget (merge, "/popups/FileMenu"); if (GTK_IS_MENU (menu)) { @@ -341,7 +341,7 @@ int main (int argc, char **argv) { GtkActionGroup *action_group; - GtkMenuMerge *merge; + GtkUIManager *merge; GtkWidget *window, *table, *frame, *menu_box, *vbox, *view, *area; GtkWidget *button; gint i; @@ -375,16 +375,16 @@ main (int argc, char **argv) gtk_box_pack_end (GTK_BOX (menu_box), area, FALSE, FALSE, 0); gtk_widget_show (area); - merge = gtk_menu_merge_new (); + merge = gtk_ui_manager_new (); g_signal_connect (area, "button_press_event", G_CALLBACK (area_press), merge); - gtk_menu_merge_insert_action_group (merge, action_group, 0); + gtk_ui_manager_insert_action_group (merge, action_group, 0); g_signal_connect (merge, "add_widget", G_CALLBACK (add_widget), menu_box); gtk_window_add_accel_group (GTK_WINDOW (window), - gtk_menu_merge_get_accel_group (merge)); + gtk_ui_manager_get_accel_group (merge)); frame = gtk_frame_new ("UI Files"); gtk_table_attach (GTK_TABLE (table), frame, 0,1, 0,1, |