Gtk_MenuFactory in gtk--?



Hello all.
    I was wondering if anyone have had any experience setting up
Gtk_MenuFactory under gtk--?  I know that at this momment,  you can not
connect menus from menufactory to C++ member functions.  But I can not
even create the menubar.  Can anyone provide code example?   I am
attaching my example prog.  Would anyone please tell me what am I doing
wrong?

Also, have anyone had any luck compiling gtkGL-0.8?  When I ./configure,
it tells me that it can not find GL, gdk, and gtk libraries, but they
are in the LD_LIBRARY_PATH...



Thank you.
Marsel Osipov

#include <gtk--.h>
#include <strings.h>

static GtkMenuEntry menu_items[] =
{
  {"<Main>/File/New", NULL, NULL, NULL},
  {"<Main>/File/Open", NULL, NULL, NULL},
  {"<Main>/File/Save", NULL, NULL, NULL},
  {"<Main>/File/<separator>", NULL, NULL, NULL},
  {"<Main>/File/Quit", NULL, NULL, NULL}
};

static int nmenu_items = sizeof(menu_items)/sizeof(menu_items[0]);

class MyWin : public Gtk_Window {
  Gtk_MenuBar mbar;
  Gtk_Menu fmenu;
  Gtk_MenuFactory factory = NULL;
  Gtk_MenuFactory *subfactory[1];
  static GHashTable *entry_ht = NULL;
  static int initialize = TRUE;
  Gtk_VBox vbox;
 
public: 
  MyWin();
  void get_main_menu(Gtk_MenuBar *);
};


MyWin::MyWin() : vbox(false, 1)
{
  factory.add_subfactory(subfactory[0], "<Main>");
  factory.add_entries(menu_items, nmenu_items);
 
  get_main_menu(mbar);
  add(&vbox);
  vbox.pack_start(&mbar);
  mbar.show();
} 

void MyWin::get_main_menu(Gtk_MenuBar *mebar)
{

  // compiler produces a mistake here
  // class 'Gtk_MenuFactory' has no member named 'widget'
  // I think this is the reason why menubar is not shown...
  //  if(mebar)
  //*mebar = subfactory[0]->widget;
}

int main(int argc, char **argv)
{
  Gtk_Main vm(&argc, &argv);
  MyWin win;
  win.set_usize(300, 200);
  win.show();
  vm.run();  
  return(0);
}
	  


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