[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
RE: itemfactory question
- From: "Poletti, Don" <don poletti comverse-in com>
- To: "'gtk-app-devel-list redhat com'" <gtk-app-devel-list redhat com>
- Subject: RE: itemfactory question
- Date: Thu, 24 Feb 2000 10:00:37 -0500
Thanks,
That actually cleared its up, Your first example used one callback and used
the action to distinguish. This example shows using different callbacks.
I need to do both kinds. Unfortunately my action parameter is not working
correctly, If I track that down then I will have everything covered. Thanks
for the example.
> -----Original Message-----
> From: Valéry Febvre [mailto:vfebvre@easter-eggs.com]
> Sent: Thursday, February 24, 2000 6:42 PM
> To: gtk-app-devel-list@redhat.com
> Subject: Re: itemfactory question
>
>
> > > For the prototype callback, I use always:
> > >
> > > void menu_callback(gpointer cb_data, guint action, GtkWidget * w)
> > > {
> > > switch (action)
> > > {
> > > case ABOUT:
> > > ...
> > > break;
> > > case EXIT:
> > > gtk_main_quit();
> > > break;
> > > ...
> > > }
> > > }
> > >
> > >
> >
> > This example implies that there is one call back per menu, but the
> > itemFactoryEntry allows a callback to be specified on each item?
> > Are you saying I can only specify a call back on the menu?
> NO
> This function can be used for only one entry.
>
> A little example:
>
> enum
> {
> ABOUT,
> EXIT
> };
>
> GtkWidget* create_window() {
> GtkWidget *win;
> GtkItemFactory *menu;
> GtkItemFactoryEntry menu_entries[] =
> {
> "/About", NULL, menu_callback1, ABOUT, "<Item>",
> "/Exit", NULL, menu_callback2, EXIT, "<Item>"
> };
>
> menu = gtk_item_factory_new(GTK_TYPE_MENU, "<Main>", NULL);
> gtk_item_factory_create_items(menu, 2, menu_entries, NULL);
>
> win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> gtk_object_set_data(GTK_OBJECT(win), "menu", menu);
> gtk_widget_ref(win);
> gtk_signal_connect (GTK_OBJECT (win), "destroy", GTK_SIGNAL_FUNC
> (gtk_main_quit), NULL);
> gtk_signal_connect (GTK_OBJECT (win), "delete_event",
> GTK_SIGNAL_FUNC
> (gtk_main_quit), NULL);
> gtk_signal_connect (GTK_OBJECT (win), "button_press_event",
> GTK_SIGNAL_FUNC (popup_menu), NULL);
> return win;
> }
>
> void menu_callback1(gpointer cb_data, guint action, GtkWidget * w)
> {
> create_about();
> }
>
> void menu_callback2(gpointer cb_data, guint action, GtkWidget * w)
> {
> gtk_main_quit();
> }
>
> static gint popup_menu(GtkWidget *w, GdkEventButton *e)
> {
> GdkModifierType modmask;
> GtkItemFactory *menu;
>
> switch(e->button) {
> case 1:
> is_motion_ok = TRUE;
> break;
> case 3:
> menu = gtk_object_get_data(GTK_OBJECT(w), "menu");
> gtk_item_factory_popup(menu, (gint)(e->x_root), (gint)(e->y_root),
> 3, GDK_CURRENT_TIME);
> break;
> }
> return 0;
> }
>
>
> I think that this example is bad because we don't used
> the fourth ItemFactoryItem's attribut (the action)
> Here, we need 2 functions whereas we could use only one function
> with a 'switch'
> Perhaps, I don't understand your problem ???
>
>
> --
> To unsubscribe: mail
> gtk-app-devel-list-request@redhat.com with
> "unsubscribe" as the Subject.
>
> Mailing list concerns should be mailed to
> <listmaster@redhat.com>
>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]