GNOME File Selector Developer Documentation | ||
---|---|---|
<<< Previous | Next >>> |
The GNOME File Selector's control has a standard property bag with which it makes itself configurable by applications. This can be obtained via the Bonobo::Control::getProperties() method.
Example 5. Obtaining a Bonobo::PropertyBag
Bonobo_PropertyBag pbag; pbag = Bonobo_Control_getProperties (corba_control, ev); |
However, as the CORBA interface for properties in Bonobo 1.0 is not as elegant as the 2.0 version, it is recommended that you use the BonoboWidget versions of these functions.
Example 6. Setting Some Properties
BonoboWidget *control; bonobo_widget_set_property (control, "AcceptDirectories", FALSE, "Application", "MyApp", "DefaultFileName", get_last_file_name(), "MimeTypes", _("Text Files:text/plain"), "MultipleSelection", TRUE, NULL); |
Here is a list of properties supported by the GNOME File Selector. I don't really know docbook so well but it will hopefully eventually be a nice table.
Example 7. Listing of Properties
name type description ------------------------------------------------------------------------------------------------------ AcceptDirectories rw boolean whether to return directories Application rw string name of application - for restoring state DefaultFileName rw string name of file name to default to when changing directories DefaultLocation rw string URI to start up with DefaultView rw string view mode to start out in if the user hasn't chosen one yet EnableVFS rw boolean restrict uris to local files only MimeTypes rw string list of mime types calling application can accept MimeTypesSequence rw sequence<string> list of mime types calling application can accept MultipleSelection rw boolean whether to allow multiple selection or not RequestedURI rw string URI to load SaveMode rw boolean whether we are a save dialog |
The AcceptDirectories property controls whether the GNOME File Selector will return directory files to your application. If your application can open directories, set this to TRUE. The default value is FALSE.
![]() | This property is ignored when SaveMode is set to TRUE. |
Set the Application property to the name of your application. This is used to restore such settings as view type and directory automatically for you the next time a user uses the GNOME File Selector.
Use the DefaultFileName property to set what the text entry defaults to when changing directories.
The DefaultLocation property can be used to specify which directory the GNOME File Selector starts up in. This is only used if the user has not used the GNOME File Selector with the specified Application. The RequestedURI property overrides both of these, and if none are set the GNOME File Selector defaults to the user's home directory.
You can use the DefaultView to specify which view should be used as default. Currently available views are "Details" and "Icons". This will be overridden if the user has used the file selector from your application before with whichever view they were last using.
If your application does not use gnome-vfs, or circumstances require it, set the EnableVFS property to FALSE (TRUE is the default value). This will restrict the GNOME File Selector to files on the local filesystem, which can be opened with the standard UNIX open() call. The paths returned by the ButtonClicked:Action event will not contain the file: prefix (/home/joe/foo.txt will be returned rather than file:///home/joe/foo.txt).
The MimeTypes property is a little complicated, but is still easy to use.
![]() | This property is mostly useful when setting properties via the item moniker (see the next section, "Easier Property Setting"). If you are using the normal property bag functions, consider using the MimeTypesSequence property. |
The string you should set for this property is a pipe (|) delimited list of string pairs, which are themselves delemited by colons (:). The first element of each pair is the name of the mime type, such as "Text Files". These can be obtained from the gnome_vfs_mime_get_description () function. In fact, if you leave the first part blank, the GNOME File Selector will automatically call this function for you.
The second element is a comma delimited list of mime types, such as "text/plain,text/x-c,text/xml".
The MimeTypesSequence property is similar to the MimeTypes property, except that it is a sequence of name/types pairs in the same manner as MimeTypes.
If your application can open multiple files, set the MultipleSelection property to FALSE. If it is set to FALSE, the string sequence returned in the ButtonClicked:Action event will only contain one element.
![]() | This property is ignored when SaveMode is set to TRUE. |
The RequestedURI property can be used to request a file or directory from the GNOME File Selector. When you set this property, the GNOME File Selector will attempt to load this directory or file.
This property can be used if you are keeping around the dialog between uses, and need to change to a different default directory (for example, if you want to save a file in a specific directory).
The SaveMode property is used to set the GNOME File Selector to save mode. When in save mode, the AcceptDirectories and MultipleSelection properties are ignored, and the action button's label will read "Save". Also when in save mode, the URI returned from the ButtonClicked:Action event will not necessarily exist.
<<< Previous | Home | Next >>> |
Events | Easier Property Setting |