mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-08-17 04:00:23 +03:00
Various bug fixes
This commit is contained in:
parent
1fc39baa70
commit
3b31208e1a
2
setup.py
2
setup.py
@ -18,7 +18,7 @@ setuptools.setup(
|
||||
]
|
||||
},
|
||||
install_requires=["PyGObject", "importlib_metadata", "platformdirs"],
|
||||
version='0.0.2',
|
||||
version='2.0.3',
|
||||
python_requires='>3.9',
|
||||
classifiers=[
|
||||
"Development Status :: 4 - Beta",
|
||||
|
@ -12,7 +12,7 @@ from waypaper.aboutdata import AboutData
|
||||
from waypaper.options import FILL_OPTIONS, BACKEND_OPTIONS
|
||||
from waypaper.translations import English, German, French, Russian, Polish, Chinese
|
||||
|
||||
aboutData = AboutData()
|
||||
about = AboutData()
|
||||
cf = Config()
|
||||
|
||||
if cf.lang == "de":
|
||||
@ -29,7 +29,7 @@ else:
|
||||
txt = English()
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(prog = aboutData.applicationName(), description = txt.msg_desc,
|
||||
parser = argparse.ArgumentParser(prog = about.applicationName(), description = txt.msg_desc,
|
||||
epilog = txt.msg_info)
|
||||
parser.add_argument("-v", "--version", help=txt.msg_arg_help, action="store_true")
|
||||
parser.add_argument("--restore", help=txt.msg_arg_rest, action="store_true")
|
||||
@ -60,7 +60,7 @@ def run():
|
||||
|
||||
# Print the version and quit:
|
||||
if args.version:
|
||||
print(f"{aboutData.applicationName()} v.{aboutData.applicationVersion()}")
|
||||
print(f"{about.applicationName()} v.{about.applicationVersion()}")
|
||||
exit(0)
|
||||
|
||||
# Start GUI:
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Module to store acces application metadata"""
|
||||
|
||||
from importlib_metadata import metadata
|
||||
|
||||
|
||||
class AboutData():
|
||||
"""This class stores application about data in a central place"""
|
||||
def __init__(self):
|
||||
@ -12,7 +14,7 @@ class AboutData():
|
||||
def applicationLogo(self):
|
||||
return str(self.__app_metadata['Name'])+".svg"
|
||||
def applicationVersion(self):
|
||||
return self.__app_metadata['Version'] # pylint: disable=no-member
|
||||
return self.__app_metadata['Version']
|
||||
def homePage(self):
|
||||
return self.__app_metadata['Home-page']
|
||||
def Author(self):
|
||||
|
@ -79,7 +79,7 @@ class App(Gtk.Window):
|
||||
self.include_subfolders_checkbox = Gtk.ToggleButton(label=self.txt.msg_subfolders)
|
||||
self.include_subfolders_checkbox.set_active(self.cf.include_subfolders)
|
||||
self.include_subfolders_checkbox.connect("toggled", self.on_include_subfolders_toggled)
|
||||
self.include_subfolders_checkbox.set_tooltip_text(TIP_SUBFOLDER)
|
||||
self.include_subfolders_checkbox.set_tooltip_text(self.txt.tip_subfolder)
|
||||
|
||||
# Create a backend dropdown menu:
|
||||
self.backend_option_combo = Gtk.ComboBoxText()
|
||||
@ -95,7 +95,7 @@ class App(Gtk.Window):
|
||||
active_num = 0
|
||||
self.backend_option_combo.set_active(active_num)
|
||||
self.backend_option_combo.connect("changed", self.on_backend_option_changed)
|
||||
self.backend_option_combo.set_tooltip_text(TIP_BACKEND)
|
||||
self.backend_option_combo.set_tooltip_text(self.txt.tip_backend)
|
||||
|
||||
# Create a fill option dropdown menu:
|
||||
self.fill_option_combo = Gtk.ComboBoxText()
|
||||
@ -104,7 +104,7 @@ class App(Gtk.Window):
|
||||
self.fill_option_combo.append_text(capitalized_option)
|
||||
self.fill_option_combo.set_active(0)
|
||||
self.fill_option_combo.connect("changed", self.on_fill_option_changed)
|
||||
self.fill_option_combo.set_tooltip_text(TIP_FILL)
|
||||
self.fill_option_combo.set_tooltip_text(self.txt.tip_fill)
|
||||
|
||||
# Create a color picker:
|
||||
self.color_picker_button = Gtk.ColorButton()
|
||||
@ -113,7 +113,7 @@ class App(Gtk.Window):
|
||||
rgba_color.parse(self.cf.color)
|
||||
self.color_picker_button.set_rgba(rgba_color)
|
||||
self.color_picker_button.connect("color-set", self.on_color_set)
|
||||
self.color_picker_button.set_tooltip_text(TIP_COLOR)
|
||||
self.color_picker_button.set_tooltip_text(self.txt.tip_color)
|
||||
|
||||
# Create a sort option dropdown menu:
|
||||
self.sort_option_combo = Gtk.ComboBoxText()
|
||||
@ -122,23 +122,23 @@ class App(Gtk.Window):
|
||||
active_num = SORT_OPTIONS.index(self.cf.sort_option)
|
||||
self.sort_option_combo.set_active(active_num)
|
||||
self.sort_option_combo.connect("changed", self.on_sort_option_changed)
|
||||
self.sort_option_combo.set_tooltip_text(TIP_SORTING)
|
||||
self.sort_option_combo.set_tooltip_text(self.txt.tip_sorting)
|
||||
|
||||
|
||||
# Create exit button:
|
||||
self.exit_button = Gtk.Button(label=self.txt.msg_exit)
|
||||
self.exit_button.connect("clicked", self.on_exit_clicked)
|
||||
self.exit_button.set_tooltip_text(TIP_EXIT)
|
||||
self.exit_button.set_tooltip_text(self.txt.tip_exit)
|
||||
|
||||
# Create refresh button:
|
||||
self.refresh_button = Gtk.Button(label=self.txt.msg_refresh)
|
||||
self.refresh_button.connect("clicked", self.on_refresh_clicked)
|
||||
self.refresh_button.set_tooltip_text(TIP_REFRESH)
|
||||
self.refresh_button.set_tooltip_text(self.txt.tip_refresh)
|
||||
|
||||
# Create random button:
|
||||
self.random_button = Gtk.Button(label=self.txt.msg_random)
|
||||
self.random_button.connect("clicked", self.on_random_clicked)
|
||||
self.random_button.set_tooltip_text(TIP_RANDOM)
|
||||
self.random_button.set_tooltip_text(self.txt.tip_random)
|
||||
|
||||
# Create a box to contain the bottom row of buttons with margin:
|
||||
self.bottom_button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=20)
|
||||
@ -199,7 +199,7 @@ class App(Gtk.Window):
|
||||
self.monitor_option_combo.append_text(monitor)
|
||||
self.monitor_option_combo.set_active(0)
|
||||
self.monitor_option_combo.connect("changed", self.on_monitor_option_changed)
|
||||
self.monitor_option_combo.set_tooltip_text(TIP_DISPLAY)
|
||||
self.monitor_option_combo.set_tooltip_text(self.txt.tip_display)
|
||||
|
||||
# Add it to the row of buttons:
|
||||
self.options_box.pack_start(self.monitor_option_combo, False, False, 0)
|
||||
@ -346,22 +346,23 @@ class App(Gtk.Window):
|
||||
def on_choose_folder_clicked(self, widget):
|
||||
"""Choosing the folder of images, saving the path, and reloading images"""
|
||||
self.choose_folder()
|
||||
self.cf.save()
|
||||
|
||||
|
||||
def on_include_subfolders_toggled(self, toggle):
|
||||
"""On chosing to include subfolders"""
|
||||
cf.include_subfolders = toggle.get_active()
|
||||
self.cf.include_subfolders = toggle.get_active()
|
||||
threading.Thread(target=self.process_images).start()
|
||||
|
||||
|
||||
def on_fill_option_changed(self, combo):
|
||||
"""Save fill parameter when it was changed"""
|
||||
cf.fill_option = combo.get_active_text()
|
||||
self.cf.fill_option = combo.get_active_text()
|
||||
|
||||
|
||||
def on_monitor_option_changed(self, combo):
|
||||
"""Save monitor parameter when it was changed"""
|
||||
cf.selected_monitor = combo.get_active_text()
|
||||
self.cf.selected_monitor = combo.get_active_text()
|
||||
|
||||
|
||||
def on_sort_option_changed(self, combo):
|
||||
|
@ -13,7 +13,7 @@ class Config:
|
||||
"""User configuration loaded from the config.ini file"""
|
||||
def __init__(self):
|
||||
self.image_folder = user_pictures_path()
|
||||
self.selected_wallpaper = None
|
||||
self.selected_wallpaper = ""
|
||||
self.selected_monitor = "All"
|
||||
self.fill_option = "fill"
|
||||
self.sort_option = "name"
|
||||
@ -21,39 +21,19 @@ class Config:
|
||||
self.color = "#ffffff"
|
||||
self.lang = "en"
|
||||
self.monitors = [self.selected_monitor]
|
||||
self.wallpaper = str()
|
||||
self.wallpaper = []
|
||||
self.include_subfolders = False
|
||||
self.aboutData = AboutData()
|
||||
self.cachePath = user_cache_path(self.aboutData.applicationName())
|
||||
self.configPath = user_config_path(self.aboutData.applicationName())
|
||||
self.config_file = self.configPath / "config.ini"
|
||||
|
||||
# Create all directories we use here
|
||||
# Create config folder:
|
||||
# Create config and cache folders:
|
||||
self.configPath.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Create cache folder:
|
||||
self.cachePath.mkdir(parents=True,exist_ok=True)
|
||||
|
||||
self.read()
|
||||
|
||||
def create(self):
|
||||
"""Create a default config.ini file if it does not exist"""
|
||||
config = configparser.ConfigParser()
|
||||
config["Settings"] = {
|
||||
"folder": str(self.image_folder),
|
||||
"fill": str(self.fill_option),
|
||||
"sort": str(self.sort_option),
|
||||
"backend": str(self.backend),
|
||||
"color": str(self.color),
|
||||
"language": str(self.lang),
|
||||
"subfolders": str(self.include_subfolders),
|
||||
"wallpaper": str(self.selected_wallpaper),
|
||||
"monitors": str(self.selected_monitor),
|
||||
}
|
||||
with open(self.config_file, "w") as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
|
||||
def read(self):
|
||||
"""Load data from the config.ini or use default if it does not exists"""
|
||||
@ -75,10 +55,11 @@ class Config:
|
||||
if self.monitors_str is not None:
|
||||
self.monitors = [str(monitor) for monitor in self.monitors_str.split(",")]
|
||||
|
||||
self.wallpaper_str = config.get("Settings", "wallpaper", fallback=self.wallpaper, raw=True)
|
||||
self.wallpaper_str = config.get("Settings", "wallpaper", fallback="", raw=True)
|
||||
if self.wallpaper_str is not None:
|
||||
self.wallpaper = [str(paper) for paper in self.wallpaper_str.split(",")]
|
||||
|
||||
|
||||
def save(self):
|
||||
"""Update the parameters and save them to the configuration file"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user