Main Page Widgets Namespaces Book

# Gtk::EntryCompletion Class Reference

Inheritance diagram for Gtk::EntryCompletion:

[legend]

List of all members.

## Detailed Description

Completion functionality for Gtk::Entry.

Gtk::EntryCompletion is an auxiliary object to be used in conjunction with Gtk::Entry to provide the completion functionality.

"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 set_text_column()), but this can be overridden with a custom match function (see 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 the display of "actions" in the popup window. Their appearance is similar to menu items, to differentiate them clearly from completion strings. When an action is selected, the action_activated signal is emitted.

## Public Types

typedef sigc::slot< bool, const Glib::ustring &, const TreeModel::const_iterator& > | SlotMatch
| For example, bool on_match(const Glib::ustring& key, const TreeModel::const_iterator& iter);.

## Public Member Functions

void | complete ()
| Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key.
void | delete_action (int index=0)
| Deletes the action at index from completion's action list.
Glib::ustring | get_completion_prefix () const
| Get the original text entered by the user that triggered the completion or an empty string if there's no completion ongoing.
const Entry* | get_entry () const
| Gets the entry completion has been attached to.
Entry* | get_entry ()
| Gets the entry completion has been attached to.
bool | get_inline_completion () const
| Return value: `true` if inline completion is turned on.
bool | get_inline_selection () const
| Returns: `true` if inline-selection mode is on.
int | get_minimum_key_length () const
| Return value: The currently used minimum key length.
Glib::RefPtr<const TreeModel> | get_model () const
| Returns `0` if the model is unset.
Glib::RefPtr<TreeModel> | get_model ()
| Returns `0` if the model is unset.
bool | get_popup_completion () const
| Return value: `true` if popup completion is turned on.
bool | get_popup_set_width () const
| Return value: `true` if the popup window will be resized to the width of.
bool | get_popup_single_match () const
| Return value: `true` if the popup window will appear regardless of the.
int | get_text_column () const
| Return value: the column containing the strings.
int | get_text_column ()
| Return value: the column containing the strings.
const GtkEntryCompletion* | gobj () const
| Provides access to the underlying C GObject.
GtkEntryCompletion* | gobj ()
| Provides access to the underlying C GObject.
GtkEntryCompletion* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | insert_action_markup (const Glib::ustring& markup, int index)
void | insert_action_text (const Glib::ustring& text, int index)
void | insert_prefix ()
| Requests a prefix insertion.
void | prepend_action_markup (const Glib::ustring& markup)
void | prepend_action_text (const Glib::ustring& text)
Glib::PropertyProxy_ReadOnly <bool> | property_inline_completion () const
| Whether the common prefix should be inserted automatically.
Glib::PropertyProxy<bool> | property_inline_completion ()
| Whether the common prefix should be inserted automatically.
Glib::PropertyProxy_ReadOnly <bool> | property_inline_selection () const
| Your description here.
Glib::PropertyProxy<bool> | property_inline_selection ()
| Your description here.
Glib::PropertyProxy_ReadOnly<int> | property_minimum_key_length () const
| Minimum length of the search key in order to look up matches.
Glib::PropertyProxy<int> | property_minimum_key_length ()
| Minimum length of the search key in order to look up matches.
Glib::PropertyProxy_ReadOnly <Glib::RefPtr<Gtk::TreeModel>> | property_model () const
| The model to find matches in.
Glib::PropertyProxy <Glib::RefPtr<Gtk::TreeModel>> | property_model ()
| The model to find matches in.
Glib::PropertyProxy_ReadOnly <bool> | property_popup_completion () const
| Whether the completions should be shown in a popup window.
Glib::PropertyProxy<bool> | property_popup_completion ()
| Whether the completions should be shown in a popup window.
Glib::PropertyProxy_ReadOnly <bool> | property_popup_set_width () const
| If TRUE.
Glib::PropertyProxy<bool> | property_popup_set_width ()
| If TRUE.
Glib::PropertyProxy_ReadOnly <bool> | property_popup_single_match () const
| If TRUE.
Glib::PropertyProxy<bool> | property_popup_single_match ()
| If TRUE.
Glib::PropertyProxy_ReadOnly<int> | property_text_column () const
| The column of the model containing the strings.
Glib::PropertyProxy<int> | property_text_column ()
| The column of the model containing the strings.
void | set_inline_completion (bool inline_completion=true)
| Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
void | set_inline_selection (bool inline_selection=true)
| Sets whether it is possible to cycle through the possible completions inside the entry.
void | set_match_func (const SlotMatch& slot)
void | set_minimum_key_length (int length)
| Requires the length of the search key for completion to be at least length.
void | set_model (const Glib::RefPtr<TreeModel>& model)
| Sets the model for a Gtk::EntryCompletion.
void | set_popup_completion (bool popup_completion=true)
| Sets whether the completions should be presented in a popup window.
void | set_popup_set_width (bool popup_set_width=true)
| Sets whether the completion popup window will be resized to be the same width as the entry.
void | set_popup_single_match (bool popup_single_match=true)
| Sets whether the completion popup window will appear even if there is only a single match.
void | set_popup_single_width (bool popup_single_match=true)
| Sets whether the completion popup window will appear even if there is only a single match.
void | set_text_column (int column)
| Convenience function for setting up the most used case of this code: a completion list with just strings.
void | set_text_column (const TreeModelColumnBase& column)
| Convenience function for setting up the most used case of this code: a completion list with just strings.
Glib::SignalProxy1<void, int> | signal_action_activated ()
| Emitted when an action is activated.
Glib::SignalProxy1< bool, const TreeModel::iterator& > | signal_cursor_on_match ()
| Emitted when a match from the cursor is on a match of the list.
Glib::SignalProxy1< bool, const Glib::ustring& > | signal_insert_prefix ()
| Emitted when the inline autocompletion is triggered.
Glib::SignalProxy1< bool, const TreeModel::iterator& > | signal_match_selected ()
| Emitted when a match from the list is selected.
virtual | ~EntryCompletion ()

## Static Public Member Functions

static Glib::RefPtr <EntryCompletion> | create ()

## Protected Member Functions

| EntryCompletion ()
virtual void | on_action_activated (int index)
virtual bool | on_match_selected (const TreeModel::iterator& iter)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr <Gtk::EntryCompletion> | wrap (GtkEntryCompletion* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Member Typedef Documentation

typedef sigc::slot<bool, const Glib::ustring&, const TreeModel::const_iterator&> Gtk::EntryCompletion::SlotMatch

For example, bool on_match(const Glib::ustring& key, const TreeModel::const_iterator& iter);.

## Constructor & Destructor Documentation

virtual Gtk::EntryCompletion::~EntryCompletion | ( |  | ) | `[virtual]`

Gtk::EntryCompletion::EntryCompletion | ( |  | ) | `[protected]`

## Member Function Documentation

void Gtk::EntryCompletion::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 gtkmm 2.4:

static Glib::RefPtr<EntryCompletion> Gtk::EntryCompletion::create | ( |  | ) | `[static]`

void Gtk::EntryCompletion::delete_action | ( | int | index = `0` | ) |

Deletes the action at index from completion's action list.

Since gtkmm 2.4:

Parameters:

  | index | The index of the item to Delete.

Glib::ustring Gtk::EntryCompletion::get_completion_prefix | ( |  | ) | const

Get the original text entered by the user that triggered the completion or an empty string if there's no completion ongoing.

Returns:
  The prefix for the current completion

Since gtkmm 2.12:

const Entry* Gtk::EntryCompletion::get_entry | ( |  | ) | const

Gets the entry completion has been attached to.

Returns:
  The entry completion has been attached to.

Since gtkmm 2.4:

Entry* Gtk::EntryCompletion::get_entry | ( |  | ) |

Gets the entry completion has been attached to.

Returns:
  The entry completion has been attached to.

Since gtkmm 2.4:

bool Gtk::EntryCompletion::get_inline_completion | ( |  | ) | const

Return value: `true` if inline completion is turned on.

Returns:
  `true` if inline completion is turned on

Since gtkmm 2.6:

bool Gtk::EntryCompletion::get_inline_selection | ( |  | ) | const

Returns: `true` if inline-selection mode is on.

Returns:
  `true` if inline-selection mode is on

Since gtkmm 2.12:

int Gtk::EntryCompletion::get_minimum_key_length | ( |  | ) | const

Return value: The currently used minimum key length.

Returns:
  The currently used minimum key length.

Since gtkmm 2.4:

Glib::RefPtr<const TreeModel> Gtk::EntryCompletion::get_model | ( |  | ) | const

Returns `0` if the model is unset.

Return value: A Gtk::TreeModel, or `0` if none is currently being used.

Returns:
  A Gtk::TreeModel, or `0` if none is currently being used.

Since gtkmm 2.4:

Glib::RefPtr<TreeModel> Gtk::EntryCompletion::get_model | ( |  | ) |

Returns `0` if the model is unset.

Return value: A Gtk::TreeModel, or `0` if none is currently being used.

Returns:
  A Gtk::TreeModel, or `0` if none is currently being used.

Since gtkmm 2.4:

bool Gtk::EntryCompletion::get_popup_completion | ( |  | ) | const

Return value: `true` if popup completion is turned on.

Returns:
  `true` if popup completion is turned on

Since gtkmm 2.6:

bool Gtk::EntryCompletion::get_popup_set_width | ( |  | ) | const

Return value: `true` if the popup window will be resized to the width of.

Returns:
  `true` if the popup window will be resized to the width of the entry

Since gtkmm 2.8:

bool Gtk::EntryCompletion::get_popup_single_match | ( |  | ) | const

Return value: `true` if the popup window will appear regardless of the.

Returns:
  `true` if the popup window will appear regardless of the number of matches.

Since gtkmm 2.8:

int Gtk::EntryCompletion::get_text_column | ( |  | ) | const

Return value: the column containing the strings.

Returns:
  The column containing the strings

Since gtkmm 2.6:

int Gtk::EntryCompletion::get_text_column | ( |  | ) |

Return value: the column containing the strings.

Deprecated:
  Use the const version of this method.

Returns:
  The column containing the strings

Since gtkmm 2.6:

const GtkEntryCompletion* Gtk::EntryCompletion::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GtkEntryCompletion* Gtk::EntryCompletion::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GtkEntryCompletion* Gtk::EntryCompletion::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gtk::EntryCompletion::insert_action_markup | ( | const Glib::ustring & | markup,
|  | int | index |
| ) |  |  |

void Gtk::EntryCompletion::insert_action_text | ( | const Glib::ustring & | text,
|  | int | index |
| ) |  |  |

void Gtk::EntryCompletion::insert_prefix | ( |  | ) |

Requests a prefix insertion.

Since gtkmm 2.6:

virtual void Gtk::EntryCompletion::on_action_activated | ( | int | index | ) | `[protected, virtual]`

virtual bool Gtk::EntryCompletion::on_match_selected | ( | const TreeModel::iterator& | iter | ) | `[protected, virtual]`

void Gtk::EntryCompletion::prepend_action_markup | ( | const Glib::ustring & | markup | ) |

void Gtk::EntryCompletion::prepend_action_text | ( | const Glib::ustring & | text | ) |

Glib::PropertyProxy_ReadOnly<bool> Gtk::EntryCompletion::property_inline_completion | ( |  | ) | const

Whether the common prefix should be inserted automatically.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::EntryCompletion::property_inline_completion | ( |  | ) |

Whether the common prefix should be inserted automatically.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::EntryCompletion::property_inline_selection | ( |  | ) | const

Your description here.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::EntryCompletion::property_inline_selection | ( |  | ) |

Your description here.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<int> Gtk::EntryCompletion::property_minimum_key_length | ( |  | ) | const

Minimum length of the search key in order to look up matches.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<int> Gtk::EntryCompletion::property_minimum_key_length | ( |  | ) |

Minimum length of the search key in order to look up matches.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::RefPtr<Gtk::TreeModel>> Gtk::EntryCompletion::property_model | ( |  | ) | const

The model to find matches in.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::RefPtr<Gtk::TreeModel>> Gtk::EntryCompletion::property_model | ( |  | ) |

The model to find matches in.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::EntryCompletion::property_popup_completion | ( |  | ) | const

Whether the completions should be shown in a popup window.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::EntryCompletion::property_popup_completion | ( |  | ) |

Whether the completions should be shown in a popup window.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::EntryCompletion::property_popup_set_width | ( |  | ) | const

If TRUE.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::EntryCompletion::property_popup_set_width | ( |  | ) |

If TRUE.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::EntryCompletion::property_popup_single_match | ( |  | ) | const

If TRUE.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::EntryCompletion::property_popup_single_match | ( |  | ) |

If TRUE.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<int> Gtk::EntryCompletion::property_text_column | ( |  | ) | const

The column of the model containing the strings.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<int> Gtk::EntryCompletion::property_text_column | ( |  | ) |

The column of the model containing the strings.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

void Gtk::EntryCompletion::set_inline_completion | ( | bool | inline_completion = `true` | ) |

Sets whether the common prefix of the possible completions should be automatically inserted in the entry.

Since gtkmm 2.6:

Parameters:

  | inline_completion | `true` to do inline completion.

void Gtk::EntryCompletion::set_inline_selection | ( | bool | inline_selection = `true` | ) |

Sets whether it is possible to cycle through the possible completions inside the entry.

Since gtkmm 2.12:

Parameters:

  | inline_selection | `true` to do inline selection.

void Gtk::EntryCompletion::set_match_func | ( | const SlotMatch& | slot | ) |

void Gtk::EntryCompletion::set_minimum_key_length | ( | int | 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 gtkmm 2.4:

Parameters:

  | length | The minimum length of the key in order to start completing.

void Gtk::EntryCompletion::set_model | ( | const Glib::RefPtr<TreeModel>& | 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 `0`, then it will unset the model.

Since gtkmm 2.4:

Parameters:

  | model | The Gtk::TreeModel.

void Gtk::EntryCompletion::set_popup_completion | ( | bool | popup_completion = `true` | ) |

Sets whether the completions should be presented in a popup window.

Since gtkmm 2.6:

Parameters:

  | popup_completion | `true` to do popup completion.

void Gtk::EntryCompletion::set_popup_set_width | ( | bool | popup_set_width = `true` | ) |

Sets whether the completion popup window will be resized to be the same width as the entry.

Since gtkmm 2.8:

Parameters:

  | popup_set_width | `true` to make the width of the popup the same as the entry.

void Gtk::EntryCompletion::set_popup_single_match | ( | bool | popup_single_match = `true` | ) |

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 gtkmm 2.8:

Parameters:

  | popup_single_match | `true` if the popup should appear even for a single match.

void Gtk::EntryCompletion::set_popup_single_width | ( | bool | popup_single_match = `true` | ) |

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 gtkmm 2.8:

Deprecated:
  Use set_popup_single_match() instead. This function was wrongly named.

Parameters:

  | popup_single_match | `true` if the popup should appear even for a single match.

void Gtk::EntryCompletion::set_text_column | ( | int | column | ) |

Convenience function for setting up the most used case of this code: a completion list with just strings.

This function 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.

This functions 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() to set the text_column property directly.

Since gtkmm 2.4:

Parameters:

  | column | The column in the model of completion to get strings from.

void Gtk::EntryCompletion::set_text_column | ( | const TreeModelColumnBase& | column | ) |

Convenience function for setting up the most used case of this code: a completion list with just strings.

This function 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.

This functions 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() to set the text_column property directly.

Since gtkmm 2.4:

Parameters:

  | column | The column in the model of completion to get strings from.

Glib::SignalProxy1< void,int > Gtk::EntryCompletion::signal_action_activated | ( |  | ) |

Emitted when an action is activated.

Parameters:

  | index | The index of the activated action.

Prototype:
  `void on_my_action_activated(int index)`

Glib::SignalProxy1<bool, const TreeModel::iterator&> Gtk::EntryCompletion::signal_cursor_on_match | ( |  | ) |

Emitted when a match from the cursor is on a match of the list.

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.

Parameters:

  | model | The TreeModel containing the matches
  | iter | A TreeModel::iterator positioned at the selected match

Returns:
  true if the signal has been handled

Prototype:
  `bool on_cursor_on_match(const TreeModel::iterator& iter)`

Since gtkmm 2.12:

Glib::SignalProxy1< bool,const Glib::ustring& > Gtk::EntryCompletion::signal_insert_prefix | ( |  | ) |

Emitted when the inline autocompletion is triggered.

The default behaviour is to make the entry display the whole prefix and select the newly inserted part.

Applications may connect to this signal in order to insert only a smaller part of the prefix into the entry - e.g. the entry used in the FileChooser inserts only the part of the prefix up to the next '/'.

Since gtkmm 2.6:

Parameters:

  | prefix | The common prefix of all possible completions.

Returns:
  true if the signal has been handled

Prototype:
  `bool on_my_insert_prefix(const Glib::ustring& prefix)`

Glib::SignalProxy1<bool, const TreeModel::iterator&> Gtk::EntryCompletion::signal_match_selected | ( |  | ) |

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.

Parameters:

  | model | The TreeModel containing the matches
  | iter | A TreeModel::iterator positioned at the selected match

Returns:
  true if the signal has been handled

Prototype:
  `bool on_match_selected(const TreeModel::iterator& iter)`

## Friends And Related Function Documentation

Glib::RefPtr<Gtk::EntryCompletion> wrap | ( | GtkEntryCompletion * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- entrycompletion.h