Exemplo n.º 1
0
    def __init__(self, title, description, left_btn_text, right_btn_text,
                 buttons_shown):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.title = Heading(title, description)
        self.title.container.set_margin_bottom(0)

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

        self.left_button = KanoButton(left_btn_text, color='orange')
        self.right_button = KanoButton(right_btn_text, color='green')

        kano_button_box = Gtk.ButtonBox()
        kano_button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
        kano_button_box.set_spacing(20)

        if buttons_shown == 2:
            kano_button_box.pack_start(self.left_button, False, False, 0)

        kano_button_box.pack_start(self.right_button, False, False, 0)

        self.pack_start(self.title.container, False, False, 0)
        self.pack_start(self.sw, True, True, 0)
        self.pack_end(kano_button_box, False, False, 0)
Exemplo n.º 2
0
class TwoButtonTemplate(Gtk.Box):
    def __init__(self, title, description, left_btn_text, right_btn_text, buttons_shown):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.title = Heading(title, description)
        self.title.container.set_margin_bottom(0)

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

        self.left_button = KanoButton(left_btn_text, color='orange')
        self.right_button = KanoButton(right_btn_text, color='green')

        kano_button_box = Gtk.ButtonBox()
        kano_button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
        kano_button_box.set_spacing(20)

        if buttons_shown == 2:
            kano_button_box.pack_start(self.left_button, False, False, 0)

        kano_button_box.pack_start(self.right_button, False, False, 0)

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

    def get_right_button(self):
        return self.right_button

    def get_left_button(self):
        return self.left_button
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    def __init__(self):
        ScrolledWindow.__init__(self, hexpand=True, vexpand=True)
        self.set_size_request(500, 300)

        self.contents = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add_with_viewport(self.contents)

        self.devices = []
        self.dev_view = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.contents.pack_start(self.dev_view, False, False, 0)
Exemplo n.º 6
0
    def __init__(self):
        ScrolledWindow.__init__(self, hexpand=True, vexpand=True)
        self.set_size_request(500, 300)

        self.contents = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add_with_viewport(self.contents)

        self.devices = []
        self.dev_view = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.contents.pack_start(self.dev_view, False, False, 0)
Exemplo n.º 7
0
    def setup_application_widgets(self):
        screen = Gdk.Screen.get_default()
        width = screen.get_width()
        height = screen.get_height()

        self.terminal = TerminalUi()
        fg_color = Gdk.Color.parse("#ffffff")[1]
        bg_color = Gdk.Color.parse("#262626")[1]
        self.terminal.set_colors(fg_color, bg_color, [])
        self.terminal.set_margin_top(10)
        self.terminal.set_margin_left(10)
        self.terminal.set_margin_right(10)

        self.spellbook = Spellbook()

        self.story = Storybook(width / 2 - 40,
                               height - self.spellbook.HEIGHT - 2 * 44 - 10)
        self.story.set_margin_top(10)
        self.story.set_margin_left(10)
        self.story.set_margin_right(10)

        story_sw = ScrolledWindow()
        story_sw.apply_styling_to_screen()
        story_sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        story_sw.add(self.story)

        left_background = Gtk.EventBox()
        left_background.get_style_context().add_class("story_background")
        right_background = Gtk.EventBox()
        right_background.get_style_context().add_class("terminal_background")

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        hbox = Gtk.Box()

        vbox.pack_start(hbox, False, False, 0)
        vbox.pack_start(self.spellbook, False, False, 0)
        hbox.pack_start(left_background, False, False, 0)
        hbox.pack_start(right_background, False, False, 0)

        left_background.add(story_sw)
        right_background.add(self.terminal)

        # Allow for margin on bottom and top bar.
        self.terminal.set_size_request(
            width / 2 - 20, height - self.spellbook.HEIGHT - 2 * 44 - 20)
        story_sw.set_size_request(width / 2 - 20,
                                  height - self.spellbook.HEIGHT - 2 * 44 - 10)

        self.run_server()
Exemplo n.º 8
0
    def __init__(self, size_x=400, size_y=150):
        Gtk.Grid.__init__(self)

        self.set_row_spacing(10)
        self.set_column_spacing(10)

        scroll = ScrolledWindow()
        scroll.set_size_request(size_x, size_y)
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self.edit_list_store = Gtk.ListStore(str)
        self.edit_list = Gtk.TreeView(self.edit_list_store)
        self.edit_list.set_headers_visible(False)

        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', True)
        renderer.connect('edited', self._item_edited_handler)
        renderer.connect('editing-started', self._item_edit_started)
        renderer.connect('editing-canceled', self._item_edit_canceled)
        column = Gtk.TreeViewColumn(cell_renderer=renderer, text=0)
        self.edit_list.append_column(column)

        self._add_btn = KanoButton(_("ADD"))
        self._add_btn.connect('button-release-event', self.add)
        self._rm_btn = KanoButton(_("REMOVE"))
        self._set_rm_btn_state()
        self._rm_btn.connect('button-release-event', self.rm)

        scroll.add_with_viewport(self.edit_list)

        self.attach(scroll, 0, 0, 2, 1)
        self.attach(self._add_btn, 0, 1, 1, 1)
        self.attach(self._rm_btn, 1, 1, 1, 1)
Exemplo n.º 9
0
    def setup_application_widgets(self):
        screen = Gdk.Screen.get_default()
        width = screen.get_width()
        height = screen.get_height()

        self.terminal = TerminalUi()
        fg_color = Gdk.Color.parse("#ffffff")[1]
        bg_color = Gdk.Color.parse("#262626")[1]
        self.terminal.set_colors(fg_color, bg_color, [])
        self.terminal.set_margin_top(10)
        self.terminal.set_margin_left(10)
        self.terminal.set_margin_right(10)

        self.spellbook = Spellbook()

        self.story = Storybook(
            width / 2 - 40,
            height - self.spellbook.HEIGHT - 2 * 44 - 10
        )
        self.story.set_margin_top(10)
        self.story.set_margin_left(10)
        self.story.set_margin_right(10)

        story_sw = ScrolledWindow()
        story_sw.apply_styling_to_screen()
        story_sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        story_sw.add(self.story)

        left_background = Gtk.EventBox()
        left_background.get_style_context().add_class("story_background")
        right_background = Gtk.EventBox()
        right_background.get_style_context().add_class("terminal_background")

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        hbox = Gtk.Box()

        vbox.pack_start(hbox, False, False, 0)
        vbox.pack_start(self.spellbook, False, False, 0)
        hbox.pack_start(left_background, False, False, 0)
        hbox.pack_start(right_background, False, False, 0)

        left_background.add(story_sw)
        right_background.add(self.terminal)

        # Allow for margin on bottom and top bar.
        self.terminal.set_size_request(
            width / 2 - 20, height - self.spellbook.HEIGHT - 2 * 44 - 20
        )
        story_sw.set_size_request(
            width / 2 - 20, height - self.spellbook.HEIGHT - 2 * 44 - 10
        )

        self.run_server()
Exemplo n.º 10
0
    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
Exemplo n.º 11
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)
Exemplo n.º 12
0
    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
Exemplo n.º 13
0
    def __init__(self, size_x=400, size_y=150):
        Gtk.Grid.__init__(self)

        self.set_row_spacing(10)
        self.set_column_spacing(10)

        scroll = ScrolledWindow()
        scroll.set_size_request(size_x, size_y)
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self.edit_list_store = Gtk.ListStore(str)
        self.edit_list = Gtk.TreeView(self.edit_list_store)
        self.edit_list.set_headers_visible(False)

        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', True)
        renderer.connect('edited', self._item_edited_handler)
        renderer.connect('editing-started', self._item_edit_started)
        renderer.connect('editing-canceled', self._item_edit_canceled)
        column = Gtk.TreeViewColumn(cell_renderer=renderer, text=0)
        self.edit_list.append_column(column)

        self._add_btn = KanoButton(_("ADD"))
        self._add_btn.connect('button-release-event', self.add)
        self._rm_btn = KanoButton(_("REMOVE"))
        self._set_rm_btn_state()
        self._rm_btn.connect('button-release-event', self.rm)

        scroll.add_with_viewport(self.edit_list)

        self.attach(scroll, 0, 0, 2, 1)
        self.attach(self._add_btn, 0, 1, 1, 1)
        self.attach(self._rm_btn, 1, 1, 1, 1)
Exemplo n.º 14
0
    def __init__(self, category, avatar_parser):
        logger.debug(
            "Initialising pop up menu with category {}".format(category))

        self.top_bar_height = 50

        # Size of the selected icon
        self.button_width = 42
        self.button_height = 42

        self._category = category
        self._parser = avatar_parser
        if self._category == self._parser.char_label:
            self._signal_name = 'character_selected'
        else:
            self._signal_name = 'pop_up_item_selected'
        self._border_path = self._parser.get_selected_border(self._category)
        self._hover_path = self._parser.get_hover_border(self._category)

        obj_names = self._parser.list_avail_objs(self._category)
        SelectMenu.__init__(self, obj_names, self._signal_name)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        # Grid which the buttons are packed into
        self._grid = Gtk.Grid()

        # pack the grid into a sw of a specified height
        sw = ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        sw.apply_styling_to_widget()
        sw.add(self._grid)
        sw.set_size_request(152, 294)

        # Labels the category
        top_bar = self._create_top_bar()
        vbox.pack_start(top_bar, False, False, 0)
        vbox.pack_start(sw, False, False, 10)

        self._pack_items()
        self.show_all()
Exemplo n.º 15
0
        def __init__(self,
                     screen_number=None,
                     screen_name=None,
                     socket_id=0,
                     onescreen=False):
            # Check for internet, if screen is 12 means no internet
            if screen_number == 12 or screen_name == 'no-internet':
                common.has_internet = False
            else:
                common.has_internet = is_internet()

            # Set combobox styling to the screen
            # Is done here so we don't attach the styling multiple times when
            # switching screens
            apply_styling_to_screen(self.CSS_PATH)
            apply_common_to_screen()
            KanoComboBox.apply_styling_to_screen()
            ScrolledWindow.apply_styling_to_screen(wide=True)

            # Set window
            base_class.__init__(self, _("Settings"), self.width, self.height,
                                socket_id)

            self.set_decorated(True)
            self.top_bar = TopBar(_("Settings"))
            self.top_bar.set_close_callback(self.close_window)
            self.prev_handler = None
            self.set_icon_name('kano-settings')

            if self._base_name == "Window":
                self.set_titlebar(self.top_bar)

            self._onescreen = onescreen

            self.connect('delete-event', Gtk.main_quit)
            # In case we are called from kano-world-launcher, terminate splash
            os.system('kano-stop-splash')
            # Init to Home Screen
            HomeScreen(self,
                       screen_number=screen_number,
                       screen_name=screen_name)
Exemplo n.º 16
0
class ScrolledWindowTemplate(Gtk.Box):

    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)

    def get_scrolled_window(self):
        return self.sw
Exemplo n.º 17
0
    def _create_main_box(self, network_list):
        '''Show the screen with the different WiFi networks
        '''

        heading = Heading(
            _("Connect to WiFi"),
            _("Choose a network"),
            self._win.is_plug(),
            back_btn=False
        )

        # This box is to pack everything in the window
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        # For now, pack the network into a scrolled window
        sw = ScrolledWindow()
        sw.apply_styling_to_widget()
        sw.set_size_request(-1, 215)
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self._network_box = self._create_network_box(network_list)
        sw.add(self._network_box)

        # Pack the scrolled window into an event box to give the illusion of a
        # border
        sw_border = self._add_border_to_widget(sw)
        sw_border.set_margin_right(30)
        sw_border.set_margin_left(30)
        sw_border.set_margin_bottom(20)
        sw_border.set_margin_top(10)

        # Then pack all the elements into the vbox
        vbox.pack_start(heading.container, False, False, 0)
        vbox.pack_start(sw_border, False, False, 0)

        # Pack in the refresh connect buttons
        button_box = self._create_refresh_connect_buttons()
        vbox.pack_end(button_box, False, False, 30)

        return vbox
Exemplo n.º 18
0
    def __init__(self, main_win, apps_obj):
        Gtk.EventBox.__init__(self, hexpand=True, vexpand=True)
        style = self.get_style_context()
        style.add_class('app-grid')

        self._win = main_win
        self._apps = apps_obj
        self._num_apps = 0

        self._sw = ScrolledWindow(hexpand=True, vexpand=True,
                                  wide_scrollbar=True)

        self._sw.props.margin_top = 7
        self._sw.props.margin_bottom = 0
        self._sw.props.margin_left = 0
        self._sw.props.margin_right = 0
        self._sw.props.border_width = 0
        self._sw.set_shadow_type(Gtk.ShadowType.NONE)

        self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self._sw.add_with_viewport(self._box)
        self.add(self._sw)
Exemplo n.º 19
0
    def __init__(self, category, avatar_parser):
        logger.debug(
            "Initialising pop up menu with category {}".format(category))

        self.top_bar_height = 50

        # Size of the selected icon
        self.button_width = 42
        self.button_height = 42

        self._category = category
        self._parser = avatar_parser
        if self._category == self._parser.char_label:
            self._signal_name = 'character_selected'
        else:
            self._signal_name = 'pop_up_item_selected'
        self._border_path = self._parser.get_selected_border(self._category)
        self._hover_path = self._parser.get_hover_border(self._category)

        obj_names = self._parser.list_avail_objs(self._category)
        SelectMenu.__init__(self, obj_names, self._signal_name)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        # Grid which the buttons are packed into
        self._grid = Gtk.Grid()

        # pack the grid into a sw of a specified height
        sw = ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        sw.apply_styling_to_widget()
        sw.add(self._grid)
        sw.set_size_request(152, 294)

        # Labels the category
        top_bar = self._create_top_bar()
        vbox.pack_start(top_bar, False, False, 0)
        vbox.pack_start(sw, False, False, 10)

        self._pack_items()
        self.show_all()
Exemplo n.º 20
0
def activate(_win):
    project_list = ProjectList()

    scrolledwindow = ScrolledWindow()
    scrolledwindow.apply_styling_to_widget()
    scrolledwindow.add_with_viewport(project_list.background)
    scrolledwindow.set_size_request(734, 404)

    _box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    _box.pack_start(scrolledwindow, False, False, 0)

    _win.pack_in_main_content(_box)
    _win.show_all()
Exemplo n.º 21
0
        def __init__(self, screen_number=None, screen_name=None,
                     socket_id=0, onescreen=False):
            # Check for internet, if screen is 12 means no internet
            if screen_number == 12 or screen_name == 'no-internet':
                common.has_internet = False
            else:
                common.has_internet = is_internet()

            # Set combobox styling to the screen
            # Is done here so we don't attach the styling multiple times when
            # switching screens
            apply_styling_to_screen(self.CSS_PATH)
            apply_common_to_screen()
            KanoComboBox.apply_styling_to_screen()
            ScrolledWindow.apply_styling_to_screen(wide=True)

            # Set window
            base_class.__init__(self, _("Settings"), self.width,
                                self.height, socket_id)

            self.set_decorated(True)
            self.top_bar = TopBar(_("Settings"))
            self.top_bar.set_close_callback(self.close_window)
            self.prev_handler = None
            self.set_icon_name('kano-settings')

            if self._base_name == "Window":
                self.set_titlebar(self.top_bar)

            self._onescreen = onescreen

            self.connect('delete-event', Gtk.main_quit)
            # In case we are called from kano-world-launcher, terminate splash
            os.system('kano-stop-splash')
            # Init to Home Screen
            HomeScreen(self, screen_number=screen_number, screen_name=screen_name)
Exemplo n.º 22
0
    def __setup_application_widgets(self):
        screen = Gdk.Screen.get_default()

        self.__spellbook = Spellbook(is_caps_lock_on=self.__is_caps_lock_on)

        width = screen.get_width()
        height = screen.get_height()
        terminal_width, terminal_height = width / 2 - 20, height - self.__spellbook.HEIGHT - 2 * 44 - 20
        story_width, story_height = width / 2 - 20, height - self.__spellbook.HEIGHT - 2 * 44 - 10
        self.__terminal = TerminalUi(terminal_width, terminal_height)
        self.__story = Storybook(story_width, story_height)

        self.hbox = Gtk.Box()

        story_sw = ScrolledWindow()
        story_sw.apply_styling_to_screen()
        story_sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        story_sw.add(self.__story)
        story_sw.set_size_request(story_width, story_height)

        left_background = Gtk.EventBox()
        left_background.get_style_context().add_class("story_background")
        left_background.add(story_sw)

        right_background = Gtk.EventBox()
        right_background.get_style_context().add_class("terminal_background")

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        vbox.pack_start(self.hbox, False, False, 0)
        vbox.pack_start(self.__spellbook, False, False, 0)
        self.hbox.pack_start(left_background, False, False, 0)
        self.hbox.pack_start(right_background, False, False, 0)

        right_background.add(self.__terminal)
Exemplo n.º 23
0
    def _generate_grid(self):
        row_count = int(math.ceil(
            float(len(self._DISPLAYED_SCREENS)) / self._col_count)
        )

        table = Gtk.Table(row_count, self._col_count, homogeneous=True,
                          hexpand=True, vexpand=True)
        table.props.margin = 0

        for idx, screen in enumerate(self._DISPLAYED_SCREENS):
            row = idx / 2
            col = idx % 2

            screen.create_menu_button(self._change_screen_cb)

            if row % 2:
                style_class = 'appgrid_grey'
            else:
                style_class = 'appgrid_white'

            screen.menu_button.button.get_style_context().add_class(style_class)

            screen.refresh_menu_button()

            table.attach(screen.menu_button.button,
                         col, col + 1, row, row + 1,
                         Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND,
                         Gtk.AttachOptions.FILL, 0, 0)


        scrolled_window = ScrolledWindow(wide_scrollbar=True, vexpand=True,
                                         hexpand=True)
        scrolled_window.get_style_context().add_class('app-grid')
        scrolled_window.add_with_viewport(table)

        return scrolled_window
Exemplo n.º 24
0
    def __setup_application_widgets(self):
        screen = Gdk.Screen.get_default()

        self.__spellbook = Spellbook(is_caps_lock_on=self.__is_caps_lock_on)

        width = screen.get_width()
        height = screen.get_height()
        terminal_width, terminal_height = width / 2 - 20, height - self.__spellbook.HEIGHT - 2 * 44 - 20
        story_width, story_height = width / 2 - 20, height - self.__spellbook.HEIGHT - 2 * 44 - 10
        self.__terminal = TerminalUi(terminal_width, terminal_height)
        self.__story = Storybook(story_width, story_height)

        self.hbox = Gtk.Box()

        story_sw = ScrolledWindow()
        story_sw.apply_styling_to_screen()
        story_sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        story_sw.add(self.__story)
        story_sw.set_size_request(story_width, story_height)

        left_background = Gtk.EventBox()
        left_background.get_style_context().add_class("story_background")
        left_background.add(story_sw)

        right_background = Gtk.EventBox()
        right_background.get_style_context().add_class("terminal_background")

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        vbox.pack_start(self.hbox, False, False, 0)
        vbox.pack_start(self.__spellbook, False, False, 0)
        self.hbox.pack_start(left_background, False, False, 0)
        self.hbox.pack_start(right_background, False, False, 0)

        right_background.add(self.__terminal)
Exemplo n.º 25
0
    def __init__(self, main_win, apps_obj):
        Gtk.EventBox.__init__(self, hexpand=True, vexpand=True)
        style = self.get_style_context()
        style.add_class('app-grid')

        self._win = main_win
        self._apps = apps_obj
        self._num_apps = 0

        self._sw = ScrolledWindow(hexpand=True, vexpand=True,
                                  wide_scrollbar=True)

        self._sw.props.margin_top = 7
        self._sw.props.margin_bottom = 0
        self._sw.props.margin_left = 0
        self._sw.props.margin_right = 0
        self._sw.props.border_width = 0
        self._sw.set_shadow_type(Gtk.ShadowType.NONE)

        self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self._sw.add_with_viewport(self._box)
        self.add(self._sw)
Exemplo n.º 26
0
    def _generate_grid(self):
        row_count = int(
            math.ceil(float(len(self._DISPLAYED_SCREENS)) / self._col_count))

        table = Gtk.Table(row_count,
                          self._col_count,
                          homogeneous=True,
                          hexpand=True,
                          vexpand=True)
        table.props.margin = 0

        for idx, screen in enumerate(self._DISPLAYED_SCREENS):
            row = idx / 2
            col = idx % 2

            screen.create_menu_button(self._change_screen_cb)

            if row % 2:
                style_class = 'appgrid_grey'
            else:
                style_class = 'appgrid_white'

            screen.menu_button.button.get_style_context().add_class(
                style_class)

            screen.refresh_menu_button()

            table.attach(screen.menu_button.button, col, col + 1, row, row + 1,
                         Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND,
                         Gtk.AttachOptions.FILL, 0, 0)

        scrolled_window = ScrolledWindow(wide_scrollbar=True,
                                         vexpand=True,
                                         hexpand=True)
        scrolled_window.get_style_context().add_class('app-grid')
        scrolled_window.add_with_viewport(table)

        return scrolled_window
Exemplo n.º 27
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()
Exemplo n.º 28
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_alignment(0.1, 0.5)
        prompt.set_size_request(410, -1)
        prompt.set_line_wrap(True)

        prompt_container = Gtk.Table(1, 1, False)
        prompt_container.attach(prompt, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)

        grid.attach(prompt_container, 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)
Exemplo n.º 29
0
class AppGrid(Gtk.EventBox):
    def __init__(self, main_win, apps_obj):
        Gtk.EventBox.__init__(self, hexpand=True, vexpand=True)
        style = self.get_style_context()
        style.add_class('app-grid')

        self._win = main_win
        self._apps = apps_obj
        self._num_apps = 0

        self._sw = ScrolledWindow(hexpand=True,
                                  vexpand=True,
                                  wide_scrollbar=True)

        self._sw.props.margin_top = 7
        self._sw.props.margin_bottom = 0
        self._sw.props.margin_left = 0
        self._sw.props.margin_right = 0
        self._sw.props.border_width = 0
        self._sw.set_shadow_type(Gtk.ShadowType.NONE)

        self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self._sw.add_with_viewport(self._box)
        self.add(self._sw)

    def new_entry(self, app, sort_by="title", reverse=False):
        if "colour" not in app:
            if (self._num_apps % 2) == 0:
                app["colour"] = "#f2914a"
            else:
                app["colour"] = "#f5a269"
            self._num_apps += 1

        entry = AppGridEntry(app, self._win, self._apps)
        self._box.pack_start(entry, False, False, 0)

        pos = 0
        for child in self._box:
            child_app_data = child.get_app_data()

            # keep the special "want-more" entry at the bottom of the list
            if "slug" in child_app_data and \
               child_app_data["slug"] == "want-more":
                break

            if reverse:
                if app[sort_by] > child_app_data[sort_by]:
                    break
            else:
                if app[sort_by] < child_app_data[sort_by]:
                    break

            pos += 1

        self._box.reorder_child(entry, pos)

        entry.show_all()
        return entry

    def get_num(self):
        return self._num_apps
Exemplo n.º 30
0
    def report_window(self):
        '''
        Report window
        Contains 2 text views and Take Screenshot, Add Image and Send buttons
        '''
        ApplicationWindow.__init__(
            self,
            _('Report a Problem'),  # noqa: F821
            self.WIDTH,
            0.35
        )

        screen = Gdk.Screen.get_default()
        specific_provider = Gtk.CssProvider()
        specific_provider.load_from_path(Media.media_dir() + 'css/style.css')
        style_context = Gtk.StyleContext()
        style_context.add_provider_for_screen(screen, specific_provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_USER)

        self.set_icon_name("feedback")
        self._grid = Gtk.Grid()

        # Create top bar
        self._top_bar = TopBar(
            title=_("Report a Problem"),  # noqa: F821
            window_width=self.WIDTH,
            has_buttons=False
        )
        self._top_bar.set_close_callback(Gtk.main_quit)
        self.set_decorated(True)
        self.set_titlebar(self._top_bar)

        self.entry = Gtk.Entry()
        self.entry.props.placeholder_text = \
            _("Add subject (optional)")  # noqa: F821
        self.entry.set_margin_left(20)
        self.entry.set_margin_right(20)
        self.entry.set_margin_top(20)
        self.entry.set_margin_bottom(10)
        self._grid.attach(self.entry, 0, 0, 1, 1)

        # Create Text view
        self._text = Gtk.TextView()
        self._text.set_editable(True)
        self._text.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        self._text.set_size_request(self.WIDTH, -1)

        self._textbuffer = self._text.get_buffer()
        self._textbuffer.set_text(
            _("Type your problem here!")  # noqa: F821
        )

        self._clear_buffer_handler_id = self._textbuffer.connect(
            "insert-text", self.clear_buffer
        )

        scrolledwindow = ScrolledWindow()
        scrolledwindow.set_vexpand(True)
        scrolledwindow.set_policy(
            Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC
        )
        scrolledwindow.apply_styling_to_widget()
        scrolledwindow.add(self._text)
        scrolledwindow.set_margin_left(2)
        scrolledwindow.set_margin_right(2)
        scrolledwindow.set_margin_top(2)
        scrolledwindow.set_margin_bottom(2)

        # Very hacky way to get a border: create a grey event box
        # which is a little bigger than the widget below
        border = Gtk.EventBox()
        border.get_style_context().add_class("grey")
        border.add(scrolledwindow)
        self._grid.attach(border, 0, 1, 1, 1)
        border.set_margin_left(20)
        border.set_margin_right(20)
        border.set_margin_top(10)
        border.set_margin_bottom(20)

        # Create take screenshot button
        self._screenshot_button = KanoButton(
            _("TAKE SCREENSHOT"),  # noqa: F821
            "blue"
        )
        self._screenshot_button.set_sensitive(True)
        self._screenshot_button.connect("button_press_event",
                                        self.screenshot_clicked)

        # Create attach screenshot button
        self._attach_button = KanoButton(
            _("ADD IMAGE"),  # noqa: F821
            "blue"
        )
        self._attach_button.set_sensitive(True)
        self._attach_button.connect("button_press_event", self.attach_clicked)

        # Create send button
        self._send_button = KanoButton(
            _("SEND")  # noqa: F821
        )
        self._send_button.set_sensitive(False)
        self._send_button.connect("button_press_event", self.send_feedback)
        self._send_button.pack_and_align()
        self._send_button.set_margin(10, 0, 10, 0)

        self.screenshot_box = Gtk.ButtonBox()
        self.screenshot_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
        self.screenshot_box.set_spacing(20)
        self.pack_screenshot_buttons()
        self.screenshot_box.set_margin_bottom(20)

        self._grid.attach(self.screenshot_box, 0, 2, 1, 1)

        # Create grey box to put the button in
        self.bottom_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.bottom_box.pack_start(self._send_button.align, False, False, 0)

        bottom_background = Gtk.EventBox()
        bottom_background.get_style_context().add_class("grey")
        bottom_background.add(self.bottom_box)

        self._grid.attach(bottom_background, 0, 3, 1, 1)

        self._grid.set_row_spacing(0)
        self.set_main_widget(self._grid)

        # kano-profile stat collection
        try:
            from kano_profile.badges import increment_app_state_variable_with_dialog
            increment_app_state_variable_with_dialog(
                'kano-feedback', 'starts', 1
            )
        except Exception:
            pass
Exemplo n.º 31
0
    def contact_window(self):
        '''
        Contact Us window
        Contains text view and a Send button
        '''
        # delete the directory containing all the info we'll send, and recreate
        delete_tmp_dir()
        create_tmp_dir()

        ApplicationWindow.__init__(
            self,
            _('Contact Us'),  # noqa: F821
            self.WIDTH,
            0.35
        )

        screen = Gdk.Screen.get_default()
        specific_provider = Gtk.CssProvider()
        specific_provider.load_from_path(Media.media_dir() + 'css/style.css')
        style_context = Gtk.StyleContext()
        style_context.add_provider_for_screen(screen, specific_provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_USER)

        # Make sure this window has no icon in the task bar
        # so it plays nice with kdesk-blur
        self.set_property('skip-taskbar-hint', True)

        self._grid = Gtk.Grid()

        # Create top bar
        self._top_bar = TopBar(
            title=_("Contact Us"),  # noqa: F821
            window_width=self.WIDTH,
            has_buttons=False
        )
        self._top_bar.set_close_callback(Gtk.main_quit)
        self.set_decorated(True)
        self.set_titlebar(self._top_bar)

        # Create Text view
        self._text = Gtk.TextView()
        self._text.set_editable(True)
        self._text.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        self._text.set_size_request(self.WIDTH, -1)

        self._textbuffer = self._text.get_buffer()
        self._textbuffer.set_text(
            _("Type your feedback here!")  # noqa: F821
        )
        self._clear_buffer_handler_id = self._textbuffer.connect(
            "insert-text", self.clear_buffer
        )

        scrolledwindow = ScrolledWindow()
        scrolledwindow.set_vexpand(True)
        scrolledwindow.set_policy(Gtk.PolicyType.NEVER,
                                  Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.apply_styling_to_widget()
        scrolledwindow.add(self._text)
        scrolledwindow.set_margin_left(2)
        scrolledwindow.set_margin_right(2)
        scrolledwindow.set_margin_top(2)
        scrolledwindow.set_margin_bottom(2)

        # Very hacky way to get a border: create a grey event box
        # which is a little bigger than the widget below
        border = Gtk.EventBox()
        border.get_style_context().add_class("grey")
        border.add(scrolledwindow)
        self._grid.attach(border, 0, 0, 1, 1)
        border.set_margin_left(20)
        border.set_margin_right(20)
        border.set_margin_top(10)
        border.set_margin_bottom(20)

        # Create send button
        self._send_button = KanoButton(
            _("SEND")  # noqa: F821
        )
        self._send_button.set_sensitive(False)
        self._send_button.connect("button_press_event", self.send_feedback)
        self._send_button.pack_and_align()
        self._send_button.align.set_padding(10, 10, 0, 0)

        bottom_background = Gtk.EventBox()
        bottom_background.get_style_context().add_class("grey")
        bottom_background.add(self._send_button.align)

        self._grid.attach(bottom_background, 0, 1, 1, 1)

        self._grid.set_row_spacing(0)
        self.set_main_widget(self._grid)

        # kano-profile stat collection
        try:
            from kano_profile.badges import \
                increment_app_state_variable_with_dialog
            increment_app_state_variable_with_dialog(
                'kano-feedback', 'starts', 1
            )
        except Exception:
            pass
Exemplo n.º 32
0
    def __init__(self, border_width=2):
        Gtk.EventBox.__init__(self)

        # Very hacky way to get a border (gg GTK): create a grey event box
        # which is a little bigger than the white event box containing the
        # widget
        apply_styling_to_screen(
            os.path.join(common_css_dir, 'multiline_entry.css')
        )
        self.get_style_context().add_class('gray-box')
        widget_box = Gtk.EventBox()
        widget_box.get_style_context().add_class('white-box')
        widget_box.set_margin_left(border_width)    # gray border width (px)
        widget_box.set_margin_right(border_width)
        widget_box.set_margin_top(border_width)
        widget_box.set_margin_bottom(border_width)
        self.add(widget_box)

        # putting the TextView into a ScrolledWindow so it doesn't resize
        # horiz & vert
        scrolled_window = ScrolledWindow()
        scrolled_window.set_vexpand(True)
        scrolled_window.set_hexpand(True)
        scrolled_window.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC
        )
        scrolled_window.apply_styling_to_widget()
        widget_box.add(scrolled_window)

        # creating the actual TextView
        self.text_view = Gtk.TextView()
        # break on words, then chars
        self.text_view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        # the white border inside the thin gray border
        self.text_view.set_margin_left(10)
        self.text_view.set_margin_right(10)
        self.text_view.set_margin_top(10)
        self.text_view.set_margin_bottom(10)
        scrolled_window.add(self.text_view)

        # placeholder text logic
        self.placeholder_text = None
        self.placeholder_text_set = False
        self.restore_buffer_handler_id = None
        self.clear_buffer_handler_id = None

        self.text_view.set_buffer(KanoTextBuffer())
        text_buffer = self.text_view.get_buffer()
        text_buffer.connect('changed', self._on_changed)
Exemplo n.º 33
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)
Exemplo n.º 34
0
    def __init__(self, border_width=2):
        Gtk.EventBox.__init__(self)

        # Very hacky way to get a border (gg GTK): create a grey event box
        # which is a little bigger than the white event box containing the
        # widget
        apply_styling_to_screen(
            os.path.join(common_css_dir, 'multiline_entry.css')
        )
        self.get_style_context().add_class('gray-box')
        widget_box = Gtk.EventBox()
        widget_box.get_style_context().add_class('white-box')
        widget_box.set_margin_left(border_width)    # gray border width (px)
        widget_box.set_margin_right(border_width)
        widget_box.set_margin_top(border_width)
        widget_box.set_margin_bottom(border_width)
        self.add(widget_box)

        # putting the TextView into a ScrolledWindow so it doesn't resize
        # horiz & vert
        scrolled_window = ScrolledWindow()
        scrolled_window.set_vexpand(True)
        scrolled_window.set_hexpand(True)
        scrolled_window.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC
        )
        scrolled_window.apply_styling_to_widget()
        widget_box.add(scrolled_window)

        # creating the actual TextView
        self.text_view = Gtk.TextView()
        # break on words, then chars
        self.text_view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        # the white border inside the thin gray border
        self.text_view.set_margin_left(10)
        self.text_view.set_margin_right(10)
        self.text_view.set_margin_top(10)
        self.text_view.set_margin_bottom(10)
        scrolled_window.add(self.text_view)

        # placeholder text logic
        self.placeholder_text = None
        self.placeholder_text_set = False
        self.restore_buffer_handler_id = None
        self.clear_buffer_handler_id = None

        self.text_view.set_buffer(KanoTextBuffer())
        text_buffer = self.text_view.get_buffer()
        text_buffer.connect('changed', self._on_changed)
Exemplo n.º 35
0
    def report_window(self):
        '''
        Report window
        Contains 2 text views and Take Screenshot, Add Image and Send buttons
        '''
        ApplicationWindow.__init__(
            self,
            _('Report a Problem'),  # noqa: F821
            self.WIDTH,
            0.35)

        screen = Gdk.Screen.get_default()
        specific_provider = Gtk.CssProvider()
        specific_provider.load_from_path(Media.media_dir() + 'css/style.css')
        style_context = Gtk.StyleContext()
        style_context.add_provider_for_screen(screen, specific_provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_USER)

        self.set_icon_name("feedback")
        self._grid = Gtk.Grid()

        # Create top bar
        self._top_bar = TopBar(
            title=_("Report a Problem"),  # noqa: F821
            window_width=self.WIDTH,
            has_buttons=False)
        self._top_bar.set_close_callback(Gtk.main_quit)
        self.set_decorated(True)
        self.set_titlebar(self._top_bar)

        self.entry = Gtk.Entry()
        if self._pii_allowed():
            self.entry.props.placeholder_text = _(
                "Add subject (optional)")  # noqa: F821
        else:
            self.entry.props.placeholder_text = _(
                "Want to send us more information?")  # noqa: F821
        self.entry.set_margin_left(20)
        self.entry.set_margin_right(20)
        self.entry.set_margin_top(20)
        self.entry.set_margin_bottom(10)
        self.entry.set_sensitive(self._pii_allowed())
        self._grid.attach(self.entry, 0, 0, 1, 1)

        # Create Text view
        self._text = Gtk.TextView()
        self._text.set_editable(True)
        self._text.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        self._text.set_size_request(self.WIDTH, -1)
        self._text.set_sensitive(self._pii_allowed())

        self._textbuffer = self._text.get_buffer()
        if self._pii_allowed():
            self._textbuffer.set_text(
                _("Type your problem here!"))  # noqa: F821
        else:
            self._textbuffer.set_text(
                _("Ask your parent to check their email."))  # noqa: F821

        self._clear_buffer_handler_id = self._textbuffer.connect(
            "insert-text", self.clear_buffer)

        scrolledwindow = ScrolledWindow()
        scrolledwindow.set_vexpand(True)
        scrolledwindow.set_policy(Gtk.PolicyType.NEVER,
                                  Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.apply_styling_to_widget()
        scrolledwindow.add(self._text)
        scrolledwindow.set_margin_left(2)
        scrolledwindow.set_margin_right(2)
        scrolledwindow.set_margin_top(2)
        scrolledwindow.set_margin_bottom(2)

        # Very hacky way to get a border: create a grey event box
        # which is a little bigger than the widget below
        border = Gtk.EventBox()
        border.get_style_context().add_class("grey")
        border.add(scrolledwindow)
        self._grid.attach(border, 0, 1, 1, 1)
        border.set_margin_left(20)
        border.set_margin_right(20)
        border.set_margin_top(10)
        border.set_margin_bottom(20)

        # Create take screenshot button
        self._screenshot_button = KanoButton(
            _("TAKE SCREENSHOT"),  # noqa: F821
            "blue")
        self._screenshot_button.set_sensitive(self._pii_allowed())
        self._screenshot_button.connect("button_press_event",
                                        self.screenshot_clicked)

        # Create attach screenshot button
        self._attach_button = KanoButton(
            _("ADD IMAGE"),  # noqa: F821
            "blue")
        self._attach_button.set_sensitive(self._pii_allowed())
        self._attach_button.connect("button_press_event", self.attach_clicked)

        # Create send button
        self._send_button = KanoButton(_("SEND")  # noqa: F821
                                       )
        self._send_button.set_sensitive(not self._pii_allowed())
        self._send_button.connect("button_press_event", self.send_feedback)
        self._send_button.pack_and_align()
        self._send_button.set_margin(10, 0, 10, 0)

        self.screenshot_box = Gtk.ButtonBox()
        self.screenshot_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
        self.screenshot_box.set_spacing(20)
        self.pack_screenshot_buttons()
        self.screenshot_box.set_margin_bottom(20)

        self._grid.attach(self.screenshot_box, 0, 2, 1, 1)

        # Create grey box to put the button in
        self.bottom_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.bottom_box.pack_start(self._send_button.align, False, False, 0)

        bottom_background = Gtk.EventBox()
        bottom_background.get_style_context().add_class("grey")
        bottom_background.add(self.bottom_box)

        self._grid.attach(bottom_background, 0, 3, 1, 1)

        self._grid.set_row_spacing(0)
        self.set_main_widget(self._grid)

        # kano-profile stat collection
        try:
            from kano_profile.badges import increment_app_state_variable_with_dialog
            increment_app_state_variable_with_dialog('kano-feedback', 'starts',
                                                     1)
        except Exception:
            pass
Exemplo n.º 36
0
    def setup_application_widgets(self):
        screen = Gdk.Screen.get_default()
        width = screen.get_width()
        height = screen.get_height()

        self.terminal = TerminalUi()
        fg_color = Gdk.Color.parse("#ffffff")[1]
        bg_color = Gdk.Color.parse("#262626")[1]
        self.terminal.set_colors(fg_color, bg_color, [])
        self.terminal.set_margin_top(10)
        self.terminal.set_margin_left(10)
        self.terminal.set_margin_right(10)
        # Set the terminal font size. There is 
        # probably a way of doing this with css to avoid hard coding
        # But I have not found it yet.
        font_desc = Pango.FontDescription()
        font_desc.set_family("monospace")
        font_desc.set_size(13*Pango.SCALE)
        self.terminal.set_font(font_desc)


        self.spellbook = Spellbook(is_caps_lock_on=self.is_caps_lock_on)

        self.story = Storybook(
            width / 2 - 40,
            height - self.spellbook.HEIGHT - 2 * 44 - 10
        )
        self.story.set_margin_top(10)
        self.story.set_margin_left(10)
        self.story.set_margin_right(10)

        story_sw = ScrolledWindow()
        story_sw.apply_styling_to_screen()
        story_sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        story_sw.add(self.story)

        left_background = Gtk.EventBox()
        left_background.get_style_context().add_class("story_background")
        right_background = Gtk.EventBox()
        right_background.get_style_context().add_class("terminal_background")

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        self.hbox = Gtk.Box()

        vbox.pack_start(self.hbox, False, False, 0)
        vbox.pack_start(self.spellbook, False, False, 0)
        self.hbox.pack_start(left_background, False, False, 0)
        self.hbox.pack_start(right_background, False, False, 0)

        left_background.add(story_sw)
        right_background.add(self.terminal)

        # Allow for margin on bottom and top bar.
        self.terminal.set_size_request(
            width / 2 - 20, height - self.spellbook.HEIGHT - 2 * 44 - 20
        )
        story_sw.set_size_request(
            width / 2 - 20, height - self.spellbook.HEIGHT - 2 * 44 - 10
        )

        self.run_server()
Exemplo n.º 37
0
    def __init__(self, parser):

        # for some reason, this is not being obeyed
        self.item_width = 55
        self.item_height = 50

        self._signal_name = 'category_item_selected'
        self._parser = parser

        # Initialise self._items
        self._items = {}

        # Save the order of the categories so we can use it outside
        self.categories = self._parser.list_available_categories()
        SelectMenu.__init__(self, self.categories, self._signal_name)

        # Add the scrollbar for the category menu
        sw = ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        # Set the scrollbar to the left
        sw.set_placement(Gtk.CornerType.TOP_RIGHT)
        sw.apply_styling_to_widget()
        sw.set_size_request(-1, 364)
        self.add(sw)

        self._vertbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        sw.add(self._vertbox)

        # The menu is one item by 7 items
        self.set_size_request(self.item_width, 7 * self.item_height)
        self._pack_buttons()
Exemplo n.º 38
0
    def __init__(self, parser):

        # for some reason, this is not being obeyed
        self.item_width = 55
        self.item_height = 50

        self._signal_name = 'category_item_selected'
        self._parser = parser

        # Initialise self._items
        self._items = {}

        # Save the order of the categories so we can use it outside
        self.categories = self._parser.list_available_categories()
        SelectMenu.__init__(self, self.categories, self._signal_name)

        # Add the scrollbar for the category menu
        sw = ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        # Set the scrollbar to the left
        sw.set_placement(Gtk.CornerType.TOP_RIGHT)
        sw.apply_styling_to_widget()
        sw.set_size_request(-1, 364)
        self.add(sw)

        self._vertbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        sw.add(self._vertbox)

        # The menu is one item by 7 items
        self.set_size_request(self.item_width, 7 * self.item_height)
        self._pack_buttons()
Exemplo n.º 39
0
def show_results(msg_upgraded, msg_added, msg_removed, debian_err_packages,
                 appstate_after_nonclean, python_ok, python_err):

    # Create Gtk textiew with markdown
    text_view = Gtk.TextView()
    text_view.set_margin_top(10)
    text_view.set_margin_bottom(20)
    text_view.set_margin_left(20)
    text_view.set_margin_right(20)
    text_buffer = text_view.get_buffer()
    bold_tag = text_buffer.create_tag("bold", weight=Pango.Weight.BOLD)

    scrolled_window = ScrolledWindow()
    scrolled_window.apply_styling_to_widget()
    scrolled_window.add_with_viewport(text_view)
    scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
    scrolled_window.set_size_request(400, 200)

    result_dialog = kano_dialog.KanoDialog("Update result", "",
                                           widget=scrolled_window,
                                           global_style=True)
    result_dialog.dialog.set_icon_name("kano-updater")
    result_dialog.dialog.set_title("Kano Updater")

    if msg_upgraded:
        text = "\nApps upgraded:\n"
        add_text_to_end(text_buffer, text, bold_tag)
        add_text_to_end(text_buffer, msg_upgraded)

    if msg_added:
        text = "\nApps added:\n"
        add_text_to_end(text_buffer, text, bold_tag)
        add_text_to_end(text_buffer, msg_added)

    if msg_removed:
        text = "\nApps removed:\n"
        add_text_to_end(text_buffer, text, bold_tag)
        add_text_to_end(text_buffer, msg_removed)

    if debian_err_packages:
        text = "\nApps with errors:\n"
        add_text_to_end(text_buffer, text, bold_tag)
        msg_error = "{}\n".format('\n'.join(debian_err_packages))
        add_text_to_end(text_buffer, msg_error)

    if appstate_after_nonclean:
        text = "\nApps with non-clean state:\n"
        add_text_to_end(text_buffer, text, bold_tag)

        non_clean_list = '\n'.join(appstate_after_nonclean.iterkeys())
        msg_non_clean_list = non_clean_list + "\n"
        add_text_to_end(text_buffer, msg_non_clean_list)

    if python_ok:
        text = "\nPython modules upgraded:\n"
        add_text_to_end(text_buffer, text, bold_tag)

        python_modules = "{}\n".format('\n'.join(python_ok))
        add_text_to_end(text_buffer, python_modules)

    if python_err:
        text = "\nPython modules with error:\n"
        add_text_to_end(text_buffer, text, bold_tag)

        err_list = '\n'.join(python_err)
        msg_python_err = err_list + "\n"
        add_text_to_end(text_buffer, msg_python_err)

    if not (msg_upgraded or msg_added or msg_removed or debian_err_packages or
            appstate_after_nonclean or python_ok or python_err):
        add_text_to_end(text_buffer, "No updates needed this time.", bold_tag)

    result_dialog.run()
    while Gtk.events_pending():
        Gtk.main_iteration()
Exemplo n.º 40
0
    def contact_window(self):
        '''
        Contact Us window
        Contains text view and a Send button
        '''
        # delete the directory containing all the info we'll send, and recreate
        delete_tmp_dir()
        create_tmp_dir()

        ApplicationWindow.__init__(
            self,
            _('Contact Us'),  # noqa: F821
            self.WIDTH,
            0.35)

        screen = Gdk.Screen.get_default()
        specific_provider = Gtk.CssProvider()
        specific_provider.load_from_path(Media.media_dir() + 'css/style.css')
        style_context = Gtk.StyleContext()
        style_context.add_provider_for_screen(screen, specific_provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_USER)

        # Make sure this window has no icon in the task bar
        # so it plays nice with kdesk-blur
        self.set_property('skip-taskbar-hint', True)

        self._grid = Gtk.Grid()

        # Create top bar
        self._top_bar = TopBar(
            title=_("Contact Us"),  # noqa: F821
            window_width=self.WIDTH,
            has_buttons=False)
        self._top_bar.set_close_callback(Gtk.main_quit)
        self.set_decorated(True)
        self.set_titlebar(self._top_bar)

        # Create Text view
        self._text = Gtk.TextView()
        self._text.set_editable(True)
        self._text.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        self._text.set_size_request(self.WIDTH, -1)
        self._text.set_sensitive(self._pii_allowed())

        self._textbuffer = self._text.get_buffer()
        if self._pii_allowed():
            self._textbuffer.set_text(
                _("Type your feedback here!"))  # noqa: F821
        else:
            self._textbuffer.set_text(
                _("Want to send us more information? Ask your parent to check their email."
                  ))  # noqa: F821
        self._clear_buffer_handler_id = self._textbuffer.connect(
            "insert-text", self.clear_buffer)

        scrolledwindow = ScrolledWindow()
        scrolledwindow.set_vexpand(True)
        scrolledwindow.set_policy(Gtk.PolicyType.NEVER,
                                  Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.apply_styling_to_widget()
        scrolledwindow.add(self._text)
        scrolledwindow.set_margin_left(2)
        scrolledwindow.set_margin_right(2)
        scrolledwindow.set_margin_top(2)
        scrolledwindow.set_margin_bottom(2)

        # Very hacky way to get a border: create a grey event box
        # which is a little bigger than the widget below
        border = Gtk.EventBox()
        border.get_style_context().add_class("grey")
        border.add(scrolledwindow)
        self._grid.attach(border, 0, 0, 1, 1)
        border.set_margin_left(20)
        border.set_margin_right(20)
        border.set_margin_top(10)
        border.set_margin_bottom(20)

        # Create send button
        self._send_button = KanoButton(_("SEND")  # noqa: F821
                                       )
        self._send_button.set_sensitive(not self._pii_allowed())
        self._send_button.connect("button_press_event", self.send_feedback)
        self._send_button.pack_and_align()
        self._send_button.align.set_padding(10, 10, 0, 0)

        bottom_background = Gtk.EventBox()
        bottom_background.get_style_context().add_class("grey")
        bottom_background.add(self._send_button.align)

        self._grid.attach(bottom_background, 0, 1, 1, 1)

        self._grid.set_row_spacing(0)
        self.set_main_widget(self._grid)

        # kano-profile stat collection
        try:
            from kano_profile.badges import \
                increment_app_state_variable_with_dialog
            increment_app_state_variable_with_dialog('kano-feedback', 'starts',
                                                     1)
        except Exception:
            pass
Exemplo n.º 41
0
class AppGrid(Gtk.EventBox):
    def __init__(self, main_win, apps_obj):
        Gtk.EventBox.__init__(self, hexpand=True, vexpand=True)
        style = self.get_style_context()
        style.add_class('app-grid')

        self._win = main_win
        self._apps = apps_obj
        self._num_apps = 0

        self._sw = ScrolledWindow(hexpand=True, vexpand=True,
                                  wide_scrollbar=True)

        self._sw.props.margin_top = 7
        self._sw.props.margin_bottom = 0
        self._sw.props.margin_left = 0
        self._sw.props.margin_right = 0
        self._sw.props.border_width = 0
        self._sw.set_shadow_type(Gtk.ShadowType.NONE)

        self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self._sw.add_with_viewport(self._box)
        self.add(self._sw)

    def new_entry(self, app, sort_by="title", reverse=False):
        if "colour" not in app:
            if (self._num_apps % 2) == 0:
                app["colour"] = "#f2914a"
            else:
                app["colour"] = "#f5a269"
            self._num_apps += 1

        entry = AppGridEntry(app, self._win, self._apps)
        self._box.pack_start(entry, False, False, 0)

        pos = 0
        for child in self._box:
            child_app_data = child.get_app_data()

            # keep the special "want-more" entry at the bottom of the list
            if "slug" in child_app_data and \
               child_app_data["slug"] == "want-more":
                break

            if reverse:
                if app[sort_by] > child_app_data[sort_by]:
                    break
            else:
                if app[sort_by] < child_app_data[sort_by]:
                    break

            pos += 1

        self._box.reorder_child(entry, pos)

        entry.show_all()
        return entry

    def get_num(self):
        return self._num_apps
Exemplo n.º 42
0
def show_results(msg_upgraded, msg_added, msg_removed, debian_err_packages,
                 appstate_after_nonclean, python_ok, python_err):

    # Create Gtk textiew with markdown
    text_view = Gtk.TextView()
    text_view.set_margin_top(10)
    text_view.set_margin_bottom(20)
    text_view.set_margin_left(20)
    text_view.set_margin_right(20)
    text_buffer = text_view.get_buffer()
    bold_tag = text_buffer.create_tag('bold', weight=Pango.Weight.BOLD)

    scrolled_window = ScrolledWindow()
    scrolled_window.apply_styling_to_widget()
    scrolled_window.add_with_viewport(text_view)
    scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
    scrolled_window.set_size_request(400, 200)

    result_dialog = kano_dialog.KanoDialog(_("Update result"),
                                           "",
                                           widget=scrolled_window,
                                           global_style=True)
    result_dialog.dialog.set_icon_name('kano-updater')
    result_dialog.dialog.set_title(_("Kano Updater"))

    if msg_upgraded:
        text = _("\nApps upgraded:\n")
        add_text_to_end(text_buffer, text, bold_tag)
        add_text_to_end(text_buffer, msg_upgraded)

    if msg_added:
        text = _("\nApps added:\n")
        add_text_to_end(text_buffer, text, bold_tag)
        add_text_to_end(text_buffer, msg_added)

    if msg_removed:
        text = _("\nApps removed:\n")
        add_text_to_end(text_buffer, text, bold_tag)
        add_text_to_end(text_buffer, msg_removed)

    if debian_err_packages:
        text = _("\nApps with errors:\n")
        add_text_to_end(text_buffer, text, bold_tag)
        msg_error = "{}\n".format('\n'.join(debian_err_packages))
        add_text_to_end(text_buffer, msg_error)

    if appstate_after_nonclean:
        text = _("\nApps with non-clean state:\n")
        add_text_to_end(text_buffer, text, bold_tag)

        non_clean_list = '\n'.join(appstate_after_nonclean.iterkeys())
        msg_non_clean_list = non_clean_list + "\n"
        add_text_to_end(text_buffer, msg_non_clean_list)

    if python_ok:
        text = _("\nPython modules upgraded:\n")
        add_text_to_end(text_buffer, text, bold_tag)

        python_modules = "{}\n".format('\n'.join(python_ok))
        add_text_to_end(text_buffer, python_modules)

    if python_err:
        text = _("\nPython modules with error:\n")
        add_text_to_end(text_buffer, text, bold_tag)

        err_list = '\n'.join(python_err)
        msg_python_err = err_list + "\n"
        add_text_to_end(text_buffer, msg_python_err)

    if not (msg_upgraded or msg_added or msg_removed or debian_err_packages
            or appstate_after_nonclean or python_ok or python_err):
        add_text_to_end(text_buffer, _("No updates needed this time."),
                        bold_tag)

    result_dialog.run()
    while Gtk.events_pending():
        Gtk.main_iteration()
Exemplo n.º 43
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()