cover: Add placeholder icon
This commit is contained in:
@@ -8,21 +8,43 @@ template $Cover: Adw.Bin {
|
||||
maximum-size: bind picture.height-request;
|
||||
tightening-threshold: bind picture.height-request;
|
||||
|
||||
Adw.Clamp {
|
||||
child: Adw.Clamp {
|
||||
unit: px;
|
||||
maximum-size: bind picture.width-request;
|
||||
tightening-threshold: bind picture.width-request;
|
||||
|
||||
Picture picture {
|
||||
paintable: bind template.paintable;
|
||||
width-request: 200;
|
||||
height-request: 300;
|
||||
content-fit: cover;
|
||||
child: Stack {
|
||||
visible-child-name: bind $_get_stack_child(template.paintable) as <string>;
|
||||
overflow: hidden;
|
||||
|
||||
StackPage {
|
||||
name: "cover";
|
||||
|
||||
child: Picture picture {
|
||||
paintable: bind template.paintable;
|
||||
width-request: 200;
|
||||
height-request: 300;
|
||||
content-fit: cover;
|
||||
};
|
||||
}
|
||||
|
||||
StackPage {
|
||||
name: "icon";
|
||||
|
||||
child: Image {
|
||||
icon-name: bind template.app-icon-name;
|
||||
pixel-size: 80;
|
||||
|
||||
styles [
|
||||
"dimmed",
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
styles [
|
||||
"card",
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from gi.repository import Adw, Gdk, GObject, Gtk
|
||||
|
||||
from cartridges.config import PREFIX
|
||||
from cartridges.config import APP_ID, PREFIX
|
||||
|
||||
|
||||
@Gtk.Template.from_resource(f"{PREFIX}/cover.ui")
|
||||
@@ -13,3 +13,8 @@ class Cover(Adw.Bin):
|
||||
__gtype_name__ = __qualname__
|
||||
|
||||
paintable = GObject.Property(type=Gdk.Paintable)
|
||||
app_icon_name = GObject.Property(type=str, default=f"{APP_ID}-symbolic")
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def _get_stack_child(self, _obj, paintable: Gdk.Paintable | None) -> str:
|
||||
return "cover" if paintable else "icon"
|
||||
|
||||
Reference in New Issue
Block a user