Re: using personal icons in the GtkScaleButton



Thank you Tadej for the clarification.

I tried substitute the gtk_button_new_from_stock for the
gtk_image_new_from_icon_name but, no errors occurs, but the image
isn't showed. What  is showed is the broken GTK+ image.

A minimal version of my code, and attached the image:
#include <gtk/gtk.h>

int main(int argc, char *argv[])
{
    GtkWidget *window, *scaleButton3;

    GtkIconFactory *iconFactory;

    GError *error = NULL;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_widget_set_size_request(window, 300, 175);

    iconFactory = gtk_icon_factory_new();

    gtk_icon_factory_add(iconFactory, "my-icon",
gtk_icon_set_new_from_pixbuf(gdk_pixbuf_new_from_file("icon.jpg",
&error)));

    if(error)
    {
        g_print("\n%s", error->message);
    }

    gtk_icon_factory_add_default(iconFactory);

    scaleButton3 = gtk_image_new_from_icon_name("my-icon",
GTK_ICON_SIZE_BUTTON);

    gtk_container_add(GTK_CONTAINER(window), scaleButton3);

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
}

2010/6/2 Tadej Borovšak <tadeboro gmail com>:
> Hi.
>
> There are two distinct stock things in GTK+: stock items[1] and stock
> icons[2]. Connection between them is purely conventional by virtue of
> using the same ID for both stock item and icon, but nothing is
> preventing you from having only item or only icon. It's developer's
> responsibility to provide this pair of application needs it.
>
> In your code, gtk_button_new_from_stock() expects to find both item
> and icon. Since stock item with ID "my-item" is not found, your string
> is treated as label.
>
> I'm almost sure that if you were to use gtk_image_new_from_icon_name()
> in place of gtk_button_new_from_stock(), things would work properly,
> because image is not interested in stock item at all - it just needs
> image.
>
> Scale button is similarly to GtkImage only interested in icons, so I'm
> not sure why would this call cause segfault. Do you have a minimal
> compilable application that demonstrates this problem?
>
> Tadej
>
> [1] http://library.gnome.org/devel/gtk/stable/gtk-Stock-Items.html
> [2] http://library.gnome.org/devel/gtk/stable/gtk-Themeable-Stock-Images.html
>
> --
> Tadej Borovšak
> tadeboro.blogspot.com
> tadeboro gmail com
> tadej borovsak gmail com
>

Attachment: icon.jpg
Description: JPEG image



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