def __init__(self, title="Application", width=None, height=None):
        Gtk.Window.__init__(self, title=title)

        self.set_decorated(False)
        self.set_resizable(False)

        screen = Gdk.Screen.get_default()
        self._win_width = width
        if width <= 1:
            self._win_width = int(screen.get_width() * width)

        self._win_height = height
        if height <= 1:
            self._win_height = int(screen.get_height() * height)
        self.set_size_request(self._win_width, self._win_height)

        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete-event', Gtk.main_quit)

        apply_common_to_screen()

        self._overlay = Gtk.Overlay()
        self.add(self._overlay)

        self._blur = Gtk.EventBox()
        self._blur.get_style_context().add_class('blur')

        self._blurred = False
Exemplo n.º 2
0
        def __init__(self, wiface='wlan0', socket_id=0, no_confirm_ether=False):

            self.wiface = wiface
            self.network_list = []
            self.no_confirm_ether = no_confirm_ether

            # Default basic styling
            apply_common_to_screen()

            # Attach specific styling
            apply_styling_to_screen(self.CSS_PATH)

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

            self.top_bar = TopBar(_("Kano WiFi"))
            self.top_bar.set_prev_callback(self.refresh_networks)
            self.top_bar.set_close_callback(Gtk.main_quit)
            self.prev_handler = None
            self.connect('delete-event', Gtk.main_quit)
            self.set_keep_above(True)
            self.set_icon_name('kano-settings')
            self.set_decorated(True)

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

            self._launch_application()
Exemplo n.º 3
0
        def __init__(self, wiface='wlan0', socket_id=0, no_confirm_ether=False):

            self.wiface = wiface
            self.network_list = []
            self.no_confirm_ether = no_confirm_ether

            # Default basic styling
            apply_common_to_screen()

            # Attach specific styling
            apply_styling_to_screen(self.CSS_PATH)

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

            self.top_bar = TopBar(_("Kano WiFi"))
            self.top_bar.set_prev_callback(self.refresh_networks)
            self.top_bar.set_close_callback(Gtk.main_quit)
            self.prev_handler = None
            self.connect('delete-event', Gtk.main_quit)
            self.set_keep_above(True)
            self.set_icon_name('kano-settings')
            self.set_decorated(True)

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

            self._launch_application()
Exemplo n.º 4
0
    def __init__(self, start_from=None):
        """
            :param start_from: Overrides the status and makes the init flow
                               start from this stage.
            :type start_from: str
        """

        super(MainWindow, self).__init__()
        self._ctl = Controller(self, start_from)
        self.connect("delete-event", Gtk.main_quit)
        self._child = None

        self._press_signal_id = None
        self._release_signal_id = None
        self._emergency_counter = 0

        self._to_id_counter = 0
        self._timeouts = []

        apply_common_to_screen()
        apply_styling_to_screen(common_css_path('scene.css'))
        apply_styling_to_screen(common_css_path('speech_bubble.css'))

        self.set_decorated(False)

        screen = Gdk.Screen.get_default()
        width = screen.get_width()
        height = screen.get_height()
        self.set_size_request(width, height + 1)
        self.set_position(Gtk.WindowPosition.CENTER)

        overlay = Gtk.Overlay()
        self._child = Gtk.EventBox()
        overlay.add(self._child)
        self.add(overlay)
        self._container = overlay
        self._container.set_halign(Gtk.Align.CENTER)
        self._container.set_valign(Gtk.Align.CENTER)

        emergency_exit = Gtk.EventBox()
        emergency_exit.set_halign(Gtk.Align.START)
        emergency_exit.set_valign(Gtk.Align.START)
        emergency_exit.set_size_request(20, 20)
        emergency_exit.connect('button-release-event', self._emergency_exit_cb)
        overlay.add_overlay(emergency_exit)

        self.connect('key-release-event', self._key_emergency_exit)
        self.connect('key-release-event', self._key_skip_stage)

        if start_from:
            debug_button = Gtk.EventBox()
            debug_button.add(Gtk.Label('Close'))
            debug_button.set_halign(Gtk.Align.END)
            debug_button.set_valign(Gtk.Align.START)
            debug_button.connect('button-release-event', Gtk.main_quit)
            overlay.add_overlay(debug_button)
Exemplo n.º 5
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()
Exemplo n.º 6
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()
Exemplo n.º 7
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.º 8
0
    def __init__(self):
        apply_common_to_screen()

        self.a = self.b = self.c = 0
        self.switching = 0

        ApplicationWindow.__init__(self, _('Login'), self.WIDTH, self.HEIGHT)
        self.connect("delete-event", Gtk.main_quit)

        # Create a new LightDM.Greeter instance which will be used by the 2 views
        self.greeter = GreeterWindow.greeter.new()

        # Create the two views: one for normal Login, the other to create a new account
        self.password_view = PasswordView(None, self.greeter)
        self.newuser_view = NewUserView(self.greeter)
        self.login_with_kw_view = LoginWithKanoWorldView(self.greeter)

        self.grid = Gtk.Grid()
        self.set_main_widget(self.grid)

        self.grid.set_column_spacing(30)
        self.grid.set_row_spacing(30)

        self.top_bar = TopBar(_('Login'))
        self._remove_top_bar_buttons()
        self.top_bar.set_size_request(self.WIDTH, -1)
        self.grid.attach(self.top_bar, 0, 0, 3, 1)

        self.grid.attach(Gtk.Label(), 0, 3, 3, 1)

        self.top_bar.set_prev_callback(self._back_cb)

        self.user_list = UserListView()

        self.go_to_users()

        cursor = Gdk.Cursor.new(Gdk.CursorType.ARROW)
        self.get_root_window().set_cursor(cursor)
Exemplo n.º 9
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.º 10
0
    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()
Exemplo n.º 11
0
    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()

        # Brings the focus back to the default button (OK) "hacky"
        if isinstance(self.widget, Gtk.Entry):

            def entry_activated(w):
                self.returnvalue = self.widget.get_text()
                self.dialog.response(Gtk.ResponseType.OK)

            self.widget.connect('activate', entry_activated)