mirror of
https://github.com/aclist/dztui.git
synced 2026-10-31 07:02:50 +01:00
chore: resolve merge conflict
This commit is contained in:
commit
38cc55530f
1 file changed
+26
-5
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import textwrap
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from importlib import resources
|
from importlib import resources
|
||||||
@@ -31,20 +32,40 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
|||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
changelog = missing_changelog
|
changelog = missing_changelog
|
||||||
|
|
||||||
# TODO: should long text be wrapped?
|
# FIXME: wrap long text
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.box = Gtk.Box(
|
self.box = Gtk.Box(
|
||||||
orientation=Gtk.Orientation.VERTICAL, spacing=5, margin_top=10
|
orientation=Gtk.Orientation.VERTICAL, spacing=5, margin_top=10
|
||||||
)
|
)
|
||||||
self.add(self.box)
|
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_keypress)
|
||||||
self.connect("key-press-event", self._on_esc_keypress)
|
self.connect("key-press-event", self._on_esc_keypress)
|
||||||
|
|
||||||
changes = self._parse(changelog)
|
changes = self._parse(changelog)
|
||||||
self._generate_nodes(changes)
|
self._generate_nodes(changes)
|
||||||
|
|
||||||
self.show_all()
|
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:
|
def grab_content_area(self) -> None:
|
||||||
self.grab_focus()
|
self.grab_focus()
|
||||||
|
|
||||||
@@ -65,9 +86,7 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
|||||||
text = "\n".join(changes)
|
text = "\n".join(changes)
|
||||||
formatted = format_pango(text)
|
formatted = format_pango(text)
|
||||||
|
|
||||||
container = Gtk.Box(
|
container = Gtk.Box(valign=Gtk.Align.START, halign=Gtk.Align.START)
|
||||||
valign=Gtk.Align.START, halign=Gtk.Align.START
|
|
||||||
)
|
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
label.set_markup(formatted)
|
label.set_markup(formatted)
|
||||||
container.add(label)
|
container.add(label)
|
||||||
@@ -81,6 +100,7 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
|||||||
expander.add(container)
|
expander.add(container)
|
||||||
expander.connect("activate", self._on_expand, container)
|
expander.connect("activate", self._on_expand, container)
|
||||||
self.box.add(expander)
|
self.box.add(expander)
|
||||||
|
self.expanders.append(expander)
|
||||||
|
|
||||||
def _on_expand(self, expander: Gtk.Box, container: Gtk.Box) -> None:
|
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)
|
container.set_margin_bottom(15)
|
||||||
|
|
||||||
def _parse(self, changelog: str) -> list[tuple[str, list[str]]]:
|
def _parse(self, changelog: str) -> list[tuple[str, list[str]]]:
|
||||||
|
|
||||||
release = ""
|
release = ""
|
||||||
releases: list[tuple[str, list[str]]] = []
|
releases: list[tuple[str, list[str]]] = []
|
||||||
release_notes: list[str] = []
|
release_notes: list[str] = []
|
||||||
@@ -107,5 +128,5 @@ class Changelog(HelpMenuMixin, ScrollableMixin, Gtk.ScrolledWindow): # type: ig
|
|||||||
release = ""
|
release = ""
|
||||||
release = line
|
release = line
|
||||||
continue
|
continue
|
||||||
release_notes.append(line.rstrip())
|
release_notes.append(textwrap.fill(line.rstrip(), width=120))
|
||||||
return releases
|
return releases
|
||||||
Reference in new issue
Block a user