Skip to content

Commit

Permalink
Move logic to style manager
Browse files Browse the repository at this point in the history
  • Loading branch information
sstendahl committed Dec 12, 2023
1 parent 8cdd281 commit 30ddd35
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ def complete_style(self, params: RcParams) -> RcParams:
params[key] = value
return params

def delete_style(self, file: Gio.File):
style_model = self.props.style_model
for index, style in enumerate(style_model):
if style is not None:
file2 = style.get_file()
if file2 is not None and file.equal(file2):
stylename = style.get_name()
style_model.remove(index)
self._stylenames.remove(stylename)
self.props.use_custom_style = False
self.props.custom_style = self._system_style_name


@Gtk.Template(resource_path="/se/sjoerd/Graphs/ui/style_preview.ui")
class StylePreview(Gtk.AspectFrame):
Expand Down Expand Up @@ -615,19 +627,9 @@ def add_color(self, _button):
@Gtk.Template.Callback()
def on_delete(self, _button):
style_manager = self._style_manager
style_model = style_manager.props.style_model
file = self.style.get_file()
for index, style in enumerate(style_model):
if style is not None:
file2 = style.get_file()
if file2 is not None and file.equal(file2):
stylename = style.get_name()
style_model.remove(index)
style_manager._stylenames.remove(stylename)
style_manager.props.use_custom_style = False
style_manager.props.custom_style = \
style_manager._system_style_name
self.style.get_file().trash(None)
style_manager.delete_style(file)
file.trash(None)
self.style = None
self.parent.navigation_view.pop()

Expand Down

0 comments on commit 30ddd35

Please sign in to comment.