kb accelerators for Ctrl-W and Ctrl-Q

use title attr to get markup tooltip
This commit is contained in:
glasseyes 2018-06-15 15:04:30 +07:00
parent 56f1487b2e
commit 8fe81ff77b
4 changed files with 24 additions and 1 deletions

View file

@ -12,13 +12,16 @@ from gi.repository import Gtk, WebKit
from get_kmp import get_download_folder, download_kmp_file
from install_window import InstallKmpWindow
from check_mime_type import check_mime_type
from accelerators import bind_accelerator, init_accel
class DownloadKmpWindow(Gtk.Window):
def __init__(self, view=None):
self.accelerators = None
Gtk.Window.__init__(self, title="Keyman keyboard")
self.endonclose = False
self.viewwindow = view
init_accel(self)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
@ -49,9 +52,13 @@ class DownloadKmpWindow(Gtk.Window):
#button.connect("clicked", self.on_open_clicked)
#hbox.pack_start(button, False, False, 0)
self.statuslabel = Gtk.Label()
hbox.pack_start(self.statuslabel, False, False, 0)
button = Gtk.Button.new_with_mnemonic("_Close")
button.connect("clicked", self.on_close_clicked)
hbox.pack_end(button, False, False, 0)
bind_accelerator(self.accelerators, button, '<Control>w')
self.add(vbox)
@ -61,6 +68,7 @@ class DownloadKmpWindow(Gtk.Window):
if download_kmp_file(url, downloadfile, True):
if verbose:
print("File downloaded")
#self.statuslabel.set_text("Package downloaded to " + downloadfile)
w = InstallKmpWindow(downloadfile, online=True, viewkmp=self.viewwindow)
if w.checkcontinue:
@ -81,6 +89,8 @@ class DownloadKmpWindow(Gtk.Window):
if parsed.path == "download":
qs = urllib.parse.parse_qs(parsed.query)
downloadfile = os.path.join(get_download_folder(), qs['filename'][0])
#self.statuslabel.set_text("Downloading package to " + downloadfile)
#self.show_all()
if self.process_kmp(view, qs['url'][0], downloadfile, True):
policy.ignore()
return True

View file

@ -20,6 +20,7 @@ from welcome import WelcomeView
from uninstall_kmp import uninstall_kmp
from get_kmp import get_download_folder
from check_mime_type import check_mime_type
from accelerators import bind_accelerator, init_accel
class InstallKmpWindow(Gtk.Window):
@ -29,6 +30,7 @@ class InstallKmpWindow(Gtk.Window):
self.online = online
self.endonclose = False
self.viewwindow = viewkmp
self.accelerators = None
keyboardid = os.path.basename(os.path.splitext(kmpfile)[0])
installed_kmp_ver = get_kmp_version(keyboardid)
if installed_kmp_ver:
@ -36,6 +38,7 @@ class InstallKmpWindow(Gtk.Window):
windowtitle = "Installing keyboard/package " + keyboardid
Gtk.Window.__init__(self, title=windowtitle)
init_accel(self)
self.set_border_width(3)
@ -158,7 +161,7 @@ class InstallKmpWindow(Gtk.Window):
prevlabel = label4
label = Gtk.Label()
if 'url' in info['author']:
label.set_markup("<a href=\"" + info['author']['url'] + "\">" + info['author']['description'] + "</a>")
label.set_markup("<a href=\"" + info['author']['url'] + "\" title=\"" + info['author']['url'] + "\">" + info['author']['description'] + "</a>")
else:
label.set_text(info['author']['description'])
label.set_halign(Gtk.Align.START)
@ -233,6 +236,7 @@ class InstallKmpWindow(Gtk.Window):
button = Gtk.Button.new_with_mnemonic("_Cancel")
button.connect("clicked", self.on_cancel_clicked)
hbox.pack_end(button, False, False, 0)
bind_accelerator(self.accelerators, button, '<Control>w')
self.add(vbox)
self.resize(635, 270)

View file

@ -12,6 +12,7 @@ from keyboard_details import KeyboardDetailsView
from downloadkeyboard import DownloadKmpWindow
from install_window import InstallKmpWindow
from uninstall_kmp import uninstall_kmp
from accelerators import bind_accelerator, init_accel
class KeyboardBox(Gtk.Box):
def __init__(self, kmp, window):
@ -120,7 +121,9 @@ class KmpGrid(Gtk.Grid):
class ViewInstalledWindow(Gtk.Window):
def __init__(self):
self.accelerators = None
Gtk.Window.__init__(self, title="Keyman keyboard")
init_accel(self)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
@ -149,6 +152,8 @@ class ViewInstalledWindow(Gtk.Window):
button = Gtk.Button.new_with_mnemonic("_Close")
button.connect("clicked", self.on_close_clicked)
hbox.pack_end(button, False, False, 0)
bind_accelerator(self.accelerators, button, '<Control>q')
bind_accelerator(self.accelerators, button, '<Control>w')
self.add(vbox)

View file

@ -10,13 +10,16 @@ gi.require_version('Gtk', '3.0')
gi.require_version('WebKit', '3.0')
from gi.repository import Gtk, WebKit
from check_mime_type import check_mime_type
from accelerators import bind_accelerator, init_accel
class WelcomeView(Gtk.Window):
def __init__(self, welcomeurl, keyboardname):
self.accelerators = None
kbtitle = keyboardname + " installed"
self.welcomeurl = welcomeurl
Gtk.Window.__init__(self, title=kbtitle)
init_accel(self)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
@ -51,6 +54,7 @@ class WelcomeView(Gtk.Window):
button = Gtk.Button.new_with_mnemonic("_OK")
button.connect("clicked", self.on_ok_clicked)
hbox.pack_end(button, False, False, 0)
bind_accelerator(self.accelerators, button, '<Control>w')
self.add(vbox)