English 中文(简体)
Using GtkMenu in Gtk+-2.14.0
原标题:
  • 时间:2009-11-13 11:05:03
  •  标签:
  • gtk

I am building an application which has GtkMenu widget. I am using Glade RAD tool to develop UI and while creating project in Glade I have specified version of GTK as 2.16 which supports GtkMenu and GtkMenuItems.

So I used GtkMenu everywhere in app (for File Menu and for Right Click Menu).

But I tried this application on my target platform, which has GTK+ 2.14 installed
Does not recognize GtkMenu or GtkMenuItem.

What should I do now? I need to use GtkMenu with GtkMenuItems but I can t upgrade target platform to use GTK+ 2.16.

So questions are:

  1. Does GTK+ 2.14 support GtkMenu and GtkImageMenuItem/GtkMenuItems?
  2. If not what should we use instead?
最佳回答

GtkMenu is a core GTK+ class. It s been in there since the first (2.0) version of the current series, and was even in GTK+ 1.x.

I think the same holds true for GtkMenuItem; there are things (like the submenu property) that are noted as having been added in 2.12, for instance.

Not sure what that says about your problem; perhaps you re mis-interpreting some error message?

UPDATE: It does seem GtkImageMenuItem is new; perhaps you can emulate it using a plain menu item?

问题回答

The issue isn t that GTK+ 2.14 doesn t support GtkMenu and friends. It s that the UI building infrastructure, GtkBuilder, doesn t support creating them from XML specifications. Unfortunately I m not sure what the recommended solution is/was; I m dealing with the same problem myself.

Gtk 2.14 definitly support menuitem, menubar etc.. You are most likely saving your user interface as a gtkbuilder UI.

GtkBuilder is taking over libglade. Unfortunatly, GtkBuilder in gtk2.14 doesn t yet support the construction of menubar and menuitem, even though gtk2.14 totally support menubar and menuitem.

What are your options?

  1. Stay as you are, your project is fully operational on gtk >= 2.16 (gtkbuilder can create menuitem in gtk >=2.16)

  2. Save your user interface as a glade user interface and then your project will work fine on gtk 2.14. You will need to use libglade instead of gtkbuilder to load the interface, connect the signals etc. However it is a bad option since libglade will slowly diseapear.

  3. If building your app on gtk2.14 is really important, then you will want to build your menu without gtkbuilder, but directly write the code. (you will need to see the 2.14 documentation, go to http://library.gnome.org/devel/gtk/2.14/GtkMenuBar.html ).

I ll go for option 3. Good luck.

Christophe





相关问题
Pointers in Lisp?

I ve started learning Lisp recently and wanted to write a program which uses gtk interface. I ve installed lambda-gtk bindings (on CMUCL). I want to have putpixel/getpixel ability on a pixbuf. But I ...

In Gtk, how do I make a Button with just a stock icon?

I want to create a button with the stock "Remove" icon on it, but without the text "Remove". If I use Button button = new Button(Stock.Remove);, I get the opposite: just the text, and no icon. I will ...

Using GtkMenu in Gtk+-2.14.0

I am building an application which has GtkMenu widget. I am using Glade RAD tool to develop UI and while creating project in Glade I have specified version of GTK as 2.16 which supports GtkMenu and ...

Can you set the FileFilters for a Gtk Dialog in Glade?

In my code, I have lines like this: Builder builder = new Builder(); builder.AddFromFile(gladefile); FileChooserDialog dialog = (FileChooserDialog) builder.GetObject("dialog"); FileFilter[] ...

热门标签