FILE/FOLDER/PICTURE CHOOSER WIDGETS FOR LINUX
Here is a pair of standalone choosers (one for
pictures and another for ordinary files) that you
can incorporate in your own programs. An
example program for calling the widgets is
provided, written in LiveCode.
However, your programs do not need to be
written in LiveCode in order to use the widgets.
This version of the widgets should run on
most Linux distros. However, regarding a
few small details, special preference has been
given to Ubuntu.
The choosers can be used for file selection
("Open", or "Save As" functions with or without
a suggested file name), or for choosing
PICTURE FILE/FOLDER CHOOSER
SIMPLE FILE/FOLDER CHOOSER
And here is the example program provided with the demo pack that you can download, demonstrating
not only how to call the chooser widgets and retrieve the information they provide, but also how to
determine their size, position, appearance and exact function:
As you can see, the widgets are each controlled by 2 INI files, one for any file filters required (shown on the right) and another for all other tailoring (shown on the left).
If you move the mouse over the leftmost INI parameters, a red screen will appear that gives you a full explanation and examples of the parameter under the mouse.
You can change these parameters individually, and then call the widgets to observe their visual and functional effects. Or for a more general demo you can click on
the 4 buttons at the bottom to see pre-prepared examples of the main widget functions: opening a file or a folder, or doing a "save as" with or without a suggested
It is fairly deducible from the demo, but it is worth further clarifying here the exact functions of parameter 16 (the last one) of the "_file_chooser.ini" and
"_picture_chooser.ini" files. If you put "folder" in line 16, the chooser will return a folder name and not a file name (even if you actually select a file). If you put
"folder\" in line 16, the same thing will happen, but the folder name returned will have a backslash as the last character. If you leave line 16 empty, the widget
will function as a file chooser, and the path+file name returned will correspond to whatever path and file the operator has selected and highlighted in the leftmost
(for the folder) and rightmost (for the file) lists of the widget. The appearance of the widgets will be exactly as shown above. However, if you put anything else into
line16 of the INI file, it will be treated as a suggested file name, which can be either partial (e.g. *.txt) or complete (e.g. newfile.txt). And a little box showing the
suggested file name will appear as illustrated here:
Of course, if the operator just clicks on the OK button in the first (partially-suggested file name) example above, the widget will beep and refuse to close until the
operator has typed or chosen a legal file name.
If you want the operator to type a file name completely without really suggesting anything, then put "*.*" or other illegal file name into line 16 of the INI file:
All in all, apart from the fact that they are greatly more tailorable, these widgets behave much like the answer dialogues provided by Windows. However, there is
one aspect which is a little different and perhaps more attractive. If you want to supply a message to the operator before he/she makes a folder/file choice, just
put the message in a text file (with any file name) and include it in the widget folder with its 2 INI files. It can have any number of lines, which will be
centralised when they are displayed. Put the name of this file into line 2 of the chooser's INI. Then, in line 3, provide a parameter such as "2,1". In this
example, the "2" determines that the message will be shown for 2 seconds, and the "1" determines that the following visual effect (dissolve) to reveal the widget
will last for 1 second. The following 3 pictures illustrate this sequence:
Please note that for the purposes of the demo only, the file name of the message is given as "_picture_chooser_prompt_file.txt" and is unalterable. This is
not the case when you employ the widgets in your own application.
MAKING YOUR OWN STANDALONES
If you download the demo pack offered (see the icon at the top of the page), then apart from the standalone programs required, you will also receive a copy of the
projects. And if you wish to create new standalone widgets from the projects yourself, there is one little thing to be remembered. To keep the widgets on the top
layer while in use, they are defined as SYSTEM WINDOWS (see the "float above everything" option in the stack's properties). If you are making alterations to the
coding and testing the widgets, it is convenient to turn this option off, but before you make a standalone, it is advisable to turn it on again. The RunRev IDE is NOT
very convenient when you are developing a project with system windows because things get covered up and sometimes this prevents access to dialogues that
require a response and you can only get out of this snooker with an Alt-Ctrl-Delete. For the chooser widgets (a simpler case), what I usually do is to save my
project with the float turned on, and then I turn it off before making the standalone, without re-saving as invited:
Finally, please note that if you define the simple widget as a folder chooser (with either "folder" of "folder\" in the last line of its INI file), the pane for choosing
a file name will not appear.
However, if you do the same thing for a picture widget, the right-hand file pane WILL appear so that the operator can browse the file contents of the folders
he/she is considering, including the use of the preview image at the bottom, but what will be returned by the widget is a FOLDER, not a file:
The handling of media devices such as flash drives, CDs and DVDs, external HDs etc. has been simplified in this version of the Linux chooser widgets, which are
fairly closely tailored to follow the layout of the Ubuntu file system. The first icon at the top of a chooser widget (marked "/") provides access to the root of the primary
HD when it is clicked. Clicking on the second and third icons (showing a DVD and a USB device) has exactly the same effect and these icons can be clicked on
indiscriminately. They both cause the widget to navigate automatically to the folder where the virtual images of these devices are stored, which is in the folder
/media. You will find subfolders for each media device that has been mounted or inserted: