Populate keyboard screen

pull/6/head
axtloss 2 years ago
parent 78aa22e2a6
commit 975ac373b6

@ -18,6 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from jade_gui.locales.locales_list import locations
from jade_gui.widgets.variant import KeyboardVariant
from gi.repository import Gtk, Adw
from gettext import gettext as _
@ -38,6 +40,9 @@ class KeyboardScreen(Adw.Bin):
variant_search = Gtk.Template.Child()
variant_entry_search = Gtk.Template.Child()
layout = None
variant = ""
def __init__(self, window, main_carousel, next_page, application, **kwargs):
super().__init__(**kwargs)
self.window = window
@ -59,15 +64,24 @@ class KeyboardScreen(Adw.Bin):
terms = self.variant_entry_search.get_text()
self.list_keyboard_variants.set_filter_func(self.filter_text, terms)
def selected_layout(self, widget, row):
def selected_layout(self, widget, row, *args):
if row is not None or row is not self.layout_entry_search:
if self.layout is not None:
for n in range(len(self.layout.variants)):
print(n)
print(self.list_keyboard_variants.get_row_at_index(n))
if self.list_keyboard_variants.get_row_at_index(n) is not None:
self.list_keyboard_variants.remove(self.list_keyboard_variants.get_row_at_index(n))
self.layout = row
for variant in row.variants:
self.list_keyboard_variants.append(KeyboardVariant(window=self.window, country=row.country, country_shorthand=row.country_shorthand, variant=variant, *args))
self.keyboard_carousel.scroll_to(self.keyboard_variants, True)
else:
print("row is none!! layout")
def selected_variant(self, widget, row):
if row is not None or row is not self.variant_entry_search:
print("variant selected")
self.variant = row
self.carousel.scroll_to(self.next_page, True)
else:
print("row is none!! variant")

@ -24,9 +24,15 @@ from gettext import gettext as _
class KeyboardLayout(Adw.ActionRow):
__gtype_name__ = 'KeyboardLayout'
def __init__(self, window, country, country_shorthand, application, **kwargs):
variants=[]
def __init__(self, window, country, country_shorthand, variants, application, **kwargs):
super().__init__(**kwargs)
self.country = country
self.country_shorthand = country_shorthand
self.set_title(country)
self.set_subtitle(country_shorthand)
self.variants = variants

@ -24,7 +24,7 @@ from gettext import gettext as _
class KeyboardVariant(Adw.ActionRow):
__gtype_name__ = 'KeyboardVariant'
def __init__(self, window, variant, country, country_shorthand, application, **kwargs):
def __init__(self, window, variant, country, country_shorthand, **kwargs):
super().__init__(**kwargs)
self.set_title(variant)

@ -88,16 +88,11 @@ class JadeGuiWindow(Gtk.ApplicationWindow):
for keymap in keymaps:
print(keymap.layout)
print(keymap.backend_layout)
self.keyboard_screen.list_keyboard_layouts.append(KeyboardLayout(window=self, country=keymap.layout, country_shorthand=keymap.backend_layout, **kwargs))
self.keyboard_screen.list_keyboard_layouts.append(KeyboardLayout(window=self, country=keymap.layout, country_shorthand=keymap.backend_layout, variants=keymap.variant, **kwargs))
### ---------
### Test variants
variant_test = KeyboardVariant(window=self, variant="Colemak", country="United Kingdom", country_shorthand="GB", **kwargs)
variant_test_two = KeyboardVariant(window=self, variant="QWERTY", country="Germany", country_shorthand="DE", **kwargs)
variant_test_three = KeyboardVariant(window=self, variant="QWERTZ", country="United States", country_shorthand="US", **kwargs)
self.keyboard_screen.list_keyboard_variants.append(variant_test)
self.keyboard_screen.list_keyboard_variants.append(variant_test_two)
self.keyboard_screen.list_keyboard_variants.append(variant_test_three)
### ---------
### Test desktops

Loading…
Cancel
Save