Re: [gtk-list] gtk_item_factory and C++

On Sun, 10 Jan 1999, Thomas Helvey wrote:

> Greetings,
> 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            
> callback_data,
>                                             guint               
> callback_action,
>                                             GtkWidget          
> *widget);
> typedef void    (*GtkItemFactoryCallback2) (GtkWidget           *widget,
>                                             gpointer            
> callback_data,
>                                             guint               
> callback_action);
> 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?

the alternate signatures have been introduced to provide backwards
compatibility regarding the callback interface, for old GtkMenuFactory code.
whether GtkItemFactoryCallback1 or GtkItemFactoryCallback2 is used as final
callback interface depends on whether you created the items with
gtk_item_factory_create_items or gtk_item_factory_create_items_ac respectively.
gtk_item_factory_create_items_ac and GtkItemFactoryCallback2 should
probably be classified as /* deprecated */.

> Regards,
> Thomas Helvey


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