Merge branch 'input-purpose-toggle' into 'master'
Honor input-purpose only changes Closes #311 See merge request World/Phosh/squeekboard!493
This commit is contained in:
@ -153,14 +153,14 @@ pub mod c {
|
|||||||
|
|
||||||
if active_changed {
|
if active_changed {
|
||||||
(imservice.active_callback)(imservice.current.active);
|
(imservice.active_callback)(imservice.current.active);
|
||||||
if imservice.current.active {
|
}
|
||||||
unsafe {
|
if imservice.current.active {
|
||||||
eekboard_context_service_set_hint_purpose(
|
unsafe {
|
||||||
imservice.state_manager,
|
eekboard_context_service_set_hint_purpose(
|
||||||
imservice.current.content_hint.bits(),
|
imservice.state_manager,
|
||||||
imservice.current.content_purpose.clone() as u32,
|
imservice.current.content_hint.bits(),
|
||||||
);
|
imservice.current.content_purpose.clone() as u32,
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
import random
|
||||||
import sys
|
import sys
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
|
gi.require_version('GLib', '2.0')
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import GLib
|
||||||
|
|
||||||
try:
|
try:
|
||||||
terminal = [("Terminal", Gtk.InputPurpose.TERMINAL)]
|
terminal = [("Terminal", Gtk.InputPurpose.TERMINAL)]
|
||||||
@ -14,6 +17,8 @@ except AttributeError:
|
|||||||
|
|
||||||
def new_grid(items, set_type):
|
def new_grid(items, set_type):
|
||||||
grid = Gtk.Grid(orientation='vertical', column_spacing=8, row_spacing=8)
|
grid = Gtk.Grid(orientation='vertical', column_spacing=8, row_spacing=8)
|
||||||
|
grid.props.margin = 6
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
for text, value in items:
|
for text, value in items:
|
||||||
l = Gtk.Label(label=text)
|
l = Gtk.Label(label=text)
|
||||||
@ -44,17 +49,41 @@ class App(Gtk.Application):
|
|||||||
("OSK provided", Gtk.InputHints.INHIBIT_OSK)
|
("OSK provided", Gtk.InputHints.INHIBIT_OSK)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def on_purpose_toggled(self, btn, entry):
|
||||||
|
purpose = Gtk.InputPurpose.PIN if btn.get_active() else Gtk.InputPurpose.PASSWORD
|
||||||
|
entry.set_input_purpose(purpose)
|
||||||
|
|
||||||
|
def on_timeout(self, e):
|
||||||
|
r = random.randint(0, len(self.purposes) - 1)
|
||||||
|
(_, purpose) = self.purposes[r]
|
||||||
|
print(f"Setting {purpose}")
|
||||||
|
e.set_input_purpose(purpose)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def add_random (self, grid):
|
||||||
|
l = Gtk.Label(label="Random")
|
||||||
|
e = Gtk.Entry(hexpand=True)
|
||||||
|
e.set_input_purpose(Gtk.InputPurpose.FREE_FORM)
|
||||||
|
grid.attach(l, 0, len(self.purposes), 1, 1)
|
||||||
|
grid.attach(e, 1, len(self.purposes), 1, 1)
|
||||||
|
GLib.timeout_add_seconds (3, self.on_timeout, e)
|
||||||
|
|
||||||
def do_activate(self):
|
def do_activate(self):
|
||||||
w = Gtk.ApplicationWindow(application=self)
|
w = Gtk.ApplicationWindow(application=self)
|
||||||
|
w.set_default_size (300, 500)
|
||||||
notebook = Gtk.Notebook()
|
notebook = Gtk.Notebook()
|
||||||
def add_purpose(entry, purpose):
|
def add_purpose(entry, purpose):
|
||||||
entry.set_input_purpose(purpose)
|
entry.set_input_purpose(purpose)
|
||||||
def add_hint(entry, hint):
|
def add_hint(entry, hint):
|
||||||
entry.set_input_hints(hint)
|
entry.set_input_hints(hint)
|
||||||
purpose_grid = new_grid(self.purposes, add_purpose)
|
purpose_grid = new_grid(self.purposes, add_purpose)
|
||||||
|
self.add_random(purpose_grid)
|
||||||
hint_grid = new_grid(self.hints, add_hint)
|
hint_grid = new_grid(self.hints, add_hint)
|
||||||
|
|
||||||
notebook.append_page(purpose_grid, Gtk.Label(label="Purposes"))
|
purpose_scroll = Gtk.ScrolledWindow()
|
||||||
|
purpose_scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||||
|
purpose_scroll.add(purpose_grid)
|
||||||
|
notebook.append_page(purpose_scroll, Gtk.Label(label="Purposes"))
|
||||||
notebook.append_page(hint_grid, Gtk.Label(label="Hints"))
|
notebook.append_page(hint_grid, Gtk.Label(label="Hints"))
|
||||||
w.add(notebook)
|
w.add(notebook)
|
||||||
w.show_all()
|
w.show_all()
|
||||||
|
|||||||
Reference in New Issue
Block a user