Merge pull request #27 from aajonusonline/main
use `unknown` icon when one is not available
This commit is contained in:
BIN
bin/nwg-drawer
BIN
bin/nwg-drawer
Binary file not shown.
@@ -6,6 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/gotk3/gotk3/gdk"
|
"github.com/gotk3/gotk3/gdk"
|
||||||
"github.com/gotk3/gotk3/gtk"
|
"github.com/gotk3/gotk3/gtk"
|
||||||
)
|
)
|
||||||
@@ -33,13 +34,19 @@ func setUpPinnedFlowBox() *gtk.FlowBox {
|
|||||||
|
|
||||||
btn, _ := gtk.ButtonNew()
|
btn, _ := gtk.ButtonNew()
|
||||||
|
|
||||||
|
var pixbuf *gdk.Pixbuf
|
||||||
var img *gtk.Image
|
var img *gtk.Image
|
||||||
|
var err error
|
||||||
if entry.Icon != "" {
|
if entry.Icon != "" {
|
||||||
pixbuf, _ := createPixbuf(entry.Icon, *iconSize)
|
pixbuf, err = createPixbuf(entry.Icon, *iconSize)
|
||||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
|
||||||
} else {
|
} else {
|
||||||
img, _ = gtk.ImageNewFromIconName("image-missing", gtk.ICON_SIZE_INVALID)
|
pixbuf, err = createPixbuf("image-missing", *iconSize)
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
pixbuf, _ = createPixbuf("unknown", *iconSize)
|
||||||
|
}
|
||||||
|
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||||
|
|
||||||
btn.SetImage(img)
|
btn.SetImage(img)
|
||||||
btn.SetAlwaysShowImage(true)
|
btn.SetAlwaysShowImage(true)
|
||||||
@@ -233,13 +240,19 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
|
|||||||
button, _ := gtk.ButtonNew()
|
button, _ := gtk.ButtonNew()
|
||||||
button.SetAlwaysShowImage(true)
|
button.SetAlwaysShowImage(true)
|
||||||
|
|
||||||
|
var pixbuf *gdk.Pixbuf
|
||||||
var img *gtk.Image
|
var img *gtk.Image
|
||||||
|
var err error
|
||||||
if entry.Icon != "" {
|
if entry.Icon != "" {
|
||||||
pixbuf, _ := createPixbuf(entry.Icon, *iconSize)
|
pixbuf, err = createPixbuf(entry.Icon, *iconSize)
|
||||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
|
||||||
} else {
|
} else {
|
||||||
img, _ = gtk.ImageNewFromIconName("image-missing", gtk.ICON_SIZE_INVALID)
|
pixbuf, err = createPixbuf("image-missing", *iconSize)
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
pixbuf, _ = createPixbuf("unknown", *iconSize)
|
||||||
|
}
|
||||||
|
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||||
|
|
||||||
button.SetImage(img)
|
button.SetImage(img)
|
||||||
button.SetImagePosition(gtk.POS_TOP)
|
button.SetImagePosition(gtk.POS_TOP)
|
||||||
|
|||||||
Reference in New Issue
Block a user