Re: [gtk-list] callback_type in gtk_item_factory_create_item



trog,
is this covered by the FAQ yet?


On Mon, 15 Mar 1999, Andreas Tille wrote:

> Hello,
> 
> the only documentation for item_factory I could find is testgtk.  There
> is an example for gtk_item_factory_create_items which contains no
> parameter callback_type.  In the source it calls gtk_item_factory_create_item
> with callback_type explicitely set to 1.  What is the sense of this
> parameter?  It has only two valid vlues 1 or 2.  All others will be
> ignored (cause errors).

with that the callback types GtkItemFactoryCallback1 or
GtkItemFactoryCallback2 will be selected, i've appended similar messages
that cover this topic.

> 
> Here are the relevant header informations:
> 
> void    gtk_item_factory_create_item    (GtkItemFactory         *ifactory,
>                                          GtkItemFactoryEntry    *entry,
>                                          gpointer callback_data,
>                                          guint callback_type);
> void    gtk_item_factory_create_items   (GtkItemFactory *ifactory,
>                                          guint n_entries,
>                                          GtkItemFactoryEntry    *entries,
>                                          gpointer callback_data);
> 
> Kind regards
> 
>      Andreas.
> 

---
ciaoTJ


Date: Thu, 14 Jan 1999 13:26:21 +0100 (CET)
From: Tim Janik <timj@gtk.org>
Reply-To: gtk-list@redhat.com
To: Andy Kahn <kahn@zk3.dec.com>
Cc: Gtk+ MList <gtk-list@redhat.com>
Subject: [gtk-list] Re: GtkItemFactoryEntry: no field for callback data?
Resent-Date: 14 Jan 1999 18:25:28 -0000
Resent-From: gtk-list@redhat.com
Resent-cc: recipient list not shown: ;

On Wed, 13 Jan 1999, Andy Kahn wrote:

> just wondering where there is no provision for specifying callback
> data as part of GtkItemFactoryEntry... i think it would be good to
> have, since not all menu items may have identical callback data.
> without it, i'm finding flexibility somewhat limited.
> --andy

the item factory features two different types of callback_data, this is
the callback signature:

static void
factory_callback (gpointer             callback_data,
                  guint                callback_action,
                  GtkWidget           *widget);

here, `callback_data' is the `callback_data' pointer that you passed into
gtk_item_factory_create_items() or gtk_item_factory_create_item().
`callback_action' is the value of GtkItemFactoryEntry.callback_action, thus
it's always menu item specific. `widget' is a pointer to the menu item that
got selected, and the factory itself can be retrived back from this widget
via gtk_item_factory_from_widget().

> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 

---
ciaoTJ

-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null



Date: Mon, 11 Jan 1999 07:45:57 +0100 (CET)
From: Tim Janik <timj@gtk.org>
Reply-To: gtk-list@redhat.com
To: gtk-list@redhat.com
Subject: [gtk-list] Re: gtk_item_factory and C++
Resent-Date: 11 Jan 1999 09:25:27 -0000
Resent-From: gtk-list@redhat.com
Resent-cc: recipient list not shown: ;

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
> 

---
ciaoTJ

-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null





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