def on_country_changed(self, combo):

        # making sure the country has been set
        country_text = combo.get_selected_item_text()
        country_index = combo.get_selected_item_index()
        if not country_text or country_index == -1:
            return

        # Remove entries from variants combo box
        self.variants_combo.remove_all()
        self.selected_country_hr = country_text
        self.selected_country_index = country_index

        # Refresh variants combo box
        self.selected_country = keyboard_config.find_country_code(country_text, self.selected_layout)
        variants = keyboard_config.find_keyboard_variants(self.selected_country)
        self.variants_combo.append('generic')
        if variants is not None:
            for v in variants:
                self.variants_combo.append(v[0])

        # if kano keyboard is connected, change to Mac layout
        kano_keyboard = detect_kano_keyboard()

        if kano_keyboard:
            self.set_variants_to_mac_layout()
        else:
            self.set_variants_to_generic()
        self.on_variants_changed(self.variants_combo)
    def apply_changes(self, button, event):

        # If enter key is pressed or mouse button is clicked
        if not hasattr(event, 'keyval') or event.keyval == 65293:

            def lengthy_process():
                if keyboard_config.is_changed(self.selected_country, self.selected_variant):
                    # Apply the keyboard changes
                    keyboard_config.set_keyboard(self.selected_country, self.selected_variant)

                    # A reboot is needed to apply the new keyboard to QT5 apps
                    common.need_reboot = True
                    
                # The callback runs a GUI task, so wrap it!
                GObject.idle_add(self.work_finished_cb)

            # Save the changes in the config file
            self.update_config()

            # An then apply the new saved changes
            thread = threading.Thread(target=lengthy_process)
            thread.start()

            kano_keyboard = detect_kano_keyboard()

            # Go back a screen
            if kano_keyboard:
                self.go_to_kano_screen()
            else:
                self.win.go_to_home()

            self.win.show_all()
def _hw_info():
    # TODO: This import is done here to avoid potential
    #       import loops with kano-peripherals.
    from kano_peripherals.wrappers.detection import is_ck2_lite, is_ck2_pro, \
        is_ckt, get_ck2_lite_version, get_ck2_pro_version, get_ckt_version

    # If CKL/CKCs cannot be detected, defaults to Computer Kits without version.
    kit_type = 'ck'
    kit_version = None

    # Detect CK Lite via the PiHat board.
    if is_ck2_lite():
        kit_type = 'ckl'
        kit_version = get_ck2_lite_version()

    # Detect CK Complete via the PowerHat board and other peripherals.
    elif is_ck2_pro():
        kit_type = 'ckc'
        kit_version = get_ck2_pro_version()

    # Detect CKT via the PowerHat board and EDID.
    elif is_ckt():
        kit_type = 'ckt'
        kit_version = get_ckt_version()

    track_data('hw-info', {
        'keyboard': 'kano' if detect_kano_keyboard() else 'generic',
        'model': get_rpi_model(),
        'partitions': get_partition_info(),
        'kit': {
            'type': kit_type,
            'version': kit_version.vstring if kit_version else kit_version
        }
    })
def _hw_info():
    # TODO: This import is done here to avoid potential
    #       import loops with kano-peripherals.
    from kano_peripherals.wrappers.detection import is_ck2_lite, is_ck2_pro, \
        is_ckt, get_ck2_lite_version, get_ck2_pro_version, get_ckt_version

    # If CKL/CKCs cannot be detected, defaults to Computer Kits without version.
    kit_type = 'ck'
    kit_version = None

    # Detect CK Lite via the PiHat board.
    if is_ck2_lite():
        kit_type = 'ckl'
        kit_version = get_ck2_lite_version()

    # Detect CK Complete via the PowerHat board and other peripherals.
    elif is_ck2_pro():
        kit_type = 'ckc'
        kit_version = get_ck2_pro_version()

    # Detect CKT via the PowerHat board and EDID.
    elif is_ckt():
        kit_type = 'ckt'
        kit_version = get_ckt_version()

    track_data(
        'hw-info', {
            'keyboard': 'kano' if detect_kano_keyboard() else 'generic',
            'model': get_rpi_model(),
            'partitions': get_partition_info(),
            'kit': {
                'type': kit_type,
                'version': kit_version.vstring if kit_version else kit_version
            }
        })
Beispiel #5
0
    def on_country_changed(self, combo):

        # making sure the country has been set
        country_text = combo.get_selected_item_text()
        country_index = combo.get_selected_item_index()
        if not country_text or country_index == -1:
            return

        # Remove entries from variants combo box
        self.variants_combo.remove_all()
        self.selected_country_hr = country_text
        self.selected_country_index = country_index

        # Refresh variants combo box
        self.selected_country = keyboard_config.find_country_code(country_text, self.selected_layout)
        variants = keyboard_config.find_keyboard_variants(self.selected_country)
        self.variants_combo.append('generic')
        if variants is not None:
            for v in variants:
                self.variants_combo.append(v[0])

        # if kano keyboard is connected, change to Mac layout
        kano_keyboard = detect_kano_keyboard()

        if kano_keyboard:
            self.set_variants_to_mac_layout()
        else:
            self.set_variants_to_generic()
        self.on_variants_changed(self.variants_combo)
Beispiel #6
0
    def apply_changes(self, button, event):

        # If enter key is pressed or mouse button is clicked
        if not hasattr(event, 'keyval') or event.keyval == 65293:

            def lengthy_process():
                if keyboard_config.is_changed(self.selected_country, self.selected_variant):
                    # Apply the keyboard changes
                    keyboard_config.set_keyboard(self.selected_country, self.selected_variant)

                    # A reboot is needed to apply the new keyboard to QT5 apps
                    common.need_reboot = True
                    
                # The callback runs a GUI task, so wrap it!
                GObject.idle_add(self.work_finished_cb)

            # Save the changes in the config file
            self.update_config()

            # An then apply the new saved changes
            thread = threading.Thread(target=lengthy_process)
            thread.start()

            kano_keyboard = detect_kano_keyboard()

            # Go back a screen
            if kano_keyboard:
                self.go_to_kano_screen()
            else:
                self.win.go_to_home()

            self.win.show_all()
def choose_keyboard_screen(win):
    # Check for kano-keyboard
    kano_keyboard = detect_kano_keyboard()
    if kano_keyboard:
        SetKanoKeyboard(win)

    else:
        SetKeyboard(win)
Beispiel #8
0
def choose_keyboard_screen(win):
    # Check for kano-keyboard
    kano_keyboard = detect_kano_keyboard()
    if kano_keyboard:
        SetKanoKeyboard(win)

    else:
        SetKeyboard(win)
    def activate(self, _, event):
        """ Move to the first setup screen """

        if not hasattr(event, 'keyval') or event.keyval == 65293:
            self.win.clear_win()

            if not detect_kano_keyboard():
                KeyboardScreen(self.win)
            elif not is_internet():
                InternetScreen(self.win)
            else:
                SettingsIntroScreen(self.win)
Beispiel #10
0
def save_hardware_info():
    """Saves hardware information related to the Raspberry Pi / Kano Kit"""

    from kano.logging import logger
    from kano.utils import get_cpu_id, get_mac_address, detect_kano_keyboard

    logger.info('save_hardware_info')
    state = {
        'cpu_id': get_cpu_id(),
        'mac_address': get_mac_address(),
        'kano_keyboard': detect_kano_keyboard(),
    }
    save_app_state_variable('kano-tracker', 'hardware_info', state)
def _hw_info():
    track_data("hw-info", {
        "keyboard": "kano" if detect_kano_keyboard() else "generic",
        "model": get_rpi_model()
    })
    def __init__(self, win):
        Template.__init__(
            self,
            _("Keyboard"),
            _("Where do you live? So I can set your keyboard."),
            _("APPLY CHANGES")
        )

        self.win = win
        self.win.set_main_widget(self)
        self.read_config()

        kano_keyboard = detect_kano_keyboard()
        self.win.top_bar.enable_prev()

        if kano_keyboard:
            self.win.change_prev_callback(self.go_to_kano_screen)
        else:
            self.win.change_prev_callback(self.win.go_to_home)

        self.kano_button.connect('button-release-event', self.apply_changes)

        # Make sure continue button is enabled
        self.kano_button.set_sensitive(False)

        # Create Continents Combo box
        self.continents_combo = KanoComboBox(max_display_items=7)
        for c in self.continents:
            self.continents_combo.append(c)
        self.continents_combo.connect('changed', self.on_continent_changed)

        # Create Countries Combo box
        self.countries_combo = KanoComboBox(max_display_items=7)
        self.countries_combo.connect('changed', self.on_country_changed)
        self.countries_combo.props.valign = Gtk.Align.CENTER

        # Create Advance mode checkbox
        advance_button = Gtk.CheckButton(_("Advanced options"))
        advance_button.set_can_focus(False)
        advance_button.props.valign = Gtk.Align.CENTER
        advance_button.connect('clicked', self.on_advance_mode)
        advance_button.set_active(False)

        # Create Variants Combo box
        self.variants_combo = KanoComboBox(max_display_items=7)
        self.variants_combo.connect('changed', self.on_variants_changed)
        self.variants_combo.props.valign = Gtk.Align.CENTER

        # Set up default values in dropdown lists
        self.set_defaults('continent')
        self.fill_countries_combo(self.continents_combo.get_selected_item_text())
        self.set_defaults('country')
        self.on_country_changed(self.countries_combo)
        self.set_defaults('variant')

        # Ceate various dropdown boxes so we can resize the dropdown lists appropriately
        # We create two boxes side by side, and then stack the country dropdow lists in one, and one by itself in the other

        #   dropdown_box_countries     dropdown_box_keys
        # |                        |                        |
        # |-------continents-------|   Advance option       |
        # |                        |                        |
        # |                        |                        |
        # |-------countries -------|--------variants--------|
        # |                        |                        |

        dropdown_box_countries = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
        dropdown_box_countries.set_size_request(230, 30)
        dropdown_box_countries.props.valign = Gtk.Align.CENTER
        dropdown_box_keys = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
        dropdown_box_keys.set_size_request(230, 30)
        dropdown_box_countries.pack_start(self.continents_combo, False, False, 0)
        dropdown_box_countries.pack_start(self.countries_combo, False, False, 0)
        dropdown_box_keys.pack_start(advance_button, False, False, 0)
        dropdown_box_keys.pack_start(self.variants_combo, False, False, 0)
        dropdown_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=20)
        dropdown_container.pack_start(dropdown_box_countries, False, False, 0)
        dropdown_container.pack_start(dropdown_box_keys, False, False, 0)

        self.box.pack_start(dropdown_container, False, False, 0)

        # show all elements except the advanced mode
        self.refresh_window()
Beispiel #13
0
    def __init__(self, win):
        Template.__init__(
            self,
            _("Keyboard"),
            _("Where do you live? So I can set your keyboard."),
            _("APPLY CHANGES")
        )

        self.win = win
        self.win.set_main_widget(self)
        self.read_config()

        kano_keyboard = detect_kano_keyboard()
        self.win.top_bar.enable_prev()

        if kano_keyboard:
            self.win.change_prev_callback(self.go_to_kano_screen)
        else:
            self.win.change_prev_callback(self.win.go_to_home)

        self.kano_button.connect('button-release-event', self.apply_changes)

        # Make sure continue button is enabled
        self.kano_button.set_sensitive(False)

        # Create Continents Combo box
        self.continents_combo = KanoComboBox(max_display_items=7)
        for c in self.continents:
            self.continents_combo.append(c)
        self.continents_combo.connect('changed', self.on_continent_changed)

        # Create Countries Combo box
        self.countries_combo = KanoComboBox(max_display_items=7)
        self.countries_combo.connect('changed', self.on_country_changed)
        self.countries_combo.props.valign = Gtk.Align.CENTER

        # Create Advance mode checkbox
        advance_button = Gtk.CheckButton(_("Advanced options"))
        advance_button.set_can_focus(False)
        advance_button.props.valign = Gtk.Align.CENTER
        advance_button.connect('clicked', self.on_advance_mode)
        advance_button.set_active(False)

        # Create Variants Combo box
        self.variants_combo = KanoComboBox(max_display_items=7)
        self.variants_combo.connect('changed', self.on_variants_changed)
        self.variants_combo.props.valign = Gtk.Align.CENTER

        # Set up default values in dropdown lists
        self.set_defaults('continent')
        self.fill_countries_combo(self.continents_combo.get_selected_item_text())
        self.set_defaults('country')
        self.on_country_changed(self.countries_combo)
        self.set_defaults('variant')

        # Ceate various dropdown boxes so we can resize the dropdown lists appropriately
        # We create two boxes side by side, and then stack the country dropdow lists in one, and one by itself in the other

        #   dropdown_box_countries     dropdown_box_keys
        # |                        |                        |
        # |-------continents-------|   Advance option       |
        # |                        |                        |
        # |                        |                        |
        # |-------countries -------|--------variants--------|
        # |                        |                        |

        dropdown_box_countries = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
        dropdown_box_countries.set_size_request(230, 30)
        dropdown_box_countries.props.valign = Gtk.Align.CENTER
        dropdown_box_keys = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
        dropdown_box_keys.set_size_request(230, 30)
        dropdown_box_countries.pack_start(self.continents_combo, False, False, 0)
        dropdown_box_countries.pack_start(self.countries_combo, False, False, 0)
        dropdown_box_keys.pack_start(advance_button, False, False, 0)
        dropdown_box_keys.pack_start(self.variants_combo, False, False, 0)
        dropdown_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=20)
        dropdown_container.pack_start(dropdown_box_countries, False, False, 0)
        dropdown_container.pack_start(dropdown_box_keys, False, False, 0)

        self.box.pack_start(dropdown_container, False, False, 0)

        # show all elements except the advanced mode
        self.refresh_window()
Beispiel #14
0
def _hw_info():
    track_data('hw-info', {
        'keyboard': 'kano' if detect_kano_keyboard() else 'generic',
        'model': get_rpi_model(),
        'partitions': get_partition_info()
    })