Commit 7a754a31 authored by Roman Alifanov's avatar Roman Alifanov

Fix dialogs: set parent window, show error log in scrollable view

parent be23b5bf
......@@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log"
"strings"
gtksbuilder "SystemUpdater/lib/gtks/builder"
"SystemUpdater/model"
......@@ -170,7 +171,7 @@ func (w *Window) showUpdateDialog() {
state := w.st.GetState()
dialog := adw.NewMessageDialog(
nil,
&w.Window.Window,
"Select Components to Update",
"Choose which components you want to update:",
)
......@@ -275,7 +276,7 @@ func (w *Window) runUpdate(categories []string) {
func (w *Window) onRebootClicked() {
dialog := adw.NewMessageDialog(
nil,
&w.Window.Window,
"Reboot System?",
"The system needs to be rebooted to complete the update.",
)
......@@ -318,7 +319,27 @@ func (w *Window) onNavigateToCategory(category string) {
}
func (w *Window) showError(title, message string) {
dialog := adw.NewMessageDialog(nil, title, message)
lines := strings.Split(message, "\n")
if len(lines) > 20 {
lines = lines[len(lines)-20:]
}
truncated := strings.Join(lines, "\n")
dialog := adw.NewMessageDialog(&w.Window.Window, title, "")
textView := gtk.NewTextView()
textView.SetEditable(false)
textView.SetCursorVisible(false)
textView.SetWrapMode(gtk.WrapWordChar)
textView.Buffer().SetText(truncated)
scrolled := gtk.NewScrolledWindow()
scrolled.SetHScrollbarPolicy(gtk.PolicyNever)
scrolled.SetVScrollbarPolicy(gtk.PolicyAutomatic)
scrolled.SetMinContentHeight(200)
scrolled.SetChild(textView)
dialog.SetExtraChild(scrolled)
dialog.AddResponse("ok", "OK")
dialog.SetDefaultResponse("ok")
dialog.Present()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment