Switch from libheif to imagemagick, fix #23

This commit is contained in:
2024-08-08 18:41:08 +02:00
parent 8b9a708cb4
commit fb91bd3b30
5 changed files with 49 additions and 9 deletions

View File

@@ -1,3 +1,6 @@
# Version 2.5
- Switch from libheif to imagemagick, HEIC conversion is now possible on Arch and Fedora!
# Version 2.4
- Adding Login window support
- Adding Russian translation (Thanks to blogdron)

View File

@@ -75,12 +75,24 @@ CinnamonDynamicWallpaperExtension.prototype = {
this.showNotification(_("Welcome to Cinnamon Dynamic Wallpaper"),
_("Check the preferences to choose a dynamic wallpaper"), true)
// Check for necessary software
if (!find_program_in_path('convert')) {
// Run on Ubuntu/Debian based distros with APT package manager
if(GLib.find_program_in_path("apturl")) {
Util.spawnCommandLine("apturl apt://imagemagick");
} else {
// Notification on other distros
this.showNotification(_("imagemagick is not installed"),
_("Please install the package manually for the full range of functions"), true)
}
}
// Hide the notification on system restart
this.settings.setValue("first_start", false)
this.settings.setValue("source_folder", DIRECTORY["path"] + "/res/images/included_image_sets/lakeside/")
}
// Start the main loop, checks in fixed time periods the
// Start the main loop, checks in fixed time periods
this._loop()
},
@@ -170,11 +182,6 @@ function init(extensionMeta) {
* @returns The extension object
*/
function enable() {
// Check for necessary software
if (!find_program_in_path('heif-convert')) {
Util.spawnCommandLine("apturl apt://libheif-examples");
}
return extension;
}

View File

@@ -204,7 +204,8 @@
<object class="GtkToggleButton" id="tb_heic_file">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Please install 'imagemagick' manually and reopen this configuration window</property>
<signal name="clicked" handler="on_toggle_button_heic_file_clicked" swapped="no"/>
<child>
<object class="GtkBox">

View File

@@ -1,5 +1,5 @@
# GTK
from gi.repository import Gio, Gdk
from gi.repository import Gio, Gdk, GLib
# Packages
import os, time, locale, subprocess, getpass
@@ -244,7 +244,8 @@ class Main_View_Model:
os.remove(extract_folder + file)
# Extract the HEIC file
os.system("heif-convert '" + file_uri + "' '" + extract_folder + file_name + ".jpg'")
print(self.get_imagemagick_prompt() + " " + file_uri + " -quality 100% " + extract_folder + file_name + ".jpg")
os.system(self.get_imagemagick_prompt() + " " + file_uri + " -quality 100% " + extract_folder + file_name + ".jpg")
return True
except:
@@ -328,3 +329,24 @@ class Main_View_Model:
if os.path.isfile('/etc/lightdm/slick-greeter.conf.backup'):
subprocess.call(['pkexec', 'rm', '/etc/lightdm/slick-greeter.conf'])
subprocess.call(['pkexec', 'mv', '/etc/lightdm/slick-greeter.conf.backup', '/etc/lightdm/slick-greeter.conf'])
def check_for_imagemagick(self) -> bool:
# Imagemagick < v.7.0
if GLib.find_program_in_path("convert") != None:
return True
# Imagemagick >= v.7.0
elif GLib.find_program_in_path("imagemagick") != None:
return True
# Not installed
else:
return False
def get_imagemagick_prompt(self) -> str:
# Imagemagick < v.7.0
if GLib.find_program_in_path("convert") != None:
return "convert"
# Imagemagick >= v.7.0
elif GLib.find_program_in_path("imagemagick") != None:
return "imagemagick convert"

View File

@@ -171,6 +171,13 @@ class Main_Window:
self.add_items_to_combo_box(self.cb_image_set, self.view_model.image_sets)
self.image_source = self.image_source # This triggers the @image_source.setter
## Disable the HEIF-Converter option, if the plugin isn't installed
if not self.view_model.check_for_imagemagick():
self.tb_heic_file.set_sensitive(False)
else:
## Remove the Tooltip
self.tb_heic_file.set_tooltip_text("")
# Page 2: Location & Times
self.add_items_to_combo_box(self.cb_network_provider, self.view_model.network_location_provider)
self.period_source = self.period_source # This triggers the @period_source.setter