Re: WHere is the icons

Stefan et al,

On Mon, Aug 10, 2015 at 2:23 PM, Stefan Salewski <mail ssalewski de> wrote:
On Mon, 2015-08-10 at 12:28 -0400, Igor Korot wrote:
But then how do I set the label for such button?
It looks like this function can be used for bitmap buttons only (no

Of course you can continue using the deprecated stock item, as long as
that still works...

My impression is, that recommendation for recent GTK3 is to have only
textual label for buttons and menu items generally, with some

We can use gtk_button_new() with a container widget argument, which may
contain a label and an image. Some details I found here

Unfortunately that is some more work now...

Here is what I have right now:

GtkWidget *gtk_my_dialog_add_button_to (GtkBox *box, const gchar *label,
                                            const gchar *stock, gint
    /* create the button */
    GtkWidget *button = gtk_button_new_with_mnemonic (label);
    gtk_widget_set_can_default(button, true);
    GtkWidget *image = NULL;
#if GTK_CHECK_VERSION( 3, 10, 0 )
    if( !gtk_check_version( 3, 10, 0 ) )
        image = gtk_image_new_from_icon_name( stock, GTK_ICON_SIZE_BUTTON );
        /* add a stock icon inside it */
        image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON);
    gtk_button_set_image (GTK_BUTTON (button), image);

    /* add to the given (container) widget */
    if (box)
        gtk_box_pack_end (box, button, FALSE, TRUE, 8);

    /* add the button to the dialog's action area */
    gtk_dialog_add_action_widget (GTK_DIALOG (dlg), button, response_id);

   return button;

extern "C" {
static void gtk_my_dialog_init(GTypeInstance* instance, void*)
// some code
#if GTK_CHECK_VERSION( 3, 10, 0 )
    if( !gtk_check_version( 3, 10, 0 ) )
        continuebtn = gtk_assert_dialog_add_button( dlg, "Continue",
        continuebtn = gtk_assert_dialog_add_button (dlg, "_Continue",
// some more code

I am running currently KDE-4 on Gentoo Linux (stable). This peice of
code works when running against GTK+-2.24, i.e. I see
both label and the icon. However, when running against GTK+-3.16.5 all
I can see is just a text and no icon.

What am I doing wrong? Am I using the right replacements? Do I use it properly?

Thank you.

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