Example #1
0
def try_login():
    '''
    Returns login status.
    If user is not logged in the first time, the logger will be launched
    '''
    # Check if user is registered
    if not is_registered():
        _, _, rc = run_cmd('kano-login 3')

    return is_registered()
Example #2
0
def try_login():
    '''
    Returns login status.
    If user is not logged in the first time, the logger will be launched
    '''
    # Check if user is registered
    if not is_registered():
        _, _, rc = run_cmd('kano-login 3', localised=True)

    return is_registered()
def try_login():
    '''
    Returns login status.
    If user is not logged in the first time, the logger will be launched
    '''
    from kano_world.functions import is_registered
    # Check if user is registered
    if not is_registered():
        _, _, rc = run_cmd('kano-login 3', localised=True)

    return is_registered()
Example #4
0
    def _setup_second_scene(self):
        self._second_scene = scene = Scene(self._ctl.main_window)
        scene.set_background(common_media_path('blueprint-bg-4-3.png'),
                             common_media_path('blueprint-bg-16-9.png'))

        self._add_profile_icon(self._second_scene)
        self._add_world_icon(scene,
                             self._launch_login,
                             offline=(not is_registered()))

        scene.add_widget(SpeechBubble(text="This is Kano World, where\n"
                                      "you can code with cool people,\n"
                                      "and get new apps.\n"
                                      "Click to continue.",
                                      source=SpeechBubble.TOP,
                                      source_align=1.0),
                         Placement(0.8, 0.2),
                         Placement(0.88, 0.2),
                         name="world_icon_speechbubble")

        # Shortcut
        #scene.add_widget(
        #    NextButton(),
        #    Placement(0.5, 0.5, 0),
        #    Placement(0.5, 0.5, 0),
        #    self.third_scene
        #)

        return scene
Example #5
0
 def check_login(self):
     '''
     Check if user is registered
     If not, then launch kano-login
     '''
     if not is_registered():
         # Make sure the login dialog goes on top
         self.set_keep_above(False)
         self.set_keep_below(True)
         self.show_all()
         _, _, rc = run_cmd('kano-login 3', localised=True)
         self.set_keep_below(False)
         self.set_keep_above(True)
         self.show_all()
 def check_login(self):
     """
     Check if user is registered
     If not, then launch kano-login
     """
     if not is_registered():
         # Make sure the login dialog goes on top
         self.set_keep_above(False)
         self.set_keep_below(True)
         self.show_all()
         _, _, rc = run_cmd("kano-login 3")
         self.set_keep_below(False)
         self.set_keep_above(True)
         self.show_all()
 def check_login(self):
     '''
     Check if user is registered
     If not, then launch kano-login
     '''
     if not is_registered():
         # Make sure the login dialog goes on top
         self.set_keep_above(False)
         self.set_keep_below(True)
         self.show_all()
         _, _, rc = run_cmd('kano-login 3', localised=True)
         self.set_keep_below(False)
         self.set_keep_above(True)
         self.show_all()
    def __init__(self, win):

        # Set window
        self.win = win
        self.win.set_decorated(False)
        self.win.set_resizable(True)

        # Set text depending on login
        login = is_registered()
        if login:
            header = _("Profile activated!")
            subheader = _(
                u"Now you can share stuff, build your character, " \
                u"and connect with friends! You've earned some " \
                u"rewards\N{HORIZONTAL ELLIPSIS}"
            )
            image_name = 'profile-created'
            button_label = _("LET'S GO")
        else:
            header = _("No online profile - for now.")
            subheader = _(
                "Your profile stores all your rewards, projects, and " \
                "challenges. But fear not - we'll save everything for " \
                "when you have internet."
            )
            image_name = 'no-profile-new'
            button_label = _("LET'S GO")

        # Set image
        img_width = 590
        img_height = 270
        image_filename = get_image(
            'login', '', image_name, str(img_width) + 'x' + str(img_height)
        )

        # Create template
        Template.__init__(self, image_filename, header, subheader,
                          button_label, "")

        self.win.set_main_widget(self)
        self.kano_button.connect('button_release_event', self.next_screen)
        self.kano_button.connect('key_release_event', self.next_screen)
        self.kano_button.grab_focus()
        self.win.show_all()

        # Force the cross button to hide
        self.win.headerbar.close_button.hide()
Example #9
0
    def __init__(self, win):

        # Set window
        self.win = win
        self.win.set_decorated(False)
        self.win.set_resizable(True)

        # Set text depending on login
        login = is_registered()
        if login:
            header = _("Profile activated!")
            subheader = _(
                u"Now you can share stuff, build your character, " \
                u"and connect with friends! You've earned some " \
                u"rewards\N{HORIZONTAL ELLIPSIS}"
            )
            image_name = 'profile-created'
            button_label = _("LET'S GO")
        else:
            header = _("No online profile - for now.")
            subheader = _(
                "Your profile stores all your rewards, projects, and " \
                "challenges. But fear not - we'll save everything for " \
                "when you have internet."
            )
            image_name = 'no-profile-new'
            button_label = _("LET'S GO")

        # Set image
        img_width = 590
        img_height = 270
        image_filename = get_image('login', '', image_name,
                                   str(img_width) + 'x' + str(img_height))

        # Create template
        Template.__init__(self, image_filename, header, subheader,
                          button_label, "")

        self.win.set_main_widget(self)
        self.kano_button.connect('button_release_event', self.next_screen)
        self.kano_button.connect('key_release_event', self.next_screen)
        self.kano_button.grab_focus()
        self.win.show_all()

        # Force the cross button to hide
        self.win.headerbar.close_button.hide()
Example #10
0
    def _setup_fourth_scene(self):
        scene = Scene(self._ctl.main_window)
        scene.set_background(common_media_path('blueprint-bg-4-3.png'),
                             common_media_path('blueprint-bg-16-9.png'))

        # Pass the callback of what we want to launch in the profile icon
        self._add_profile_icon(scene)
        self._add_world_icon(scene, offline=(not is_registered()))
        self._add_taskbar(scene)

        # Go through all the desktop icons and add them to the desktop
        # Either go through all files in a folder with a specific pattern, or
        # just list them in an array

        # All icons are in /usr/share/icons/Kano/88x88/apps
        # or /usr/share/kano-desktop/icons
        parent_dir = "/usr/share/kano-desktop/icons"
        parent_dir_2 = "/usr/share/icons/Kano/88x88/apps"

        self._apps_next_button_shown = False

        # Order the icons needed
        icon_info = [
            ("snake", os.path.join(parent_dir, "snake.png")),
            ("pong", os.path.join(parent_dir, "pong.png")),
            ("minecraft", os.path.join(parent_dir, "make-minecraft.png")),
            ("music", os.path.join(parent_dir, "sonicpi.png")),
            ("internet", os.path.join(parent_dir, "internet-desktop.png")),
            ("apps", os.path.join(parent_dir, "apps.png")),
            ("home", os.path.join(parent_dir, "kano-homefolder.png")),
            ("art", os.path.join(parent_dir_2, "kano-draw.png")),
            ("terminal-quest", os.path.join(parent_dir_2, "linux-story.png")),
            ("scratch", os.path.join(parent_dir, "scratch.png")),
            ("video", os.path.join(parent_dir_2, "video.png"))
            #("plus", os.path.join(parent_dir, "plus-icon.png"))
        ]

        self._desktop_icons = {
            "snake": {
                "text": "Customize your own Snake game,\n" +
                "and share special gameboards.",
                "position": [0, 340],
                "source_align": 0.1
            },
            "pong": {
                "text": "You can make this classic game yourself,\n" +
                "with new rules, cheats, and powers.",
                "position": [0, 340],
                "source_align": 0.42
            },
            "minecraft": {
                "text": "Normal people play Minecraft.\n" +
                "On Kano, you can hack the game with code.",
                "position": [95, 340],
                "source_align": 0.5
            },
            "terminal-quest": {
                "text": "The Terminal talks to the computer's\n" +
                "brain directly. Use its powers to go on a quest.",
                "position": [0, 210],
                "source_align": 0.37
            },
            "music": {
                "text":
                "You can make sounds, beats, loops,\n" + "and songs on Kano.",
                "position": [290, 340],
                "source_align": 0.5
            },
            "art": {
                "text": "Ever drawn or painted?\n" +
                "You can create incredible artworks with code.",
                "position": [0, 210],
                "source_align": 0.07
            },
            "internet": {
                "text": "You can browse the web.",
                "position": [490, 360],
                "source_align": 0.5
            },
            "scratch": {
                "text": "You can play with code blocks.",
                "position": [167, 210],
                "source_align": 0.5
            },
            "home": {
                "text": "Look at your files and folders here.",
                "position": [550, 360],
                "source_align": 1.0
            },
            "apps": {
                "text": "Find even more apps here.",
                "position": [620, 360],
                "source_align": 0.5
            },
            "video": {
                "text": "YouTube",
                "position": [435, 250],
                "source_align": 0.5
            }
        }

        fixed = Gtk.Fixed()
        fixed.set_size_request(1024, 720)
        scene.add_widget(fixed,
                         Placement(0.5, 1.0, 0),
                         Placement(0.5, 1.0, 0),
                         name="icon_grid_fixed")

        icon_grid = Gtk.Grid()
        icon_grid.set_row_spacing(35)
        icon_grid.set_column_spacing(35)
        row = 1
        column = 0

        for info in icon_info:
            (name, f) = info
            icon = Gtk.Button()
            self._desktop_icons[name]['icon'] = Gtk.Image.new_from_file(f)
            self._desktop_icons[name]['bwicon'] = desaturate_image(
                Gtk.Image.new_from_file(f))
            icon.set_image(self._desktop_icons[name]['bwicon'])
            attach_cursor_events(icon)

            icon.connect("clicked", self._change_apps_speechbubble_text, name,
                         scene)
            icon_grid.attach(icon, column, row, 1, 1)
            column += 1

            if column >= 7:
                column = 0
                row -= 1

        fixed.put(icon_grid, 40, 380)

        # Pack the speechbubble into a fixed so it the same distance from
        # apps for all resolutions.
        speechbubble_fixed = Gtk.Fixed()
        speechbubble_fixed.set_size_request(1024, 720)
        speechbubble_fixed.put(
            SpeechBubble(text='These are your Apps!\n' +
                         'You can make games, songs,\n' +
                         'artworks and more,\n' + 'then share them to World.',
                         source=SpeechBubble.BOTTOM), 300, 100)

        scene.add_widget(speechbubble_fixed,
                         Placement(0.5, 1),
                         Placement(0.5, 1),
                         name="app_speechbubble")

        return scene
Example #11
0
    def _setup_third_scene(self):

        self._toolbar_icons = {
            "home": {
                "text":
                "Click the Home button to\n" + "return to the desktop.",
                "position": [0, 100],
                "source_align": 0.2
            },
            "help": {
                "text": "If you need Help,\n" + "you can click here.",
                "position": [19, 100],
                "source_align": 0.5
            },
            "profile": {
                "text": "Here's where you can\n" + "sync your online Profile.",
                "position": [38, 100],
                "source_align": 0.5
            },
            "wifi": {
                "text": "You can change Internet\n" + "settings here.",
                "position": [75, 100],
                "source_align": 0.5
            },
            "updater": {
                "text": "Want updates?\n" + "Click on the Updater.",
                "position": [150, 100],
                "source_align": 0.5
            },
            "settings": {
                "text": "And this is where you can change\n" +
                "all the system Settings.",
                "position": [55, 100],
                "source_align": 0.7
            },
            "audio": {
                "text": "Control the volume\n" + "of the system.",
                "position": [150, 100],
                "source_align": 1.0
            }
        }

        self._toolbar_next_button_shown = False

        scene = Scene(self._ctl.main_window)
        scene.set_background(common_media_path('blueprint-bg-4-3.png'),
                             common_media_path('blueprint-bg-16-9.png'))

        self._add_profile_icon(scene)
        self._add_world_icon(scene, offline=(not is_registered()))

        # Pack the speechbubble into a fixed so it the same distance from
        # toolbar for all resolutions
        speechbubble_fixed = Gtk.Fixed()
        speechbubble_fixed.set_size_request(500, 400)
        speechbubble_fixed.put(
            SpeechBubble(
                text='This is your Taskbar!\n' +
                'Click on the different widgets to find\n' +
                'out more about what they do.',
                # 'Use its buttons to change settings,\n' +
                # 'get updates, and more.',
                source=SpeechBubble.BOTTOM),
            0,
            100)
        scene.add_widget(speechbubble_fixed,
                         Placement(1, 1),
                         Placement(1, 1),
                         name="toolbar_speechbubble")

        self._add_taskbar(scene, attach_callbacks=True)

        return scene
Example #12
0
 def is_fulfilled(self):
     return is_registered()
Example #13
0
from kano.gtk3.labelled_entries import LabelledEntries

from kano_profile.paths import bin_dir
from kano_profile.profile import load_profile, save_profile_variable
from kano_profile.tracker import save_hardware_info, save_kano_version
from kano_world.functions import (login as login_, is_registered,
                                  reset_password, get_email,
                                  get_mixed_username)

from kano_login.templates.kano_button_box import KanoButtonBox
from kano_login.swag_screen import SwagScreen

from kano_registration_gui.RegistrationScreen1 import RegistrationScreen1

profile = load_profile()
force_login = is_registered() and 'kanoworld_username' in profile


class Login(Gtk.Box):
    width = 550

    def __init__(self, win, prev_screen=None, first_boot=False):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        self.win = win
        self.win.set_main_widget(self)
        self.win.set_decorated(True)
        self.win.set_size_request(self.width, -1)
        self.first_boot = first_boot

        self.heading = Heading(_("Login"),
Example #14
0
    def send_feedback(self, button=None, event=None, body_title=None):
        '''
        Sends all the information
        Shows a dialogue when Report mode
        Runs a thread for the spinner button and mouse
        '''
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:

            self.check_login()
            if not is_registered():
                self.after_feedback_sent(completed=False)
                return

            if self.bug_report:
                title = _("Important")  # noqa: F821
                description = _(  # noqa: F821
                    "Your feedback will include debugging information.\n"
                    "Do you want to continue?"
                )
                kdialog = KanoDialog(
                    title, description,
                    {
                        _("CANCEL"):  # noqa: F821
                        {
                            "return_value": 1
                        },
                        _("OK"):  # noqa: F821
                        {
                            "return_value": 0
                        }
                    },
                    parent_window=self
                )
                rc = kdialog.run()
                if rc != 0:
                    # Enable button and refresh
                    button.set_sensitive(True)
                    Gtk.main_iteration()
                    return

            self.set_cursor_to_watch()
            self._send_button.start_spinner()
            self._send_button.set_sensitive(False)
            self._text.set_sensitive(False)

            def lengthy_process():
                button_dict = {
                    _("OK"): {  # noqa: F821
                        "return_value": self.CLOSE_FEEDBACK
                    }
                }

                if not is_internet():
                    title = _("No internet connection")  # noqa: F821
                    description = _("Configure your connection")  # noqa: F821
                    button_dict = {
                        _("OK"): {  # noqa: F821
                            "return_value": self.LAUNCH_WIFI
                        }
                    }
                else:
                    success, error = self.send_user_info(body_title=body_title)
                    if success:
                        title = _("Info")  # noqa: F821
                        description = _(  # noqa: F821
                            "Feedback sent correctly"
                        )
                        button_dict = {
                            _("OK"): {  # noqa: F821
                                "return_value": self.CLOSE_FEEDBACK
                            }
                        }
                    else:
                        title = _("Info")  # noqa: F821
                        description = _(  # noqa: F821
                            "Something went wrong, error: {}"
                        ).format(error)
                        button_dict = {
                            _("CLOSE FEEDBACK"): {  # noqa: F821
                                "return_value": self.CLOSE_FEEDBACK,
                                "color": "red"
                            },
                            _("TRY AGAIN"): {  # noqa: F821
                                "return_value": self.KEEP_OPEN,
                                "color": "green"
                            }
                        }

                def done(title, description, button_dict):
                    self.set_cursor_to_normal()
                    self._send_button.stop_spinner()
                    self._send_button.set_sensitive(True)
                    self._text.set_sensitive(True)

                    # If the user decides to launch the wifi config,
                    # the window needs to be able to go below kano-settings
                    self.set_keep_above(False)

                    kdialog = KanoDialog(title, description, button_dict,
                                         parent_window=self)
                    kdialog.dialog.set_keep_above(False)
                    response = kdialog.run()

                    if response == self.LAUNCH_WIFI:
                        run_cmd(
                            'sudo /usr/bin/kano-settings 12',
                            localised=True
                        )
                        self.after_feedback_sent(completed=False)
                    elif response == self.CLOSE_FEEDBACK:
                        self.after_feedback_sent(completed=True)

                GObject.idle_add(done, title, description, button_dict)

            thread = threading.Thread(target=lengthy_process)
            thread.start()
Example #15
0
    def send_feedback(self, button=None, event=None, body_title=None):
        '''
        Sends all the information
        Shows a dialogue when Report mode
        Runs a thread for the spinner button and mouse
        '''
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:

            self.check_login()
            if not is_registered():
                self.after_feedback_sent(completed=False)
                return

            if self.bug_report:
                title = _("Important")
                description = _(
                    "Your feedback will include debugging information.\n"
                    "Do you want to continue?")
                kdialog = KanoDialog(title,
                                     description, {
                                         _("CANCEL"): {
                                             "return_value": 1
                                         },
                                         _("OK"): {
                                             "return_value": 0
                                         }
                                     },
                                     parent_window=self)
                rc = kdialog.run()
                if rc != 0:
                    # Enable button and refresh
                    button.set_sensitive(True)
                    Gtk.main_iteration()
                    return

            self.set_cursor_to_watch()
            self._send_button.start_spinner()
            self._send_button.set_sensitive(False)
            self._text.set_sensitive(False)

            def lengthy_process():
                button_dict = {_("OK"): {"return_value": self.CLOSE_FEEDBACK}}

                if not is_internet():
                    title = _("No internet connection")
                    description = _("Configure your connection")
                    button_dict = {_("OK"): {"return_value": self.LAUNCH_WIFI}}
                else:
                    success, error = self.send_user_info(body_title=body_title)
                    if success:
                        title = _("Info")
                        description = _("Feedback sent correctly")
                        button_dict = \
                            {
                                _("OK"):
                                {
                                    "return_value": self.CLOSE_FEEDBACK
                                }
                            }
                    else:
                        title = _("Info")
                        description = _(
                            "Something went wrong, error: {}").format(error)
                        button_dict = \
                            {
                                _("CLOSE FEEDBACK"):
                                {
                                    "return_value": self.CLOSE_FEEDBACK,
                                    "color": "red"
                                },
                                _("TRY AGAIN"):
                                {
                                    "return_value": self.KEEP_OPEN,
                                    "color": "green"
                                }
                            }

                def done(title, description, button_dict):
                    self.set_cursor_to_normal()
                    self._send_button.stop_spinner()
                    self._send_button.set_sensitive(True)
                    self._text.set_sensitive(True)

                    # If the user decides to launch the wifi config,
                    # the window needs to be able to go below kano-settings
                    self.set_keep_above(False)

                    kdialog = KanoDialog(title,
                                         description,
                                         button_dict,
                                         parent_window=self)
                    kdialog.dialog.set_keep_above(False)
                    response = kdialog.run()

                    if response == self.LAUNCH_WIFI:
                        run_cmd('sudo /usr/bin/kano-settings 12',
                                localised=True)
                        self.after_feedback_sent(completed=False)
                    elif response == self.CLOSE_FEEDBACK:
                        self.after_feedback_sent(completed=True)

                GObject.idle_add(done, title, description, button_dict)

            thread = threading.Thread(target=lengthy_process)
            thread.start()
Example #16
0
 def is_fulfilled(self):
     return is_registered()
Example #17
0
from kano_login.swag_screen import SwagScreen
from kano_login.templates.kano_button_box import KanoButtonBox

from kano_profile.paths import bin_dir
from kano_profile.profile import load_profile, save_profile_variable
from kano_profile.tracker import save_hardware_info, save_kano_version

from kano_registration_gui.RegistrationScreen import RegistrationScreen

from kano_world.functions import get_email, get_mixed_username, is_registered, \
    reset_password, recover_username
from kano_world.functions import login as login_

profile = load_profile()
force_login = is_registered() and 'kanoworld_username' in profile


class Login(Gtk.Box):
    width = 550

    def __init__(self, win, prev_screen=None, first_boot=False):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        self.win = win
        self.win.set_main_widget(self)
        self.win.set_decorated(True)
        self.win.set_size_request(self.width, -1)
        self.first_boot = first_boot

        self.heading = Heading(_("Login"),