Size background button according to monitor size

This commit is contained in:
Romain Vigier
2022-02-23 22:26:40 +01:00
parent 104bfd5d25
commit 1b7e63d9d1
+11 -1
View File
@@ -34,15 +34,25 @@ var BackgroundButton = GObject.registerClass({
'Height of the displayed thumbnail',
GObject.ParamFlags.READWRITE,
0, 600,
120
180
),
},
}, class BackgroundButton extends Gtk.Button {
constructor(props = {}) {
super(props);
this.#setupSize();
this.#setupDropTarget();
}
#setupSize() {
const display = Gdk.Display.get_default();
const monitor = display.get_monitors().get_item(0);
if (monitor.width_mm > monitor.height_mm)
this.thumb_height *= monitor.height_mm / monitor.width_mm;
else
this.thumb_width *= monitor.width_mm / monitor.height_mm;
}
#setupDropTarget() {
const dropTarget = Gtk.DropTarget.new(Gio.File.$gtype, Gdk.DragAction.COPY);
dropTarget.connect('drop', (_target, file, _x, _y) => {