gtkd-developers / GtkD

GtkD is a D binding and OO wrapper of GTK+ originally created by Antonio Monteiro
http://gtkd.org
Other
322 stars 71 forks source link

Button.setImage(new Image(StockID.name)) doesn't work #300

Closed mark-summerfield closed 4 years ago

mark-summerfield commented 4 years ago

Using Button.setImage doesn't seem to work with stock item images. Attached is a tiny runnable example that shows a "missing icon" icon instead of the wanted icon. b1bug.zip

        optionsButton = new Button("_Options");
        // Supposed to work but doesn't:
        optionsButton.setImage(new Image(StockID.PREFERENCES));
        helpButton = new Button(StockID.HELP);
MikeWey commented 4 years ago

The code calls a different constructor than the one accepting a StockID because the IconSize is missing. The value that is in the StockID enum is passed to the constructor expecting a filename.

This should work:

optionsButton = new Button("_Options");
optionsButton.setImage(new Image(StockID.PREFERENCES, IconSize.BUTTON));
mark-summerfield commented 4 years ago

That didn't work for me, but this variation did:

        optionsButton.setImage(new Image(StockID.PREFERENCES,
                                         IconSize.fromName("BUTTON")));