From df0a5ac0098e28c6a5d94fe838b394d26a7ae350 Mon Sep 17 00:00:00 2001 From: tfuxu <73042332+tfuxu@users.noreply.github.com> Date: Tue, 23 Aug 2022 19:57:53 +0200 Subject: [PATCH] fix: comment out self.on_apply_button() in get_default_wallpaper func to get rid of error toast on startup when build in Flatpak * set tooltip text in monet_file_chooser_button * update copyright in window.py and add one in plugin_row.py * update local.sh and fix 'user' rule in Makefile * replace all remaining print() to buglog(), and redirect to to_slug_case in utils.py --- Makefile | 7 +++---- local.sh | 3 +-- src/__init__.py | 11 +++-------- src/builtin_preset_row.py | 4 ++-- src/main.py | 2 +- src/plugin_row.py | 17 +++++++++++++++++ src/preset_row.py | 4 ++-- src/window.py | 39 ++++++++++++++++++++++++--------------- 8 files changed, 53 insertions(+), 34 deletions(-) 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/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/main.py b/src/main.py index eaf2585b..d5f022a6 100644 --- a/src/main.py +++ b/src/main.py @@ -155,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() diff --git a/src/plugin_row.py b/src/plugin_row.py index bde8b945..2aa4730a 100644 --- a/src/plugin_row.py +++ b/src/plugin_row.py @@ -1,3 +1,20 @@ +# 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 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/window.py b/src/window.py index aee8746e..87eafa7d 100644 --- a/src/window.py +++ b/src/window.py @@ -1,18 +1,21 @@ # 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. # +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + import os @@ -90,19 +93,24 @@ 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() @@ -116,6 +124,7 @@ class GradienceMainWindow(Adw.ApplicationWindow): 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: