mirror of
https://github.com/aclist/dztui.git
synced 2026-08-27 10:17:31 +02:00
chore: resolve merge conflict
This commit is contained in:
commit
38cc55530f
@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from importlib import resources
|
||||
@ -31,20 +32,40 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
||||
logger.critical(e)
|
||||
changelog = missing_changelog
|
||||
|
||||
# TODO: should long text be wrapped?
|
||||
# FIXME: wrap long text
|
||||
self.controller = controller
|
||||
self.box = Gtk.Box(
|
||||
orientation=Gtk.Orientation.VERTICAL, spacing=5, margin_top=10
|
||||
)
|
||||
self.add(self.box)
|
||||
|
||||
expand_all = Gtk.Button(
|
||||
label="Expand all", halign=Gtk.Align.START, margin_start=20
|
||||
)
|
||||
expand_all.connect("clicked", self._on_expand_all_clicked)
|
||||
self.box.add(expand_all)
|
||||
|
||||
self.expanded = False
|
||||
self.expanders: list[Gtk.Expander] = []
|
||||
self.connect("key-press-event", self._on_keypress)
|
||||
self.connect("key-press-event", self._on_esc_keypress)
|
||||
|
||||
changes = self._parse(changelog)
|
||||
self._generate_nodes(changes)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def _on_expand_all_clicked(self, button: Gtk.Button) -> None:
|
||||
self.expanded = not self.expanded
|
||||
for expander in self.expanders:
|
||||
# NOTE: simply setting set_expanded() does not trigger activate() signal,
|
||||
# so margins are not applied
|
||||
if expander.get_expanded() == self.expanded:
|
||||
continue
|
||||
expander.activate()
|
||||
label = "Collapse all" if self.expanded else "Expand all"
|
||||
button.set_label(label)
|
||||
|
||||
def grab_content_area(self) -> None:
|
||||
self.grab_focus()
|
||||
|
||||
@ -65,9 +86,7 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
||||
text = "\n".join(changes)
|
||||
formatted = format_pango(text)
|
||||
|
||||
container = Gtk.Box(
|
||||
valign=Gtk.Align.START, halign=Gtk.Align.START
|
||||
)
|
||||
container = Gtk.Box(valign=Gtk.Align.START, halign=Gtk.Align.START)
|
||||
label = Gtk.Label()
|
||||
label.set_markup(formatted)
|
||||
container.add(label)
|
||||
@ -81,6 +100,7 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
||||
expander.add(container)
|
||||
expander.connect("activate", self._on_expand, container)
|
||||
self.box.add(expander)
|
||||
self.expanders.append(expander)
|
||||
|
||||
def _on_expand(self, expander: Gtk.Box, container: Gtk.Box) -> None:
|
||||
"""
|
||||
@ -94,6 +114,7 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
||||
container.set_margin_bottom(15)
|
||||
|
||||
def _parse(self, changelog: str) -> list[tuple[str, list[str]]]:
|
||||
|
||||
release = ""
|
||||
releases: list[tuple[str, list[str]]] = []
|
||||
release_notes: list[str] = []
|
||||
@ -107,5 +128,5 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
||||
release = ""
|
||||
release = line
|
||||
continue
|
||||
release_notes.append(line.rstrip())
|
||||
release_notes.append(textwrap.fill(line.rstrip(), width=120))
|
||||
return releases
|
||||
|
||||
Loading…
Reference in New Issue
Block a user