Re: patch to remove compiler warnings for tests/testgtk.c



Sven Neumann <sven gimp org> writes:

> Hi,
> 
> here's a patch that makes tests/testgtk.c compile without warnings.
> OK to commit?

I don't like this fix ... using GtkSignalFunc when we do have
a fixed prototype seems wrong to me. I'd either:

 - Add a typedef:

   typedef void (*OptionMenuFunc) (GtkWidget *widget, gpointer data)

   And casts to that typedf.

or:

 - Fix the callbacks all to have the same signature so no cast
   is necessary.

If I was doing it, I'd do the second, but either would be fine.

Regards,
                                        Owen

> Index: tests/testgtk.c
> ===================================================================
> RCS file: /cvs/gnome/gtk+/tests/testgtk.c,v
> retrieving revision 1.282
> diff -u -p -r1.282 testgtk.c
> --- tests/testgtk.c	2001/11/13 00:53:43	1.282
> +++ tests/testgtk.c	2001/11/14 15:49:52
> @@ -72,7 +72,7 @@ static GtkWidget *
>  build_option_menu (gchar           *items[],
>  		   gint             num_items,
>  		   gint             history,
> -		   void           (*func)(GtkWidget *widget, gpointer data),
> +		   GtkSignalFunc    callback,
>  		   gpointer         data);
>  
>  /* macro, structure and variables used by tree window demos */
> @@ -103,7 +103,7 @@ static GtkWidget *
>  build_option_menu (gchar           *items[],
>  		   gint             num_items,
>  		   gint             history,
> -		   void           (*func)(GtkWidget *widget, gpointer data),
> +		   GtkSignalFunc    callback,
>  		   gpointer         data)
>  {
>    GtkWidget *omenu;
> @@ -113,8 +113,7 @@ build_option_menu (gchar           *item
>    gint i;
>  
>    omenu = gtk_option_menu_new ();
> -  gtk_signal_connect (GTK_OBJECT (omenu), "changed",
> -		      GTK_SIGNAL_FUNC (func), data);
> +  gtk_signal_connect (GTK_OBJECT (omenu), "changed", callback, data);
>        
>    menu = gtk_menu_new ();
>    group = NULL;
> @@ -3047,7 +3046,7 @@ create_menus (void)
>  			  NULL);
>        
>        accel_group = gtk_accel_group_new ();
> -      gtk_window_add_accel_group (window, accel_group);
> +      gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
>  
>        gtk_window_set_title (GTK_WINDOW (window), "menus");
>        gtk_container_set_border_width (GTK_CONTAINER (window), 0);
> @@ -3354,21 +3353,21 @@ create_item_factory (void)
>  			  NULL);
>        
>        accel_group = gtk_accel_group_new ();
> -      item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
> +      item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
> +                                           accel_group);
>        gtk_object_set_data_full (GTK_OBJECT (window),
>  				"<main>",
>  				item_factory,
>  				(GtkDestroyNotify) gtk_object_unref);
> -      gtk_window_add_accel_group (window, accel_group);
> +      gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
>        gtk_window_set_title (GTK_WINDOW (window), "Item Factory");
>        gtk_container_set_border_width (GTK_CONTAINER (window), 0);
> -      gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
> +      gtk_item_factory_create_items (item_factory, 
> +                                     nmenu_items, menu_items, NULL);
>  
>        /* preselect /Preferences/Shape/Oval over the other radios
>         */
> -      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory,
> -										      "/Preferences/Shape/Oval")),
> -				      TRUE);
> +      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory, "/Preferences/Shape/Oval")), TRUE);
>  
>        box1 = gtk_vbox_new (FALSE, 0);
>        gtk_container_add (GTK_CONTAINER (window), box1);
> @@ -4793,7 +4792,7 @@ create_list (void)
>        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
>  
>        list_omenu = build_option_menu (items, 3, 3, 
> -				      list_toggle_sel_mode,
> +				      GTK_SIGNAL_FUNC (list_toggle_sel_mode),
>  				      list);
>        gtk_box_pack_start (GTK_BOX (hbox), list_omenu, FALSE, TRUE, 0);
>  
> @@ -5299,7 +5298,7 @@ create_clist (void)
>        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
>  
>        clist_omenu = build_option_menu (items, 3, 3, 
> -				       clist_toggle_sel_mode,
> +				       GTK_SIGNAL_FUNC (clist_toggle_sel_mode),
>  				       clist);
>        gtk_box_pack_start (GTK_BOX (hbox), clist_omenu, FALSE, TRUE, 0);
>  
> @@ -6185,26 +6184,28 @@ void create_ctree (void)
>        gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
>  
>        omenu1 = build_option_menu (items1, 4, 2, 
> -				  ctree_toggle_line_style,
> +				  GTK_SIGNAL_FUNC (ctree_toggle_line_style),
>  				  ctree);
>        gtk_box_pack_start (GTK_BOX (hbox), omenu1, FALSE, TRUE, 0);
>        gtk_tooltips_set_tip (tooltips, omenu1, "The tree's line style.", NULL);
>  
>        omenu2 = build_option_menu (items2, 4, 1, 
> -				  ctree_toggle_expander_style,
> +				  GTK_SIGNAL_FUNC (ctree_toggle_expander_style),
>  				  ctree);
>        gtk_box_pack_start (GTK_BOX (hbox), omenu2, FALSE, TRUE, 0);
>        gtk_tooltips_set_tip (tooltips, omenu2, "The tree's expander style.",
>  			    NULL);
>  
>        omenu3 = build_option_menu (items3, 2, 0, 
> -				  ctree_toggle_justify, ctree);
> +				  GTK_SIGNAL_FUNC (ctree_toggle_justify), 
> +                                  ctree);
>        gtk_box_pack_start (GTK_BOX (hbox), omenu3, FALSE, TRUE, 0);
>        gtk_tooltips_set_tip (tooltips, omenu3, "The tree's justification.",
>  			    NULL);
>  
>        omenu4 = build_option_menu (items4, 3, 3, 
> -				  ctree_toggle_sel_mode, ctree);
> +				  GTK_SIGNAL_FUNC (ctree_toggle_sel_mode), 
> +                                  ctree);
>        gtk_box_pack_start (GTK_BOX (hbox), omenu4, FALSE, TRUE, 0);
>        gtk_tooltips_set_tip (tooltips, omenu4, "The list's selection mode.",
>  			    NULL);
> @@ -7604,7 +7605,7 @@ create_notebook (void)
>        gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0);
>  
>        omenu = build_option_menu (items, G_N_ELEMENTS (items), 0,
> -				 notebook_type_changed,
> +				 GTK_SIGNAL_FUNC (notebook_type_changed),
>  				 sample_notebook);
>        gtk_box_pack_start (GTK_BOX (box2), omenu, FALSE, TRUE, 0);
>  
> @@ -9283,9 +9284,10 @@ create_progress_bar (void)
>  			5, 5);
>        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
>  
> -      pdata->omenu1 = build_option_menu (items1, 4, 0,
> -					 progressbar_toggle_orientation,
> -					 pdata);
> +      pdata->omenu1 = 
> +        build_option_menu (items1, 4, 0,
> +                           GTK_SIGNAL_FUNC (progressbar_toggle_orientation),
> +                                            pdata);
>        hbox = gtk_hbox_new (FALSE, 0);
>        gtk_table_attach (GTK_TABLE (tab), hbox, 1, 2, 0, 1,
>  			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
> @@ -9354,9 +9356,9 @@ create_progress_bar (void)
>  			5, 5);
>        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
>  
> -      pdata->omenu2 = build_option_menu	(items2, 2, 0,
> -					 progressbar_toggle_bar_style,
> -					 pdata);
> +      pdata->omenu2 = build_option_menu (items2, 2, 0,
> +                                         GTK_SIGNAL_FUNC (progressbar_toggle_bar_style),
> +                                         pdata);
>        hbox = gtk_hbox_new (FALSE, 0);
>        gtk_table_attach (GTK_TABLE (tab), hbox, 1, 2, 3, 4,
>  			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list



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