mirror of
https://github.com/nwg-piotr/nwg-drawer.git
synced 2024-09-11 14:07:17 +03:00
use unknown
icon when one is not available
This commit is contained in:
parent
a1bb05c816
commit
54e880df47
BIN
bin/nwg-drawer
BIN
bin/nwg-drawer
Binary file not shown.
@ -6,10 +6,25 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/gotk3/gotk3/gdk"
|
||||
"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 {
|
||||
if pinnedFlowBox != nil {
|
||||
pinnedFlowBox.Destroy()
|
||||
@ -33,12 +48,9 @@ func setUpPinnedFlowBox() *gtk.FlowBox {
|
||||
|
||||
btn, _ := gtk.ButtonNew()
|
||||
|
||||
var img *gtk.Image
|
||||
if entry.Icon != "" {
|
||||
pixbuf, _ := createPixbuf(entry.Icon, *iconSize)
|
||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||
} else {
|
||||
img, _ = gtk.ImageNewFromIconName("image-missing", gtk.ICON_SIZE_INVALID)
|
||||
img, err := getImageFromIcon(entry.Icon)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
btn.SetImage(img)
|
||||
@ -233,12 +245,9 @@ func flowBoxButton(entry desktopEntry) *gtk.Button {
|
||||
button, _ := gtk.ButtonNew()
|
||||
button.SetAlwaysShowImage(true)
|
||||
|
||||
var img *gtk.Image
|
||||
if entry.Icon != "" {
|
||||
pixbuf, _ := createPixbuf(entry.Icon, *iconSize)
|
||||
img, _ = gtk.ImageNewFromPixbuf(pixbuf)
|
||||
} else {
|
||||
img, _ = gtk.ImageNewFromIconName("image-missing", gtk.ICON_SIZE_INVALID)
|
||||
img, err := getImageFromIcon(entry.Icon)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
button.SetImage(img)
|
||||
|
Loading…
Reference in New Issue
Block a user