示例#1
0
    def __init__(self):
        Gtk.Grid.__init__(self)

        self.get_style_context().add_class('password')
        self.set_row_spacing(10)

        title = Heading(_('Select Account'), _('Log in to which account?'))
        self.attach(title.container, 0, 0, 2, 1)

        self.scrolled_window = ScrolledWindow()
        self.scrolled_window.set_size_request(self.WIDTH, self.HEIGHT)
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.box.set_spacing(10)
        self.box.set_margin_left(10)
        self.box.set_margin_right(10)
        self.scrolled_window.add(self.box)
        self.attach(self.scrolled_window, 0, 1, 2, 1)

        self.last_username = get_last_user()
        self._populate()

        self.add_account_btn = OrangeButton(_('Add Account'))
        self.add_account_btn.connect('clicked', self._btn_add_account_pressed)
        self.attach(self.add_account_btn, 0, 2, 1, 1)

        self.shutdown_btn = OrangeButton(_('Shutdown'))
        self.shutdown_btn.connect('clicked', self._btn_shutdown_pressed)
        self.attach(self.shutdown_btn, 1, 2, 1, 1)
    def __init__(self, win):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.win = win
        self.win.set_main_widget(self)
        # Main image
        image = Gtk.Image.new_from_file(media + "/Graphics/no-internet-screen.png")
        # Orange button
        later_button = OrangeButton(_("Later"))
        later_button.connect('button-release-event', self.win.close_window)
        # Green button
        self.kano_button = KanoButton(_("CONNECT NOW"))
        self.kano_button.pack_and_align()
        self.kano_button.connect('button-release-event', self.go_to_wifi)
        self.kano_button.connect('key-release-event', self.go_to_wifi)
        # Text label
        text_align = self.create_text_align()
        # Place elements
        image.set_margin_top(50)
        image.set_margin_bottom(30)
        self.pack_start(image, False, False, 0)
        self.pack_start(text_align, False, False, 2)
        self.pack_start(self.kano_button.align, False, False, 10)
        self.pack_start(later_button, False, False, 3)
        # Refresh window
        self.win.show_all()
示例#3
0
    def __init__(self):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        kano_button_text = _("CREATE")
        skip_button_text = _("Skip")
        login_button_text = _("I have a profile")
        header = _('Keep your creations safe')
        subheader = _(
            'Create a Kano World account so you never lose your progress...\n'
            'and to get inspired by creations from the community')
        img_width = 590
        img_height = 270

        self.skip_button = OrangeButton(skip_button_text)
        self.login_button = OrangeButton(login_button_text)

        image_filename = get_image('login', "", 'first-screen',
                                   str(img_width) + 'x' + str(img_height))
        self.image = Gtk.Image.new_from_file(image_filename)
        self.pack_start(self.image, False, False, 0)

        self.heading = Heading(header, subheader)
        self.kano_button = KanoButton(kano_button_text)

        self.pack_start(self.heading.container, False, False, 0)

        self.button_box = Gtk.ButtonBox(spacing=10)
        self.button_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        self.pack_start(self.button_box, False, False, 0)

        self.button_box.pack_start(self.login_button, False, False, 0)
        self.button_box.pack_start(self.kano_button, False, False, 0)
        self.button_box.pack_start(self.skip_button, False, False, 0)
    def __init__(self, win, char_creator):
        Gtk.EventBox.__init__(self)

        self._win = win

        # Should this be inherited, passed as a variable, or global?
        # Could be a member variable in window.
        # self.char_creator = self._win.get_char_creator()
        self.char_creator = char_creator
        self._win.pack_in_main_content(self.char_creator)
        self.char_creator.reset_selected_menu_items()

        save_changes_button = KanoButton(_("Save changes").upper())
        save_changes_button.connect("clicked", self.save_changes)

        discard_changes_button = OrangeButton(_("Discard").upper())
        discard_changes_button.connect("clicked", self.discard)
        discard_changes_button.set_margin_left(100)
        empty_label = Gtk.Label("")

        button_box = Gtk.ButtonBox()
        button_box.pack_start(discard_changes_button, False, False, 0)
        button_box.pack_start(save_changes_button, False, False, 0)
        button_box.pack_start(empty_label, False, False, 0)

        self._win.pack_in_bottom_bar(button_box)
        self._win.show_all()

        # Hide all the pop ups
        self.char_creator._hide_pop_ups()
示例#5
0
    def __init__(self, win):
        Template.__init__(
            self,
            _("Keyboard"),
            _("Kano keyboard detected"),
            _("APPLY CHANGES")
        )

        self.win = win
        self.win.set_main_widget(self)
        self.win.top_bar.enable_prev()

        # height is 106px
        img = Gtk.Image()
        img.set_from_file(common.media + "/Graphics/keyboard.png")

        # Link to advance options
        self.to_advance_button = OrangeButton(_("Layout options"))
        self.to_advance_button.connect('button_press_event', self.to_advance)

        self.kano_button.connect('button-release-event', self.win.go_to_home)
        self.win.change_prev_callback(self.win.go_to_home)

        self.box.pack_start(img, False, False, 0)
        self.box.pack_start(self.to_advance_button, False, False, 0)

        # Refresh window
        self.win.show_all()
示例#6
0
    def create_parental_button(self):
        desc = (
            _("Use different levels to:\n" \
              "- Block mature content in browser and YouTube\n" \
              "- Or restrict internet access to only Kano World activity")
        ).split('\n')

        self.parental_button = Gtk.CheckButton()
        box = LabelledListTemplate.label_button(
            self.parental_button,
            _("Parental lock"),
            desc[0])

        grid = Gtk.Grid()
        grid.attach(box, 0, 0, 1, 1)

        i = 1

        for text in desc[1:]:
            label = Gtk.Label(text)
            label.set_alignment(xalign=0, yalign=0.5)
            label.set_padding(xpad=25, ypad=0)
            label.get_style_context().add_class('normal_label')
            grid.attach(label, 0, i, 1, 1)
            i = i + 1

        if get_parental_enabled():
            parental_config_button = OrangeButton(_("Configure"))
            parental_config_button.connect('button-press-event',
                                           self.go_to_parental_config)
            grid.attach(parental_config_button, 0, i, 1, 1)

        return grid
示例#7
0
    def __init__(self, win, title, description, original_overscan=None):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.kano_button = KanoButton(_("APPLY CHANGES"))
        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.pack_and_align()

        self.heading = Heading(title, description)
        self.pack_start(self.heading.container, False, False, 0)

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

        self.win.top_bar.enable_prev()

        # Launch pipe for the overscan c code
        launch_pipe()

        self.overscan_values = get_overscan_status()
        self.original_overscan = original_overscan

        # Pass original overscan values between the classes
        # If original_overscan hasn't been generated yet, get it from current
        # overscan status. Alternatively, maybe read this from a file in future
        if original_overscan is None:
            self.original_overscan = get_overscan_status()

        # Reset button
        self.reset_button = OrangeButton()
        reset_icon_path = os.path.join(common.media, '/Icons/reset.png')
        reset_image = Gtk.Image().new_from_file(reset_icon_path)
        self.reset_button.set_image(reset_image)
        self.reset_button.connect('button_press_event', self.reset)
class SetKanoKeyboard(Template):
    def __init__(self, win):
        Template.__init__(
            self,
            _("Keyboard"),
            _("Kano keyboard detected"),
            _("APPLY CHANGES")
        )

        self.win = win
        self.win.set_main_widget(self)
        self.win.top_bar.enable_prev()

        # height is 106px
        img = Gtk.Image()
        img.set_from_file(common.media + "/Graphics/keyboard.png")

        # Link to advance options
        self.to_advance_button = OrangeButton(_("Layout options"))
        self.to_advance_button.connect('button_press_event', self.to_advance)

        self.kano_button.connect('button-release-event', self.win.go_to_home)
        self.win.change_prev_callback(self.win.go_to_home)

        self.box.pack_start(img, False, False, 0)
        self.box.pack_start(self.to_advance_button, False, False, 0)

        # Refresh window
        self.win.show_all()

    def to_advance(self, widget, event):

        self.win.clear_win()
        SetKeyboard(self.win)
示例#9
0
    def __init__(self):
        Gtk.Grid.__init__(self)

        self.get_style_context().add_class('password')
        self.set_row_spacing(10)

        title = Heading(_('Select Account'),
                        _('Log in to which account?'))
        self.attach(title.container, 0, 0, 2, 1)

        self.scrolled_window = ScrolledWindow()
        self.scrolled_window.set_size_request(self.WIDTH, self.HEIGHT)
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.box.set_spacing(10)
        self.box.set_margin_left(10)
        self.box.set_margin_right(10)
        self.scrolled_window.add(self.box)
        self.attach(self.scrolled_window, 0, 1, 2, 1)

        self.last_username = get_last_user()
        self._populate()

        self.add_account_btn = OrangeButton(_('Add Account'))
        self.add_account_btn.connect('clicked', self._btn_add_account_pressed)
        self.attach(self.add_account_btn, 0, 2, 1, 1)

        self.shutdown_btn = OrangeButton(_('Shutdown'))
        self.shutdown_btn.connect('clicked', self._btn_shutdown_pressed)
        self.attach(self.shutdown_btn, 1, 2, 1, 1)
    def __init__(self, kano_button_text, orange_text="", orange_text_2="", orange_text_3=""):

        Gtk.Box.__init__(self)
        self.kano_button = KanoButton(kano_button_text)

        if orange_text != "":
            self.orange_button = OrangeButton(orange_text)
            self.pack_start(self.orange_button, False, False, 0)
            self.pack_start(self.kano_button, False, False, 0)

            if orange_text_2 == "":
                # The empty label is to centre the kano_button
                label = Gtk.Label("    ")
                self.pack_start(label, False, False, 0)
            else:
                self.orange_button2 = OrangeButton(orange_text_2)
                if orange_text_3 == "":
                    self.pack_start(self.orange_button2, False, False, 0)
                else:
                    # If two orange button texts, we align them vertically
                    self.vertbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
                    self.add(self.vertbox)
                    self.orange_button3 = OrangeButton(orange_text_3)
                    self.vertbox.pack_start(self.orange_button2, False, False, 0)
                    self.vertbox.pack_start(self.orange_button3, False, False, 0)
        else:
            self.pack_start(self.kano_button, False, False, 0)
示例#11
0
    def __init__(self, user, greeter):
        Gtk.Grid.__init__(self)

        self.get_style_context().add_class('password')
        self.set_row_spacing(10)

        self.greeter = greeter

        self.user = user
        self.title = self._set_title()

        self.attach(self.title.container, 0, 0, 1, 1)
        self.label = Gtk.Label(user)
        self.label.get_style_context().add_class('login')
        self.attach(self.label, 0, 1, 1, 1)
        self.password = Gtk.Entry()
        self.password.set_visibility(False)
        self.password.set_alignment(0.5)
        self.password.connect('activate', self._login_cb)
        self.attach(self.password, 0, 2, 1, 1)

        self.login_btn = KanoButton(_('Login').upper())
        self.login_btn.connect('clicked', self._login_cb)
        self.attach(self.login_btn, 0, 3, 1, 1)

        # Protect against removing the last Kano user
        # so you do not get locked out from logging into the Kit
        system_users = KanoUserList().get_users()
        if len(system_users) > 1:
            delete_account_btn = OrangeButton(_('Remove Account'))
            delete_account_btn.connect('clicked', self.delete_user)
            self.attach(delete_account_btn, 0, 4, 1, 1)
示例#12
0
    def __init__(self, user, greeter):
        Gtk.Grid.__init__(self)

        self.get_style_context().add_class('password')
        self.set_row_spacing(10)

        self.greeter = greeter

        self.user = user
        self.title = self._set_title()

        self.attach(self.title.container, 0, 0, 1, 1)
        self.label = Gtk.Label(user)
        self.label.get_style_context().add_class('login')
        self.attach(self.label, 0, 1, 1, 1)
        self.password = Gtk.Entry()
        self.password.set_visibility(False)
        self.password.set_alignment(0.5)
        self.password.connect('activate', self._login_cb)
        self.attach(self.password, 0, 2, 1, 1)

        self.login_btn = KanoButton(_('Login').upper())
        self.login_btn.connect('clicked', self._login_cb)
        self.attach(self.login_btn, 0, 3, 1, 1)

        # Protect against removing the last Kano user
        # so you do not get locked out from logging into the Kit
        system_users = KanoUserList().get_users()
        if len(system_users) > 1:
            delete_account_btn = OrangeButton(_('Remove Account'))
            delete_account_btn.connect('clicked', self.delete_user)
            self.attach(delete_account_btn, 0, 4, 1, 1)
示例#13
0
class KanoButtonBox(Gtk.Box):

    def __init__(self, kano_button_text, orange_text="", orange_text_2=""):

        Gtk.Box.__init__(self)
        self.kano_button = KanoButton(kano_button_text)

        if not orange_text == "":
            self.orange_button = OrangeButton(orange_text)
            self.pack_start(self.orange_button, False, False, 0)
            self.pack_start(self.kano_button, False, False, 0)

            if orange_text_2 == "":
                # The empty label is to centre the kano_button
                label = Gtk.Label("    ")
                self.pack_start(label, False, False, 0)
            else:
                self.orange_button2 = OrangeButton(orange_text_2)
                self.pack_start(self.orange_button2, False, False, 0)
        else:
            self.pack_start(self.kano_button, False, False, 0)

    def get_kano_button(self):
        return self.kano_button

    def set_kano_button_cb(self, cb, args=[]):
        self.kano_button.connect('button-release-event', cb, args)

    def set_orange_button_cb(self, cb, args=[]):
        self.orange_button.connect('button-release-event', cb, args)

    def set_orange_button2_cb(self, cb, args=None):
        self.orange_button2.connect('button-release-event', cb, args)
示例#14
0
    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()
示例#15
0
    def __init__(self,
                 num_of_pages=3,
                 selected_page=1,
                 back_text=_("BACK"),
                 next_text=_("NEXT")):

        Gtk.Alignment.__init__(self, xalign=0.5, xscale=0)
        self.num_of_pages = num_of_pages
        self.selected = selected_page

        self._box = Gtk.Box()
        self.add(self._box)

        # The back button has subtly different styling to the next button
        # When the back button is disabled, it goes invisible, while
        # the NEXT button goes grey.
        self._back_button = OrangeButton(back_text)
        self._back_button.connect('clicked', self.back_button_clicked)
        attach_cursor_events(self._back_button)

        self._next_button = OrangeButton(next_text)
        self._next_button.connect('clicked', self.next_button_clicked)
        attach_cursor_events(self._next_button)

        self.dot_box = Gtk.Box()
        self._create_progress_dots(self.selected)
        self._box.pack_start(self._back_button, False, False, 40)
        self._box.pack_start(self.dot_box, False, False, 0)
        self._box.pack_start(self._next_button, False, False, 40)

        if self.selected == 1:
            self._back_button.set_sensitive(False)
        if self.selected == self.num_of_pages:
            self._next_button.set_sensitive(False)
示例#16
0
    def __init__(self, win):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.win = win
        self.win.set_main_widget(self)
        # Main image
        image = Gtk.Image.new_from_file(media + "/Graphics/no-internet-screen.png")
        # Orange button
        later_button = OrangeButton(_("Later"))
        later_button.connect('button-release-event', self.win.close_window)
        # Green button
        self.kano_button = KanoButton(_("CONNECT NOW"))
        self.kano_button.pack_and_align()
        self.kano_button.connect('button-release-event', self.go_to_wifi)
        self.kano_button.connect('key-release-event', self.go_to_wifi)
        # Text label
        text_align = self.create_text_align()
        # Place elements
        image.set_margin_top(50)
        image.set_margin_bottom(30)
        self.pack_start(image, False, False, 0)
        self.pack_start(text_align, False, False, 2)
        self.pack_start(self.kano_button.align, False, False, 10)
        self.pack_start(later_button, False, False, 3)
        # Refresh window
        self.win.show_all()
示例#17
0
    def __init__(self):
        Gtk.Box.__init__(self)

        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.get_style_context().add_class('get_data_checkbutton')
        self.checkbutton.set_margin_left(30)

        self.tc_button = OrangeButton(_("I agree to the terms and conditions"))
        self.tc_button.connect('clicked', self._emit_t_and_c_signal)

        self.pack_start(self.checkbutton, False, False, 0)
        self.pack_start(self.tc_button, False, False, 0)
    def add_button(self, label, callback=None):
        if not self._button_box:
            self._button_box = Gtk.Box()
            self._content.pack_start(self._button_box, False, False, 15)

        button = OrangeButton(label)
        if callback:
            button.connect('button_release_event', callback)
            button.connect('key_release_event', callback)
        self._button_box.pack_start(button, False, False, 10)
        self._button_box.set_halign(Gtk.Align.CENTER)
        self._button_box.set_valign(Gtk.Align.CENTER)

        return button
示例#19
0
    def __init__(self, win, original_overscan=None):
        OverscanTemplate.__init__(
            self,
            win,
            _("Overscan"),
            _("This setting lets you adjust your screen's size."),
            original_overscan
        )

        self.win.change_prev_callback(self.go_to_display)

        # Listen for key events
        self.key_press_handler = self.win.connect('key-press-event', self.on_key_press)

        # slider
        self.t_value = Gtk.Label()
        self.t_value.get_style_context().add_class('slider_label')
        self.t_scale = Gtk.HScale.new_with_range(0, get_overscan_limit(), 1)
        self.t_scale.set_value(self.overscan_values['top'])
        self.t_scale.set_size_request(400, 30)
        self.t_scale.connect('value_changed', self.adjust_all)
        self.t_scale.connect('value_changed', self.update_all_values)
        self.t_scale.set_draw_value(False)
        self.update_all_values(self.t_scale)

        box = Gtk.Box()
        box.pack_start(self.t_scale, False, False, 5)
        box.pack_start(self.t_value, False, False, 5)
        box.pack_start(self.reset_button, False, False, 25)

        align = Gtk.Alignment(xalign=0.6, xscale=0, yscale=0, yalign=0.5)
        align.add(box)

        # Advance button
        self.advanced_button = OrangeButton()
        self.advanced_button.connect('button_press_event', self.go_to_advanced)
        self.advanced_button.set_label(_("Advanced"))

        button_box = Gtk.ButtonBox()
        button_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        button_box.pack_start(self.advanced_button, False, False, 15)
        button_box.pack_start(self.kano_button.align, False, False, 15)
        empty_label = Gtk.Label(" ")
        button_box.pack_start(empty_label, False, False, 0)

        self.pack_start(align, True, True, 0)
        self.pack_end(button_box, False, False, 30)

        self.win.show_all()
示例#20
0
    def __init__(self,
                 title,
                 description,
                 button_text,
                 orange_button_text=None):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.sw = ScrolledWindow()
        self.sw.apply_styling_to_widget(wide=False)

        self.title = Heading(title, description)
        self.kano_button = KanoButton(button_text)
        self.kano_button.pack_and_align()

        self.pack_start(self.title.container, False, False, 0)
        self.pack_start(self.sw, True, True, 0)

        if orange_button_text:
            box_align = Gtk.Alignment(xscale=0, xalign=0.5)
            button_box = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL,
                                       spacing=40)

            label = Gtk.Label("")
            self.orange_button = OrangeButton(orange_button_text)
            button_box.pack_start(label, False, False, 0)
            button_box.pack_start(self.kano_button.align, False, False, 0)
            button_box.pack_start(self.orange_button, False, False, 0)

            box_align.add(button_box)
            self.pack_start(box_align, False, False, 0)
        else:
            self.pack_start(self.kano_button.align, False, False, 0)
示例#21
0
    def __init__(self, img_filename, title, description, kano_button_text,
                 orange_button_text):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        if img_filename:
            self.image = Gtk.Image.new_from_file(img_filename)
            self.pack_start(self.image, False, False, 0)

        self.heading = Heading(title, description)
        self.kano_button = KanoButton(kano_button_text)

        self.pack_start(self.heading.container, False, False, 0)

        self.button_box = Gtk.ButtonBox(spacing=10)
        self.button_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        self.button_box.set_margin_bottom(30)
        self.pack_start(self.button_box, False, False, 0)

        if not orange_button_text == "":
            self.orange_button = OrangeButton(orange_button_text)
            self.button_box.pack_start(self.orange_button, False, False, 0)
            self.button_box.pack_start(self.kano_button, False, False, 0)
            # The empty label is to centre the kano_button
            label = Gtk.Label("    ")
            self.button_box.pack_start(label, False, False, 0)
        else:
            self.button_box.pack_start(self.kano_button, False, False, 0)
    def __init__(self, win, title, description, original_overscan=None):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.kano_button = KanoButton("APPLY CHANGES")
        self.kano_button.connect("button-release-event", self.apply_changes)
        self.kano_button.pack_and_align()

        self.heading = Heading(title, description)
        self.pack_start(self.heading.container, False, False, 0)

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

        self.win.top_bar.enable_prev()

        # Launch pipe for the overscan c code
        launch_pipe()

        self.overscan_values = get_overscan_status()
        self.original_overscan = original_overscan

        # Pass original overscan values between the classes
        # If original_overscan hasn't been generated yet, get it from current overscan status
        # Alternatively, maybe read this from a file in future
        if original_overscan is None:
            self.original_overscan = get_overscan_status()

        # Reset button
        self.reset_button = OrangeButton()
        reset_image = Gtk.Image().new_from_file(common.media + "/Icons/reset.png")
        self.reset_button.set_image(reset_image)
        self.reset_button.connect("button_press_event", self.reset)
示例#23
0
    def __add_orange_button(self, orange_info, kano_button_box):
        orange_text = orange_info['name']
        orange_return_value = orange_info['return_value']

        button_container = Gtk.ButtonBox(spacing=10)
        button_container.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        self.orange_button = OrangeButton(orange_text)
        self.orange_button.connect('button-release-event', self.exit_dialog,
                                   orange_return_value)

        button_container.pack_start(self.orange_button, False, False, 0)
        button_container.pack_start(kano_button_box, False, False, 0)
        # The empty label is to centre the kano_button
        label = Gtk.Label("    ")
        button_container.pack_start(label, False, False, 0)

        return button_container
示例#24
0
    def __init__(self, kano_button_text, orange_text="", orange_text_2=""):

        Gtk.Box.__init__(self)
        self.kano_button = KanoButton(kano_button_text)

        if not orange_text == "":
            self.orange_button = OrangeButton(orange_text)
            self.pack_start(self.orange_button, False, False, 0)
            self.pack_start(self.kano_button, False, False, 0)

            if orange_text_2 == "":
                # The empty label is to centre the kano_button
                label = Gtk.Label("    ")
                self.pack_start(label, False, False, 0)
            else:
                self.orange_button2 = OrangeButton(orange_text_2)
                self.pack_start(self.orange_button2, False, False, 0)
        else:
            self.pack_start(self.kano_button, False, False, 0)
示例#25
0
    def create_parental_button(self):
        desc = (_(" Use different levels to:\n"
                  "- Block mature content in browser and YouTube\n"
                  "- Or restrict internet access to only Kano World activity")
                ).split('\n')

        self.parental_button = Gtk.CheckButton()
        box = LabelledListTemplate.label_button(self.parental_button,
                                                _("Parental lock"), desc[0])

        grid = self._labelled_list_helper(desc, box)

        if get_parental_enabled():
            parental_config_button = OrangeButton(_("Configure"))
            parental_config_button.connect('button-press-event',
                                           self.go_to_parental_config)
            grid.attach(parental_config_button, 0, len(desc), 1, 1)

        return grid
示例#26
0
    def __init__(self,
                 title,
                 description,
                 buttons,
                 is_plug=False,
                 img_path=None):
        super(Template, self).__init__(orientation=Gtk.Orientation.VERTICAL)
        self._focus_widget = None

        heading = Heading(title, description, is_plug, back_btn=False)
        bbox = Gtk.ButtonBox()
        bbox.set_spacing(20)
        bbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
        bbox.set_margin_right(10)
        bbox.set_margin_left(10)

        for b in buttons:
            label = b["label"]

            if not label:
                gtk_button = Gtk.Label()

            else:
                button_type = b["type"]
                callback = b["callback"]

                if button_type == "KanoButton":
                    color = b["color"]
                    gtk_button = KanoButton(label, color=color)
                elif button_type == "OrangeButton":
                    gtk_button = OrangeButton(label)

                gtk_button.connect("clicked", callback)
            bbox.pack_start(gtk_button, False, False, 0)

            if "focus" in b:
                self._focus_widget = gtk_button

        self.pack_start(heading.container, False, False, 0)
        heading.container.set_margin_right(15)
        heading.container.set_margin_left(15)

        if img_path:
            image = Gtk.Image.new_from_file(img_path)

        if is_plug:
            self.pack_start(image, False, False, 10)
            self.pack_start(bbox, False, False, 30)
        else:
            self.pack_start(image, False, False, 20)
            self.pack_end(bbox, False, False, 30)

        self.show_all()
    def __init__(self):
        Gtk.Box.__init__(self)

        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.get_style_context().add_class('get_data_checkbutton')
        self.checkbutton.set_margin_left(30)

        self.tc_button = OrangeButton(_("I agree to the terms and conditions"))
        self.tc_button.connect('clicked', self._emit_t_and_c_signal)

        self.pack_start(self.checkbutton, False, False, 0)
        self.pack_start(self.tc_button, False, False, 0)
    def __init__(self, win, char_creator):
        Gtk.EventBox.__init__(self)

        self._win = win

        # Should this be inherited, passed as a variable, or global?
        # Could be a member variable in window.
        # self.char_creator = self._win.get_char_creator()
        self.char_creator = char_creator
        self._win.pack_in_main_content(self.char_creator)
        self.char_creator.reset_selected_menu_items()

        self._save_changes_button = KanoButton(_("Save changes").upper())
        self._save_changes_button.connect('clicked', self.save_changes)
        self._save_changes_button.set_sensitive(False)

        self.char_creator.connect('character_changed',
                                  self._make_button_sensitive)

        discard_changes_button = OrangeButton(_("Discard").upper())
        discard_changes_button.connect('clicked', self.discard)
        discard_changes_button.set_margin_left(100)
        empty_label = Gtk.Label("")

        button_box = Gtk.ButtonBox()
        button_box.pack_start(discard_changes_button, False, False, 0)
        button_box.pack_start(self._save_changes_button, False, False, 0)
        button_box.pack_start(empty_label, False, False, 0)

        self._win.pack_in_bottom_bar(button_box)
        self._win.show_all()

        # Hide all the pop ups
        self.char_creator._hide_pop_ups()
示例#29
0
class TermsAndConditions(Gtk.Box):
    __gsignals__ = {'t-and-cs-clicked': (GObject.SIGNAL_RUN_FIRST, None, ())}

    def __init__(self):
        Gtk.Box.__init__(self)

        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.get_style_context().add_class('get_data_checkbutton')
        self.checkbutton.set_margin_left(30)

        self.tc_button = OrangeButton(_("I agree to the terms and conditions"))
        self.tc_button.connect('clicked', self._emit_t_and_c_signal)

        self.pack_start(self.checkbutton, False, False, 0)
        self.pack_start(self.tc_button, False, False, 0)

    def is_checked(self):
        return self.checkbutton.get_active()

    def _emit_t_and_c_signal(self, widget):
        self.emit('t-and-cs-clicked')

    def disable_all(self):
        self.checkbutton.set_sensitive(False)
        self.tc_button.set_sensitive(False)

    def enable_all(self):
        self.checkbutton.set_sensitive(True)
        self.tc_button.set_sensitive(True)
示例#30
0
    def __init__(self):
        Gtk.Window.__init__(self, title=self._TITLE)

        apply_common_to_screen()

        window_height = self._IMAGE_HEIGHT + 220
        self.set_size_request(self._IMAGE_WIDTH, window_height)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_position(Gtk.WindowPosition.CENTER)

        self.set_icon_name('kano-updater')

        # Put the window above all the existing ones when it starts
        # FIXME: this needs to happen within a 'realized' signal handler
        #        disabled for now
        #self.get_window().raise_()

        image = Gtk.Image()
        image.set_from_file(self._HEADER_IMAGE)

        background = Gtk.EventBox()
        background.set_size_request(self._IMAGE_WIDTH, self._IMAGE_HEIGHT)
        background.add(image)

        # Header
        heading = Heading(self._HEADING, self._BYLINE)
        heading.description.set_line_wrap(True)

        action = KanoButton(self._ACTION.upper())
        action.connect('clicked', self._do_action)
        action.set_halign(Gtk.Align.CENTER)

        later = OrangeButton(_("Later"))
        later.connect('clicked', self._do_later)
        later.set_halign(Gtk.Align.START)
        later.set_margin_left(40)

        buttons = Gtk.Overlay()
        buttons.add(action)
        buttons.add_overlay(later)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
        box.pack_start(background, False, False, 0)
        box.pack_start(heading.container, False, False, 10)
        box.pack_start(buttons, False, False, 0)

        self.add(box)

        self.show_all()
class TermsAndConditions(Gtk.Box):
    __gsignals__ = {
        't-and-cs-clicked': (GObject.SIGNAL_RUN_FIRST, None, ())
    }

    def __init__(self):
        Gtk.Box.__init__(self)

        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.get_style_context().add_class('get_data_checkbutton')
        self.checkbutton.set_margin_left(30)

        self.tc_button = OrangeButton(_("I agree to the terms and conditions"))
        self.tc_button.connect('clicked', self._emit_t_and_c_signal)

        self.pack_start(self.checkbutton, False, False, 0)
        self.pack_start(self.tc_button, False, False, 0)

    def is_checked(self):
        return self.checkbutton.get_active()

    def _emit_t_and_c_signal(self, widget):
        self.emit('t-and-cs-clicked')

    def disable_all(self):
        self.checkbutton.set_sensitive(False)
        self.tc_button.set_sensitive(False)

    def enable_all(self):
        self.checkbutton.set_sensitive(True)
        self.tc_button.set_sensitive(True)
示例#32
0
    def __init__(self,
                 kano_button_text,
                 orange_text="",
                 orange_text_2="",
                 orange_text_3=""):

        Gtk.Box.__init__(self)
        self.kano_button = KanoButton(kano_button_text)

        if orange_text != "":
            self.orange_button = OrangeButton(orange_text)
            self.pack_start(self.orange_button, False, False, 0)
            self.pack_start(self.kano_button, False, False, 0)

            if orange_text_2 == "":
                # The empty label is to centre the kano_button
                label = Gtk.Label("    ")
                self.pack_start(label, False, False, 0)
            else:
                self.orange_button2 = OrangeButton(orange_text_2)
                if orange_text_3 == "":
                    self.pack_start(self.orange_button2, False, False, 0)
                else:
                    # If two orange button texts, we align them vertically
                    self.vertbox = Gtk.Box(
                        orientation=Gtk.Orientation.VERTICAL, spacing=6)
                    self.add(self.vertbox)
                    self.orange_button3 = OrangeButton(orange_text_3)
                    self.vertbox.pack_start(self.orange_button2, False, False,
                                            0)
                    self.vertbox.pack_start(self.orange_button3, False, False,
                                            0)
        else:
            self.pack_start(self.kano_button, False, False, 0)
示例#33
0
    def __init__(self, stage, now_cb, later_cb):
        super(ParentalScreen, self).__init__(False, 0)

        self.set_hexpand(False)
        self.set_vexpand(False)
        self.set_margin_left(40)
        self.set_margin_right(40)

        heading = Gtk.Label('For parents...')
        add_class(heading, 'console-screen-heading')

        copy = 'You can put a safety filter on Kano\'s internet. ' + \
               'You can set it now or later.'
        desc = Gtk.Label(copy)
        desc.set_line_wrap(True)
        add_class(desc, 'console-screen-desc')

        padlock = Gtk.Image.new_from_file(stage.media_path('padlock.png'))

        later = KanoButton('GOT IT')
        later.connect('clicked', self._cb_wrapper, later_cb,
                      'init-flow-parental-skipped')
        later.set_size_request(200, 50)

        now = OrangeButton('SET NOW')
        now.connect('clicked', self._cb_wrapper, now_cb,
                    'init-flow-parental-set')

        emptylabel = Gtk.Label("       ")

        buttons = Gtk.ButtonBox()
        buttons.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        buttons.pack_start(emptylabel, True, True, 0)
        buttons.pack_start(later, True, True, 20)
        buttons.pack_start(now, True, True, 20)

        self.pack_start(heading, False, False, 30)
        self.pack_start(desc, False, False, 20)
        self.pack_start(padlock, False, False, 10)
        self.pack_start(buttons, True, True, 30)
示例#34
0
    def create_parental_button(self):
        desc = (
            _(" Use different levels to:\n"
              "- Block mature content in browser and YouTube\n"
              "- Or restrict internet access to only Kano World activity")
        ).split('\n')

        self.parental_button = Gtk.CheckButton()
        box = LabelledListTemplate.label_button(
            self.parental_button,
            _("Parental lock"),
            desc[0])

        grid = self._labelled_list_helper(desc, box)

        if get_parental_enabled():
            parental_config_button = OrangeButton(_("Configure"))
            parental_config_button.connect('button-press-event',
                                           self.go_to_parental_config)
            grid.attach(parental_config_button, 0, len(desc), 1, 1)

        return grid
示例#35
0
    def __init__(self):
        Gtk.Window.__init__(self, title=self._TITLE)

        apply_common_to_screen()

        window_height = self._IMAGE_HEIGHT + 220
        self.set_size_request(self._IMAGE_WIDTH, window_height)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_position(Gtk.WindowPosition.CENTER)

        self.set_icon_name('kano-updater')

        # Make sure this window is always above
        self.set_keep_above(True)

        image = Gtk.Image()
        image.set_from_file(self._HEADER_IMAGE)

        background = Gtk.EventBox()
        background.set_size_request(self._IMAGE_WIDTH, self._IMAGE_HEIGHT)
        background.add(image)

        # Header
        heading = Heading(self._HEADING, self._BYLINE)
        heading.description.set_line_wrap(True)

        action = KanoButton(self._ACTION.upper())
        action.connect('clicked', self._do_action)
        action.set_halign(Gtk.Align.CENTER)

        later = OrangeButton(_('Later'))
        later.connect('clicked', Gtk.main_quit)
        later.set_halign(Gtk.Align.START)
        later.set_margin_left(40)

        buttons = Gtk.Overlay()
        buttons.add(action)
        buttons.add_overlay(later)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
        box.pack_start(background, False, False, 0)
        box.pack_start(heading.container, False, False, 10)
        box.pack_start(buttons, False, False, 0)

        self.add(box)

        self.show_all()
    def __init__(self, win, original_overscan=None):
        OverscanTemplate.__init__(
            self,
            win,
            "Overscan",
            "This setting lets you adjust your screen's size.",
            original_overscan
        )

        self.win.change_prev_callback(self.go_to_display)

        # Listen for key events
        self.key_press_handler = self.win.connect("key-press-event", self.on_key_press)

        ## slider
        self.t_value = Gtk.Label()
        self.t_value.get_style_context().add_class("slider_label")
        self.t_scale = Gtk.HScale.new_with_range(0, 100, 1)
        self.t_scale.set_value(self.overscan_values['top'])
        self.t_scale.set_size_request(400, 30)
        self.t_scale.connect('value_changed', self.adjust_all)
        self.t_scale.connect('value_changed', self.update_all_values)
        self.t_scale.set_draw_value(False)
        self.update_all_values(self.t_scale)

        box = Gtk.Box()
        box.pack_start(self.t_scale, False, False, 5)
        box.pack_start(self.t_value, False, False, 5)
        box.pack_start(self.reset_button, False, False, 25)

        align = Gtk.Alignment(xalign=0.6, xscale=0, yscale=0, yalign=0.5)
        align.add(box)

        # Advance button
        self.advanced_button = OrangeButton()
        self.advanced_button.connect("button_press_event", self.go_to_advanced)
        self.advanced_button.set_label("Advanced")

        button_box = Gtk.ButtonBox()
        button_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        button_box.pack_start(self.advanced_button, False, False, 15)
        button_box.pack_start(self.kano_button.align, False, False, 15)
        empty_label = Gtk.Label(" ")
        button_box.pack_start(empty_label, False, False, 0)

        self.pack_start(align, True, True, 0)
        self.pack_end(button_box, False, False, 30)

        self.win.show_all()
示例#37
0
    def __add_orange_button(self, orange_info, kano_button_box):
        orange_text = orange_info["name"]
        orange_return_value = orange_info["return_value"]

        button_container = Gtk.ButtonBox(spacing=10)
        button_container.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        self.orange_button = OrangeButton(orange_text)
        self.orange_button.connect("button-release-event", self.exit_dialog, orange_return_value)

        button_container.pack_start(self.orange_button, False, False, 0)
        button_container.pack_start(kano_button_box, False, False, 0)
        # The empty label is to centre the kano_button
        label = Gtk.Label("    ")
        button_container.pack_start(label, False, False, 0)

        return button_container
    def __init__(self):
        Gtk.Box.__init__(self)

        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.get_style_context().add_class("get_data_checkbutton")
        self.checkbutton.set_size_request(50, 50)
        self.checkbutton.set_margin_left(30)

        self.tc_button = OrangeButton(_("I agree to the terms and conditions"))
        self.tc_button.connect("clicked", self._emit_t_and_c_signal)

        tc_label = self.tc_button.label
        tc_label.set_max_width_chars(20)
        tc_label.set_line_wrap(True)

        self.pack_start(self.checkbutton, False, False, 0)
        self.pack_start(self.tc_button, False, False, 0)
示例#39
0
class KanoButtonBox(Gtk.Box):
    def __init__(self,
                 kano_button_text,
                 orange_text="",
                 orange_text_2="",
                 orange_text_3=""):

        Gtk.Box.__init__(self)
        self.kano_button = KanoButton(kano_button_text)

        if orange_text != "":
            self.orange_button = OrangeButton(orange_text)
            self.pack_start(self.orange_button, False, False, 0)
            self.pack_start(self.kano_button, False, False, 0)

            if orange_text_2 == "":
                # The empty label is to centre the kano_button
                label = Gtk.Label("    ")
                self.pack_start(label, False, False, 0)
            else:
                self.orange_button2 = OrangeButton(orange_text_2)
                if orange_text_3 == "":
                    self.pack_start(self.orange_button2, False, False, 0)
                else:
                    # If two orange button texts, we align them vertically
                    self.vertbox = Gtk.Box(
                        orientation=Gtk.Orientation.VERTICAL, spacing=6)
                    self.add(self.vertbox)
                    self.orange_button3 = OrangeButton(orange_text_3)
                    self.vertbox.pack_start(self.orange_button2, False, False,
                                            0)
                    self.vertbox.pack_start(self.orange_button3, False, False,
                                            0)
        else:
            self.pack_start(self.kano_button, False, False, 0)

    def get_kano_button(self):
        return self.kano_button

    def set_kano_button_cb(self, cb, args=[]):
        self.kano_button.connect('button-release-event', cb, args)

    def set_orange_button_cb(self, cb, args=[]):
        self.orange_button.connect('button-release-event', cb, args)

    def set_orange_button2_cb(self, cb, args=None):
        self.orange_button2.connect('button-release-event', cb, args)

    def set_orange_button3_cb(self, cb, args=None):
        self.orange_button3.connect('button-release-event', cb, args)
示例#40
0
    def add_button(self, label, callback=None):
        if not self._button_box:
            self._button_box = Gtk.Box()
            self._content.pack_start(self._button_box, False, False, 15)

        button = OrangeButton(label)
        if callback:
            button.connect('button_release_event', callback)
            button.connect('key_release_event', callback)
        self._button_box.pack_start(button, False, False, 10)
        self._button_box.set_halign(Gtk.Align.CENTER)
        self._button_box.set_valign(Gtk.Align.CENTER)

        return button
class KanoButtonBox(Gtk.Box):

    def __init__(self, kano_button_text, orange_text="", orange_text_2="", orange_text_3=""):

        Gtk.Box.__init__(self)
        self.kano_button = KanoButton(kano_button_text)

        if orange_text != "":
            self.orange_button = OrangeButton(orange_text)
            self.pack_start(self.orange_button, False, False, 0)
            self.pack_start(self.kano_button, False, False, 0)

            if orange_text_2 == "":
                # The empty label is to centre the kano_button
                label = Gtk.Label("    ")
                self.pack_start(label, False, False, 0)
            else:
                self.orange_button2 = OrangeButton(orange_text_2)
                if orange_text_3 == "":
                    self.pack_start(self.orange_button2, False, False, 0)
                else:
                    # If two orange button texts, we align them vertically
                    self.vertbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
                    self.add(self.vertbox)
                    self.orange_button3 = OrangeButton(orange_text_3)
                    self.vertbox.pack_start(self.orange_button2, False, False, 0)
                    self.vertbox.pack_start(self.orange_button3, False, False, 0)
        else:
            self.pack_start(self.kano_button, False, False, 0)

    def get_kano_button(self):
        return self.kano_button

    def set_kano_button_cb(self, cb, args=[]):
        self.kano_button.connect('button-release-event', cb, args)

    def set_orange_button_cb(self, cb, args=[]):
        self.orange_button.connect('button-release-event', cb, args)

    def set_orange_button2_cb(self, cb, args=None):
        self.orange_button2.connect('button-release-event', cb, args)

    def set_orange_button3_cb(self, cb, args=None):
        self.orange_button3.connect('button-release-event', cb, args)
class TermsAndConditions(Gtk.Box):
    __gsignals__ = {
        't-and-cs-clicked': (GObject.SIGNAL_RUN_FIRST, None, ())
    }

    def __init__(self):
        Gtk.Box.__init__(self)

        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.get_style_context().add_class("get_data_checkbutton")
        self.checkbutton.set_size_request(50, 50)
        self.checkbutton.set_margin_left(30)

        self.tc_button = OrangeButton(_("I agree to the terms and conditions"))
        self.tc_button.connect("clicked", self._emit_t_and_c_signal)

        tc_label = self.tc_button.label
        tc_label.set_max_width_chars(20)
        tc_label.set_line_wrap(True)

        self.pack_start(self.checkbutton, False, False, 0)
        self.pack_start(self.tc_button, False, False, 0)

    def is_checked(self):
        return self.checkbutton.get_active()

    def _emit_t_and_c_signal(self, widget):
        self.emit("t-and-cs-clicked")

    def disable_all(self):
        self.checkbutton.set_sensitive(False)
        self.tc_button.set_sensitive(False)

    def enable_all(self):
        self.checkbutton.set_sensitive(True)
        self.tc_button.set_sensitive(True)
示例#43
0
    def __init__(self, win):

        Template.__init__(self, "", _("to be set"), _("COMPLETE"))

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

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

        internet_img = Gtk.Image()

        # Very hacky way to centre the Proxy button - put spaces in the label
        self.proxy_button = OrangeButton(_("Proxy  "))
        self.proxy_button.connect('button-release-event', self.go_to_proxy)
        self.disable_proxy = OrangeButton(_("Disable proxy"))

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

        internet_status = Gtk.Label()
        internet_status_style = internet_status.get_style_context()
        internet_status.set_alignment(xalign=1, yalign=0.5)

        internet_action = Gtk.Label()
        internet_action_style = internet_action.get_style_context()
        internet_status_style.add_class('internet_status_top')
        internet_action_style.add_class('internet_status_bottom')
        internet_action.set_alignment(xalign=1, yalign=0.5)

        status_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
        status_box.props.valign = Gtk.Align.CENTER

        configure_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)

        container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        container.pack_start(status_box, False, False, 2)
        container.pack_start(internet_img, False, False, 2)
        self.box.pack_start(container, False, False, 0)

        network_info_dict = network_info()
        common.has_internet = is_internet()

        if not common.has_internet or not network_info_dict:
            if network_info_dict:
                description = _("Use the browser to log in or configure proxy")
            else:
                description = _("Configure wireless")

            title = _("Get connected")

            self.add_connection = KanoButton(_("WIFI"))
            self.add_connection.connect('button_release_event', self.configure_wifi)
            # We removed the ability to use keyboard to click, so we also remove ability
            # to get keyboard focus
            self.add_connection.set_can_focus(False)

            # For now, this is removed as the event listener is interefering with the
            # kano-connect
            #self.add_connection.connect("key_release_event", self.configure_wifi)

            status_box.pack_start(self.add_connection, False, False, 0)
            internet_img.set_from_file(common.media + "/Graphics/Internet-noConnection.png")
            internet_status.set_text(_("No network found"))
            self.kano_button.set_label(_("BACK"))

            status_box.pack_start(configure_container, False, False, 3)

            go_to_portal_button = OrangeButton(_("Browser Login"))
            go_to_portal_button.connect('button-press-event', self.cb_launch_browser)
            configure_container.pack_start(go_to_portal_button, False, False, 0)

            divider_label = Gtk.Label("|")
            configure_container.pack_start(divider_label, False, False, 3)

            configure_container.pack_end(self.proxy_button, False, False, 0)

        else:
            self.kano_button.set_label(_("COMPLETE"))

            status_box.pack_start(internet_status, False, False, 3)
            status_box.pack_start(internet_action, False, False, 3)
            status_box.pack_start(configure_container, False, False, 3)

            network = network_info_dict.keys()[0]
            ip = network_info_dict[network]['address']
            network_text = network_info_dict[network]['nice_name']

            internet_img.set_from_file(common.media + "/Graphics/Internet-Connection.png")

            internet_status.set_text(network_text)
            internet_action.set_text(ip)

            go_to_portal_button = OrangeButton(_("Browser Login"))
            go_to_portal_button.connect('button-press-event', self.cb_launch_browser)
            configure_container.pack_start(go_to_portal_button, False, False, 0)

            if network_text == 'Ethernet':
                title = _("Connection found!")
                description = _("You're on a wired network")
                # Change to ethernet image here
                internet_img.set_from_file(common.media + "/Graphics/Internet-ethernetConnection.png")

            else:
                title = _("Connection found!")
                description = _("You're on a wireless network")

                divider_label = Gtk.Label("|")
                configure_container.pack_start(divider_label, False, False, 3)

                configure_button = OrangeButton(_("Configure"))
                configure_button.connect('button_press_event', self.configure_wifi)
                configure_container.pack_start(configure_button, False, False, 0)

            divider_label = Gtk.Label("|")
            configure_container.pack_start(divider_label, False, False, 3)
            configure_container.pack_end(self.proxy_button, False, False, 0)

        self.title.title.set_text(title)
        self.title.description.set_text(description)
        self.win.show_all()
示例#44
0
class SetWifi(Template):
    wifi_connection_attempted = False

    def __init__(self, win):

        Template.__init__(self, "", _("to be set"), _("COMPLETE"))

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

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

        internet_img = Gtk.Image()

        # Very hacky way to centre the Proxy button - put spaces in the label
        self.proxy_button = OrangeButton(_("Proxy  "))
        self.proxy_button.connect('button-release-event', self.go_to_proxy)
        self.disable_proxy = OrangeButton(_("Disable proxy"))

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

        internet_status = Gtk.Label()
        internet_status_style = internet_status.get_style_context()
        internet_status.set_alignment(xalign=1, yalign=0.5)

        internet_action = Gtk.Label()
        internet_action_style = internet_action.get_style_context()
        internet_status_style.add_class('internet_status_top')
        internet_action_style.add_class('internet_status_bottom')
        internet_action.set_alignment(xalign=1, yalign=0.5)

        status_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
        status_box.props.valign = Gtk.Align.CENTER

        configure_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)

        container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        container.pack_start(status_box, False, False, 2)
        container.pack_start(internet_img, False, False, 2)
        self.box.pack_start(container, False, False, 0)

        network_info_dict = network_info()
        common.has_internet = is_internet()

        if not common.has_internet or not network_info_dict:
            if network_info_dict:
                description = _("Use the browser to log in or configure proxy")
            else:
                description = _("Configure wireless")

            title = _("Get connected")

            self.add_connection = KanoButton(_("WIFI"))
            self.add_connection.connect('button_release_event', self.configure_wifi)
            # We removed the ability to use keyboard to click, so we also remove ability
            # to get keyboard focus
            self.add_connection.set_can_focus(False)

            # For now, this is removed as the event listener is interefering with the
            # kano-connect
            #self.add_connection.connect("key_release_event", self.configure_wifi)

            status_box.pack_start(self.add_connection, False, False, 0)
            internet_img.set_from_file(common.media + "/Graphics/Internet-noConnection.png")
            internet_status.set_text(_("No network found"))
            self.kano_button.set_label(_("BACK"))

            status_box.pack_start(configure_container, False, False, 3)

            go_to_portal_button = OrangeButton(_("Browser Login"))
            go_to_portal_button.connect('button-press-event', self.cb_launch_browser)
            configure_container.pack_start(go_to_portal_button, False, False, 0)

            divider_label = Gtk.Label("|")
            configure_container.pack_start(divider_label, False, False, 3)

            configure_container.pack_end(self.proxy_button, False, False, 0)

        else:
            self.kano_button.set_label(_("COMPLETE"))

            status_box.pack_start(internet_status, False, False, 3)
            status_box.pack_start(internet_action, False, False, 3)
            status_box.pack_start(configure_container, False, False, 3)

            network = network_info_dict.keys()[0]
            ip = network_info_dict[network]['address']
            network_text = network_info_dict[network]['nice_name']

            internet_img.set_from_file(common.media + "/Graphics/Internet-Connection.png")

            internet_status.set_text(network_text)
            internet_action.set_text(ip)

            go_to_portal_button = OrangeButton(_("Browser Login"))
            go_to_portal_button.connect('button-press-event', self.cb_launch_browser)
            configure_container.pack_start(go_to_portal_button, False, False, 0)

            if network_text == 'Ethernet':
                title = _("Connection found!")
                description = _("You're on a wired network")
                # Change to ethernet image here
                internet_img.set_from_file(common.media + "/Graphics/Internet-ethernetConnection.png")

            else:
                title = _("Connection found!")
                description = _("You're on a wireless network")

                divider_label = Gtk.Label("|")
                configure_container.pack_start(divider_label, False, False, 3)

                configure_button = OrangeButton(_("Configure"))
                configure_button.connect('button_press_event', self.configure_wifi)
                configure_container.pack_start(configure_button, False, False, 0)

            divider_label = Gtk.Label("|")
            configure_container.pack_start(divider_label, False, False, 3)
            configure_container.pack_end(self.proxy_button, False, False, 0)

        self.title.title.set_text(title)
        self.title.description.set_text(description)
        self.win.show_all()

    def cb_launch_browser(self, control, signal):
        # start the default browser to visit the default page
        launch_browser()

    def go_to_proxy(self, widget, event):
        self.win.clear_win()
        SetProxy(self.win)

    def configure_wifi(self, widget=None, event=None):
        # If is a mouse click event or key pressed is ENTER
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:
            self.kano_button.set_sensitive(True)
            self.wifi_connection_attempted = True

            # Blur window
            self.win.blur()
            self.win.show_all()

            # Force blur to be shown
            while Gtk.events_pending():
                Gtk.main_iteration()

            # Call WiFi config
            os.system('/usr/bin/kano-wifi-gui')

            # Refresh window after WiFi Setup
            self.win.unblur()
            self.win.clear_win()
            SetWifi(self.win)
示例#45
0
    def __init__(self, win):
        # Show the Display brand and model
        self.model = get_edid_name()
        info_message = _("\nScreen Model: {}".format(self.model))

        # And the current display resolution
        try:
            current_resolution = get_status()['resolution']
            info_message += _("\nCurrent Resolution: {}").format(_(current_resolution))
        except:
            pass

        Template.__init__(
            self,
            _("Display"),
            info_message,
            _("APPLY CHANGES")
        )

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

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

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

        horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                       spacing=40)
        horizontal_container.set_valign(Gtk.Align.CENTER)

        # HDMI mode combo box
        self.mode_combo = KanoComboBox(max_display_items=7)
        self.mode_combo.connect('changed', self.on_mode_changed)

        # Fill list of modes
        modes = list_supported_modes()
        self.mode_combo.append('auto')
        mode_string = '{hdmi_group}:{hdmi_mode}  {width}x{height}  {refresh_rate}Hz  {aspect_ratio}'

        if modes:
            for mode in modes:
                self.mode_combo.append(mode_string.format(
                    hdmi_group=mode['group'],
                    hdmi_mode=mode['mode'],
                    width=mode['width'],
                    height=mode['height'],
                    refresh_rate=mode['rate'],
                    aspect_ratio=mode['aspect_ratio']
                ))

        horizontal_container.pack_start(self.mode_combo, False, False, 0)
        self.mode_combo.props.valign = Gtk.Align.CENTER

        # Select the current setting in the dropdown list
        saved_group, saved_mode = read_hdmi_mode()
        active_item = find_matching_mode(modes, saved_group, saved_mode)
        self.mode_combo.set_selected_item_index(active_item)
        self.init_item = active_item
        self.mode_index = active_item
        # Overscan button
        overscan_button = OrangeButton(_("Overscan"))
        horizontal_container.pack_end(overscan_button, False, False, 0)
        overscan_button.connect('button-release-event', self.go_to_overscan)

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

        # Create Flip 180 checkbox
        flip_button = Gtk.CheckButton(_("Flip Screen"))
        flip_button.set_can_focus(False)
        flip_button.props.valign = Gtk.Align.CENTER
        flip_button.set_active(get_screen_value('display_rotate') == 2)
        flip_button.connect('clicked', self.flip)

        self.box.pack_start(flip_button, False, False, 0)
        self.kano_button.set_sensitive(False)

        # Add apply changes button under the main settings content
        self.win.show_all()
    def __init__(self, win):
        # Show the Display brand and model
        self.model = get_model()
        info_message = ' (Changing this requires a reboot)'

        # And the current display resolution
        try:
            current_resolution = get_status()['resolution']
            info_message += '\n\nCurrent resolution: {}'.format(current_resolution)
        except:
            pass

        Template.__init__(
            self,
            "Display",
            self.model + info_message,
            "APPLY CHANGES"
        )

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

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

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

        horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=40)
        horizontal_container.set_valign(Gtk.Align.CENTER)

        # HDMI mode combo box
        self.mode_combo = KanoComboBox(max_display_items=7)
        self.mode_combo.connect("changed", self.on_mode_changed)

        # Fill list of modes
        modes = list_supported_modes()
        self.mode_combo.append("auto")
        if modes:
            for v in modes:
                self.mode_combo.append(v)

        horizontal_container.pack_start(self.mode_combo, False, False, 0)
        self.mode_combo.props.valign = Gtk.Align.CENTER

        # Select the current setting in the dropdown list
        saved_group, saved_mode = read_hdmi_mode()
        active_item = find_matching_mode(modes, saved_group, saved_mode)
        self.mode_combo.set_selected_item_index(active_item)
        self.init_item = active_item
        self.mode_index = active_item
        # Overscan button
        overscan_button = OrangeButton("Overscan")
        horizontal_container.pack_end(overscan_button, False, False, 0)
        overscan_button.connect("button-release-event", self.go_to_overscan)

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

        # Create Flip 180 checkbox 
        flip_button = Gtk.CheckButton("Flip Screen")
        flip_button.set_can_focus(False)
        flip_button.props.valign = Gtk.Align.CENTER
        flip_button.set_active(get_config_value("display_rotate") == 2)
        flip_button.connect("clicked", self.flip)

        self.box.pack_start(flip_button, False, False, 0)
        self.kano_button.set_sensitive(False)

        # Add apply changes button under the main settings content
        self.win.show_all()
示例#47
0
class SetSimpleOverscan(OverscanTemplate):
    def __init__(self, win, original_overscan=None):
        OverscanTemplate.__init__(
            self,
            win,
            _("Overscan"),
            _("This setting lets you adjust your screen's size."),
            original_overscan
        )

        self.win.change_prev_callback(self.go_to_display)

        # Listen for key events
        self.key_press_handler = self.win.connect('key-press-event', self.on_key_press)

        # slider
        self.t_value = Gtk.Label()
        self.t_value.get_style_context().add_class('slider_label')
        self.t_scale = Gtk.HScale.new_with_range(0, get_overscan_limit(), 1)
        self.t_scale.set_value(self.overscan_values['top'])
        self.t_scale.set_size_request(400, 30)
        self.t_scale.connect('value_changed', self.adjust_all)
        self.t_scale.connect('value_changed', self.update_all_values)
        self.t_scale.set_draw_value(False)
        self.update_all_values(self.t_scale)

        box = Gtk.Box()
        box.pack_start(self.t_scale, False, False, 5)
        box.pack_start(self.t_value, False, False, 5)
        box.pack_start(self.reset_button, False, False, 25)

        align = Gtk.Alignment(xalign=0.6, xscale=0, yscale=0, yalign=0.5)
        align.add(box)

        # Advance button
        self.advanced_button = OrangeButton()
        self.advanced_button.connect('button_press_event', self.go_to_advanced)
        self.advanced_button.set_label(_("Advanced"))

        button_box = Gtk.ButtonBox()
        button_box.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        button_box.pack_start(self.advanced_button, False, False, 15)
        button_box.pack_start(self.kano_button.align, False, False, 15)
        empty_label = Gtk.Label(" ")
        button_box.pack_start(empty_label, False, False, 0)

        self.pack_start(align, True, True, 0)
        self.pack_end(button_box, False, False, 30)

        self.win.show_all()

    def reset(self, widget=None, event=None):
        # Restore overscan if any
        if self.original_overscan != self.overscan_values:
            set_overscan_status(self.original_overscan)
            self.t_scale.set_value(self.original_overscan['top'])

    def go_to_advanced(self, event=None, arg=None):

        # Remove key press handler from screen
        self.win.disconnect(self.key_press_handler)
        self.win.clear_win()
        SetAdvancedOverscan(self.win, self.original_overscan)

    def on_key_press(self, widget, event):
        # Right arrow (65363)
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Right:
            self.overscan_values['top'] += 1
            self.overscan_values['bottom'] += 1
            self.overscan_values['left'] += 1
            self.overscan_values['right'] += 1
            set_overscan_status(self.overscan_values)
            self.t_scale.set_value(self.overscan_values['top'])
            return
        # Left arrow (65361)
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Left:
            self.overscan_values['top'] -= 1
            self.overscan_values['bottom'] -= 1
            self.overscan_values['left'] -= 1
            self.overscan_values['right'] -= 1
            set_overscan_status(self.overscan_values)
            self.t_scale.set_value(self.overscan_values['top'])
            return

    def update_all_values(self, widget):
        new_value = str(int(widget.get_value()))
        self.t_value.set_text(new_value)
示例#48
0
    def __init__(self, win):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.win = win
        self.win.set_main_widget(self)
        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        image = Gtk.Image.new_from_file(media + "/Graphics/about-screen.png")

        version_number, os_name = get_current_version()
        os_variant = read_file_contents('/etc/kanux_version_variant')

        version_align = self.create_align(
            "Kano OS: {name} v{version}".format(name=os_name, version=version_number),
            'about_version'
        )
        if os_variant:
            variant_align = self.create_align(
                "{variant}".format(variant=os_variant),
                'about_version'
            )
        space_align = self.create_align(
            _("Disk space used: {used}B / {total}B").format(**get_space_available())
        )
        try:
            celsius = u"{:.1f}\N{DEGREE SIGN}C".format(get_temperature())
        except ValueError:
            celsius = "?"
        temperature_align = self.create_align(
            _(u"Temperature: {celsius}").format(celsius=celsius)
        )
        model_align = self.create_align(
            _("Model: {model}").format(model=get_model_name())
        )

        terms_and_conditions = OrangeButton(_("Terms and conditions"))
        terms_and_conditions.connect(
            'button_release_event', self.show_terms_and_conditions
        )

        credits_button = OrangeButton(_("Meet the team"))
        credits_button.connect(
            'button_release_event', self.show_credits
        )

        self.kano_button = KanoButton(_("BACK"))
        self.kano_button.pack_and_align()

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        hbox.pack_start(terms_and_conditions, False, False, 4)
        hbox.pack_start(credits_button, False, False, 4)
        hbutton_container = Gtk.Alignment(
            xalign=0.5, xscale=0, yalign=0, yscale=0
        )
        hbutton_container.add(hbox)

        image.set_margin_top(10)
        self.pack_start(image, False, False, 10)
        self.pack_start(version_align, False, False, 2)
        if os_variant:
            self.pack_start(variant_align, False, False, 2)
        self.pack_start(space_align, False, False, 1)
        self.pack_start(temperature_align, False, False, 1)
        self.pack_start(model_align, False, False, 1)
        self.pack_start(hbutton_container, False, False, 3)
        self.pack_start(self.kano_button.align, False, False, 10)

        self.kano_button.connect('button-release-event', self.win.go_to_home)
        self.kano_button.connect('key-release-event', self.win.go_to_home)

        # Refresh window
        self.win.show_all()
示例#49
0
class OverscanTemplate(Gtk.Box):
    def __init__(self, win, title, description, original_overscan=None):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.kano_button = KanoButton(_("APPLY CHANGES"))
        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.pack_and_align()

        self.heading = Heading(title, description)
        self.pack_start(self.heading.container, False, False, 0)

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

        self.win.top_bar.enable_prev()

        # Launch pipe for the overscan c code
        launch_pipe()

        self.overscan_values = get_overscan_status()
        self.original_overscan = original_overscan

        # Pass original overscan values between the classes
        # If original_overscan hasn't been generated yet, get it from current
        # overscan status. Alternatively, maybe read this from a file in future
        if original_overscan is None:
            self.original_overscan = get_overscan_status()

        # Reset button
        self.reset_button = OrangeButton()
        reset_icon_path = os.path.join(common.media, '/Icons/reset.png')
        reset_image = Gtk.Image().new_from_file(reset_icon_path)
        self.reset_button.set_image(reset_image)
        self.reset_button.connect('button_press_event', self.reset)

    def apply_changes(self, button, event):
        # NB, write_overscan_values ends the transaction
        write_overscan_values(self.overscan_values)
        self.original_overscan = self.overscan_values

        # Tell user to reboot to see changes
        common.need_reboot = True

        self.go_to_display()

    def adjust(self, adj, varname):
        self.overscan_values[varname] = int(adj.get_value())
        set_overscan_status(self.overscan_values)

    def adjust_all(self, adj):
        self.overscan_values['top'] = int(adj.get_value())
        self.overscan_values['bottom'] = int(adj.get_value())
        self.overscan_values['left'] = int(adj.get_value())
        self.overscan_values['right'] = int(adj.get_value())
        set_overscan_status(self.overscan_values)

    def go_to_display(self, widget=None, button=None):
        self.reset()
        self.win.clear_win()
        SetDisplay(self.win)

    def reset(self, widget=None, event=None):
        pass
示例#50
0
class UserListView(Gtk.Grid):
    HEIGHT = 250
    WIDTH = 1  # not important

    def __init__(self):
        Gtk.Grid.__init__(self)

        self.get_style_context().add_class('password')
        self.set_row_spacing(10)

        title = Heading(_('Select Account'), _('Log in to which account?'))
        self.attach(title.container, 0, 0, 2, 1)

        self.scrolled_window = ScrolledWindow()
        self.scrolled_window.set_size_request(self.WIDTH, self.HEIGHT)
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.box.set_spacing(10)
        self.box.set_margin_left(10)
        self.box.set_margin_right(10)
        self.scrolled_window.add(self.box)
        self.attach(self.scrolled_window, 0, 1, 2, 1)

        self.last_username = get_last_user()
        self._populate()

        self.add_account_btn = OrangeButton(_('Add Account'))
        self.add_account_btn.connect('clicked', self._btn_add_account_pressed)
        self.attach(self.add_account_btn, 0, 2, 1, 1)

        self.shutdown_btn = OrangeButton(_('Shutdown'))
        self.shutdown_btn.connect('clicked', self._btn_shutdown_pressed)
        self.attach(self.shutdown_btn, 1, 2, 1, 1)

    def _populate(self):
        # Populate list
        user_list = KanoUserList()
        for user_name in user_list.get_users():
            logger.debug('adding user {}'.format(user_name))
            self.add_item(user_name)

    def add_item(self, username):
        user = User(username)
        self.box.pack_start(user, False, False, 0)
        if username == self.last_username:
            user.grab_focus()

    def _btn_add_account_pressed(self, event=None, button=None):
        logger.debug('opening new user dialog')
        win = self.get_toplevel()
        win.go_to_newuser()

    def _btn_shutdown_pressed(self, event=None, button=None):
        shutdown_dialog = KanoDialog(
            title_text=_('Shutting down..'),
            description_text=_(
                'Are you sure you want to shutdown your Kano now?'),
            button_dict=[{
                'label': _('Cancel').upper(),
                'color': 'green',
                'return_value': False
            }, {
                'label': _('SHUTDOWN').upper(),
                'color': 'orange',
                'return_value': True
            }])
        shutdown_dialog.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        poweroff = shutdown_dialog.run()

        if poweroff:
            LightDM.shutdown()
class ParentalConfig(Template):
    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()

    def go_to_advanced(self, widget):
        from kano_settings.set_advanced import SetAdvanced

        self.win.clear_win()
        SetAdvanced(self.win)

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

        level = self.parental_level.get_value()
        set_parental_level(level)
        set_setting('Parental-level', level)

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

        if level == 3.0:
            # If on the highest parental control, prompt user to relaunch
            # the browser
            kdialog = KanoDialog(
                title_text='Settings',
                description_text=("If any browsers are open, please relaunch "
                                  "them for this setting to take effect"),
                parent_window=self.win
            )
            kdialog.run()

        else:
            # Only reboot for the lower parental controls
            common.need_reboot = True

        self.win.go_to_home()

    def go_to_blacklist(self, button, event):
        self.win.clear_win()
        AllowedSites(self.win)

    def _value_change_handler(self, gtk_range):
        for level, (title, desc) in enumerate(self._parental_labels):
            style_title = title.get_style_context()
            style_desc = desc.get_style_context()
            if gtk_range.get_value() == level:
                style_title.add_class('parental_activated')
                style_desc.add_class('parental_desc_activated')
                self.blacklist_button.set_sensitive(not level == 3.0)
            else:
                style_title.remove_class('parental_activated')
                style_title.add_class('normal_label')
                style_desc.remove_class('parental_desc_activated')
                style_desc.add_class('normal_label')
示例#52
0
class UserListView(Gtk.Grid):
    HEIGHT = 250
    WIDTH = 1  # not important

    def __init__(self):
        Gtk.Grid.__init__(self)

        self.get_style_context().add_class('password')
        self.set_row_spacing(10)

        title = Heading(_('Select Account'),
                        _('Log in to which account?'))
        self.attach(title.container, 0, 0, 2, 1)

        self.scrolled_window = ScrolledWindow()
        self.scrolled_window.set_size_request(self.WIDTH, self.HEIGHT)
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.box.set_spacing(10)
        self.box.set_margin_left(10)
        self.box.set_margin_right(10)
        self.scrolled_window.add(self.box)
        self.attach(self.scrolled_window, 0, 1, 2, 1)

        self.last_username = get_last_user()
        self._populate()

        self.add_account_btn = OrangeButton(_('Add Account'))
        self.add_account_btn.connect('clicked', self._btn_add_account_pressed)
        self.attach(self.add_account_btn, 0, 2, 1, 1)

        self.shutdown_btn = OrangeButton(_('Shutdown'))
        self.shutdown_btn.connect('clicked', self._btn_shutdown_pressed)
        self.attach(self.shutdown_btn, 1, 2, 1, 1)

    def _populate(self):
        # Populate list
        user_list = KanoUserList()
        for user_name in user_list.get_users():
            logger.debug('adding user {}'.format(user_name))
            self.add_item(user_name)

    def add_item(self, username):
        user = User(username)
        self.box.pack_start(user, False, False, 0)
        if username == self.last_username:
            user.grab_focus()

    def _btn_add_account_pressed(self, event=None, button=None):
        logger.debug('opening new user dialog')
        win = self.get_toplevel()
        win.go_to_newuser()

    def _btn_shutdown_pressed(self, event=None, button=None):
        shutdown_dialog = KanoDialog(title_text='Shutting down..',
                                     description_text='Are you sure you want to shutdown your Kano now?',
                                     button_dict=[
                                         {
                                             'label': _('Cancel').upper(),
                                             'color': 'green',
                                             'return_value': False
                                         },
                                         {
                                             'label': _('SHUTDOWN').upper(),
                                             'color': 'orange',
                                             'return_value': True
                                         }
                                     ])
        shutdown_dialog.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        poweroff = shutdown_dialog.run()

        if poweroff:
            LightDM.shutdown()
示例#53
0
class PageControl(Gtk.Alignment):

    __gsignals__ = {
        'back-button-clicked': (GObject.SIGNAL_RUN_FIRST, None, ()),
        'next-button-clicked': (GObject.SIGNAL_RUN_FIRST, None, ())
    }

    def __init__(self,
                 num_of_pages=3,
                 selected_page=1,
                 back_text=_("BACK"),
                 next_text=_("NEXT")):

        Gtk.Alignment.__init__(self, xalign=0.5, xscale=0)
        self.num_of_pages = num_of_pages
        self.selected = selected_page

        self._box = Gtk.Box()
        self.add(self._box)

        # The back button has subtly different styling to the next button
        # When the back button is disabled, it goes invisible, while
        # the NEXT button goes grey.
        self._back_button = OrangeButton(back_text)
        self._back_button.connect('clicked', self.back_button_clicked)
        attach_cursor_events(self._back_button)

        self._next_button = OrangeButton(next_text)
        self._next_button.connect('clicked', self.next_button_clicked)
        attach_cursor_events(self._next_button)

        self.dot_box = Gtk.Box()
        self._create_progress_dots(self.selected)
        self._box.pack_start(self._back_button, False, False, 40)
        self._box.pack_start(self.dot_box, False, False, 0)
        self._box.pack_start(self._next_button, False, False, 40)

        if self.selected == 1:
            self._back_button.set_sensitive(False)
        if self.selected == self.num_of_pages:
            self._next_button.set_sensitive(False)

        # self.connect('next-button-clicked', self.select_dot)
        # self.connect('back-button-clicked', self.select_dot)

    @property
    def back_button(self):
        return self._back_button

    @property
    def next_button(self):
        return self._next_button

    def disable_buttons(self):
        self._next_button.set_sensitive(False)
        self._back_button.set_sensitive(False)

    def enable_buttons(self):
        self._next_button.set_sensitive(True)
        self._back_button.set_sensitive(True)

    def enable_next(self):
        self._next_button.set_sensitive(True)

    def enable_back(self):
        self._back_button.set_sensitive(True)

    def disable_next(self):
        self._next_button.set_sensitive(False)

    def disable_back(self):
        self._back_button.set_sensitive(False)

    def set_back_button_text(self, text):
        self._back_button.set_label(text)

    def set_next_button_text(self, text):
        self._next_button.set_label(text)

    def get_back_button(self):
        return self._back_button

    def get_next_button(self):
        return self._next_button

    # TODO: these are expanding to fill the parent container.
    def _create_progress_dots(self, index):
        '''Index is a number from1 to 3, and represents which is
        the selected dot (i.e selected page number)
        '''

        logger.debug("Creating dots")

        for child in self.dot_box.get_children():
            self.dot_box.remove(child)

        for i in range(self.num_of_pages):
            if i + 1 == index:
                dot = self.selected_dot()
                dot.set_margin_left(3)
                dot.set_margin_right(3)
                dot.set_margin_top(9)
                dot.set_margin_bottom(9)
            else:
                dot = self.unselected_dot()
                dot.set_margin_left(5)
                dot.set_margin_right(5)
                dot.set_margin_top(11)
                dot.set_margin_bottom(11)

            self.dot_box.pack_start(dot, False, False, 0)

        self.dot_box.show_all()

    def unselected_dot(self):
        '''Produce an unselected grey spot
        '''

        grey_dot = Gtk.EventBox()
        grey_dot.get_style_context().add_class('grey_dot')
        grey_dot.set_size_request(6, 6)
        return grey_dot

    def selected_dot(self):
        '''Produce a selected orange dot
        '''

        orange_dot = Gtk.EventBox()
        orange_dot.get_style_context().add_class('orange_dot')
        orange_dot.set_size_request(10, 10)
        return orange_dot

    # these functions may not be needed
    def select_dot(self, widget, index):
        '''index is the integers 1 - 3, to represent the page numbers
        '''

        if index not in range(self.num_of_pages):
            return

        self._create_progress_dots(index)

        if index == 1:
            self._back_button.set_sensitive(False)
            self._next_button.set_sensitive(True)
        elif index == self.num_of_pages:
            self._next_button.set_sensitive(False)
            self._back_button.set_sensitive(True)
        else:
            self._next_button.set_sensitive(True)
            self._back_button.set_sensitive(True)

        self.show_all()

    # These give external windows a way of knowing when these buttons have been
    # clicked, without mixing up the classes
    def back_button_clicked(self, widget):
        # Are these needed?
        # self.selected -= 1
        self.emit('back-button-clicked')  # , self.selected)

    def next_button_clicked(self, widget):
        # self.selected += 1
        self.emit('next-button-clicked')  # , self.selected)
    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()
示例#55
0
class KanoDialog:
    CSS_PATH = os.path.join(common_css_dir, "dialog.css")

    # button_dict includes the button text, color and button return values
    # It can either be a dictionary for backwards compatibility, or a list
    def __init__(
        self,
        title_text="",
        description_text="",
        button_dict=None,
        widget=None,
        has_entry=False,
        has_list=False,
        scrolled_text="",
        global_style="",
        parent_window=None,
        orange_info=None,
        hide_from_taskbar=False,
    ):

        self.title_text = title_text
        self.description_text = description_text
        self.widget = widget
        self.button_info = button_dict
        self.returnvalue = 0
        self.has_entry = has_entry
        self.has_list = has_list
        self.scrolled_text = scrolled_text
        self.global_style = global_style
        self.parent_window = parent_window
        self.orange_info = orange_info

        self.dialog = Gtk.Dialog()
        self.dialog.set_decorated(False)
        self.dialog.set_resizable(False)

        # TODO: review this - should this always be set?
        # self.dialog.set_keep_above(True)
        self.dialog.set_skip_taskbar_hint(hide_from_taskbar)
        self.dialog.set_border_width(5)

        apply_styling_to_widget(self.dialog, self.CSS_PATH)
        apply_colours_to_widget(self.dialog)

        # if widget or an orange button is added, to get styling correct
        # the global_styling property should be on.
        # TODO: is this needed any more?
        if global_style or (widget is not None or orange_info is not None):
            apply_common_to_screen()

        content_area, action_area = self.__colour_dialog_background()

        self.title = Heading(self.title_text, self.description_text)
        content_area.pack_start(self.title.container, False, False, 0)

        # If button_info is None, or an empty dictionary or list, default to an OK button
        if not self.button_info:
            button_defaults["label"] = _("OK")
            self.button_info = [button_defaults]

        # convert button dictionary to list
        if isinstance(self.button_info, dict):
            self.__convert_dict_to_list()

        kano_button_box = self.__generate_buttons()

        if orange_info is not None:
            button_container = self.__add_orange_button(orange_info, kano_button_box)
        else:
            button_container = Gtk.Alignment()
            button_container.add(kano_button_box)
            # annoying uneven alignment - cannot seem to centre y position
            button_container.set_padding(6, 3, 0, 0)

        action_area.pack_start(button_container, False, False, 0)

        # Add scrolled window
        if self.scrolled_text:
            scrolledwindow = self.__add_scrolled_window()
            content_area.pack_start(scrolledwindow, False, False, 0)

        # or add widget
        elif self.widget is not None:
            content_area.pack_start(self.widget, False, False, 0)

        # Set keyboard focus on first button if no entry
        if not has_entry:
            self.buttons[0].grab_focus()

    def __add_scrolled_window(self):
        text = Gtk.TextView()
        text.get_buffer().set_text(self.scrolled_text)
        text.set_wrap_mode(Gtk.WrapMode.WORD)
        text.set_editable(False)

        scrolledwindow = ScrolledWindow()
        scrolledwindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.add_with_viewport(text)
        scrolledwindow.set_size_request(400, 200)
        scrolledwindow.apply_styling_to_widget(wide=False)

        return scrolledwindow

    def __add_orange_button(self, orange_info, kano_button_box):
        orange_text = orange_info["name"]
        orange_return_value = orange_info["return_value"]

        button_container = Gtk.ButtonBox(spacing=10)
        button_container.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        self.orange_button = OrangeButton(orange_text)
        self.orange_button.connect("button-release-event", self.exit_dialog, orange_return_value)

        button_container.pack_start(self.orange_button, False, False, 0)
        button_container.pack_start(kano_button_box, False, False, 0)
        # The empty label is to centre the kano_button
        label = Gtk.Label("    ")
        button_container.pack_start(label, False, False, 0)

        return button_container

    def __colour_dialog_background(self):
        content_area = self.dialog.get_content_area()
        self.content_background = Gtk.EventBox()
        self.add_style(self.content_background, "white")
        self.content_background.set_size_request(140, 140)
        content_area.reparent(self.content_background)
        action_area = self.dialog.get_action_area()
        self.action_background = Gtk.EventBox()
        self.add_style(self.action_background, "white")
        action_area.reparent(self.action_background)
        action_area.set_layout(Gtk.ButtonBoxStyle.CENTER)

        # Set area around the buttons grey by default
        self.set_action_background("grey")

        container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        container.add(self.content_background)
        container.add(self.action_background)
        self.dialog.add(container)

        return content_area, action_area

    def __convert_dict_to_list(self):
        button_list = []

        for button_name, button_arguments in self.button_info.iteritems():
            button_arguments["label"] = button_name
            button_list.append(button_arguments)

        self.button_info = button_list

    def __generate_buttons(self):
        self.buttons = []
        kano_button_box = Gtk.Box()

        for button in self.button_info:
            for argument, value in button_defaults.iteritems():

                # Use default info if not provided
                if argument not in button:
                    button[argument] = value

                    # Create default return values for OK and CANCEL buttons
                    if argument == "return_value":
                        if hasattr(button, "label"):
                            if button["label"] == _("OK"):
                                button["return_value"] = 0
                            elif button["label"] == _("CANCEL"):
                                button["return_value"] = 1
                    if argument == "color":
                        if button["label"] == _("CANCEL"):
                            button["color"] = "red"

            color = button["color"]
            return_value = button["return_value"]
            button_name = button["label"]

            button = KanoButton(button_name)
            button.set_color(color)
            button.connect("button-release-event", self.exit_dialog, return_value)
            button.connect("key-release-event", self.exit_dialog, return_value)
            self.buttons.append(button)
            kano_button_box.pack_start(button, False, False, 6)

        return kano_button_box

    def add_style(self, widget, app_class):
        apply_styling_to_widget(widget, self.CSS_PATH)
        style = widget.get_style_context()
        style.add_class(app_class)

    def exit_dialog(self, button, event, return_value):
        # 65293 is the ENTER keycode
        if not hasattr(event, "keyval") or event.keyval == 65293:
            self.returnvalue = return_value
            # If we have an entry
            if self.has_entry:
                # We have to click an OK button to get entry value
                # May want to change this logic later to be more flexible
                if unicode(button.get_label().decode("utf8")) == _("OK"):
                    self.returnvalue = self.widget.get_text()
            elif self.has_list:
                # get selected radio button only if press the OK button
                if unicode(button.get_label().decode("utf8")) == _("OK"):
                    self.returnvalue = radio_returnvalue
            # TODO: change the structure so we emit different signals depending on the button clicked
            self.dialog.response(Gtk.ResponseType.OK)

        # Indicate that the signal has been handled
        return True

    def run(self):
        if self.parent_window is not None:
            # Make the dialog always above the parent window
            self.dialog.set_transient_for(self.parent_window)

        if self.parent_window is not None and hasattr(self.parent_window, "blur") and callable(self.parent_window.blur):
            self.parent_window.blur()

        self.dialog.show_all()
        self.dialog.set_icon_name("kano-dialog")
        self.dialog.run()
        self.dialog.destroy()

        if (
            self.parent_window is not None
            and hasattr(self.parent_window, "unblur")
            and callable(self.parent_window.unblur)
        ):
            self.parent_window.unblur()

        return self.returnvalue

    def close(self):
        """
        Use this method if your app is nesting several Kano Dialogs,
        and you need to step through without stacking them up.
        """
        self.dialog.destroy()

        # Dispatch events so Gtk has a chance to close the dialog
        while Gtk.events_pending():
            Gtk.main_iteration()

    def set_text(self, title_text, description_text):
        self.title_text = title_text
        self.description_text = description_text
        self.title.set_text(title_text, description_text)

    def set_action_background(self, color):
        for c in background_colors:
            self.action_background.get_style_context().add_class(c)
        self.action_background.get_style_context().add_class(color)
示例#56
0
    def __init__(self, win):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.win = win
        self.win.set_main_widget(self)
        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        image = Gtk.Image.new_from_file(media + "/Graphics/about-screen.png")

        version_align = self.create_align(
            "Kano OS v.{version}".format(version=get_current_version()),
            'about_version'
        )
        space_align = self.create_align(
            _("Disk space used: {used}B / {total}B").format(**get_space_available())
        )
        try:
            celsius = u"{:.1f}\N{DEGREE SIGN}C".format(get_temperature())
        except ValueError:
            celsius = "?"
        temperature_align = self.create_align(
            _(u"Temperature: {celsius}").format(celsius=celsius)
        )
        model_align = self.create_align(
            _("Model: {model}").format(model=get_model_name())
        )

        terms_and_conditions = OrangeButton(_("Terms and conditions"))
        terms_and_conditions.connect(
            'button_release_event', self.show_terms_and_conditions
        )

        credits_button = OrangeButton(_("Meet the team"))
        credits_button.connect(
            'button_release_event', self.show_credits
        )

        changelog_button = OrangeButton(_("Changelog"))
        changelog_button.connect(
            'button_release_event', self.show_changelog
        )

        self.kano_button = KanoButton(_("BACK"))
        self.kano_button.pack_and_align()

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        hbox.pack_start(terms_and_conditions, False, False, 4)
        hbox.pack_start(credits_button, False, False, 4)
        hbox.pack_start(changelog_button, False, False, 4)
        hbutton_container = Gtk.Alignment(
            xalign=0.5, xscale=0, yalign=0, yscale=0
        )
        hbutton_container.add(hbox)

        image.set_margin_top(10)
        self.pack_start(image, False, False, 10)
        self.pack_start(version_align, False, False, 2)
        self.pack_start(space_align, False, False, 1)
        self.pack_start(temperature_align, False, False, 1)
        self.pack_start(model_align, False, False, 1)
        self.pack_start(hbutton_container, False, False, 3)
        self.pack_start(self.kano_button.align, False, False, 10)

        self.kano_button.connect('button-release-event', self.win.go_to_home)
        self.kano_button.connect('key-release-event', self.win.go_to_home)

        # Refresh window
        self.win.show_all()
示例#57
0
    def _initialise_window(self):
        '''
        Inititlaises the gtk window
        '''
        self.last_click = 0

        self.app_name_opened = 'feedback-widget-opened'
        self.typeahead = None
        self.help_tip_message = _("Type your feedback here!")

        self.rotating_mode = True
        self.in_submit = False

        apply_styling_to_screen(media_dir() + 'css/widget.css')

        ScrolledWindow.apply_styling_to_screen(wide=False)

        self.visible = False
        self.set_hexpand(False)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_keep_above(False)
        self.set_property('skip-taskbar-hint', True)

        self._grid = grid = Gtk.Grid(hexpand=True, vexpand=True)

        qmark = Gtk.Label('?')
        qmark.get_style_context().add_class('qmark')

        qmark_centering = Gtk.Alignment(xalign=0.5, yalign=0.5)
        qmark_centering.add(qmark)

        qmark_box = Gtk.EventBox()
        qmark_box.get_style_context().add_class('qmark_box')
        qmark_box.add(qmark_centering)
        qmark_box.set_size_request(self.HEIGHT_COMPACT, self.HEIGHT_COMPACT)

        grid.attach(qmark_box, 0, 0, 1, 1)

        self._prompt = prompt = Gtk.Label(self.wprompts.get_current_prompt(),
                                          hexpand=False)
        prompt.get_style_context().add_class('prompt')
        prompt.set_justify(Gtk.Justification.LEFT)
        prompt.set_size_request(410, -1)
        prompt.set_line_wrap(True)

        prompt_align = Gtk.Alignment(xalign=0.5, yalign=0.5)
        prompt_align.add(prompt)

        prompt_ebox = Gtk.EventBox()
        prompt_ebox.add(prompt_align)

        grid.attach(prompt_ebox, 1, 0, 2, 1)

        self._x_button = x_button = Gtk.Button('x')
        x_button.set_size_request(20, 20)
        x_button.connect('clicked', self._shrink)
        x_button.get_style_context().add_class('x_button')
        x_button.set_margin_right(20)

        x_button_ebox = Gtk.EventBox()
        x_button_ebox.add(x_button)
        x_button_ebox.connect("realize", self._set_cursor_to_hand_cb)

        x_button_align = Gtk.Alignment(xalign=1, yalign=0.5,
                                       xscale=0, yscale=0)
        x_button_align.add(x_button_ebox)

        grid.attach(x_button_align, 3, 0, 1, 1)

        self._gray_box = gray_box = Gtk.EventBox()
        gray_box.get_style_context().add_class('gray_box')
        gray_box.set_size_request(-1,
                                  self.HEIGHT_EXPANDED - self.HEIGHT_COMPACT)

        gray_box_centering = Gtk.Alignment(xalign=0, yalign=0, xscale=1.0,
                                           yscale=1.0)
        gray_box_centering.add(gray_box)

        grid.attach(gray_box_centering, 0, 1, 1, 2)

        self._ebox = Gtk.EventBox()
        self._ebox.get_style_context().add_class('scrolled_win')
        grid.attach(self._ebox, 1, 1, 2, 1)

        self._pack_input_widget()

        self._send = send = OrangeButton('SEND')
        apply_styling_to_widget(send.label, media_dir() + 'css/widget.css')
        send.set_sensitive(False)
        send.connect('clicked', self._send_clicked)
        send.set_margin_left(10)
        send.set_margin_right(20)
        send.set_margin_top(10)
        send.set_margin_bottom(15)
        send_align = Gtk.Alignment(xalign=1, yalign=0.5, xscale=0, yscale=0)
        send_align.add(send)

        grid.attach(send_align, 3, 2, 1, 1)

        self.set_main_widget(grid)
        self.show_all()

        self._dont_shrink = False
        self._shrink()

        self.connect("focus-out-event", self._shrink)
        self.connect("button-press-event", self._toggle)