Compare commits

...

2 Commits

Author SHA1 Message Date
Hugo Posnic
6a408edfa0 Implement an AdwStatusPage for start page 2023-04-03 00:09:17 +02:00
Hugo Posnic
7a606a4c6a Add libs versions in debug section of AdwAboutWindow 2023-04-02 23:45:32 +02:00
3 changed files with 108 additions and 59 deletions

View File

@ -3,7 +3,6 @@
<template class="CurtailWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Curtail</property>
<property name="default-width">650</property>
<property name="default-height">350</property>
<child>
<object class="GtkBox" id="mainbox">
<property name="margin-start">10</property>
@ -12,74 +11,57 @@
<property name="margin-bottom">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="homebox">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">true</property>
<object class="AdwStatusPage" id="homebox">
<property name="vexpand">true</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Compress your images</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<style>
<class name="title-1"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Drag and drop your images here…</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">or</property>
<attributes>
<attribute name="style" value="italic"></attribute>
</attributes>
</object>
</child>
<child>
<object class="GtkButton" id="filechooser_button">
<property name="label" translatable="yes">Browse Files</property>
<property name="action-name">win.select-file</property>
<property name="margin-bottom">20</property>
<style>
<class name="suggested-action"/>
<class name="pill"/>
</style>
</object>
</child>
<property name="icon-name">com.github.huluti.Curtail</property>
<property name="title" translatable="no">Curtail</property>
<property name="description" translatable="yes">Drag and drop your images here…</property>
<child>
<object class="GtkBox">
<property name="margin-top">10</property>
<property name="margin-bottom">20</property>
<property name="spacing">10</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="halign">end</property>
<property name="label" translatable="yes">Lossless</property>
<object class="GtkButton">
<property name="label" translatable="yes">_Browse Files</property>
<property name="halign">center</property>
<property name="action-name">win.select-file</property>
<property name="margin-bottom">40</property>
<property name="use-underline">1</property>
<style>
<class name="suggested-action"/>
<class name="pill"/>
</style>
</object>
</child>
<child>
<object class="GtkSwitch" id="toggle_lossy">
<object class="GtkBox">
<property name="spacing">10</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<property name="label" translatable="yes">Lossy</property>
<child>
<object class="GtkLabel">
<property name="halign">end</property>
<property name="label" translatable="yes">Lossless</property>
</object>
</child>
<child>
<object class="GtkSwitch" id="toggle_lossy">
<property name="halign">center</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<property name="label" translatable="yes">Lossy</property>
</object>
</child>
</object>
</child>
</object>
</child>
<style>
<class name="icon-dropshadow"/>
</style>
</object>
</child>
<child>

View File

@ -15,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import platform
import subprocess
from gi.repository import Gtk, GLib, Gio, GdkPixbuf
@ -90,3 +93,67 @@ def create_image_from_file(filename, max_width, max_height):
image = Gtk.Image.new_from_pixbuf(scaled_pixbuf)
return image
def debug_infos():
python_version = platform.python_version()
gtk_version = '{}.{}.{}'.format(Gtk.get_major_version(),
Gtk.get_minor_version(), Gtk.get_micro_version())
# Jpegoptim
try:
jpegoptim = subprocess.check_output("jpegoptim --version", shell=True)
jpegoptim = extract_version(jpegoptim.decode('utf-8'))
except Exception as err:
jpegoptim = _('Version not found')
# OptiPNG
try:
optipng = subprocess.check_output("optipng -version", shell=True)
optipng = extract_version(optipng.decode('utf-8'))
except Exception as err:
pass
optipng = _('Version not found')
# pngquant
try:
pngquant = subprocess.check_output("pngquant --version", shell=True)
pngquant = extract_version(pngquant.decode('utf-8'))
except Exception as err:
pngquant = _('Version not found')
# Libwebp
try:
libwebp = subprocess.check_output("cwebp -version", shell=True)
libwebp = extract_version(libwebp.decode('utf-8'))
except Exception as err:
libwebp = _('Version not found')
debug = '''Python: {}\n
Gtk: {}\n
Jpegoptim: {}\n
OptiPNG: {}\n
pngquant: {}\n
Libwep: {}\n'''.format(
python_version,
gtk_version,
jpegoptim,
optipng,
pngquant,
libwebp
)
return debug
def extract_version(text):
# regular expression to match the version string,
# consists of three groups of one or more digits separated by dots
version_regex = r"(\d+\.\d+\.\d+)"
match = re.search(version_regex, text)
if match:
version_string = match.group(1) # extract the version string from the match object
return version_string
else:
return _('Version not found')

View File

@ -23,7 +23,7 @@ from .resultitem import ResultItem
from .preferences import CurtailPrefsWindow
from .compressor import Compressor
from .tools import add_filechooser_filters, get_file_type, \
create_image_from_file, sizeof_fmt
create_image_from_file, sizeof_fmt, debug_infos
CURTAIL_PATH = '/com/github/huluti/Curtail/'
SETTINGS_SCHEMA = 'com.github.huluti.Curtail'
@ -49,7 +49,6 @@ class CurtailWindow(Gtk.ApplicationWindow):
resultbox = Gtk.Template.Child()
scrolled_window = Gtk.Template.Child()
listbox = Gtk.Template.Child()
filechooser_button = Gtk.Template.Child()
toggle_lossy = Gtk.Template.Child()
results_model = Gio.ListStore.new(ResultItem)
@ -310,7 +309,7 @@ class CurtailWindow(Gtk.ApplicationWindow):
copyright='© Hugo Posnic'
)
about.add_credit_section(
_("Contributors"),
_('Contributors'),
[
'Steven Teskey',
'Andrey Kozlovskiy',
@ -320,6 +319,7 @@ class CurtailWindow(Gtk.ApplicationWindow):
'Maximiliano'
]
)
about.set_debug_info(debug_infos())
about.present()
def on_quit(self, *args):