mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-02 21:57:41 +00:00
Merge pull request #3214 from keymanapp/feat/issue-2087
fix(linux): Restart km-config after installing keyboard
This commit is contained in:
commit
dce7c84208
4 changed files with 54 additions and 51 deletions
|
|
@ -256,7 +256,8 @@ class InstallKmpWindow(Gtk.Dialog):
|
|||
|
||||
def run(self):
|
||||
if self.checkcontinue:
|
||||
Gtk.Dialog.run(self)
|
||||
return Gtk.Dialog.run(self)
|
||||
return Gtk.ResponseType.CANCEL
|
||||
|
||||
def doc_policy(self, web_view, decision, decision_type):
|
||||
logging.info("Checking policy")
|
||||
|
|
@ -284,9 +285,9 @@ class InstallKmpWindow(Gtk.Dialog):
|
|||
if os.path.isfile(welcome_file):
|
||||
uri_path = pathlib.Path(welcome_file).as_uri()
|
||||
logging.debug(uri_path)
|
||||
w = WelcomeView(uri_path, self.kbname)
|
||||
w.resize(800, 600)
|
||||
w.show_all()
|
||||
w = WelcomeView(self, uri_path, self.kbname)
|
||||
w.run()
|
||||
w.destroy()
|
||||
else:
|
||||
dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.INFO,
|
||||
Gtk.ButtonsType.OK, "Keyboard " + self.kbname + " installed")
|
||||
|
|
|
|||
|
|
@ -24,21 +24,20 @@ from keyman_config.kmpmetadata import parsemetadata
|
|||
# there is data in kmp.inf/kmp.json
|
||||
# there is possibly data in kbid.json (downloaded from api)
|
||||
|
||||
class KeyboardDetailsView(Gtk.Window):
|
||||
class KeyboardDetailsView(Gtk.Dialog):
|
||||
# TODO Display all the information that is available
|
||||
# especially what is displayed for Keyman on Windows
|
||||
# TODO clean up file once have what we want
|
||||
def __init__(self, kmp):
|
||||
def __init__(self, parent, kmp):
|
||||
#kmp has name, version, packageID, area
|
||||
if "keyboard" in kmp["name"].lower():
|
||||
wintitle = kmp["name"]
|
||||
else:
|
||||
wintitle = kmp["name"] + " keyboard"
|
||||
Gtk.Window.__init__(self, title=wintitle)
|
||||
Gtk.Dialog.__init__(self, wintitle, parent)
|
||||
init_accel(self)
|
||||
|
||||
hbox_outer = Gtk.Box(spacing = 12)
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
||||
self.set_border_width(6)
|
||||
|
||||
packageDir = os.path.join(kmp['areapath'], kmp['packageID'])
|
||||
kmp_json = os.path.join(packageDir, "kmp.json")
|
||||
|
|
@ -289,10 +288,6 @@ class KeyboardDetailsView(Gtk.Window):
|
|||
# label.set_halign(Gtk.Align.START)
|
||||
# label.set_selectable(True)
|
||||
# grid.attach_next_to(label, label9, Gtk.PositionType.RIGHT, 1, 1)
|
||||
vbox.pack_start(box, True, True, 12)
|
||||
|
||||
hbox = Gtk.Box(spacing = 6)
|
||||
vbox.pack_start(hbox, False, False, 12)
|
||||
|
||||
# Add an entire row of padding
|
||||
lbl_pad = Gtk.Label()
|
||||
|
|
@ -329,17 +324,8 @@ class KeyboardDetailsView(Gtk.Window):
|
|||
grid.attach_next_to(lbl_share_kbd, image, Gtk.PositionType.BOTTOM, 2, 1)
|
||||
prevlabel = lbl_share_kbd
|
||||
|
||||
button = Gtk.Button.new_with_mnemonic("_Close")
|
||||
button.set_tooltip_text("Close window")
|
||||
button.connect("clicked", self.on_close_clicked)
|
||||
self.add_button("_Close", Gtk.ResponseType.CLOSE)
|
||||
|
||||
hbox.pack_end(button, False, False, 0)
|
||||
bind_accelerator(self.accelerators, button, '<Control>w')
|
||||
|
||||
hbox_outer.pack_start(vbox, True, True, 12)
|
||||
self.add(hbox_outer)
|
||||
self.resize(635, 270)
|
||||
|
||||
def on_close_clicked(self, button):
|
||||
logging.debug("Closing keyboard details window")
|
||||
self.close()
|
||||
self.get_content_area().pack_start(box, True, True, 12)
|
||||
self.resize(800, 450)
|
||||
self.show_all()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
import logging
|
||||
import os.path
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
|
|
@ -40,13 +42,13 @@ class ViewInstalledWindowBase(Gtk.Window):
|
|||
logging.debug("Download clicked")
|
||||
downloadDlg = DownloadKmpWindow(self)
|
||||
response = downloadDlg.run()
|
||||
file = None
|
||||
if response == Gtk.ResponseType.OK:
|
||||
file = downloadDlg.downloadfile
|
||||
downloadDlg.destroy()
|
||||
if response != Gtk.ResponseType.OK:
|
||||
downloadDlg.destroy()
|
||||
return
|
||||
|
||||
if file != None:
|
||||
self.install_file(file)
|
||||
file = downloadDlg.downloadfile
|
||||
downloadDlg.destroy()
|
||||
self.restart(self.install_file(file))
|
||||
|
||||
def on_installfile_clicked(self, button):
|
||||
logging.debug("Install from file clicked")
|
||||
|
|
@ -58,14 +60,24 @@ class ViewInstalledWindowBase(Gtk.Window):
|
|||
filter_text.add_pattern("*.kmp")
|
||||
dlg.add_filter(filter_text)
|
||||
response = dlg.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
self.install_file(dlg.get_filename())
|
||||
if response != Gtk.ResponseType.OK:
|
||||
dlg.destroy()
|
||||
return
|
||||
|
||||
file = dlg.get_filename()
|
||||
dlg.destroy()
|
||||
self.restart(self.install_file(file))
|
||||
|
||||
def install_file(self, kmpfile):
|
||||
installDlg = InstallKmpWindow(kmpfile, viewkmp=self)
|
||||
installDlg.run()
|
||||
result = installDlg.run()
|
||||
installDlg.destroy()
|
||||
return result
|
||||
|
||||
def restart(self, response = Gtk.ResponseType.OK):
|
||||
if response != Gtk.ResponseType.CANCEL:
|
||||
subprocess.Popen(sys.argv)
|
||||
self.close()
|
||||
|
||||
def run(self):
|
||||
self.resize(576, 324)
|
||||
|
|
@ -295,9 +307,9 @@ class ViewInstalledWindow(ViewInstalledWindowBase):
|
|||
if welcome_file and os.path.isfile(welcome_file):
|
||||
uri_path = pathlib.Path(welcome_file).as_uri()
|
||||
logging.info("opening " + uri_path)
|
||||
w = WelcomeView(uri_path, model[treeiter][3])
|
||||
w.resize(800, 600)
|
||||
w.show_all()
|
||||
w = WelcomeView(self, uri_path, model[treeiter][3])
|
||||
w.run()
|
||||
w.destroy()
|
||||
else:
|
||||
logging.info("welcome.htm not available")
|
||||
|
||||
|
|
@ -331,8 +343,8 @@ class ViewInstalledWindow(ViewInstalledWindowBase):
|
|||
logging.info("Uninstalling keyboard" + model[treeiter][1])
|
||||
# can only uninstall with the gui from user area
|
||||
uninstall_kmp(model[treeiter][3])
|
||||
logging.info("need to refresh window after uninstalling a keyboard")
|
||||
self.refresh_installed_kmp()
|
||||
logging.info("need to restart window after uninstalling a keyboard")
|
||||
self.restart()
|
||||
elif response == Gtk.ResponseType.NO:
|
||||
logging.info("Not uninstalling keyboard " + model[treeiter][1])
|
||||
|
||||
|
|
@ -342,9 +354,9 @@ class ViewInstalledWindow(ViewInstalledWindowBase):
|
|||
logging.info("Show keyboard details of " + model[treeiter][1])
|
||||
areapath = get_install_area_path(model[treeiter][4])
|
||||
kmp = { "name" : model[treeiter][1], "version" : model[treeiter][2], "packageID" : model[treeiter][3], "areapath" : areapath}
|
||||
w = KeyboardDetailsView(kmp)
|
||||
w.resize(800, 450)
|
||||
w.show_all()
|
||||
w = KeyboardDetailsView(self, kmp)
|
||||
w.run()
|
||||
w.destroy()
|
||||
|
||||
if __name__ == '__main__':
|
||||
w = ViewInstalledWindow()
|
||||
|
|
|
|||
|
|
@ -13,26 +13,28 @@ from gi.repository import Gtk, WebKit2
|
|||
from keyman_config.check_mime_type import check_mime_type
|
||||
from keyman_config.accelerators import bind_accelerator, init_accel
|
||||
|
||||
class WelcomeView(Gtk.Window):
|
||||
# NOTE: WebKit2 is not able to load XHTML files nor files with an encoding other
|
||||
# than ASCII or UTF-8
|
||||
|
||||
def __init__(self, welcomeurl, keyboardname):
|
||||
class WelcomeView(Gtk.Dialog):
|
||||
|
||||
def __init__(self, parent, welcomeurl, keyboardname):
|
||||
self.accelerators = None
|
||||
kbtitle = keyboardname + " installed"
|
||||
self.welcomeurl = welcomeurl
|
||||
Gtk.Window.__init__(self, title=kbtitle)
|
||||
Gtk.Dialog.__init__(self, kbtitle, parent)
|
||||
init_accel(self)
|
||||
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
|
||||
|
||||
s = Gtk.ScrolledWindow()
|
||||
self.webview = WebKit2.WebView()
|
||||
self.webview.connect("decide-policy", self.doc_policy)
|
||||
self.webview.load_uri(welcomeurl)
|
||||
s.add(self.webview)
|
||||
vbox.pack_start(s, True, True, 0)
|
||||
|
||||
self.get_content_area().pack_start(s, True, True, 0)
|
||||
|
||||
hbox = Gtk.Box(spacing=12)
|
||||
vbox.pack_start(hbox, False, False, 6)
|
||||
self.get_content_area().pack_start(hbox, False, False, 6)
|
||||
|
||||
button = Gtk.Button.new_with_mnemonic("Open in _Web browser")
|
||||
button.connect("clicked", self.on_openweb_clicked)
|
||||
|
|
@ -44,7 +46,8 @@ class WelcomeView(Gtk.Window):
|
|||
hbox.pack_end(button, False, False, 12)
|
||||
bind_accelerator(self.accelerators, button, '<Control>w')
|
||||
|
||||
self.add(vbox)
|
||||
self.resize(800, 600)
|
||||
self.show_all()
|
||||
|
||||
def doc_policy(self, web_view, decision, decision_type):
|
||||
logging.info("Checking policy")
|
||||
|
|
@ -67,4 +70,5 @@ class WelcomeView(Gtk.Window):
|
|||
|
||||
def on_ok_clicked(self, button):
|
||||
logging.info("Closing welcome window")
|
||||
self.response(Gtk.ResponseType.OK)
|
||||
self.close()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue