开发者

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 Gla开发者_StackOverflow中文版de 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜