Coder Social home page Coder Social logo

file-dialog's Introduction

File Dialog

Build Status Coverage Status

A simple replacement for Pharo's native file/folder selection dialog.

Features

  • list of most common places (home, root, image directory, temp)
  • custom bookmarks by dragging folders from file-pane to bookmark-pane
  • toggle hidden files (right-click on file listing)
  • preset file name
  • filtering files by extensions or patterns and toggling between filters
  • synchronous and asynchronous mode

Installation

(catalog soon)

Metacello new
	baseline: 'FileDialog';
	repository: 'github://peteruhnak/file-dialog/repository';
	load.

Replacing native dialogs

If you feel brave, you can replace the native dialogs everywhere in the system by running

FDMorphicUIManager new beDefault

Of course you can switch back anytime you want.

MorphicUIManager new beDefault

Howto

If you chose using the extended UIManager, then you can use that

UIManager default chooseFileMatching: #('*.ston')

You can also use the classes directly — there are just minor differences in the behavior, such as DirectoryDialog will not show files, etc.

Classes

  • FDSaveFileDialog - saving a file
  • FDOpenFileDialog - selecting a file
  • FDOpenDirectoryDialog - selecting a directory

API

The user-facing API is in the public protocol of FDFileDialog

  • defaultFolder: aPath — where should the dialog open, the default is the imageDirectory
  • defaultName: aString — prefill the file name input
  • extensionFilters: aCollection — a collection of label -> extensions filters
  • fileFilters: aCollection — a collection of label -> pattern filters
  • whenSelected: aBlock — a one arg block executed when a file was selected
  • openModal — when you open the dialog as modal, you will get the selected value as a return instead of using the block

extensionFilters: is just a convenience for fileFilters: automatically adding labels & stuff, so the following is equivalent

extensionFilters: { 'STON files' -> #(ston json) }
fileFilters: { 'STON files (*.ston, *.json)' -> #('*.ston' '*.json') }

Custom Icons

Example

asynchronous — execute behavior on selection from a block

FDOpenFileDialog new
	whenSelected: [ :file | file inspect ];
	extensionFilters: {
		'All images' -> #(jpg png gif svg).
		'All files' -> #()
	};
	defaultFolder: FileLocator imageDirectory asFileReference;
	open

synchronous — return the selected file as a value

file := FDOpenFileDialog new
	openModal

file-dialog's People

Contributors

ducasse avatar peteruhnak avatar stephaneggermont avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.