[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Problems with GtkUIManager
- From: Lorenzo Gil Sanchez <lgs sicem biz>
- To: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: Problems with GtkUIManager
- Date: Fri, 23 Jul 2004 12:35:23 +0200
After some more tests, I can answer myself:
This does NOT work:
gtk_ui_manager_add_ui (uim, mid, "/ui/", "mymenubar",
"MenubarAction", GTK_UI_MANAGER_MENUBAR,
FALSE);
This works:
gtk_ui_manager_add_ui (uim, mid, "ui/", "mymenubar",
"MenubarAction", GTK_UI_MANAGER_MENUBAR,
FALSE);
Note I removed the first '/' in the path of the second call.
I guess we should say so in the docs so nobody spend 45 minutes trying
to do that.
I attach a tiny patch to fix that. Please tell me if I should fill a bug
for such a small thing or commit it directly.
Lorenzo
Index: gtk/gtkuimanager.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkuimanager.c,v
retrieving revision 1.53
diff -u -r1.53 gtkuimanager.c
--- gtk/gtkuimanager.c 20 Jul 2004 17:10:24 -0000 1.53
+++ gtk/gtkuimanager.c 23 Jul 2004 10:32:04 -0000
@@ -1542,7 +1542,7 @@
* gtk_ui_manager_add_ui:
* @self: a #GtkUIManager
* @merge_id: the merge id for the merged UI, see
gtk_ui_manager_new_merge_id()
- * @path: a path
+ * @path: a path (it should not start by a slash)
* @name: the name for the added UI element
* @action: the name of the action to be proxied, or %NULL to add a
separator
* @type: the type of UI element to add.
El vie, 23-07-2004 a las 12:09, Lorenzo Gil Sanchez escribió:
> Sorry, forgot to attach the file :|
>
> Lorenzo
>
> #include <gtk/gtk.h>
>
> static void on_click (GtkButton *button, gpointer data) {
> GtkUIManager *uim = GTK_UI_MANAGER (data);
>
> gtk_ui_manager_ensure_update (uim);
> g_print (gtk_ui_manager_get_ui (uim));
> }
>
> static void dummy (GtkAction *action) {
> ;
> }
>
> GtkActionEntry actions[] = {
> { "MenubarAction", NULL, "Dummy"},
> { "FileAction", NULL, "_File"},
> { "FileOpenAction", GTK_STOCK_OPEN, NULL, NULL, "Open it",
> G_CALLBACK(dummy)}
> };
>
> int main(int argc, char **argv) {
> GtkWidget *window;
> GtkWidget *button;
> GtkUIManager *uim;
> GtkActionGroup *ag;
> int mid;
>
> gtk_init (&argc, &argv);
>
> ag = gtk_action_group_new("MyActionGroup");
> gtk_action_group_add_actions(ag, actions, 2, NULL);
>
> uim = gtk_ui_manager_new ();
> gtk_ui_manager_insert_action_group (uim, ag, 0);
>
> mid = gtk_ui_manager_new_merge_id (uim);
> gtk_ui_manager_add_ui (uim, mid, "/ui/", "mymenubar", "MenubarAction",
> GTK_UI_MANAGER_MENUBAR, FALSE);
>
> gtk_ui_manager_add_ui (uim, mid, "/ui/mymenubar/", "filemenu",
> "FileAction",
> GTK_UI_MANAGER_MENU, FALSE);
>
> gtk_ui_manager_add_ui (uim, mid, "/ui/mymenubar/filemenu", "open",
> "FileOpenAction", GTK_UI_MANAGER_MENUITEM, FALSE);
>
> window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>
> button = gtk_button_new_with_label ("Dump UI Info");
>
> g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_click),
> uim);
>
> gtk_container_add (GTK_CONTAINER (window), button);
>
> gtk_widget_show_all (window);
>
> gtk_main ();
>
> return 0;
> }
>
>
> El vie, 23-07-2004 a las 12:04, Lorenzo Gil Sanchez escribió:
> > Hi,
> >
> > I'm trying to create an UIManager totally from scratch, e.g. with no XML
> > files. I wonder if this is possible because after several calls to
> > gtk_ui_manager_add_ui(...) I do a gtk_ui_manager_get_ui(...) and nothing
> > is there. No errors, no warnings, but nothing is there.
> >
> > I attach a 50 lines test program to show what I mean.
> >
> > Any help is very appreciated
> >
> > Lorenzo Gil Sanchez
> >
> > ______________________________________________________________________
> > _______________________________________________
> > gtk-app-devel-list mailing list
> > gtk-app-devel-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
> ______________________________________________________________________
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]