Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

A bunch of improvements #250

Merged
merged 3 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
meson builddir --prefix="$(shell pwd)/builddir/testdir" --wipe
ninja -C builddir install
ninja -C builddir run
3 changes: 1 addition & 2 deletions local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
11 changes: 3 additions & 8 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# __init__.py
#
# Change the look of Adwaita, with ease
# Copyright (C) 2022 Gradience Team
#
Expand All @@ -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 <https://www.gnu.org/licenses/>.

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 <https://www.gnu.org/licenses/>.
4 changes: 2 additions & 2 deletions src/builtin_preset_row.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -29,7 +29,7 @@ def __init__(self, name, toast_overlay, author="", **kwargs):

@Gtk.Template.Callback()
def on_apply_button_clicked(self, *_args):
print("apply")
buglog("apply")

self.app.load_preset_from_resource(
f"{rootdir}/presets/"
Expand Down
3 changes: 2 additions & 1 deletion src/constants.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@'
translate_url = '@TRANSLATE_URL@'
20 changes: 11 additions & 9 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import sys
import json
import os
import re
import traceback

import gi
Expand All @@ -32,10 +31,10 @@
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):
Expand Down Expand Up @@ -73,7 +72,7 @@ def __init__(self):
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()

Expand Down Expand Up @@ -127,11 +126,11 @@ def do_activate(self):
)

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):
Expand All @@ -156,7 +155,7 @@ def open_dir_callback(_, result):
)

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()
Expand Down Expand Up @@ -631,19 +630,22 @@ def show_about_window(self, *_args):
# Translators: This is a place to put your credits (formats: "Name
# https://example.com" or "Name <email@example.com>", 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=_("""
<ul>
<li>Add AdwViewSwitcher in the header bar.</li>
Expand Down Expand Up @@ -708,7 +710,7 @@ def create_stateful_action(
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):
Expand Down
21 changes: 19 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Expand Down Expand Up @@ -71,4 +80,12 @@ gradience_sources = [
]

PY_INSTALLDIR.install_sources(gradience_sources, subdir: 'gradience')
#install_data(gradience_sources, install_dir: MODULE_DIR)
#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')
17 changes: 17 additions & 0 deletions src/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
35 changes: 35 additions & 0 deletions src/modules/utils.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

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}")
24 changes: 21 additions & 3 deletions src/plugin_row.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

from gi.repository import Gtk, Gdk, Adw

from .modules.utils import buglog
from .constants import rootdir


Expand All @@ -21,14 +39,14 @@ def __init__(self, title, id, **kwargs):

@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()
10 changes: 6 additions & 4 deletions src/plugins_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

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:
Expand All @@ -41,7 +43,7 @@ def __init__(self):
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():
Expand Down
4 changes: 2 additions & 2 deletions src/preset_row.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -36,7 +36,7 @@ def __init__(self, name, win, author="", **kwargs):

@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",
Expand Down
8 changes: 5 additions & 3 deletions src/run_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

from gi.repository import GLib

from .modules.utils import buglog


class RunAsync(threading.Thread):
def __init__(self, task_func, callback=None, *args, **kwargs):
Expand All @@ -44,19 +46,19 @@ def target(self, *args, **kwargs):
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
_ex_type, _ex_value, trace = sys.exc_info()
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
Loading