def fill_layout_treeview(self): lang = self.settings.get("language_code") keyboard_names._default_filename = self.filename if not keyboard_names.has_language(lang): lang = "C" kbd_names = keyboard_names.KeyboardNames(self.filename) kbd_names._load(lang) sorted_layouts = [] for layout in kbd_names._layout_by_human: sorted_layouts.append(layout) sorted_layouts = misc.sort_list(sorted_layouts, self.settings.get("locale")) # Block signal self.layout_treeview.handler_block_by_func( self.on_keyboardlayout_cursor_changed) # Clear our model liststore = self.layout_treeview.get_model() liststore.clear() # Add layouts (sorted) for layout in sorted_layouts: liststore.append([layout]) # Unblock signal self.layout_treeview.handler_unblock_by_func( self.on_keyboardlayout_cursor_changed)
def fill_variant_treeview(self): selected = self.layout_treeview.get_selection() if selected: (ls, iter) = selected.get_selected() if iter: keyboard_layout = ls.get_value(iter, 0) # store layout selected self.keyboard_layout_human = keyboard_layout lang = self.settings.get("language_code") if not keyboard_names.has_language(lang): lang = "C" kbd_names = keyboard_names.KeyboardNames(self.filename) kbd_names._load(lang) country_code = kbd_names._layout_by_human[ self.keyboard_layout_human] self.keyboard_layout = country_code variants = kbd_names._variant_by_human sorted_variants = [] for variant in variants[country_code]: sorted_variants.append(variant) sorted_variants.sort() #sorted_variants = misc.sort_list(sorted_variants, self.settings.get("locale")) # Block signal self.variant_treeview.handler_block_by_func( self.on_keyboardvariant_cursor_changed) # Clear our model liststore = self.variant_treeview.get_model() liststore.clear() # Add keyboard variants (sorted) for variant in sorted_variants: liststore.append([variant]) # Unblock signal self.variant_treeview.handler_unblock_by_func( self.on_keyboardvariant_cursor_changed) #selection = self.variant_treeview.get_selection() self.variant_treeview.set_cursor(0) else: liststore = self.variant_treeview.get_model() liststore.clear()
def store_values(self): # We've previously stored our layout, now store our variant selected = self.variant_treeview.get_selection() keyboard_variant_human = "USA" if selected: (ls, iter) = selected.get_selected() if iter: keyboard_variant_human = ls.get_value(iter, 0) lang = self.settings.get("language_code") kbd_names = keyboard_names.KeyboardNames(self.filename) if not kbd_names.has_language(lang): lang = "C" kbd_names._load(lang) try: keyboard_layout_human = self.keyboard_layout_human except AttributeError: keyboard_layout_human = "USA" self.keyboard_layout_human = keyboard_layout_human country_code = kbd_names._layout_by_human[self.keyboard_layout_human] self.keyboard_layout = country_code self.keyboard_variant = kbd_names._variant_by_human[country_code][ keyboard_variant_human] self.settings.set("keyboard_layout", self.keyboard_layout) self.settings.set("keyboard_variant", self.keyboard_variant) # This fixes issue 75: Won't pick/load the keyboard layout after selecting one (sticks to qwerty) if not self.testing and self.prepare_called: self.setkb() return True