ItemFactory callbacks not quite working



Folks,

I've got these few snips of code:

void set_xaxis_context(gpointer cb_data, guint action, GtkWidget *w);

static GtkItemFactoryEntry context_menu[] = {
  { "/Set X-Axis", 	NULL, 		set_xaxis_context, 	0, 	NULL
},
};

 w_layout[number].context_menu=gtk_item_factory_new(GTK_TYPE_MENU, "<main>",
NULL);
 gtk_item_factory_create_items(w_layout[number].context_menu, nmenu_items,
context_menu, NULL);
 gtk_object_set_data(GTK_OBJECT(w_layout[number].context_menu), "id",
GINT_TO_POINTER(number));

void set_xaxis_context(gpointer cb_data, guint action, GtkWidget *widget)
{
  gpointer data;
  data=gtk_object_get_data(GTK_OBJECT(widget), "id");
  if (data!=NULL)
    printf("ID %d\n", GPOINTER_TO_INT(data));
  else
    printf("NULL!\n");
}

gint button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer
data)
{
  // other stuff
  if(event->button==3)
  {
    gtk_item_factory_popup(w_layout[foc].context_menu, (guint)
event->x_root, (guint) event->y_root, 1, 0);
    return TRUE;
  }
  return FALSE;
}

This code all looks good. I press the RMB on my area and the popup menu
appears normally. When I click on the "Set X-Axis" item the callback is
called but it always returns NULL. I've tried using the widget->parent
widget instead and that didn't help. Can anyone point out what I am doing
wrong?

Thanks!

Rich



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