[Glade-devel] Glade 2.6 : toolbar widget, warning with gtk_image_new_from_stock

Boris HUISGEN bhuisgen@wanadoo.fr
Tue, 25 May 2004 17:20:09 +0200


Hi,


A small problem occurs with toolbar buttons / icons in Glade 2.6. When I
compile source, some errors are noticed like this :

interface.cc: In function `GtkWidget* create_main_window()':
interface.cc:299: invalid conversion from `gint' to `GtkIconSize'
interface.cc:307: invalid conversion from `gint' to `GtkIconSize'
interface.cc: In function `GtkWidget* create_configeditor_dialog()':
interface.cc:2978: invalid conversion from `gint' to `GtkIconSize'
make[3]: *** [interface.o] Error 1

The problem is related to function gtk_image_new_from_stock () : her
second parameter has type 'GtkIconSize' and not 'gint'.

Here is the code generated by glade 2.6 :

>   GtkWidget *toolbar_main;
>   gint tmp_toolbar_icon_size;
>   GtkWidget *tmp_image;
>   GtkWidget *button_redirect;
> 
>   toolbar_main = gtk_toolbar_new ();
>   gtk_widget_show (toolbar_main);
>   gtk_box_pack_start (GTK_BOX (vbox1), toolbar_main, FALSE, FALSE, 0);
>   gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_main),
> GTK_TOOLBAR_BOTH_HORIZ);
>   tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR
> (toolbar_main));
> 
>   tmp_image = gtk_image_new_from_stock ("gtk-yes",
> tmp_toolbar_icon_size);
>   gtk_widget_show (tmp_image);
>   button_redirect = (GtkWidget*) gtk_tool_button_new (tmp_image,
> _("Redirect"));
>   gtk_widget_show (button_redirect);
>   gtk_container_add (GTK_CONTAINER (toolbar_main), button_redirect);
>   gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (button_redirect),
> tooltips, _("Redirect the domain"), NULL);
>   gtk_tool_item_set_is_important (GTK_TOOL_ITEM (button_redirect),
> TRUE);


Now the corrected code (simply fixed at line 2) :

>   GtkWidget *toolbar_main;
>   GtkIconSize tmp_toolbar_icon_size;
>   GtkWidget *tmp_image;
>   GtkWidget *button_redirect;
> 
>   toolbar_main = gtk_toolbar_new ();
>   gtk_widget_show (toolbar_main);
>   gtk_box_pack_start (GTK_BOX (vbox1), toolbar_main, FALSE, FALSE, 0);
>   gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_main),
> GTK_TOOLBAR_BOTH_HORIZ);
>   tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR
> (toolbar_main));
> 
>   tmp_image = gtk_image_new_from_stock ("gtk-yes",
> tmp_toolbar_icon_size);
>   gtk_widget_show (tmp_image);
>   button_redirect = (GtkWidget*) gtk_tool_button_new (tmp_image,
> _("Redirect"));
>   gtk_widget_show (button_redirect);
>   gtk_container_add (GTK_CONTAINER (toolbar_main), button_redirect);
>   gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (button_redirect),
> tooltips, _("Redirect the domain"), NULL);
>   gtk_tool_item_set_is_important (GTK_TOOL_ITEM (button_redirect),
> TRUE);


Thanks to correct this in the next release :)


-- 
Boris HUISGEN

Email : bhuisgen@wanadoo.fr
Site Web : http://unlimit.homedns.org