Re: Problems with GtkUIManager



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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]