Beispiel #1
0
    def replace_installed_refs_remote(self, new_remote_name):
        """Replace remote for all the refs.

        :param str new_remote_name: the remote name which will be used instead of the current one
        """
        install_path = self._installation.get_path()
        install_path = install_path.get_path()  # unpack the Gio.File

        variant_type = VariantType(self.FLATPAK_DEPLOY_DATA_GVARIANT_STRING)

        for ref in self.get_refs_full_format():
            deploy_path = os.path.join(install_path, ref, "active/deploy")

            with open(deploy_path, "rb") as f:
                content = f.read()

            variant = Variant.new_from_bytes(variant_type, Bytes(content),
                                             False)
            children = [
                variant.get_child_value(i) for i in range(variant.n_children())
            ]
            # Replace the origin
            children[0] = Variant('s', new_remote_name)
            new_variant = Variant.new_tuple(*children)
            serialized = new_variant.get_data_as_bytes().get_data()

            with open(deploy_path, "wb") as f:
                f.write(serialized)
Beispiel #2
0
    def __init__(self, fullscreen=False, decorated=False):
        """Create a new anaconda main window.

          :param bool fullscreen: if True, fullscreen the window, if false maximize
        """
        super().__init__()

        # Remove the title bar, resize controls and other stuff if the window manager
        # allows it and decorated is set to False. Otherwise, it has no effect.
        self.set_decorated(decorated)

        # Hide the titlebar when maximized if the window manager allows it.
        # This makes anaconda look full-screenish but without covering parts
        # needed to interact with the window manager, like the GNOME top bar.
        self.set_hide_titlebar_when_maximized(True)

        # The Anaconda and Initial Setup windows might sometimes get decorated with
        # a titlebar which contains the __init__.py header text by default.
        # As all Anaconda and Initial Setup usually have a very distinct title text
        # inside the window, the titlebar text is redundant and should be disabled.
        self.set_title(_(WINDOW_TITLE_TEXT))

        # Set the icon used in the taskbar of window managers that have a taskbar
        # The "org.fedoraproject.AnacondaInstaller" icon is part of fedora-logos
        self.set_icon_name("org.fedoraproject.AnacondaInstaller")

        # Treat an attempt to close the window the same as hitting quit
        self.connect("delete-event", self._on_delete_event)

        # Create a black, 50% opacity pixel that will be scaled to fit the lightbox overlay
        # The confusing list of unnamed parameters is:
        # bytes, colorspace (there is no other colorspace), has-alpha,
        # bits-per-sample (has to be 8), width, height,
        # rowstride (bytes between row starts, but we only have one row)
        self._transparent_base = GdkPixbuf.Pixbuf.new_from_bytes(
            Bytes.new([0, 0, 0, 127]), GdkPixbuf.Colorspace.RGB, True, 8, 1, 1,
            1)

        # Contain everything in an overlay so the window can be overlayed with the transparency
        # for the lightbox effect
        self._overlay = Gtk.Overlay()
        self._overlay_img = None
        self._overlay.connect("get-child-position",
                              self._on_overlay_get_child_position)

        self._overlay_depth = 0

        # Create a stack and a list of what's been added to the stack
        # Double the stack transition duration since the default 200ms is too
        # quick to get the point across
        self._stack = Gtk.Stack(transition_duration=400)
        self._stack_contents = set()

        # Create an accel group for the F12 accelerators added after window transitions
        self._accel_group = Gtk.AccelGroup()
        self.add_accel_group(self._accel_group)

        # Make the window big
        if fullscreen:
            self.fullscreen()
        else:
            self.maximize()

        self._overlay.add(self._stack)
        self.add(self._overlay)
        self.show_all()

        self._current_action = None

        # Help button mnemonics handling
        self._mnemonic_signal = None
        # we have a sensible initial value, just in case
        self._saved_help_button_label = _("Help!")

        # Apply the initial language attributes
        self._language = None
        self.reapply_language()

        # Keybinder from GI needs to be initialized before use
        Keybinder.init()
        Keybinder.bind("<Shift>Print", self._handle_print_screen, [])

        self._screenshot_index = 0
Beispiel #3
0
    def __init__(self, fullscreen=False, decorated=False):
        """Create a new anaconda main window.

          :param bool fullscreen: if True, fullscreen the window, if false maximize
        """
        super().__init__()

        # Remove the title bar, resize controls and other stuff if the window manager
        # allows it and decorated is set to False. Otherwise, it has no effect.
        self.set_decorated(decorated)

        # Hide the titlebar when maximized if the window manager allows it.
        # This makes anaconda look full-screenish but without covering parts
        # needed to interact with the window manager, like the GNOME top bar.
        self.set_hide_titlebar_when_maximized(True)

        # The Anaconda and Initial Setup windows might sometimes get decorated with
        # a titlebar which contains the __init__.py header text by default.
        # As all Anaconda and Initial Setup usually have a very distinct title text
        # inside the window, the titlebar text is redundant and should be disabled.
        self.set_title(_(WINDOW_TITLE_TEXT))

        # Set the icon used in the taskbar of window managers that have a taskbar
        # The "anaconda" icon is part of fedora-logos
        self.set_icon_name("anaconda")

        # Treat an attempt to close the window the same as hitting quit
        self.connect("delete-event", self._on_delete_event)

        # Create a black, 50% opacity pixel that will be scaled to fit the lightbox overlay
        # The confusing list of unnamed parameters is:
        # bytes, colorspace (there is no other colorspace), has-alpha,
        # bits-per-sample (has to be 8), width, height,
        # rowstride (bytes between row starts, but we only have one row)
        self._transparent_base = GdkPixbuf.Pixbuf.new_from_bytes(Bytes.new([0, 0, 0, 127]),
                GdkPixbuf.Colorspace.RGB, True, 8, 1, 1, 1)

        # Contain everything in an overlay so the window can be overlayed with the transparency
        # for the lightbox effect
        self._overlay = Gtk.Overlay()
        self._overlay_img = None
        self._overlay.connect("get-child-position", self._on_overlay_get_child_position)

        self._overlay_depth = 0

        # Create a stack and a list of what's been added to the stack
        # Double the stack transition duration since the default 200ms is too
        # quick to get the point across
        self._stack = Gtk.Stack(transition_duration=400)
        self._stack_contents = set()

        # Create an accel group for the F12 accelerators added after window transitions
        self._accel_group = Gtk.AccelGroup()
        self.add_accel_group(self._accel_group)

        # Make the window big
        if fullscreen:
            self.fullscreen()
        else:
            self.maximize()

        self._overlay.add(self._stack)
        self.add(self._overlay)
        self.show_all()

        self._current_action = None

        # Help button mnemonics handling
        self._mnemonic_signal = None
        # we have a sensible initial value, just in case
        self._saved_help_button_label = _("Help!")

        # Apply the initial language attributes
        self._language = None
        self.reapply_language()

        # Keybinder from GI needs to be initialized before use
        Keybinder.init()
        Keybinder.bind("<Shift>Print", self._handle_print_screen, [])

        self._screenshot_index = 0