Only update preview if the file is a valid image
This commit is contained in:
@@ -455,8 +455,11 @@ const Preferences = class {
|
|||||||
this.settings.connect('changed::background-day', () => updateBackgroundsBackgroundsDayBackgroundButtonUri());
|
this.settings.connect('changed::background-day', () => updateBackgroundsBackgroundsDayBackgroundButtonUri());
|
||||||
backgroundsBackgroundsDayBackgroundButton.connect('update-preview', () => {
|
backgroundsBackgroundsDayBackgroundButton.connect('update-preview', () => {
|
||||||
const file = backgroundsBackgroundsDayBackgroundButton.get_preview_filename();
|
const file = backgroundsBackgroundsDayBackgroundButton.get_preview_filename();
|
||||||
|
const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff'];
|
||||||
|
if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) {
|
||||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
|
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
|
||||||
dayBackgroundPreview.set_from_pixbuf(pixbuf);
|
dayBackgroundPreview.set_from_pixbuf(pixbuf);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
backgroundsBackgroundsDayBackgroundButton.connect('file-set', () => {
|
backgroundsBackgroundsDayBackgroundButton.connect('file-set', () => {
|
||||||
this.settings.set_string('background-day', backgroundsBackgroundsDayBackgroundButton.get_uri());
|
this.settings.set_string('background-day', backgroundsBackgroundsDayBackgroundButton.get_uri());
|
||||||
@@ -471,8 +474,11 @@ const Preferences = class {
|
|||||||
this.settings.connect('changed::background-night', () => updateBackgroundsBackgroundsNightBackgroundButtonUri());
|
this.settings.connect('changed::background-night', () => updateBackgroundsBackgroundsNightBackgroundButtonUri());
|
||||||
backgroundsBackgroundsNightBackgroundButton.connect('update-preview', () => {
|
backgroundsBackgroundsNightBackgroundButton.connect('update-preview', () => {
|
||||||
const file = backgroundsBackgroundsNightBackgroundButton.get_preview_filename();
|
const file = backgroundsBackgroundsNightBackgroundButton.get_preview_filename();
|
||||||
|
const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff'];
|
||||||
|
if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) {
|
||||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
|
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
|
||||||
nightBackgroundPreview.set_from_pixbuf(pixbuf);
|
nightBackgroundPreview.set_from_pixbuf(pixbuf);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
backgroundsBackgroundsNightBackgroundButton.connect('file-set', () => {
|
backgroundsBackgroundsNightBackgroundButton.connect('file-set', () => {
|
||||||
this.settings.set_string('background-night', backgroundsBackgroundsNightBackgroundButton.get_uri());
|
this.settings.set_string('background-night', backgroundsBackgroundsNightBackgroundButton.get_uri());
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="pixel_size">256</property>
|
<property name="pixel_size">256</property>
|
||||||
<property name="icon_name">image-loading</property>
|
<property name="icon_name">image-missing</property>
|
||||||
<property name="icon_size">0</property>
|
<property name="icon_size">0</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkDialog" id="ondemand_keyboard_shortcut_dialog">
|
<object class="GtkDialog" id="ondemand_keyboard_shortcut_dialog">
|
||||||
|
|||||||
Reference in New Issue
Block a user