need help with passing a GSList of GtkWidget's as a gpointer



Hi.  I've read through the GTK+ API, FAQ & tutorial, as well as the 
gtk-list archives, but to no avail.

I'm trying to pass a callback function a GSList of GtkWidgets, but get
failed type checking assertions:


<runtime error>
Gtk-CRITICAL **: file gtktogglebutton.c: line 284 (gtk_toggle_button_set_active): assertion `GTK_IS_TOGGLE_BUTTON (toggle_button)' failed.
</runtime error>


This is on a Solaris 2.7 (aka SunOS 5.7) Ultra10, using the
Sun WorkShop C++ Compiler 5.0


<code>
void function0(void)
{
  GtkWidget* button;
  GSList*    button_list;
  gint       i;

  /* create & setup window ... */

  for (i=0; i<8; i++) {   /* populate GSList */
    button = gtk_check_button_new();
    button_list = g_slist_append( button_list, button );
    /* pack check button somewhere ... */
  }

  button = gtk_button_new_with_label("Set All");
  gtk_signal_connect( GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(set_all_button_clicked_cb),
                      button_list );
  /* pack "set all" button somewhere ... */

  g_slist_free(button_list);
}


void set_all_button_clicked_cb( GtkButton* button, gpointer data )
{
  GSList*          button_list   = (GSList*)data;
  GtkWidget*       widget        = (GtkWidget*)NULL;
  GtkToggleButton* toggle_button = (GtkToggleButton*)NULL;

  while (NULL != button_list)
  {
    widget = (GtkWidget*)(button_list->data);
    toggle_button = (GtkToggleButton*)(widget);
    gtk_toggle_button_set_active( toggle_button, TRUE );
    button_list = button_list->next;
  }
}
</code>


Needless to say, the check buttons do not get set. :)

Any hints would be greatly appreciated.

Thanks,
 Sean
--
Sean Scanlon
sean scanlon teradyne com





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