def __init__(self, data, storage, payload, partitioning): super().__init__(data, storage, payload) self.title = N_("Partition Scheme Options") self._container = None self._part_schemes = OrderedDict() self._partitioning = partitioning self._request = PartitioningRequest.from_structure( self._partitioning.Request) supported_choices = get_supported_autopart_choices() if supported_choices: # Fallback value (eg when default is not supported) self._selected_scheme_value = supported_choices[0][1] selected_choice = self._request.partitioning_scheme for item in supported_choices: self._part_schemes[item[0]] = item[1] if item[1] == selected_choice: self._selected_scheme_value = item[1]
def __init__(self, title, create_clicked_cb, autopart_type_changed_cb, encrypted_changed_cb, default_scheme, default_encryption, partitions_to_reuse=True): super().__init__(title) # Create a box where we store the "Here's how you create a new blah" info. self._createBox = Gtk.Grid() self._createBox.set_row_spacing(6) self._createBox.set_column_spacing(6) self._createBox.set_margin_start(16) label = Gtk.Label( label=_("You haven't created any mount points for your " "%(product)s %(version)s installation yet. " "You can:") % { "product": productName, "version": productVersion }, wrap=True, xalign=0, yalign=0.5) self._createBox.attach(label, 0, 0, 2, 1) dot = Gtk.Label(label="•", xalign=0.5, yalign=0.4, hexpand=False) self._createBox.attach(dot, 0, 1, 1, 1) self._createNewButton = Gtk.LinkButton( uri="", label=C_("GUI|Custom Partitioning|Autopart Page", "_Click here to create them automatically.")) label = self._createNewButton.get_children()[0] label.set_xalign(0) label.set_yalign(0.5) label.set_hexpand(True) label.set_line_wrap(True) label.set_use_underline(True) # Create this now to pass into the callback. It will be populated later # on in this method. store = Gtk.ListStore(str, int) combo = Gtk.ComboBox(model=store) cellrendr = Gtk.CellRendererText() combo.pack_start(cellrendr, True) combo.add_attribute(cellrendr, "text", 0) combo.connect("changed", autopart_type_changed_cb) self._createNewButton.set_has_tooltip(False) self._createNewButton.set_halign(Gtk.Align.START) self._createNewButton.connect("clicked", create_clicked_cb, combo) self._createNewButton.connect("activate-link", lambda *args: Gtk.true()) self._createBox.attach(self._createNewButton, 1, 1, 1, 1) dot = Gtk.Label(label="•", xalign=0.5, yalign=0, hexpand=False) self._createBox.attach(dot, 0, 2, 1, 1) label = Gtk.Label( label=_("Create new mount points by clicking the '+' button."), xalign=0, yalign=0.5, hexpand=True, wrap=True) self._createBox.attach(label, 1, 2, 1, 1) if partitions_to_reuse: dot = Gtk.Label(label="•", xalign=0.5, yalign=0, hexpand=False) self._createBox.attach(dot, 0, 3, 1, 1) label = Gtk.Label(label=_( "Or, assign new mount points to existing " "partitions after selecting them below."), xalign=0, yalign=0.5, hexpand=True, wrap=True) self._createBox.attach(label, 1, 3, 1, 1) label = Gtk.Label(label=C_( "GUI|Custom Partitioning|Autopart Page", "_New mount points will use the following partitioning scheme:"), xalign=0, yalign=0.5, wrap=True, use_underline=True) self._createBox.attach(label, 0, 4, 2, 1) label.set_mnemonic_widget(combo) default = None for name, code in get_supported_autopart_choices(): itr = store.append([_(name), code]) if code == default_scheme: default = itr combo.set_margin_start(18) combo.set_margin_end(18) combo.set_hexpand(False) combo.set_active_iter(default or store.get_iter_first()) self._createBox.attach(combo, 0, 5, 2, 1) label = Gtk.Label(label=C_( "GUI|Custom Partitioning|Autopart Page", "_Automatically created mount points can be encrypted by default:" ), xalign=0, yalign=0.5, wrap=True, use_underline=True) self._createBox.attach(label, 0, 6, 2, 1) checkbox = Gtk.CheckButton(label="Encrypt my data.") checkbox.connect("toggled", encrypted_changed_cb) checkbox.set_active(default_encryption) checkbox.set_margin_start(18) checkbox.set_margin_end(18) checkbox.set_hexpand(False) label.set_mnemonic_widget(checkbox) self._createBox.attach(checkbox, 0, 7, 2, 1) self.add(self._createBox)