Allow dropping images on background button
This commit is contained in:
@@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Night Theme Switcher\n"
|
"Project-Id-Version: Night Theme Switcher\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2022-02-19 11:38+0100\n"
|
"POT-Creation-Date: 2022-02-23 21:30+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@@ -17,34 +17,38 @@ msgstr ""
|
|||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: src/modules/TimerOndemand.js:206
|
#: src/modules/TimerOndemand.js:213
|
||||||
msgid "Turn Night Mode On"
|
msgid "Turn Night Mode On"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/modules/TimerOndemand.js:206
|
#: src/modules/TimerOndemand.js:213
|
||||||
msgid "Turn Night Mode Off"
|
msgid "Turn Night Mode Off"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/modules/TimerOndemand.js:218
|
#: src/modules/TimerOndemand.js:228
|
||||||
msgid "Extension Settings"
|
msgid "Extension Settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/modules/TimerOndemand.js:227
|
#: src/modules/TimerOndemand.js:237
|
||||||
msgid "Night Mode Off"
|
msgid "Night Mode Off"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/modules/TimerOndemand.js:227
|
#: src/modules/TimerOndemand.js:237
|
||||||
msgid "Night Mode On"
|
msgid "Night Mode On"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/modules/TimerOndemand.js:228
|
#: src/modules/TimerOndemand.js:238
|
||||||
msgid "Turn On"
|
msgid "Turn On"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/modules/TimerOndemand.js:228
|
#: src/modules/TimerOndemand.js:238
|
||||||
msgid "Turn Off"
|
msgid "Turn Off"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/preferences/BackgroundButton.js:61
|
||||||
|
msgid "Only JPEG, PNG, TIFF and XML files can be set as background image."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/preferences/SchedulePage.js:45 src/preferences/ui/SchedulePage.ui:63
|
#: src/preferences/SchedulePage.js:45 src/preferences/ui/SchedulePage.ui:63
|
||||||
msgid "Night Light"
|
msgid "Night Light"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -61,15 +65,15 @@ msgstr ""
|
|||||||
msgid "On-demand"
|
msgid "On-demand"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/preferences/SchedulePage.js:90
|
#: src/preferences/SchedulePage.js:91
|
||||||
msgid "None"
|
msgid "None"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/preferences/SchedulePage.js:91
|
#: src/preferences/SchedulePage.js:92
|
||||||
msgid "Top bar"
|
msgid "Top bar"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/preferences/SchedulePage.js:92
|
#: src/preferences/SchedulePage.js:93
|
||||||
msgid "System menu"
|
msgid "System menu"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
// SPDX-FileCopyrightText: 2021, 2022 Romain Vigier <contact AT romainvigier.fr>
|
// SPDX-FileCopyrightText: 2021, 2022 Romain Vigier <contact AT romainvigier.fr>
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
const { Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk } = imports.gi;
|
const { Adw, Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk } = imports.gi;
|
||||||
const { extensionUtils } = imports.misc;
|
const { extensionUtils } = imports.misc;
|
||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
const _ = extensionUtils.gettext;
|
||||||
|
|
||||||
|
|
||||||
var BackgroundButton = GObject.registerClass({
|
var BackgroundButton = GObject.registerClass({
|
||||||
@@ -37,6 +38,36 @@ var BackgroundButton = GObject.registerClass({
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
}, class BackgroundButton extends Gtk.Button {
|
}, class BackgroundButton extends Gtk.Button {
|
||||||
|
constructor(props = {}) {
|
||||||
|
super(props);
|
||||||
|
this.#setupDropTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
#setupDropTarget() {
|
||||||
|
const dropTarget = Gtk.DropTarget.new(Gio.File.$gtype, Gdk.DragAction.COPY);
|
||||||
|
dropTarget.connect('drop', (_target, file, _x, _y) => {
|
||||||
|
const contentType = Gio.content_type_guess(file.get_basename(), null)[0];
|
||||||
|
if (
|
||||||
|
Gio.content_type_equals(contentType, 'image/jpeg') ||
|
||||||
|
Gio.content_type_equals(contentType, 'image/png') ||
|
||||||
|
Gio.content_type_equals(contentType, 'image/tiff') ||
|
||||||
|
Gio.content_type_equals(contentType, 'application/xml')
|
||||||
|
) {
|
||||||
|
this.uri = file.get_uri();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (this.root instanceof Adw.PreferencesWindow) {
|
||||||
|
this.root.add_toast(new Adw.Toast({
|
||||||
|
title: _('Only JPEG, PNG, TIFF and XML files can be set as background image.'),
|
||||||
|
timeout: 10,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add_controller(dropTarget);
|
||||||
|
}
|
||||||
|
|
||||||
openFileChooser() {
|
openFileChooser() {
|
||||||
this._filechooser.transient_for = this.get_root();
|
this._filechooser.transient_for = this.get_root();
|
||||||
this._filechooser.show();
|
this._filechooser.show();
|
||||||
|
|||||||
Reference in New Issue
Block a user