[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] create - Gtk::FileSelection

アーカイブの一覧に戻る

ruby-****@sourc***** ruby-****@sourc*****
2005年 10月 14日 (金) 11:38:39 JST


-------------------------
REMOTE_ADDR = 15.211.169.100
REMOTE_HOST = 
REMOTE_USER = ruby-gnome2-hiki
        URL = /hiki.cgi?Gtk%3A%3AFileSelection
-------------------------
TITLE       = Gtk::FileSelection
KEYWORD     = 
= class Gtk::FileSelection
((* Note: This will be deprecated in the future. Use Gtk::FileChooserDialog instead. *))

Gtk::FileSelection should be used to retrieve file or directory names from the user. It will create a new dialog window containing a directory list, and a file list corresponding to the current working directory. The filesystem can be navigated using the directory list or the drop-down history menu. Alternatively, the TAB key can be used to navigate using filename completion - common in text based editors such as emacs and jed.

File selection dialogs are created with a call to Gtk::FileSelection.new.

The default filename can be set using Gtk::FileSelection#filename= and the selected filename retrieved using Gtk::FileSelection#filename.

Use Gtk::FileSelection#complete to display files and directories that match a given pattern. This can be used for example, to show only *.txt files, or only files beginning with gtk*.

Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog. These can be hidden using Gtk::FileSelection#hide_fileop_buttons and shown again using Gtk::FileSelection#show_fileop_buttons.

=== Example 1. Getting a filename from the user.
 require 'gtk2'
 
 Gtk.init
 fs = Gtk::FileSelection.new("Please select a file for editing.")
 fs.ok_button.signal_connect("clicked") do
   puts "Selected filename: #{fs.filename}"
 end
 fs.cancel_button.signal_connect("clicked") do
   Gtk.main_quit
 end
 fs.show_all
 
 Gtk.main

== Object Hierarchy
* Object
  * GLib::Instantiatable
    * GLib::Object
      * Gtk::Object
        * Gtk::Widget
          * Gtk::Container
            * Gtk::Bin
              * Gtk::Window
                * Gtk::Dialog
                  * Gtk::FileSelection

== Class Methods
--- Gtk::FileSelection.new(title = nil)
    Creates a new file selection dialog box. By default it will contain a list of the application's current working directory, and a file listing. Operation buttons that allow the user to create a directory, delete files and rename files, are also present.
    * title: a message that will be placed in the file requestor's titlebar. 
    * Returns: the new file selection.  

== Instance Methods
--- filename
    This method returns the selected filename in the on-disk encoding (see GLib.filename_from_utf8), which may or may not be the same as that used by GTK+ (UTF-8). To convert to UTF-8, call GLib.filename_to_utf8. The returned string points to a statically allocated buffer and should be copied if you plan to keep it around.
    Retrieves the currently selected filename from the file selection dialog. If no file is selected then the selected directory path is returned.
--- filename=(filename)
    Sets a default path for the file requestor. If filename includes a directory path, then the requestor will open with that path as its current working directory.
    The encoding of filename is the on-disk encoding, which may not be UTF-8. See GLib.filename_from_utf8.
    * filename: a string to set as the default file name. 
    * Returns: filename
--- set_filename(filename)
    Same as filename=.
    * filename: a string to set as the default file name. 
    * Returns: filename

--- complete(pattern)
    Will attempt to match pattern to a valid filenames or subdirectories in the current directory. If a match can be made, the matched filename will appear in the text entry field of the file selection dialog. If a partial match can be made, the "Files" list will contain those file names which have been partially matched, and the "Folders" list those directories which have been partially matched. You need to call this method after showing the widget with Gtk::Widget#show(or #show_all)
    * pattern: a string of characters which may or may not match any filenames in the current directory. (e.g.) "*.rb"
    * Returns: self

--- show_fileop_buttons
    Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
    * Returns: self

--- hide_fileop_buttons
    Hides the file operation buttons that normally appear at the top of the dialog. Useful if you wish to create a custom file selector, based on Gtk::FileSelection.
    * Returns: self

--- selections
    Retrieves the list of file selections the user has made in the dialog box. This method is intended for use when the user can select multiple files in the file list. The first file in the list is equivalent to what Gtk::FileSelection#filename would return.
    The filenames are in the encoding of GLib.filename_from_utf8, which may or may not be the same as that used by GTK+ (UTF-8). To convert to UTF-8, call GLib.filename_to_utf8 on each string.
    * Returns: an array of strings. 

--- select_multiple?
    Determines whether or not the user is allowed to select multiple files in the file list. See Gtk::FileSelection#select_multiple=.
    * Returns: true if the user is allowed to select multiple files in the file list 
--- select_multiple=(select_multiple)
    Sets whether the user is allowed to select multiple files in the file list. Use Gtk::FileSelection#selections to get the list of selected files.
    * select_multiple: whether or not the user is allowed to select multiple files in the file list. 
    * Returns: select_multiple
--- set_select_multiple(select_multiple)
    Same as select_multiple=.
    * select_multiple: whether or not the user is allowed to select multiple files in the file list. 
    * Returns: select_multiple

--- show_fileops?
    Retrieve whether the file operation buttons is shown or not.
    * Returns: true if the file operation button is shown.
--- show_fileops=(fileops)
    Sets true if it shows the file operation buttons, otherwise it hides the buttons. See Gtk::FileSelection#show_fileop_buttons=, Gtk::FileSelection#hide_fileop_buttons=.
    * fileops: true if the file operation button is shown.
    * Returns: fileops
--- set_show_fileops(fileops)
    Same as show_fileops=.
    * fileops: true if the file operation button is shown.
    * Returns: self

--- fileop_dialog
    the dialog box used to display the Gtk::FileSelection. It can be customized by adding/removing widgets from it using the standard Gtk::Dialog methods.
    * Returns: fileop_dialog(Gtk::Dialog)

--- dir_list
    the list widget corresponding to directories.
    * Returns: the file_list widget(Gtk::TreeView)
--- file_list
    the list widget corresponding to files.
    * Returns: the file_list widget(Gtk::TreeView)

--- ok_button
    a main button that signals should be connected to in order to perform an action when the user hits either OK.
    * Returns: the ok_button(Gtk::Button)
--- cancel_button
    a main button that signals should be connected to in order to perform an action when the user hits either Cancel.
    * Returns: the cancel_button(Gtk::Button)

--- history_pulldown
    the Gtk::OptionMenu used to create the drop-down directory history.
    * Returns: the history_pulldown(Gtk::OptionMenu).

--- fileop_c_dir
    the button that appear at the top of the file selection dialog a part of "operation buttons".
    * Returns: the fileop_c_dir button(Gtk::Button)
--- fileop_del_file
    the button that appear at the top of the file selection dialog a part of "operation buttons".
    * Returns: the fileop_del_file button(Gtk::Button)
--- fileop_ren_file
    the button that appear at the top of the file selection dialog a part of "operation buttons".
    * Returns: the fileop_ren_file button(Gtk::Button)

== Properties
--- filename: String (Read/Write)
    The currently selected filename

--- select-multiple: true or false (Read/Write)
    Whether to allow multiple files to be selected

--- show-fileops: true or false (Read/Write)
    Whether buttons for creating/manipulating files should be displayed

== See Also
* Gtk::Dialog - Add your own widgets into the Gtk::FileSelection.


- ((<Masao>))






ruby-gnome2-cvs メーリングリストの案内
アーカイブの一覧に戻る