Format code with black and autopep8

This commit is contained in:
deepsource-autofix[bot] 2022-09-07 15:55:05 +00:00 committed by GitHub
parent 61961112fb
commit db94c6b914
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 62 deletions

View file

@ -329,8 +329,9 @@ class GradienceApplication(Adw.Application):
) )
self.props.active_window.save_preset_button.add_css_class("warning") self.props.active_window.save_preset_button.add_css_class("warning")
self.props.active_window.save_preset_button.get_child( self.props.active_window.save_preset_button.get_child().set_tooltip_text(
).set_tooltip_text(_("Unsaved changes")) _("Unsaved changes")
)
def clear_dirty(self): def clear_dirty(self):
self.is_dirty = False self.is_dirty = False
@ -339,8 +340,9 @@ class GradienceApplication(Adw.Application):
) )
self.props.active_window.save_preset_button.remove_css_class("warning") self.props.active_window.save_preset_button.remove_css_class("warning")
self.props.active_window.save_preset_button.get_child().set_label("") self.props.active_window.save_preset_button.get_child().set_label("")
self.props.active_window.save_preset_button.get_child( self.props.active_window.save_preset_button.get_child().set_tooltip_text(
).set_tooltip_text(_("Save changes")) _("Save changes")
)
def reload_variables(self): def reload_variables(self):
parsing_errors = [] parsing_errors = []
@ -398,7 +400,9 @@ class GradienceApplication(Adw.Application):
def show_apply_color_scheme_dialog(self, *_args): def show_apply_color_scheme_dialog(self, *_args):
dialog = GradienceAppTypeDialog( dialog = GradienceAppTypeDialog(
_("Apply this color scheme?"), _("Apply this color scheme?"),
_("Warning: any custom CSS files for those app types will be irreversibly overwritten!"), _(
"Warning: any custom CSS files for those app types will be irreversibly overwritten!"
),
"apply", "apply",
_("Apply"), _("Apply"),
Adw.ResponseAppearance.SUGGESTED, Adw.ResponseAppearance.SUGGESTED,

View file

@ -58,12 +58,7 @@ def get_user_flatpak_path():
return GLib.build_filenamev([userDataDir, "flatpak"]) return GLib.build_filenamev([userDataDir, "flatpak"])
def user_save_keyfile( def user_save_keyfile(toast_overlay, settings, user_keyfile, filename, gtk_ver):
toast_overlay,
settings,
user_keyfile,
filename,
gtk_ver):
try: try:
user_keyfile.save_to_file(filename) user_keyfile.save_to_file(filename)
except Glib.GError as e: except Glib.GError as e:
@ -82,12 +77,7 @@ def user_save_keyfile(
) )
def global_save_keyfile( def global_save_keyfile(toast_overlay, settings, global_keyfile, filename, gtk_ver):
toast_overlay,
settings,
global_keyfile,
filename,
gtk_ver):
try: try:
global_keyfile.save_to_file(filename) global_keyfile.save_to_file(filename)
except Glib.GError as e: except Glib.GError as e:

View file

@ -34,13 +34,7 @@ class GradienceOption(Adw.ActionRow):
explanation_button = Gtk.Template.Child("explanation-button") explanation_button = Gtk.Template.Child("explanation-button")
explanation_label = Gtk.Template.Child("explanation-label") explanation_label = Gtk.Template.Child("explanation-label")
def __init__( def __init__(self, name, title, explanation, adw_gtk3_support="yes", **kwargs):
self,
name,
title,
explanation,
adw_gtk3_support="yes",
**kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
self.set_name(name) self.set_name(name)
@ -52,7 +46,8 @@ class GradienceOption(Adw.ActionRow):
elif adw_gtk3_support == "partial": elif adw_gtk3_support == "partial":
self.warning_button.add_css_class("warning") self.warning_button.add_css_class("warning")
self.warning_label.set_label( self.warning_label.set_label(
_("This option is only partially supported by the adw-gtk3 theme.")) _("This option is only partially supported by the adw-gtk3 theme.")
)
elif adw_gtk3_support == "no": elif adw_gtk3_support == "no":
self.warning_button.add_css_class("error") self.warning_button.add_css_class("error")
self.warning_label.set_label( self.warning_label.set_label(

View file

@ -59,8 +59,9 @@ class GradiencePaletteShades(Adw.ActionRow):
Gtk.Application.get_default().is_ready Gtk.Application.get_default().is_ready
and kwargs.get("update_from") == "color_value" and kwargs.get("update_from") == "color_value"
): ):
Gtk.Application.get_default( Gtk.Application.get_default().palette[self.prefix][str(i)] = shades[
).palette[self.prefix][str(i)] = shades[str(i)] str(i)
]
if ( if (
Gtk.Application.get_default().is_ready Gtk.Application.get_default().is_ready

View file

@ -64,7 +64,10 @@ class GradiencePluginsList:
group = Adw.PreferencesGroup() group = Adw.PreferencesGroup()
group.set_title(_("Plugins")) group.set_title(_("Plugins"))
group.set_description( group.set_description(
_("Plugins add additional features to Gradience, plugins are made by Gradience community and can make issues.")) _(
"Plugins add additional features to Gradience, plugins are made by Gradience community and can make issues."
)
)
if self.pm: if self.pm:
for pluginInfo in self.pm.getAllPlugins(): for pluginInfo in self.pm.getAllPlugins():
row = GradiencePluginRow(pluginInfo.plugin_object) row = GradiencePluginRow(pluginInfo.plugin_object)

View file

@ -56,7 +56,8 @@ class GradiencePresetWindow(Adw.Window):
custom_presets = {} custom_presets = {}
official_repositories = { official_repositories = {
"Official": "https://github.com/GradienceTeam/Community/raw/main/presets.json"} "Official": "https://github.com/GradienceTeam/Community/raw/main/presets.json"
}
search_results_list = [] search_results_list = []
@ -252,8 +253,9 @@ class GradiencePresetWindow(Adw.Window):
self.toast_overlay.add_toast( self.toast_overlay.add_toast(
Adw.Toast(title=_("Preset imported"))) Adw.Toast(title=_("Preset imported")))
else: else:
self.toast_overlay.add_toast(Adw.Toast( self.toast_overlay.add_toast(
title=_("Unsupported file format, must be .json"))) Adw.Toast(title=_("Unsupported file format, must be .json"))
)
self.reload_pref_group() self.reload_pref_group()
@ -289,8 +291,9 @@ class GradiencePresetWindow(Adw.Window):
raise KeyError("variables") raise KeyError("variables")
if preset.get("palette") is None: if preset.get("palette") is None:
raise KeyError("palette") raise KeyError("palette")
presets_list[file_name.replace( presets_list[file_name.replace(".json", "")] = preset[
".json", "")] = preset["name"] "name"
]
except Exception: except Exception:
self.toast_overlay.add_toast( self.toast_overlay.add_toast(
Adw.Toast(title=_("Failed to load preset")) Adw.Toast(title=_("Failed to load preset"))
@ -315,8 +318,9 @@ class GradiencePresetWindow(Adw.Window):
raise KeyError("variables") raise KeyError("variables")
if preset.get("palette") is None: if preset.get("palette") is None:
raise KeyError("palette") raise KeyError("palette")
presets_list["user"][file_name.replace( presets_list["user"][file_name.replace(".json", "")] = preset[
".json", "")] = preset["name"] "name"
]
except Exception: except Exception:
self.toast_overlay.add_toast( self.toast_overlay.add_toast(
Adw.Toast(title=_("Failed to load preset")) Adw.Toast(title=_("Failed to load preset"))
@ -335,7 +339,10 @@ class GradiencePresetWindow(Adw.Window):
self.preset_list = Adw.PreferencesGroup() self.preset_list = Adw.PreferencesGroup()
self.preset_list.set_title(_("User Presets")) self.preset_list.set_title(_("User Presets"))
self.preset_list.set_description( self.preset_list.set_description(
_('See <a href="https://github.com/GradienceTeam/Community">GradienceTeam/Community</a> on Github for more presets')) _(
'See <a href="https://github.com/GradienceTeam/Community">GradienceTeam/Community</a> on Github for more presets'
)
)
if self.custom_presets: if self.custom_presets:
for repo, presets in self.custom_presets.items(): for repo, presets in self.custom_presets.items():
@ -346,6 +353,9 @@ class GradiencePresetWindow(Adw.Window):
else: else:
self.preset_empty = Adw.ActionRow() self.preset_empty = Adw.ActionRow()
self.preset_empty.set_title( self.preset_empty.set_title(
_("No preset found! Use the import button to import one or search one on the Explore tab")) _(
"No preset found! Use the import button to import one or search one on the Explore tab"
)
)
self.preset_list.add(self.preset_empty) self.preset_list.add(self.preset_empty)
self.installed.add(self.preset_list) self.installed.add(self.preset_list)

View file

@ -18,13 +18,7 @@
class GradienceSetting: class GradienceSetting:
def __init__( def __init__(self, name, title, value_type, explanation=None, default_value=None):
self,
name,
title,
value_type,
explanation=None,
default_value=None):
# TODO supported types: # TODO supported types:
# text # text
# integer # integer

View file

@ -64,27 +64,19 @@ class GradienceMainWindow(Adw.ApplicationWindow):
self.settings = Gio.Settings(app_id) self.settings = Gio.Settings(app_id)
self.settings.bind( self.settings.bind(
"window-width", "window-width", self, "default-width", Gio.SettingsBindFlags.DEFAULT
self, )
"default-width",
Gio.SettingsBindFlags.DEFAULT)
self.settings.bind( self.settings.bind(
"window-height", "window-height", self, "default-height", Gio.SettingsBindFlags.DEFAULT
self, )
"default-height",
Gio.SettingsBindFlags.DEFAULT)
self.settings.bind( self.settings.bind(
"window-maximized", "window-maximized", self, "maximized", Gio.SettingsBindFlags.DEFAULT
self, )
"maximized",
Gio.SettingsBindFlags.DEFAULT)
self.settings.bind( self.settings.bind(
"window-fullscreen", "window-fullscreen", self, "fullscreened", Gio.SettingsBindFlags.DEFAULT
self, )
"fullscreened",
Gio.SettingsBindFlags.DEFAULT)
self.connect("close-request", self.__close_window) self.connect("close-request", self.__close_window)
self.style_manager = self.get_application().style_manager self.style_manager = self.get_application().style_manager
@ -139,7 +131,10 @@ class GradienceMainWindow(Adw.ApplicationWindow):
self.monet_pref_group.set_name("monet") self.monet_pref_group.set_name("monet")
self.monet_pref_group.set_title(_("Monet Engine")) self.monet_pref_group.set_title(_("Monet Engine"))
self.monet_pref_group.set_description( self.monet_pref_group.set_description(
_("Monet is an engine that generates a Material Design 3 palette from an image's color.")) _(
"Monet is an engine that generates a Material Design 3 palette from an image's color."
)
)
self.apply_button = Gtk.Button() self.apply_button = Gtk.Button()
self.apply_button.set_label(_("Apply")) self.apply_button.set_label(_("Apply"))
@ -274,7 +269,10 @@ class GradienceMainWindow(Adw.ApplicationWindow):
palette_pref_group.set_name("palette_colors") palette_pref_group.set_name("palette_colors")
palette_pref_group.set_title(_("Palette Colors")) palette_pref_group.set_title(_("Palette Colors"))
palette_pref_group.set_description( palette_pref_group.set_description(
_('Named palette colors used by some applications. Default colors follow the <a href="https://developer.gnome.org/hig/reference/palette.html">GNOME Human Interface Guidelines</a>.')) _(
'Named palette colors used by some applications. Default colors follow the <a href="https://developer.gnome.org/hig/reference/palette.html">GNOME Human Interface Guidelines</a>.'
)
)
for color in settings_schema["palette"]: for color in settings_schema["palette"]:
palette_shades = GradiencePaletteShades( palette_shades = GradiencePaletteShades(
color["prefix"], color["title"], color["n_shades"] color["prefix"], color["title"], color["n_shades"]