gtk_item_factory and C++


After hearing many good things about gtk, I have decided to adopt it for
use in my project(s). I went out and got a copy of the distribution and
built and installed it on my SuSE 5.3 system. (The gthread package
didn't build here, I had to hack *-posix.c to #include
<pthread/mit/pthread.h> instead of <pthread.h> which doesn't exist here.
The gthread test failed, but I'm not using threads right now so it
doesn't bother me too much.)

After an initial look at gtk-- and an attempt to get it to compile
(egcs-1.1.1), I couldn't seem to find a combination of gtk-- and gtk
that would build with each other. I decided to forgo using gtk--, and
decided to write my own wrappers where and when I needed them.

As a first cut I decided to do some cut and paste programming to see if
I could get a basic app framework up (menu, main window, optional
toolbar etc.) so I grabbed the item factory chunk out of the test
program, the item factory looked like a great way to create basic menus
without writing a lot of code. However when compiled with C++ the
example code gives me the following warning:
guiproto.C:42: warning: ANSI C++ prohibits conversion from `(void *,
guint, stru
ct GtkWidget *)' to `(...)'
The compiler is complaining about the multiple definitions of
GtkItemFactoryCallback in gtkitemfactory.h
typedef void    (*GtkItemFactoryCallback)  ();
typedef void    (*GtkItemFactoryCallback1) (gpointer            
typedef void    (*GtkItemFactoryCallback2) (GtkWidget           *widget,

In the GtkItemFactoryEntry struct only the GtkItemFactoryCallback
function is declared resulting in the warning.
struct _GtkItemFactoryEntry
  gchar *path;
  gchar *accelerator;

  GtkItemFactoryCallback callback;
  guint                  callback_action;

  gchar          *item_type;

Selecting one callback interface here would be better for both
efficiency and type safety (the code has to check which version of the
callback function was used). Is there a reason why the menu callbacks
need more than one interface? Would it be possible to fix this without
breaking other things too badly?

Thomas Helvey

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