Size background button according to monitor size
This commit is contained in:
@@ -34,15 +34,25 @@ var BackgroundButton = GObject.registerClass({
|
|||||||
'Height of the displayed thumbnail',
|
'Height of the displayed thumbnail',
|
||||||
GObject.ParamFlags.READWRITE,
|
GObject.ParamFlags.READWRITE,
|
||||||
0, 600,
|
0, 600,
|
||||||
120
|
180
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
}, class BackgroundButton extends Gtk.Button {
|
}, class BackgroundButton extends Gtk.Button {
|
||||||
constructor(props = {}) {
|
constructor(props = {}) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.#setupSize();
|
||||||
this.#setupDropTarget();
|
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() {
|
#setupDropTarget() {
|
||||||
const dropTarget = Gtk.DropTarget.new(Gio.File.$gtype, Gdk.DragAction.COPY);
|
const dropTarget = Gtk.DropTarget.new(Gio.File.$gtype, Gdk.DragAction.COPY);
|
||||||
dropTarget.connect('drop', (_target, file, _x, _y) => {
|
dropTarget.connect('drop', (_target, file, _x, _y) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user