diff --git a/Makefile b/Makefile index 875c92d4..fa0a6bf2 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ global: sudo ninja -C builddir install user: - meson builddiruser - meson configure builddiruser -Dprefix="$(pwd)/builddiruser/testdir" - ninja -C builddiruser install - ninja -C builddiruser run \ No newline at end of file + meson builddir --prefix="$(shell pwd)/builddir/testdir" --wipe + ninja -C builddir install + ninja -C builddir run \ No newline at end of file diff --git a/local.sh b/local.sh index 2d0aa59a..19b85fe1 100755 --- a/local.sh +++ b/local.sh @@ -21,7 +21,6 @@ read -p "Do you want to install Python requirements? (yes, no): " answer if [[ "$answer" == "yes" ]]; then pip3 install --user -r requirements.txt - pip3 install $(pwd)/monet/material_color_utilities_python-0.1.0-py3-none-any.whl elif [[ "$answer" == "no" ]]; then echo "Skipping requirements installation" fi @@ -31,7 +30,7 @@ rm -r builddir echo "Rebuilding" meson builddir -meson configure builddir -Dprefix="$(pwd)/builddir/testdir" +meson configure builddir -Dprefix="$(pwd)/builddir/testdir" -Dbuildtype=debug ninja -C builddir install echo "Running" diff --git a/meson.build b/meson.build index 441d2e4e..d413d802 100644 --- a/meson.build +++ b/meson.build @@ -13,9 +13,9 @@ python = import('python') # Project information PROJECT_URL = 'https://github.com/GradienceTeam/Gradience' -BUGTRACKER_URL = 'https://github.com/tfuxu/themeteor/issues' +BUGTRACKER_URL = 'https://github.com/GradienceTeam/Gradience/issues' HELP_URL = 'https://github.com/orgs/GradienceTeam/discussions' -TRANSLATE_URL = 'https://www.transifex.com/Gradienceteam/Gradience' +TRANSLATE_URL = 'https://hosted.weblate.org/projects/GradienceTeam/gradience/' # Constants PROJECT_RDNN_NAME = 'com.github.GradienceTeam.Gradience' diff --git a/src/__init__.py b/src/__init__.py index 21cfb9a7..89484be8 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,3 +1,5 @@ +# __init__.py +# # Change the look of Adwaita, with ease # Copyright (C) 2022 Gradience Team # @@ -12,11 +14,4 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import re -from anyascii import anyascii - - -def to_slug_case(non_slug): - return re.sub(r"[^0-9a-z]+", "-", anyascii(non_slug).lower()).strip("-") +# along with this program. If not, see . \ No newline at end of file diff --git a/src/builtin_preset_row.py b/src/builtin_preset_row.py index 4031816c..ff23f0ed 100644 --- a/src/builtin_preset_row.py +++ b/src/builtin_preset_row.py @@ -1,7 +1,7 @@ from gi.repository import Gtk, Gdk, Adw from .constants import rootdir -from . import to_slug_case +from .modules.utils import to_slug_case, buglog import json import os @@ -29,7 +29,7 @@ class GradienceBuiltinPresetRow(Adw.ActionRow): @Gtk.Template.Callback() def on_apply_button_clicked(self, *_args): - print("apply") + buglog("apply") self.app.load_preset_from_resource( f"{rootdir}/presets/" diff --git a/src/constants.py.in b/src/constants.py.in index c2f5b835..55d1e3d4 100644 --- a/src/constants.py.in +++ b/src/constants.py.in @@ -19,9 +19,10 @@ rootdir = '/com/github/GradienceTeam/Gradience' app_id = '@APP_ID@' +rel_ver = '@RELEASE_VER@' version = '@VERSION@' build_type = '@BUILD_TYPE@' project_url = '@PROJECT_URL@' bugtracker_url = '@BUGTRACKER_URL@' help_url = '@HELP_URL@' -trnaslate_url = '@TRANSLATE_URL@' \ No newline at end of file +translate_url = '@TRANSLATE_URL@' \ No newline at end of file diff --git a/src/main.py b/src/main.py index d0bc3053..d5f022a6 100644 --- a/src/main.py +++ b/src/main.py @@ -19,7 +19,6 @@ import sys import json import os -import re import traceback import gi @@ -32,10 +31,10 @@ from .palette_shades import GradiencePaletteShades from .option import GradienceOption from .app_type_dialog import GradienceAppTypeDialog from .custom_css_group import GradienceCustomCSSGroup -from .constants import rootdir, app_id, version, bugtracker_url, help_url, project_url +from .constants import rootdir, app_id, rel_ver, version, bugtracker_url, help_url, project_url from .welcome import GradienceWelcomeWindow from .presets_manager_window import GradiencePresetWindow -from . import to_slug_case +from .modules.utils import to_slug_case, buglog class GradienceApplication(Adw.Application): @@ -73,7 +72,7 @@ class GradienceApplication(Adw.Application): self.settings.get_value("disabled-plugins")) self.first_run = self.settings.get_boolean("first-run") - print(f"disabled plugins: {self.disabled_plugins}") + buglog(f"disabled plugins: {self.disabled_plugins}") self.style_manager = Adw.StyleManager.get_default() @@ -127,11 +126,11 @@ class GradienceApplication(Adw.Application): ) if self.first_run: - print("first run") + buglog("first run") welcome = GradienceWelcomeWindow(self.win) welcome.present() else: - print("normal run") + buglog("normal run") self.win.present() def open_preset_directory(self, *_args): @@ -156,7 +155,7 @@ class GradienceApplication(Adw.Application): ) def load_preset_from_file(self, preset_path): - print("load preset from file", preset_path) + buglog("load preset from file", preset_path) preset_text = "" with open(preset_path, "r", encoding="utf-8") as file: preset_text = file.read() @@ -631,19 +630,22 @@ class GradienceApplication(Adw.Application): # Translators: This is a place to put your credits (formats: "Name # https://example.com" or "Name ", no quotes) # and is not meant to be translated literally. + # TODO: Automate this process using CI, because not everyone knows about this translator_credits="""Maxime V https://www.transifex.com/user/profile/Adaoh/ FineFindus https://github.com/FineFindus Karol Lademan https://www.transifex.com/user/profile/karlod/ Monty Monteusz https://www.transifex.com/user/profile/MontyQIQI/ Renato Corrêa https://www.transifex.com/user/profile/renatocrrs/ Aggelos Tselios https://www.transifex.com/user/profile/AndroGR/ - David "Daudix UFO" Lapshin https://github.com/daudix-UFO' + David "Daudix UFO" Lapshin https://github.com/daudix-UFO 0xMRTT https://github.com/0xMRTT + tfuxu https://github.com/tfuxu Juanjo Cillero https://www.transifex.com/user/profile/renux918/ Taylan Tatlı https://www.transifex.com/user/profile/TaylanTatli34/""", copyright="© 2022 Gradience Team", license_type=Gtk.License.GPL_3_0, version=version, + release_notes_version=rel_ver, release_notes=_("""
  • Add AdwViewSwitcher in the header bar.
  • @@ -708,7 +710,7 @@ This app is written in Python and uses GTK 4 and libadwaita. self.set_accels_for_action(f"app.{name}", shortcuts) def reload_plugins(self): - print("reload plugins") + buglog("reload plugins") self.win.plugins_group = self.win.plugins_list.to_group() def show_adwaita_demo(self, *_args): diff --git a/src/meson.build b/src/meson.build index 4c2684ae..99a6694d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -37,7 +37,16 @@ configure_file( configure_file( input: 'constants.py.in', output: 'constants.py', - configuration: conf, + configuration: configuration_data({ + 'APP_ID': APPLICATION_ID, + 'RELEASE_VER': meson.project_version(), + 'VERSION': meson.project_version() + VERSION_SUFFIX, + 'BUILD_TYPE': get_option('buildtype'), + 'PROJECT_URL': PROJECT_URL, + 'BUGTRACKER_URL': BUGTRACKER_URL, + 'HELP_URL': HELP_URL, + 'TRANSLATE_URL': TRANSLATE_URL + }), install: true, install_dir: PY_INSTALLDIR.get_install_dir() / 'gradience', ) @@ -71,4 +80,12 @@ gradience_sources = [ ] PY_INSTALLDIR.install_sources(gradience_sources, subdir: 'gradience') -#install_data(gradience_sources, install_dir: MODULE_DIR) \ No newline at end of file +#install_data(gradience_sources, install_dir: MODULE_DIR) + +# Install modules +gradience_modules = [ + 'modules/__init__.py', + 'modules/utils.py' +] + +PY_INSTALLDIR.install_sources(gradience_modules, subdir: 'gradience/modules') diff --git a/src/modules/__init__.py b/src/modules/__init__.py new file mode 100644 index 00000000..f330c9ac --- /dev/null +++ b/src/modules/__init__.py @@ -0,0 +1,17 @@ +# __init__.py +# +# Change the look of Adwaita, with ease +# Copyright (C) 2022 Gradience Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . \ No newline at end of file diff --git a/src/modules/utils.py b/src/modules/utils.py new file mode 100644 index 00000000..cf17dffd --- /dev/null +++ b/src/modules/utils.py @@ -0,0 +1,35 @@ +# utils.py +# +# Change the look of Adwaita, with ease +# Copyright (C) 2022 Gradience Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import re + +from anyascii import anyascii +from gradience.constants import build_type + + +def to_slug_case(non_slug): + return re.sub(r"[^0-9a-z]+", "-", anyascii(non_slug).lower()).strip("-") + +# Use it instead of print(), so there isn't any output in stdout if Gradience was build in release mode +# TODO: Can be replaced with `logging` module [https://docs.python.org/3/library/logging.html] in future +def buglog(*args): + if build_type == "debug": + message = "" + for obj in args: + message += str(obj) + return print(f"[DEBUG]: {message}") diff --git a/src/plugin_row.py b/src/plugin_row.py index 338d3c9e..2aa4730a 100644 --- a/src/plugin_row.py +++ b/src/plugin_row.py @@ -1,6 +1,24 @@ +# plugin_row.py +# +# Change the look of Adwaita, with ease +# Copyright (C) 2022 Gradience Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . from gi.repository import Gtk, Gdk, Adw +from .modules.utils import buglog from .constants import rootdir @@ -21,14 +39,14 @@ class GradiencePluginRow(Adw.ActionRow): @Gtk.Template.Callback() def on_settings_plugin_clicked(self, *_args): - print("settings") + buglog("settings") @Gtk.Template.Callback() def on_remove_plugin_clicked(self, *_args): - print("removed") + buglog("removed") @Gtk.Template.Callback() def on_switch_toggled(self, *_args): - print("toggled") + buglog("toggled") Gtk.Application.get_default().reload_plugins() diff --git a/src/plugins_list.py b/src/plugins_list.py index 3d742d02..d5631a45 100644 --- a/src/plugins_list.py +++ b/src/plugins_list.py @@ -16,14 +16,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import sys import os -from pathlib import Path import importlib import pkgutil -from .plugin_row import GradiencePluginRow + from gi.repository import Gtk, Adw, Gio, Gdk -import sys +from pathlib import Path +from .modules.utils import buglog +from .plugin_row import GradiencePluginRow class GradiencePluginsList: @@ -41,7 +43,7 @@ class GradiencePluginsList: for plugin_id, plugin in self.discoverd_plugins.items(): self.plugins[plugin_id] = plugin.GradiencePlugin() - print(self.plugins) + buglog(self.plugins) def load_all_custom_settings(self, settings): for plugin_id, plugin in self.plugins.items(): diff --git a/src/preset_row.py b/src/preset_row.py index 8abd4c03..4417fbee 100644 --- a/src/preset_row.py +++ b/src/preset_row.py @@ -1,7 +1,7 @@ from gi.repository import Gtk, Gdk, Adw from .constants import rootdir -from . import to_slug_case +from .modules.utils import to_slug_case import json import os @@ -36,7 +36,7 @@ class GradiencePresetRow(Adw.ActionRow): @Gtk.Template.Callback() def on_apply_button_clicked(self, *_args): - print("apply") + buglog("apply") self.app.load_preset_from_file(os.path.join( os.environ.get("XDG_CONFIG_HOME", diff --git a/src/run_async.py b/src/run_async.py index 65c59bad..c043896e 100644 --- a/src/run_async.py +++ b/src/run_async.py @@ -24,6 +24,8 @@ import traceback from gi.repository import GLib +from .modules.utils import buglog + class RunAsync(threading.Thread): def __init__(self, task_func, callback=None, *args, **kwargs): @@ -44,12 +46,12 @@ class RunAsync(threading.Thread): result = None error = None - print(f"Running async job [{self.task_func}].") + buglog(f"Running async job [{self.task_func}].") try: result = self.task_func(*args, **kwargs) except Exception as exception: - print("Error while running async job: " + buglog("Error while running async job: " f"{self.task_func}\nException: {exception}") error = exception @@ -57,6 +59,6 @@ class RunAsync(threading.Thread): traceback.print_tb(trace) traceback_info = '\n'.join(traceback.format_tb(trace)) - print([str(exception), traceback_info]) + buglog([str(exception), traceback_info]) self.source_id = GLib.idle_add(self.callback, result, error) return self.source_id diff --git a/src/welcome.py b/src/welcome.py index c0542cd3..b9312713 100644 --- a/src/welcome.py +++ b/src/welcome.py @@ -16,10 +16,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from gi.repository import Gtk, Adw, Gio, Gdk -from .constants import rootdir import time + +from gi.repository import Gtk, Adw, Gio, Gdk + from .run_async import RunAsync +from .modules.utils import buglog +from .constants import rootdir @Gtk.Template(resource_path=f"{rootdir}/ui/welcome.ui") @@ -115,15 +118,15 @@ class GradienceWelcomeWindow(Adw.Window): quit() def check_adw_gtk3(self): - print("check if adw-gtk3 installed") + buglog("check if adw-gtk3 installed") return True def adw_gtk3(self): if not self.check_adw_gtk3(): # install - print("install adw-gtk3") + buglog("install adw-gtk3") def configure_system(self): - print("confiure system") + buglog("configure system") def install_runner(self, widget): def set_completed(result, error=False): diff --git a/src/window.py b/src/window.py index ec08fb07..87eafa7d 100644 --- a/src/window.py +++ b/src/window.py @@ -1,45 +1,40 @@ # window.py # -# Copyright 2022 Gradience Team +# Change the look of Adwaita, with ease +# Copyright (C) 2022 Gradience Team # -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name(s) of the above copyright -# holders shall not be used in advertising or otherwise to promote the sale, -# use or other dealings in this Software without prior written -# authorization. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +import os from gi.repository import Gtk, Adw, Gio, Gdk + +from svglib.svglib import svg2rlg +from reportlab.graphics import renderPM +from material_color_utilities_python import * + from .error import GradienceError from .settings_schema import settings_schema from .palette_shades import GradiencePaletteShades from .option import GradienceOption from .app_type_dialog import GradienceAppTypeDialog from .custom_css_group import GradienceCustomCSSGroup -from material_color_utilities_python import * -from .constants import rootdir, app_id, build_type from .presets_manager_window import GradiencePresetWindow from .plugins_list import GradiencePluginsList -from svglib.svglib import svg2rlg -from reportlab.graphics import renderPM -import os +from .modules.utils import buglog +from .constants import rootdir, app_id, build_type @Gtk.Template(resource_path=f"{rootdir}/ui/window.ui") @@ -98,32 +93,38 @@ class GradienceMainWindow(Adw.ApplicationWindow): self.get_default_wallpaper() + # FIXME: This function works only when build using meson, because Flatpak can't access host's dconf with current config/impl def get_default_wallpaper(self): background_settings = Gio.Settings("org.gnome.desktop.background") if self.style_manager.get_dark(): - self.monet_image_file = background_settings.get_string( + picture_uri = background_settings.get_string( "picture-uri-dark") else: - self.monet_image_file = background_settings.get_string( - "picture-uri-dark") - self.monet_image_file = Gio.File.new_for_uri(self.monet_image_file) + picture_uri = background_settings.get_string( + "picture-uri") + buglog(picture_uri) + self.monet_image_file = Gio.File.new_for_uri(picture_uri) image_basename = self.monet_image_file.get_basename() + buglog(image_basename) self.monet_file_chooser_button.set_label(image_basename) self.monet_image_file = self.monet_image_file.get_path() - self.on_apply_button() + self.monet_file_chooser_button.set_tooltip_text(self.monet_image_file) + buglog(self.monet_image_file) + #self.on_apply_button() # Comment out for now, because it always shows that annoying toast on startup def on_file_picker_button_clicked(self, *args): self.monet_file_chooser_dialog.show() def __close_window(self, widegt): if self.get_application().is_dirty: - print("app is dirty") + buglog("app is dirty") def on_monet_file_chooser_response(self, widget, response): if response == Gtk.ResponseType.ACCEPT: self.monet_image_file = self.monet_file_chooser_dialog.get_file() image_basename = self.monet_image_file.get_basename() self.monet_file_chooser_button.set_label(image_basename) + self.monet_file_chooser_button.set_tooltip_text(self.monet_image_file) self.monet_file_chooser_dialog.hide() if response == Gtk.ResponseType.ACCEPT: @@ -217,7 +218,7 @@ class GradienceMainWindow(Adw.ApplicationWindow): renderPM.drawToFile(drawing, self.monet_image_file, fmt='PNG') if self.monet_image_file.endswith(".xml"): - print("XML WIP") + buglog("XML WIP") try: self.monet_img = Image.open(self.monet_image_file)