Skip to content

Instantly share code, notes, and snippets.

@Metaxal
Last active March 31, 2022 12:09
Show Gist options
  • Save Metaxal/0bbd874891442aad78fbd0c08a329cd9 to your computer and use it in GitHub Desktop.
Save Metaxal/0bbd874891442aad78fbd0c08a329cd9 to your computer and use it in GitHub Desktop.
A quickscript to open a recent file via a search-list-box for easier retrieval
#lang racket/base
(require racket/gui/base
racket/class
racket/list
quickscript
quickscript/utils
framework
search-list-box)
;;; Author: Laurent Orseau https://github.com/Metaxal
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
;;; From: https://github.com/Quickscript-Competiton/July2020entries/issues/15
;;; NOTICE: The package `search-list-box` must be installed first!
(script-help-string "Open a recent file (dialog uses a search-list-box)")
(define-script open-recent
#:label "&Open recent"
(λ (selection #:frame drfr)
(define recent (preferences:get 'framework:recently-opened-files/pos))
(define fr
(new search-list-box-frame%
[parent drfr]
[label "Open recent"]
[width 600] [height 400]
[contents recent]
[key (λ (c) (path->string (first c)))]
[filter word-filter]
[callback
(λ (sel str content)
(when content
(smart-open-file drfr (first content))
(when (send cb-close get-value)
(send fr show #f))))]))
(define cb-close (new check-box% [parent fr]
[label "&Close dialog after opening a file?"]
[value #t]))
#f))
(module url2script-info racket/base
(provide filename url)
(define filename "open-recent.rkt")
(define url "https://gist.github.com/Metaxal/0bbd874891442aad78fbd0c08a329cd9"))
@Metaxal
Copy link
Author

Metaxal commented Mar 31, 2022

Also in the quickscript-competition-2020 package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment