Only update preview if the file is a valid image
This commit is contained in:
+10
-4
@@ -455,8 +455,11 @@ const Preferences = class {
|
||||
this.settings.connect('changed::background-day', () => updateBackgroundsBackgroundsDayBackgroundButtonUri());
|
||||
backgroundsBackgroundsDayBackgroundButton.connect('update-preview', () => {
|
||||
const file = backgroundsBackgroundsDayBackgroundButton.get_preview_filename();
|
||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
|
||||
dayBackgroundPreview.set_from_pixbuf(pixbuf);
|
||||
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);
|
||||
dayBackgroundPreview.set_from_pixbuf(pixbuf);
|
||||
}
|
||||
});
|
||||
backgroundsBackgroundsDayBackgroundButton.connect('file-set', () => {
|
||||
this.settings.set_string('background-day', backgroundsBackgroundsDayBackgroundButton.get_uri());
|
||||
@@ -471,8 +474,11 @@ const Preferences = class {
|
||||
this.settings.connect('changed::background-night', () => updateBackgroundsBackgroundsNightBackgroundButtonUri());
|
||||
backgroundsBackgroundsNightBackgroundButton.connect('update-preview', () => {
|
||||
const file = backgroundsBackgroundsNightBackgroundButton.get_preview_filename();
|
||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
|
||||
nightBackgroundPreview.set_from_pixbuf(pixbuf);
|
||||
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);
|
||||
nightBackgroundPreview.set_from_pixbuf(pixbuf);
|
||||
}
|
||||
});
|
||||
backgroundsBackgroundsNightBackgroundButton.connect('file-set', () => {
|
||||
this.settings.set_string('background-night', backgroundsBackgroundsNightBackgroundButton.get_uri());
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</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>
|
||||
</object>
|
||||
<object class="GtkDialog" id="ondemand_keyboard_shortcut_dialog">
|
||||
|
||||
Reference in New Issue
Block a user