新規作成  編集  Ruby-GNOME2 Project Website  ページ一覧  検索  更新履歴  編集履歴  RSS  ログイン

Gtk::EntryCompletion

Gtk::EntryCompletion クラス

Gtk::EntryCompletion is an auxiliary object to be used in conjunction with Gtk::Entry to provide the completion functionality. It implements the Gtk::CellLayout interface, to allow the user to add extra cells to the Gtk::TreeView with completion matches.

"Completion functionality" means that when the user modifies the text in the entry, Gtk::EntryCompletion checks which rows in the model match the current content of the entry, and displays a list of matches. By default, the matching is done by comparing the entry text case-insensitively against the text column of the model (see Gtk::EntryCompletion#text_column=), but this can be overridden with a custom match method (see Gtk::EntryCompletion_set_match_func?).

When the user selects a completion, the content of the entry is updated. By default, the content of the entry is replaced by the text column of the model, but this can be overridden by connecting to the ::match-selected signal and updating the entry in the signal handler. Note that you should return TRUE from the signal handler to suppress the default behaviour.

To add completion functionality to an entry, use Gtk::Entry#set_completion.

In addition to regular completion matches, which will be inserted into the entry when they are selected, Gtk::EntryCompletion also allows to display "actions" in the popup window. Their appearance is similar to menuitems, to differentiate them clearly from completion strings. When an action is selected, the ::action-activated signal is emitted.

クラスメソッド

Gtk::EntryCompletion.new
Creates a new Gtk::EntryCompletion object. Since 2.4
  • Returns: A newly created GtkEntryCompletion object.

インスタンスメソッド

entry
Gets the entry completion has been attached to. Since 2.4
  • Returns: The entry completion has been attached to.
model
Returns the model the Gtk::EntryCompletion is using as data source. Returns nil if the model is unset. Since 2.4
model=(model)
Sets the model for a Gtk::EntryCompletion. If completion already has a model set, it will remove it before setting the new model. If model is nil, then it will unset the model. Since 2.4
set_model(model)
Same as Gtk::EntryCompletion#model=. Since 2.4
set_match_func{|completion, key, iter| ... }
Sets the match function for completion as a block. The match function is used to determine if a row should or should not be in the completion list. Since 2.4
  • {|completion, key, iter| ... } : match function for completion as a block. A block which decides whether the row indicated by iter matches a given key, and should be displayed as a possible completion for key. Note that key is normalized and case-folded (see g_utf8_normalize() and g_utf8_casefold()). If this is not appropriate, match functions have access to the unmodified key via Gtk::Entry#text.
    • completion: the Gtk::EntryCompletion
    • key: the string to match, normalized and case-folded
    • iter: a Gtk::TreeIter indicating the row to match
    • Returns: true if iter should be displayed as a possible completion for key
  • Returns: self
minimum_key_length
Returns the minimum key length as set for completion. Since 2.4
  • Returns: The currently used minimum key length.
minimum_key_length=(length)
Requires the length of the search key for completion to be at least length. This is useful for long lists, where completing using a small key takes a lot of time and will come up with meaningless results anyway (ie, a too large dataset). Since 2.4
  • length: The minimum length of the key in order to start completing
  • Returns: length
set_minimum_key_length(length)
Same as Gtk::EntryCompletion#minimum_key_length=. Since 2.4
  • length: The minimum length of the key in order to start completing
  • Returns: self
complete
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key. The completion list view will be updated accordingly. Since 2.4
  • Returns: self
insert_action_text(index, text)
Inserts an action in completion's action item list at position index with text text. If you want the action item to have markup, use Gtk::EntryCompletion#insert_action_markup. Since 2.4
  • index: The index of the item to insert.
  • text: Text of the item to insert.
  • Returns: self
insert_action_markup(index, markup)
Inserts an action in completion's action item list at position index with markup markup. Since 2.4
  • index: The index of the item to insert.
  • markup: Markup of the item to insert.
  • Returns: self
delete_action(index)
Deletes the action at index from completion's action list. Since 2.4
  • index: The index of the item to Delete.
  • Returns: self
text_column=(column)
Convenience method for setting up the most used case of this code: a completion list with just strings. This method will set up completion to have a list displaying all (and just) strings in the completion list, and to get those strings from column in the model of completion. The method creates and adds a Gtk::CellRendererText for the selected column. If you need to set the text column, but don't want the cell renderer, use GLib::Object#set_property to set the ::text_column property directly. Since 2.4
  • column: The column(Integer) in the model of completion to get strings from.
  • Returns: column
set_text_column(column)
Same as Gtk::EntryCompletion#text_column=. Since 2.4
  • column: The column(Integer) in the model of completion to get strings from.
  • Returns: self
popup_set_width=(popup_set_width)
Sets whether the completion popup window will be resized to be the same width as the entry. Since 2.8
  • popup_set_width: true to make the width of the popup the same as the entry
  • Returns: popup_set_width
set_popup_set_width(popup_set_width)
Same as Gtk::EntryCompletion#popup_set_width=. Since 2.8
  • popup_set_width: true to make the width of the popup the same as the entry
  • Returns: self
popup_set_width?
Returns whether the completion popup window will be resized to the width of the entry. Since 2.8
  • Returns: true if the popup window will be resized to the width of the entry
popup_single_match=(popup_single_match)
Sets whether the completion popup window will appear even if there is only a single match. You may want to set this to false if you are using inline completion. Since 2.8
  • popup_single_match: true if the popup should appear even for a single match
  • Returns: popup_single_match
set_popup_single_match(popup_single_match)
Same as Gtk::EntryCompletion#popup_single_match=. Since 2.8
  • popup_single_match: true if the popup should appear even for a single match
  • Returns: self
popup_single_match?
Returns whether the completion popup window will appear even if there is only a single match. Since 2.8
  • Returns: true if the popup window will appear regardless of the number of matches.
completion_prefix()
要編集
insert_prefix()
要編集
inline_selection=()
要編集
set_inline_selection()
要編集
inline_selection?()
要編集
popup_completion=()
要編集
set_popup_completion()
要編集
popup_completion?()
要編集
inline_completion=()
要編集
set_inline_completion()
要編集
inline_completion?()
要編集
text_column()
要編集

プロパティ

minimum-key-length: Integer (Read/Write)
Minimum length of the search key in order to look up matches. Since 2.4
  • Allowed values: >= -1
  • Default value: 1
model: Gtk::TreeModel (Read/Write)
The model to find matches in. Since 2.4
popup-set-width: true or false (Read/Write)
Determines whether the completions popup window will be resized to the width of the entry. Default value: true. Since 2.8
popup-single-match: true or false (Read/Write)Write
Determines whether the completions popup window will be shown for a single possible completion. You probably want to set this to false if you are using inline completion. Default value: true. Since 2.8
inline-selection:
要編集
popup-completion:
要編集
inline-completion:
要編集
text-column:
要編集

シグナル

action-activated: self, index
Gets emitted when an action is activated. Since 2.4
  • self: the object which received the signal
  • index: the index of the activated action
match-selected: self
Gets emitted when a match from the list is selected. The default behaviour is to replace the contents of the entry with the contents of the text column in the row pointed to by iter. Since 2.4
  • self: the object which received the signal
  • model: the Gtk::TreeModel containing the matches
  • iter: a Gtk::TreeIter positioned at the selected match
  • Returns: true if the signal has been handled
cursor-on-match:
要編集
insert-prefix:
要編集

更新履歴

  • 2014-06-16 クラスのメンバで漏れていたものを追加。 - きたがわ
更新日時:2014/06/16 06:42:03
キーワード:
参照:[Gtk::Entry] [Ruby/GTK] [Ruby/GTK Object Hierarchy] [Gtk::EntryCompletion]