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,10 +6,25 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getImageFromIcon(ico string) (img *gtk.Image, err error) {
|
||||||
|
var pixbuf *gdk.Pixbuf
|
||||||
|
if ico != "" {
|
||||||
|
pixbuf, err = createPixbuf(ico, *iconSize)
|
||||||
|
} else {
|
||||||
|
pixbuf, err = createPixbuf("image-missing", *iconSize)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
pixbuf, _ = createPixbuf("unknown", *iconSize)
|
||||||
|
}
|
||||||
|
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func setUpPinnedFlowBox() *gtk.FlowBox {
|
func setUpPinnedFlowBox() *gtk.FlowBox {
|
||||||
if pinnedFlowBox != nil {
|
if pinnedFlowBox != nil {
|
||||||
pinnedFlowBox.Destroy()
|
pinnedFlowBox.Destroy()
|
||||||
@@ -33,12 +48,9 @@ func setUpPinnedFlowBox() *gtk.FlowBox {
|
|||||||
|
|
||||||
btn, _ := gtk.ButtonNew()
|
btn, _ := gtk.ButtonNew()
|
||||||
|
|
||||||
var img *gtk.Image
|
img, err := getImageFromIcon(entry.Icon)
|
||||||
if entry.Icon != "" {
|
if err != nil {
|
||||||
pixbuf, _ := createPixbuf(entry.Icon, *iconSize)
|
log.Error(err)
|
||||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
|
||||||
} else {
|
|
||||||
img, _ = gtk.ImageNewFromIconName("image-missing", gtk.ICON_SIZE_INVALID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.SetImage(img)
|
btn.SetImage(img)
|
||||||
@@ -233,12 +245,9 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
|
|||||||
button, _ := gtk.ButtonNew()
|
button, _ := gtk.ButtonNew()
|
||||||
button.SetAlwaysShowImage(true)
|
button.SetAlwaysShowImage(true)
|
||||||
|
|
||||||
var img *gtk.Image
|
img, err := getImageFromIcon(entry.Icon)
|
||||||
if entry.Icon != "" {
|
if err != nil {
|
||||||
pixbuf, _ := createPixbuf(entry.Icon, *iconSize)
|
log.Error(err)
|
||||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
|
||||||
} else {
|
|
||||||
img, _ = gtk.ImageNewFromIconName("image-missing", gtk.ICON_SIZE_INVALID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button.SetImage(img)
|
button.SetImage(img)
|
||||||
|
|||||||
Reference in New Issue
Block a user