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
This commit is contained in:
tfuxu 2022-08-23 19:57:53 +02:00
parent e9ad48f100
commit df0a5ac009
8 changed files with 53 additions and 34 deletions

View file

@ -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

View file

@ -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"

View file

@ -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 <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/>.

View file

@ -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/"

View file

@ -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()

View file

@ -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 <https://www.gnu.org/licenses/>.
from gi.repository import Gtk, Gdk, Adw

View file

@ -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",

View file

@ -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 <https://www.gnu.org/licenses/>.
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: