From fb58ddd04a46c3f98a743f99973c456bf46b1a81 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Mon, 9 Jan 2023 14:46:17 +0100 Subject: [PATCH] feat(linux): Add Back button to "Download Keyman Keyboards" dialog Fixes #4828 --- .../keyman_config/downloadkeyboard.py | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/linux/keyman-config/keyman_config/downloadkeyboard.py b/linux/keyman-config/keyman_config/downloadkeyboard.py index d79b1e3d44..50edc34de1 100755 --- a/linux/keyman-config/keyman_config/downloadkeyboard.py +++ b/linux/keyman-config/keyman_config/downloadkeyboard.py @@ -30,13 +30,26 @@ class DownloadKmpWindow(Gtk.Dialog): s = Gtk.ScrolledWindow() self.webview = WebKit2.WebView() self.webview.connect("decide-policy", self._keyman_policy) + self.webview.connect("load-changed", self._update_back_button) url = KeymanComUrl + "/go/linux/" + __releaseversion__ + "/download-keyboards" self.webview.load_uri(url) s.add(self.webview) self.get_content_area().pack_start(s, True, True, 0) - self.add_button(_("_Close"), Gtk.ResponseType.CLOSE) + hbox = Gtk.Box(spacing=6) + self.get_content_area().pack_start(hbox, False, False, 0) + + self.back_button = Gtk.Button.new_with_mnemonic(_("_Back")) + self.back_button.set_tooltip_text(_("Back to search")) + self.back_button.connect("clicked", self._on_back_clicked) + self.back_button.set_sensitive(False) + hbox.pack_start(self.back_button, False, False, 0) + + close_button = Gtk.Button.new_with_mnemonic(_("_Close")) + close_button.set_tooltip_text(_("Close dialog")) + close_button.connect("clicked", self._on_close_clicked) + hbox.pack_end(close_button, False, False, 0) if self.parentWindow is not None: self.getinfo = GetInfo(self.parentWindow.incomplete_kmp) @@ -44,6 +57,15 @@ class DownloadKmpWindow(Gtk.Dialog): self.resize(800, 450) self.show_all() + def _update_back_button(self, webview, load_event): + self.back_button.set_sensitive(webview.can_go_back()) + + def _on_back_clicked(self, button): + self.webview.go_back() + + def _on_close_clicked(self, button): + self.response(Gtk.ResponseType.CLOSE) + def _process_kmp(self, url, downloadfile: str): logging.info("Downloading kmp file to %s", downloadfile) if download_kmp_file(url, downloadfile):