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



Only hint I can think of is set button_list to null before appending to it. and appending is inefficient btw u might consider prepending or using a GList :) but either way set it to NULL first.

On Wed, Apr 04, 2001 at 04:28:41PM -0500, Sean Scanlon wrote:
> 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
> 
> 
> _______________________________________________
> 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]