def is_changed(country_code, variant):
    continent = get_setting('Keyboard-continent-human')
    country = get_setting('Keyboard-country-human')

    stored_variant = get_setting('Keyboard-variant-human').lower()
    stored_layout = keyboard_layouts.layouts[continent][country].lower()

    if variant == 'generic':
        variant = ''

    return (country_code != stored_layout or variant != stored_variant)
Example #2
0
def is_changed(country_code, variant):
    continent = get_setting('Keyboard-continent-human')
    country = get_setting('Keyboard-country-human')

    stored_variant = get_setting('Keyboard-variant-human').lower()
    stored_layout = keyboard_layouts.layouts[continent][country].lower()

    if variant == 'generic':
        variant = ''

    return (country_code != stored_layout or variant != stored_variant)
def set_saved_keyboard():
    continent = get_setting('Keyboard-continent-human')
    country = get_setting('Keyboard-country-human')
    variant = get_setting('Keyboard-variant-human')

    try:
        layout = keyboard_layouts.layouts[continent][country]
    except KeyError:
        return

    if variant != 'generic':
        for (variant_human, variant_code) in keyboard_layouts.variants[layout]:
            if variant_human == variant:
                variant = variant_code

    set_keyboard(layout, variant)
Example #4
0
def set_saved_keyboard():
    continent = get_setting('Keyboard-continent-human')
    country = get_setting('Keyboard-country-human')
    variant = get_setting('Keyboard-variant-human')

    try:
        layout = keyboard_layouts.layouts[continent][country]
    except KeyError:
        return

    if variant != 'generic':
        for (variant_human, variant_code) in keyboard_layouts.variants[layout]:
            if variant_human == variant:
                variant = variant_code

    set_keyboard(layout, variant)
Example #5
0
    def apply_changes(self, widget, event):
        # If enter key is pressed or mouse button is clicked
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:

            if (get_setting('Audio') == _('HDMI') and self.HDMI is True) or \
               (get_setting('Audio') == _('Analogue') and self.HDMI is False):

                logger.debug("set_audio / apply_changes: audio settings haven't changed, don't apply new changes")
                self.win.go_to_home()
                return

            set_to_HDMI(self.HDMI)

            # Tell user to reboot to see changes
            common.need_reboot = True
            self.win.go_to_home()
    def __init__(self, win):
        Template.__init__(self, _("Parental lock"),
                          _("Configure your parental lock settings"),
                          _("APPLY CHANGES"), win.is_plug(), True)

        self.parental_level = Gtk.VScale(adjustment=Gtk.Adjustment(
            value=0, lower=0, upper=3, step_incr=1, page_incr=0, page_size=0))
        self.parental_level.get_style_context().add_class('parental_slider')
        self.parental_level.set_draw_value(False)
        self.parental_level.set_round_digits(0)
        self.parental_level.set_inverted(True)
        self.parental_level.set_value(get_setting('Parental-level'))
        self.parental_level.connect('value-changed',
                                    self._value_change_handler)

        self._parental_labels = [
            (Gtk.Label(_("Low Settings")),
             Gtk.Label(
                 _("Block predefined blacklisted websites and\nactivates SafeSearch on Google and Youtube"
                   ))),
            (Gtk.Label(_("Medium Settings")),
             Gtk.Label(_("Use safe DNS servers to filter all traffic"))),
            (Gtk.Label(_("High Settings")),
             Gtk.Label(
                 _("Enable all filters and restrict search engine access"))),
            (Gtk.Label(_("Ultimate Settings")),
             Gtk.Label(_("Only allow access to Kano World activities")))
        ]

        self.blacklist_button = OrangeButton(_("Configure allowed/blocked"))
        self.blacklist_button.connect('button-press-event',
                                      self.go_to_blacklist)

        self._value_change_handler(self.parental_level)

        parental_level_grid = Gtk.Grid()
        parental_level_grid.attach(self.parental_level, 0, 0, 1, 7)
        parental_level_grid.attach(self._parental_labels[3][0], 1, 0, 1, 1)
        parental_level_grid.attach(self._parental_labels[3][1], 1, 1, 1, 1)
        parental_level_grid.attach(self._parental_labels[2][0], 1, 2, 1, 1)
        parental_level_grid.attach(self._parental_labels[2][1], 1, 3, 1, 1)
        parental_level_grid.attach(self._parental_labels[1][0], 1, 4, 1, 1)
        parental_level_grid.attach(self._parental_labels[1][1], 1, 5, 1, 1)
        parental_level_grid.attach(self._parental_labels[0][0], 1, 6, 1, 1)
        parental_level_grid.attach(self._parental_labels[0][1], 1, 7, 1, 1)

        self.box.set_spacing(20)
        self.box.pack_start(parental_level_grid, False, False, 0)
        self.box.pack_start(self.blacklist_button, False, False, 0)

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

        self.set_prev_callback(self.go_to_advanced)
        self.win.change_prev_callback(self.win.go_to_home)
        self.win.top_bar.enable_prev()

        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.connect('key-release-event', self.apply_changes)
        self.win.show_all()
Example #7
0
def is_HDMI():
    # Find the audio setting
    amixer_string, e, rc = run_cmd(amixer_get_cmd)
    if rc:
        logger.warn("error from amixer: {} {} {}".format(amixer_string, e, rc))

    if amixer_string.find(hdmi_string) != -1:
        # Make sure config file is up to date
        if get_setting('Audio') != _("HDMI"):
            set_setting('Audio', _("HDMI"))
        return True

    # Default to Analogue
    else:
        # Make sure config file is up to date
        if get_setting('Audio') != _("Analogue"):
            set_setting('Audio', _("Analogue"))
        return False
Example #8
0
    def apply_changes(self, widget, event):
        # If enter key is pressed or mouse button is clicked
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:

            if (get_setting('Audio') == _('HDMI') and self.HDMI is True) or \
               (get_setting('Audio') == _('Analogue') and self.HDMI is False):

                logger.debug(
                    "set_audio / apply_changes: audio settings haven't changed, don't apply new changes"
                )
                self.win.go_to_home()
                return

            set_to_HDMI(self.HDMI)

            # Tell user to reboot to see changes
            common.need_reboot = True
            self.win.go_to_home()
Example #9
0
    def configure_cpu_monitor_animation(self, checkbox=None):
        is_ticked = self.cpu_monitor_checkbox.get_active()
        was_enabled = get_setting('LED-Speaker-anim')

        if is_ticked and not was_enabled:
            set_setting('LED-Speaker-anim', is_ticked)
            run_bg('kano-speakerleds cpu-monitor start', unsudo=True)
        elif was_enabled and not is_ticked:
            set_setting('LED-Speaker-anim', is_ticked)
            run_bg('kano-speakerleds cpu-monitor stop', unsudo=True)
    def configure_cpu_monitor_animation(self, checkbox=None):
        is_ticked = self.cpu_monitor_checkbox.get_active()
        was_enabled = get_setting('LED-Speaker-anim')

        if is_ticked and not was_enabled:
            set_setting('LED-Speaker-anim', is_ticked)
            run_bg('kano-speakerleds cpu-monitor start', unsudo=True)
        elif was_enabled and not is_ticked:
            set_setting('LED-Speaker-anim', is_ticked)
            run_bg('kano-speakerleds cpu-monitor stop', unsudo=True)
Example #11
0
 def read_config(self):
     self.selected_continent_index = get_setting('Keyboard-continent-index')
     self.selected_country_index = get_setting('Keyboard-country-index')
     self.selected_variant_index = get_setting('Keyboard-variant-index')
     self.selected_continent_hr = get_setting('Keyboard-continent-human')
     self.selected_country_hr = get_setting('Keyboard-country-human')
     self.selected_variant_hr = get_setting('Keyboard-variant-human')
 def read_config(self):
     self.selected_continent_index = get_setting('Keyboard-continent-index')
     self.selected_country_index = get_setting('Keyboard-country-index')
     self.selected_variant_index = get_setting('Keyboard-variant-index')
     self.selected_continent_hr = get_setting('Keyboard-continent-human')
     self.selected_country_hr = get_setting('Keyboard-country-human')
     self.selected_variant_hr = get_setting('Keyboard-variant-human')
        def _trigger_tracking_event(self):
            """ Generate a tracker event with some hardware settings.

                This will send a track_date event called 'user-settings'
                with the audio setting, parental lock level and display
                configuration.
            """

            track_data('user-settings', {
                'audio': 'hdmi' if is_HDMI() else 'analog',
                'parental-lock-level': get_setting('Parental-level'),
                'display': get_status()
            })
Example #14
0
        def _trigger_tracking_event(self):
            """ Generate a tracker event with some hardware settings.

                This will send a track_date event called 'user-settings'
                with the audio setting, parental lock level and display
                configuration.
            """

            track_data('user-settings', {
                'audio': 'hdmi' if is_HDMI() else 'analog',
                'parental-lock-level': get_setting('Parental-level'),
                'display': get_status()
            })
Example #15
0
    def show_configuration(self):
        enable_all = False
        disable_all = False
        disable_world = False

        if not notifications.is_enabled():
            disable_all = True
        elif not notifications.world_notifications_allowed():
            disable_world = True
        else:
            enable_all = True

        self.disable_world_radiobutton.set_active(disable_world)
        self.enable_all_radiobutton.set_active(enable_all)
        self.disable_all_radiobutton.set_active(disable_all)
        self.cpu_monitor_checkbox.set_active(get_setting('LED-Speaker-anim'))
Example #16
0
    def _load_saved_settings(self):
        locale_setting = strip_encoding_from_locale(get_locale())
        locale_setting = get_setting('Locale')
        lang_code, region_code = Locales.get_codes_from_locale_code(
            locale_setting)

        lang = Locales.lang_code_to_lang(lang_code)
        region = Locales.region_code_to_region(region_code)

        selected_index = self._language_combo.get_items().index(lang)
        self._language_combo.set_selected_item_index(selected_index)

        self._on_language_changed(self._language_combo)

        selected_index = self._region_combo.get_items().index(region)
        self._region_combo.set_selected_item_index(selected_index)
    def show_configuration(self):
        enable_all = False
        disable_all = False
        disable_world = False

        if not notifications.is_enabled():
            disable_all = True
        elif not notifications.world_notifications_allowed():
            disable_world = True
        else:
            enable_all = True

        self.disable_world_radiobutton.set_active(disable_world)
        self.enable_all_radiobutton.set_active(enable_all)
        self.disable_all_radiobutton.set_active(disable_all)
        self.cpu_monitor_checkbox.set_active(get_setting('LED-Speaker-anim'))
    def set_defaults(self, setting):

        # Set the default info on the dropdown lists
        # "Keyboard-continent":continents_combo, "Keyboard-country", "Keyboard-variant"]:

        active_item = get_setting("Keyboard-" + setting + "-index")

        if setting == "continent":
            self.continents_combo.set_selected_item_index(int(active_item))
        elif setting == "country":
            self.countries_combo.set_selected_item_index(int(active_item))
        elif setting == "variant":
            self.variants_combo.set_selected_item_index(int(active_item))
        else:
            logger.error("Bad argument in set_defaults - should be 'continent', 'country' or 'variant'")
            return
Example #19
0
    def set_defaults(self, setting):

        # Set the default info on the dropdown lists
        # 'Keyboard-continent':continents_combo, 'Keyboard-country', 'Keyboard-variant']:

        active_item = get_setting('Keyboard-' + setting + '-index')

        if setting == 'continent':
            self.continents_combo.set_selected_item_index(int(active_item))
        elif setting == 'country':
            self.countries_combo.set_selected_item_index(int(active_item))
        elif setting == 'variant':
            self.variants_combo.set_selected_item_index(int(active_item))
        else:
            logger.error("Bad argument in set_defaults - should be 'continent', 'country' or 'variant'")
            return
Example #20
0
    def _load_saved_settings(self):
        locale_setting = strip_encoding_from_locale(get_locale())
        locale_setting = get_setting('Locale')
        lang_code, region_code = Locales.get_codes_from_locale_code(
            locale_setting)

        lang = Locales.lang_code_to_lang(lang_code)
        region = Locales.region_code_to_region(region_code)

        selected_index = self._language_combo.get_items().index(lang)
        self._language_combo.set_selected_item_index(selected_index)

        self._on_language_changed(self._language_combo)

        selected_index = self._region_combo.get_items().index(region)
        self._region_combo.set_selected_item_index(selected_index)
    def set_defaults(self, setting):

        # Set the default info on the dropdown lists
        # 'Keyboard-continent':continents_combo, 'Keyboard-country', 'Keyboard-variant']:

        active_item = get_setting('Keyboard-' + setting + '-index')

        if setting == 'continent':
            self.continents_combo.set_selected_item_index(int(active_item))
        elif setting == 'country':
            self.countries_combo.set_selected_item_index(int(active_item))
        elif setting == 'variant':
            self.variants_combo.set_selected_item_index(int(active_item))
        else:
            logger.error("Bad argument in set_defaults - should be 'continent', 'country' or 'variant'")
            return
Example #22
0
    def refresh_menu_button(self):
        description = ''

        if self._setting_param:
            description = get_setting(self._setting_param)
        else:
            if self.name == 'wifi':
                if common.has_internet:
                    description = 'Connected'
                else:
                    description = 'Not connected'

            elif self.name == 'account':
                description = get_user_unsudoed()

            elif self.name == 'display':
                return

        self.menu_button.description.set_text(description)
Example #23
0
    def refresh_menu_button(self):
        description = ''

        if self._setting_param:
            description = get_setting(self._setting_param)
        else:
            if self.name == 'wifi':
                if common.has_internet:
                    description = _("Connected")
                else:
                    description = _("Not connected")

            elif self.name == 'account':
                description = get_user_unsudoed()

            elif self.name == 'display':
                return

        self.menu_button.description.set_text(description)
Example #24
0
    def apply_changes(self, button, event):
        pw_dialog = ParentalPasswordDialog(self.win)
        if not pw_dialog.verify():
            return

        whitelist = [row[0] for row in self.whitelist.edit_list_store]
        blacklist = [row[0] for row in self.blacklist.edit_list_store]

        write_whitelisted_sites(whitelist)
        write_blacklisted_sites(blacklist)

        level = get_setting('Parental-level')
        set_parental_level(level)
        common.need_reboot = True

        # track which parental control level people use
        track_data('parental-control-level-changed', {'level': level})

        self.win.go_to_home()
    def apply_changes(self, button, event):
        pw_dialog = ParentalPasswordDialog(self.win)
        if not pw_dialog.verify():
            return

        whitelist = [row[0] for row in self.whitelist.edit_list_store]
        blacklist = [row[0] for row in self.blacklist.edit_list_store]

        write_whitelisted_sites(whitelist)
        write_blacklisted_sites(blacklist)

        level = get_setting('Parental-level')
        set_parental_level(level)
        common.need_reboot = True

        # track which parental control level people use
        track_data("parental-control-level-changed", {
            "level": level
        })

        self.win.go_to_home()
Example #26
0
def get_gfx_driver():
    return get_setting('Use_GLX')
Example #27
0
def get_parental_level():
    if not get_parental_enabled():
        return -1

    return get_setting('Parental-level')
Example #28
0
 def reset_wallpaper(self):
     image_name = get_setting('Wallpaper')
     self.set_wallpaper_by_image_name(image_name)
Example #29
0
def get_parental_level():
    if not get_parental_enabled():
        return -1

    return get_setting('Parental-level')
 def reset_wallpaper(self):
     image_name = get_setting('Wallpaper')
     self.set_wallpaper_by_image_name(image_name)
    def __init__(self, win):
        Template.__init__(
            self,
            "Parental lock",
            "Configure your parental lock settings",
            "APPLY CHANGES",
            win.is_plug(),
            True
        )

        self.parental_level = Gtk.VScale(
            adjustment=Gtk.Adjustment(value=0, lower=0, upper=3,
                                      step_incr=1, page_incr=0, page_size=0))
        self.parental_level.get_style_context().add_class('parental_slider')
        self.parental_level.set_draw_value(False)
        self.parental_level.set_round_digits(0)
        self.parental_level.set_inverted(True)
        self.parental_level.set_value(get_setting('Parental-level'))
        self.parental_level.connect('value-changed', self._value_change_handler)

        self._parental_labels = [
            (
                Gtk.Label("Low Settings"),
                Gtk.Label("Block predefined blacklisted websites and\nactivates SafeSearch on Google and Youtube")
            ),
            (
                Gtk.Label("Medium Settings"),
                Gtk.Label("Use safe DNS servers to filter all traffic")
            ),
            (
                Gtk.Label("High Settings"),
                Gtk.Label("Enable all filters and restrict search engine access")
            ),
            (
                Gtk.Label("Ultimate Settings"),
                Gtk.Label("Only allow access to Kano World activities")
            )
        ]

        self.blacklist_button = OrangeButton("Configure allowed/blocked")
        self.blacklist_button.connect("button-press-event",
                                      self.go_to_blacklist)

        self._value_change_handler(self.parental_level)

        parental_level_grid = Gtk.Grid()
        parental_level_grid.attach(self.parental_level, 0, 0, 1, 7)
        parental_level_grid.attach(self._parental_labels[3][0], 1, 0, 1, 1)
        parental_level_grid.attach(self._parental_labels[3][1], 1, 1, 1, 1)
        parental_level_grid.attach(self._parental_labels[2][0], 1, 2, 1, 1)
        parental_level_grid.attach(self._parental_labels[2][1], 1, 3, 1, 1)
        parental_level_grid.attach(self._parental_labels[1][0], 1, 4, 1, 1)
        parental_level_grid.attach(self._parental_labels[1][1], 1, 5, 1, 1)
        parental_level_grid.attach(self._parental_labels[0][0], 1, 6, 1, 1)
        parental_level_grid.attach(self._parental_labels[0][1], 1, 7, 1, 1)

        self.box.set_spacing(20)
        self.box.pack_start(parental_level_grid, False, False, 0)
        self.box.pack_start(self.blacklist_button, False, False, 0)

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

        self.set_prev_callback(self.go_to_advanced)
        self.win.change_prev_callback(self.win.go_to_home)
        self.win.top_bar.enable_prev()

        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.connect('key-release-event', self.apply_changes)
        self.win.show_all()
Example #32
0
def get_gfx_driver():
    return get_setting('Use_GLX')