Re: GtkRadioMenuItem



Hi again...

I have take a look into gtkradiomenuitem.c and implemeted my callback like this:

void CB_Mouse_Action(GtkWidget* widget, gpointer data)
{
  gint item=_number_of_items;
  GtkRadioMenuItem *tmp_item;
  GSList *slist;

  GtkRadioMenuItem *tmp_widget = (GtkRadioMenuItem *) widget;
  GGLInterface* tempGGL = (GGLInterface*) data;

  if (GTK_CHECK_MENU_ITEM(widget)->active == TRUE) {
    if (tmp_widget->group) {
      slist= tmp_widget->group;
      while ((tmp_item != tmp_widget) && (slist)) {
          tmp_item = (GtkRadioMenuItem *)slist->data;
	  if (tmp_item == tmp_widget) {
            if (CLASS_DEBUG) g_print("Got it!! %d\n",item);
            tempGGL->_mouse_action = item;
	  else {
	    slist = slist->next;
	    item--;
	  }
	} //while
      }
    }
}

I use item-- cause GtkRadioMenuItems seem to be inserted at the beginning of the GSList.

Is there a better way to do this? I don't like this particular solution :)


Thanks again,
	Ignacio Nodal

Ignacio Nodal wrote:

Hi,

I've create a submenu using GtkRadioMenuItems.
I don't want to use individuals callbacks for each GtkRadioMenuItems in the same submenu. Instead I want to call a unique callback but I need to know which submenu item called it.

All GtkRadioMenuItems in the submenu belong to the same group and have been added to it in order.

For example "Menu" has a submenu with three GtkRadioMenuItems:

Menu
  ->GtkRadioMenuItem0
  ->GtkRadioMenuItem1
  ->GtkRadioMenuItem2

So if I use the same callback for all submenu items and activate GtkRadioMenuItem2, I need to know it was GtkRadioMenuItem2 who calls the callback and not another.

Any idea?

Thanks in advance,

    Ignacio Nodal

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list







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