Example #1
0
    def set_path_chooser(self,
                         callback_on_changed,
                         action=None,
                         default_path=None):
        """Display a file/folder chooser."""
        self.install_button.set_visible(False)
        self.continue_button.show()
        self.continue_button.set_sensitive(False)

        if action == "file":
            title = "Select file"
            action = Gtk.FileChooserAction.OPEN
            enable_warnings = False
        elif action == "folder":
            title = "Select folder"
            action = Gtk.FileChooserAction.SELECT_FOLDER
            enable_warnings = True
        else:
            raise ValueError("Invalid action %s", action)

        if self.location_entry:
            self.location_entry.destroy()
        self.location_entry = FileChooserEntry(
            title,
            action,
            path=default_path,
            warn_if_non_empty=enable_warnings,
            warn_if_ntfs=enable_warnings)
        self.location_entry.entry.connect("changed", callback_on_changed,
                                          action)
        self.widget_box.pack_start(self.location_entry, False, False, 0)
Example #2
0
    def generate_file_chooser(self, option, path=None):
        """Generate a file chooser button to select a file."""
        option_name = option["option"]
        label = Label(option["label"])
        default_path = option.get("default_path") or (self.runner.default_path
                                                      if self.runner else "")
        file_chooser = FileChooserEntry(title=_("Select file"),
                                        action=Gtk.FileChooserAction.OPEN,
                                        path=path,
                                        default_path=default_path)
        file_chooser.set_size_request(200, 30)

        if "default_path" in option:
            default_path = self.lutris_config.system_config.get(
                option["default_path"])
            if default_path and os.path.exists(default_path):
                file_chooser.entry.set_text(default_path)

        if path:
            # If path is relative, complete with game dir
            if not os.path.isabs(path):
                path = os.path.expanduser(path)
                if not os.path.isabs(path):
                    if self.game and self.game.directory:
                        path = os.path.join(self.game.directory, path)
            file_chooser.entry.set_text(path)

        file_chooser.set_valign(Gtk.Align.CENTER)
        self.wrapper.pack_start(label, False, False, 0)
        self.wrapper.pack_start(file_chooser, True, True, 0)
        self.option_widget = file_chooser
        file_chooser.entry.connect("changed", self._on_chooser_file_set,
                                   option_name)
Example #3
0
    def set_path_chooser(self,
                         callback_on_changed,
                         action=None,
                         default_path=None):
        """Display a file/folder chooser."""

        self.install_button.set_visible(False)
        self.continue_button.show()
        self.continue_button.set_sensitive(False)

        if action == 'file':
            title = 'Select file'
            action = Gtk.FileChooserAction.OPEN
        elif action == 'folder':
            title = 'Select folder'
            action = Gtk.FileChooserAction.SELECT_FOLDER

        if self.location_entry:
            self.location_entry.destroy()
        self.location_entry = FileChooserEntry(title, action, default_path)
        self.location_entry.show_all()
        if callback_on_changed:
            self.location_entry.entry.connect('changed', callback_on_changed,
                                              action)

        self.widget_box.pack_start(self.location_entry, False, False, 0)
Example #4
0
    def generate_file_chooser(self, option, path=None):
        """Generate a file chooser button to select a file."""
        option_name = option['option']
        label = Label(option['label'])
        file_chooser = FileChooserEntry(
            title='Select file',
            action=Gtk.FileChooserAction.OPEN,
            default_path=path  # reverse_expanduser(path)
        )
        file_chooser.set_size_request(200, 30)

        if 'default_path' in option:
            config_key = option['default_path']
            default_path = self.lutris_config.system_config.get(config_key)
            if default_path and os.path.exists(default_path):
                file_chooser.entry.set_text(default_path)

        if path:
            # If path is relative, complete with game dir
            if not os.path.isabs(path):
                path = os.path.expanduser(path)
            file_chooser.entry.set_text(path)

        file_chooser.set_valign(Gtk.Align.CENTER)
        label.set_alignment(0.5, 0.5)
        self.wrapper.pack_start(label, False, False, 0)
        self.wrapper.pack_start(file_chooser, True, True, 0)
        self.option_widget = file_chooser
        file_chooser.entry.connect('changed', self._on_chooser_file_set,
                                   option_name)
Example #5
0
 def _get_game_cache_box(self):
     box = Gtk.Box(spacing=12, margin_right=12, margin_left=12)
     label = Label("Cache path")
     box.pack_start(label, False, False, 0)
     cache_path = get_cache_path()
     path_chooser = FileChooserEntry(
         title="Set the folder for the cache path",
         action=Gtk.FileChooserAction.SELECT_FOLDER,
         path=cache_path)
     path_chooser.entry.connect("changed", self._on_cache_path_set)
     box.pack_start(path_chooser, True, True, 0)
     return box
Example #6
0
 def set_install_destination(self, default_path=None):
     """Display the destination chooser."""
     self.install_button.set_visible(False)
     self.continue_button.show()
     self.continue_button.set_sensitive(False)
     location_entry = FileChooserEntry("Select folder",
                                       Gtk.FileChooserAction.SELECT_FOLDER,
                                       path=default_path,
                                       warn_if_non_empty=True,
                                       warn_if_ntfs=True)
     location_entry.entry.connect("changed", self.on_target_changed)
     self.widget_box.pack_start(location_entry, False, False, 0)
Example #7
0
 def set_install_destination(self, default_path=None):
     """Display the destination chooser."""
     self.install_button.set_visible(False)
     self.continue_button.show()
     self.continue_button.set_sensitive(False)
     location_entry = FileChooserEntry("Select folder",
                                       Gtk.FileChooserAction.SELECT_FOLDER,
                                       default_path=default_path,
                                       path_type=PATH_TYPE.INSTALL_TO,
                                       warnings=FileChooserWarnings.NTFS
                                       | FileChooserWarnings.NON_EMPTY)
     location_entry.entry.connect("changed", self.on_target_changed)
     self.widget_box.pack_start(location_entry, False, False, 0)
Example #8
0
 def generate_directory_chooser(self, option_name, label_text, value=None):
     """Generate a file chooser button to select a directory."""
     label = Label(label_text)
     directory_chooser = FileChooserEntry(
         title='Select folder',
         action=Gtk.FileChooserAction.SELECT_FOLDER,
         default_path=reverse_expanduser(value))
     directory_chooser.entry.connect('changed', self.on_chooser_dir_set,
                                     option_name)
     directory_chooser.set_valign(Gtk.Align.CENTER)
     label.set_alignment(0.5, 0.5)
     self.wrapper.pack_start(label, False, False, 0)
     self.wrapper.pack_start(directory_chooser, True, True, 0)
     self.option_widget = directory_chooser
Example #9
0
 def generate_directory_chooser(self, option, path=None):
     """Generate a file chooser button to select a directory."""
     label = Label(option["label"])
     option_name = option["option"]
     default_path = None
     if not path and self.game and self.game.runner:
         default_path = self.game.runner.working_dir
     directory_chooser = FileChooserEntry(
         title=_("Select folder"), action=Gtk.FileChooserAction.SELECT_FOLDER, path=path, default_path=default_path
     )
     directory_chooser.entry.connect("changed", self._on_chooser_dir_set, option_name)
     directory_chooser.set_valign(Gtk.Align.CENTER)
     self.wrapper.pack_start(label, False, False, 0)
     self.wrapper.pack_start(directory_chooser, True, True, 0)
     self.option_widget = directory_chooser
Example #10
0
 def get_file_provider_label(self):
     """Return the label displayed before the download starts"""
     if self.provider != "user":
         return InstallerLabel(gtk_safe(self.installer_file.human_url),
                               wrap=False)
     box = Gtk.VBox(spacing=6)
     location_entry = FileChooserEntry(self.installer_file.human_url,
                                       Gtk.FileChooserAction.OPEN,
                                       path=None)
     location_entry.entry.connect("changed", self.on_location_changed)
     location_entry.show()
     box.pack_start(location_entry, False, False, 0)
     if self.installer_file.uses_pga_cache(create=True):
         cache_option = Gtk.CheckButton(
             _("Cache file for future installations"))
         cache_option.set_active(self.cache_to_pga)
         cache_option.connect("toggled", self.on_user_file_cached)
         box.pack_start(cache_option, False, False, 0)
     return box
Example #11
0
    def get_cache_config(self):
        """Return the widgets for the cache configuration"""
        prefs_box = Gtk.VBox()

        box = Gtk.Box(spacing=12, margin_right=12, margin_left=12)
        label = Gtk.Label(_("Cache path"))
        box.pack_start(label, False, False, 0)
        cache_path = get_cache_path()
        path_chooser = FileChooserEntry(
            title=_("Set the folder for the cache path"),
            action=Gtk.FileChooserAction.SELECT_FOLDER,
            path=cache_path)
        path_chooser.entry.connect("changed", self._on_cache_path_set)
        box.pack_start(path_chooser, True, True, 0)

        prefs_box.pack_start(box, False, False, 6)
        cache_help_label = Gtk.Label(visible=True)
        cache_help_label.set_size_request(400, -1)
        cache_help_label.set_markup(
            _("If provided, this location will be used by installers to cache "
              "downloaded files locally for future re-use. \nIf left empty, the "
              "installer files are discarded after the install completion."))
        prefs_box.pack_start(cache_help_label, False, False, 6)
        return prefs_box