Using GtkMenu in Gtk+-2.14.0 - 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:
Does GTK+ 2.14 support GtkMenu and GtkImageMenuItem/GtkMenuItems?
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?
Stay as you are, your project is fully operational on gtk >= 2.16 (gtkbuilder can create menuitem in gtk >=2.16)
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.
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

Related

GDK2 Alternative for gdk_window_set_fullscreen_mode

I'm trying to set my window to be GDK_FULLSCREEN_ON_ALL_MONITORS but for this I have to use gdk_window_set_fullscreen_mode, what is the GDK2 version of this?
Thanks
There is no GDK 2.x version of this API. The set_fullscreen_mode() method was added in 2013, long after GTK+ 2.x was API frozen; this means that no new function is going to be added to the GTK+ 2.x API.
The implementation of the set_fullscreen_mode() on X11 is not trivial; it implies getting the XINERAMA index of each monitor and sending a specially crafter ClientMessage to the running window manager for the _NET_WM_FULLSCREEN_MONITORS atom. You can see the implementation used in GDK attached to the issue that introduced it.
If you need this kind of functionality, you will have to use GTK+ 3.x.

Glass Development Kit Javadoc in Eclipse

I am unable to add the Javadoc for the Google Glass Development Kit (GDK) to either Eclipse or Android Studio; I'd love to be able to reference the GDK documentation right inside my IDE instead of just referencing the webpage.
Is there any way to do this? I'm aware of the typical way to add Javadoc to an Eclipse project, but I can't seem to find the actual documentation files for the GDK anywhere...
Thanks in advance!
Currently there is none for the small number of Google glass specific classes. The majority of classes are simple Android. (I understand from a talk with Jenny Murphy that the Google glass specific classes are implemented in native language and the java is just wrapper code.)
Perhaps this will change with the next GDK release (briefly saw indications of testing an XE15.2 version in the glass gdk issues, though that is hidden now).

Why can't I find Java desktop application in Netbeans 7.1

I downloaded Netbeans 7.1 with all bundle from http://netbeans.org/downloads and installed it successfully on Windows 7.
But I can't find Java Desktop Application which should be under Java category when add new project as 7.0 does.
Where is it? Or what is the substitute one in 7.1? I need something to create GUI by dragging components.
Thanks.
Look here: http://netbeans.org/bugzilla/show_bug.cgi?id=204661
Support for [B]SAF (JSR 296, basically the framework that was behind your "Java Desktop Application" project template) has been abruptly dropped (for no valid reason, let me add).
However, as Bill says in his answer, it is not necessary to use the SAF in order to visually design a form. NetBeans swing-designer (known as Matisse) can be used to design any JFrame, JDialog, JPanel, etc.
You just have to
Right click -> New -> JFrame Form...
and you're ready to drag-and-drop!
(The features you'll be missing are the extra bells and whistles that such framework provided, like SAF Actions, windowing persistence, simplified management for long running Tasks and related visual feedback [now you have to get your hands dirty with the SwingWorker class], etc)
Java Desktop refers to an effort to create a standard or library (libraries) that never really produced anything of significance. I think its likely that they finally removed it from Netbeans.
Its easier to just create a new Java Application project, don't bother with a main, then create a new JFrame Form. That class will have a main for you to use, and you can also design the frame in the form. You can also create JPanel Form classes. Note: you can do this in just about any project in netbeans, there is nothing special about the projects for them.
its better to use NetBeans 7.0 for full support of swing components.
many tutorials and guides feature the "Java Desktop Application" (like the ones for JXMapKit : http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html )
You can find something helpful to create CRUD desktop application in Java.
You can find it here.

What is the relation between GTK, GTK+ and GTK2?

I'm confused by the GTK terminology. According to Wikipedia, there seem to be bindings to GTK+ that are called GTK (GtkAda) and GTK2 (gtk2hs, Gtk2-Perl).
Could someone clear this up for me?
The first incarnation of the project was called GTK (which stood for GIMP Toolkit).
At some very early point, while the project was still part of The GIMP (and before version 1.0), it was renamed to GTK+. Despite this, people often referred to it as GTK out of convenience or ignorance.
The GTK+ name was used for more than 20 years through versions 1.x, 2.x, and 3.x, but the "GIMP Toolkit" expansion was dropped. I don't know when exactly this happened but perhaps during the 1.x → 2.x transition.
There is nothing officially called GTK2. It's just what some people call the 2.x series of GTK+.
On 2019-02-06, the project was renamed back to GTK, which will affect version 4.0 onwards.
GTK/GTK+ and GTK2 are different versions of the same API. GTK is an old, deprecated version, GTK2 is the previous one, GTK+ 3/GTK3 is the current version.
GTK+ is the correct name of the old API, but most people just call it GTK.
The C++ bindings for GTK+ are part of the project GTKmm.
GTK is the library for creating GUI-s for Linux / GNU. It has several versions (I think the latest is version 3).
In order for other programming languages to use it (other than C), there have to exist libraries that can bind GTK to that particular language.
PHP-GTK means that there's a library binding GTK to PHP enabling PHP to create apps that can be displayed in a nice interface. It supports, however, only up to version 2.2 of the GTK.
Same goes for other languages, they have a prefix / suffix and (GtkAda for example) those libraries also tell you up to what version they support GTK (since you might want to try newer GTK functions that aren't available in the library binding GTK to your language).

In Gtk, when is it better to use Glade/GtkBuilder than native code?

Glade helped me get started on a project quickly, but I've found it harder to maintain in the long run, and I'm thinking about switching it all to native code. In what circumstances would you choose glade, and when would you use native code?
I would personally only use native code for performance reasons. I find it much easier to work with gtkbuilder. Have you used glade or gtkbuilder? With Glade 3, gtkbuilder format is easy to use and easy to layout and design. Also, gtkbuilder is easier to load widgets from than glade was.
if by native code you mean "direct GTK calls to build ui", then i'd switch to it for several reasons:
if widgets are built dynamically depending on user preferences, etc
if i use a lot of custom widgets, esp. contained within each other (for example GDL docking panels)
to maintain backwards compatibility with older version of GTK
upd: also i'm still using glade2.x which has code generation (patched it to compile against latest gtk2). it really helps to get quickstart on "gui build from code", and works with both ancient and newer GTK versions. though i'm afraid i will have some troubles porting to gtk3 :)
and i never choose gtkbuilder over other alternatives, 'cause it is not available in (still widespread) older GTK versions.. dunno if i'll ever switch to it.. maybe when gtk3 comes out.