Ardour  9.0-pre0-582-g084a23a80d
Gtk::EntryCompletion Class Reference

#include <entrycompletion.h>

Inheritance diagram for Gtk::EntryCompletion:
[legend]

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);. More...
 

Public Member Functions

virtual ~EntryCompletion ()
 
GtkEntryCompletiongobj ()
 Provides access to the underlying C GObject. More...
 
const GtkEntryCompletiongobj () const
 Provides access to the underlying C GObject. More...
 
GtkEntryCompletiongobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Entryget_entry ()
 
const Entryget_entry () const
 
void set_model (const Glib::RefPtr< TreeModel > &model)
 
Glib::RefPtr< TreeModelget_model ()
 
Glib::RefPtr< const TreeModelget_model () const
 
void unset_model ()
 
void set_match_func (const SlotMatch &slot)
 
void set_minimum_key_length (int length)
 
int get_minimum_key_length () const
 
void complete ()
 
void insert_prefix ()
 
void insert_action_text (const Glib::ustring &text, int index)
 
void prepend_action_text (const Glib::ustring &text)
 
void insert_action_markup (const Glib::ustring &markup, int index)
 
void prepend_action_markup (const Glib::ustring &markup)
 
void delete_action (int index=0)
 
void set_inline_completion (bool inline_completion=true)
 
bool get_inline_completion () const
 
void set_inline_selection (bool inline_selection=true)
 
bool get_inline_selection () const
 
void set_popup_completion (bool popup_completion=true)
 
bool get_popup_completion () const
 
void set_popup_set_width (bool popup_set_width=true)
 
bool get_popup_set_width () const
 
void set_popup_single_width (bool popup_single_match=true)
 
void set_popup_single_match (bool popup_single_match=true)
 
bool get_popup_single_match () const
 
Glib::ustring get_completion_prefix () const
 
void set_text_column (const TreeModelColumnBase &column)
 
void set_text_column (int column)
 
int get_text_column ()
 
int get_text_column () const
 
Glib::SignalProxy1< void, int > signal_action_activated ()
 
Glib::SignalProxy1< bool, const TreeModel::iterator & > signal_match_selected ()
 
Glib::SignalProxy1< bool, const TreeModel::iterator & > signal_cursor_on_match ()
 
Glib::SignalProxy1< bool, const Glib::ustring & > signal_insert_prefix ()
 
Glib::PropertyProxy< Glib::RefPtr< Gtk::TreeModel > > property_model ()
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gtk::TreeModel > > property_model () const
 
Glib::PropertyProxy< int > property_minimum_key_length ()
 
Glib::PropertyProxy_ReadOnly< int > property_minimum_key_length () const
 
Glib::PropertyProxy< int > property_text_column ()
 
Glib::PropertyProxy_ReadOnly< int > property_text_column () const
 
Glib::PropertyProxy< bool > property_inline_completion ()
 
Glib::PropertyProxy_ReadOnly< bool > property_inline_completion () const
 
Glib::PropertyProxy< bool > property_popup_completion ()
 
Glib::PropertyProxy_ReadOnly< bool > property_popup_completion () const
 
Glib::PropertyProxy< bool > property_popup_set_width ()
 
Glib::PropertyProxy_ReadOnly< bool > property_popup_set_width () const
 
Glib::PropertyProxy< bool > property_popup_single_match ()
 
Glib::PropertyProxy_ReadOnly< bool > property_popup_single_match () const
 
Glib::PropertyProxy< bool > property_inline_selection ()
 
Glib::PropertyProxy_ReadOnly< bool > property_inline_selection () const
 

Static Public Member Functions

static GType get_type () G_GNUC_CONST
 
static Glib::RefPtr< EntryCompletioncreate ()
 

Protected Member Functions

 EntryCompletion ()
 
virtual bool on_match_selected (const TreeModel::iterator &iter)
 
virtual void on_action_activated (int index)
 This is a default handler for the signal signal_action_activated(). More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::EntryCompletionwrap (GtkEntryCompletion *object, bool take_copy=false)
 

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.

Definition at line 79 of file entrycompletion.h.

Member Typedef Documentation

◆ SlotMatch

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);.

Definition at line 183 of file entrycompletion.h.

Constructor & Destructor Documentation

◆ ~EntryCompletion()

virtual Gtk::EntryCompletion::~EntryCompletion ( )
virtual

◆ EntryCompletion()

Gtk::EntryCompletion::EntryCompletion ( )
protected

Member Function Documentation

◆ complete()

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.

◆ create()

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

◆ delete_action()

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

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

Parameters
indexThe index of the item to Delete.

◆ get_completion_prefix()

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

◆ get_entry() [1/2]

Entry* Gtk::EntryCompletion::get_entry ( )

Gets the entry completion has been attached to.

Returns
The entry completion has been attached to.

◆ get_entry() [2/2]

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

Gets the entry completion has been attached to.

Returns
The entry completion has been attached to.

◆ get_inline_completion()

bool Gtk::EntryCompletion::get_inline_completion ( ) const

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

Returns
true if inline completion is turned on.

◆ get_inline_selection()

bool Gtk::EntryCompletion::get_inline_selection ( ) const

Returns true if inline-selection mode is turned on.

Returns
true if inline-selection mode is on.

◆ get_minimum_key_length()

int Gtk::EntryCompletion::get_minimum_key_length ( ) const

Returns the minimum key length as set for completion.

Returns
The currently used minimum key length.

◆ get_model() [1/2]

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

Returns the model the Gtk::EntryCompletion is using as data source. Returns 0 if the model is unset.

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

◆ get_model() [2/2]

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

Returns the model the Gtk::EntryCompletion is using as data source. Returns 0 if the model is unset.

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

◆ get_popup_completion()

bool Gtk::EntryCompletion::get_popup_completion ( ) const

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

Returns
true if popup completion is turned on.

◆ get_popup_set_width()

bool Gtk::EntryCompletion::get_popup_set_width ( ) const

Returns whether the completion popup window will be resized to the width of the entry.

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

◆ get_popup_single_match()

bool Gtk::EntryCompletion::get_popup_single_match ( ) const

Returns whether the completion popup window will appear even if there is only a single match.

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

◆ get_text_column() [1/2]

int Gtk::EntryCompletion::get_text_column ( )

Returns the column in the model of completion to get strings from.

Returns
The column containing the strings.

◆ get_text_column() [2/2]

int Gtk::EntryCompletion::get_text_column ( ) const

Returns the column in the model of completion to get strings from.

Returns
The column containing the strings.

◆ get_type()

static GType Gtk::EntryCompletion::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GtkEntryCompletion* Gtk::EntryCompletion::gobj ( )
inline

Provides access to the underlying C GObject.

Definition at line 118 of file entrycompletion.h.

◆ gobj() [2/2]

const GtkEntryCompletion* Gtk::EntryCompletion::gobj ( ) const
inline

Provides access to the underlying C GObject.

Definition at line 121 of file entrycompletion.h.

◆ gobj_copy()

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.

◆ insert_action_markup()

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

◆ insert_action_text()

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

◆ insert_prefix()

void Gtk::EntryCompletion::insert_prefix ( )

Requests a prefix insertion.

◆ on_action_activated()

virtual void Gtk::EntryCompletion::on_action_activated ( int  index)
protectedvirtual

This is a default handler for the signal signal_action_activated().

◆ on_match_selected()

virtual bool Gtk::EntryCompletion::on_match_selected ( const TreeModel::iterator iter)
protectedvirtual

◆ prepend_action_markup()

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

◆ prepend_action_text()

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

◆ property_inline_completion() [1/2]

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

Whether the common prefix should be inserted automatically.

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

◆ property_inline_completion() [2/2]

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

Whether the common prefix should be inserted automatically.

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

◆ property_inline_selection() [1/2]

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

Your description here.

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

◆ property_inline_selection() [2/2]

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

Your description here.

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

◆ property_minimum_key_length() [1/2]

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

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

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

◆ property_minimum_key_length() [2/2]

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

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

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

◆ property_model() [1/2]

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

The model to find matches in.

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

◆ property_model() [2/2]

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

The model to find matches in.

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

◆ property_popup_completion() [1/2]

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

Whether the completions should be shown in a popup window.

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

◆ property_popup_completion() [2/2]

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

Whether the completions should be shown in a popup window.

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

◆ property_popup_set_width() [1/2]

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

If TRUE, the popup window will have the same size as the entry.

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

◆ property_popup_set_width() [2/2]

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

If TRUE, the popup window will have the same size as the entry.

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

◆ property_popup_single_match() [1/2]

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

If TRUE, the popup window will appear for a single match.

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

◆ property_popup_single_match() [2/2]

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

If TRUE, the popup window will appear for a single match.

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

◆ property_text_column() [1/2]

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

The column of the model containing the strings.

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

◆ property_text_column() [2/2]

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

The column of the model containing the strings.

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

◆ set_inline_completion()

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.

Parameters
inline_completiontrue to do inline completion.

◆ set_inline_selection()

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

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

Parameters
inline_selectiontrue to do inline selection.

◆ set_match_func()

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

◆ set_minimum_key_length()

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).

Parameters
lengthThe minimum length of the key in order to start completing.

◆ set_model()

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. Use unset_model() to unset the old model.

Parameters
modelThe Gtk::TreeModel.

◆ set_popup_completion()

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

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

Parameters
popup_completiontrue to do popup completion.

◆ set_popup_set_width()

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.

Parameters
popup_set_widthtrue to make the width of the popup the same as the entry.

◆ set_popup_single_match()

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.

Parameters
popup_single_matchtrue if the popup should appear even for a single match.

◆ set_popup_single_width()

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.

Parameters
popup_single_matchtrue if the popup should appear even for a single match.

◆ set_text_column() [1/2]

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.

Parameters
columnThe column in the model of completion to get strings from.

◆ set_text_column() [2/2]

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.

Parameters
columnThe column in the model of completion to get strings from.

◆ signal_action_activated()

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

Emitted when an action is activated.

Parameters
indexThe index of the activated action.
Slot Prototype:
void on_my_action_activated(int index)

◆ signal_cursor_on_match()

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
modelThe TreeModel containing the matches
iterA 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)

◆ signal_insert_prefix()

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 '/'.

Parameters
prefixThe common prefix of all possible completions.
Returns
true if the signal has been handled
Slot Prototype:
bool on_my_insert_prefix(const Glib::ustring& prefix)

◆ signal_match_selected()

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.

It is necessary to connect your signal handler before the default one, which would otherwise return true, a value which signifies that the signal has been handled, thus preventing any other handler from being invoked.

To do this, pass false to this signal proxy's connect() method. For example: completion->signal_match_selected().connect(sigc::mem_fun(*this, &YourClass::on_completion_match_selected), false);

Parameters
modelThe TreeModel containing the matches
iterA TreeModel::iterator positioned at the selected match
Returns
true if the signal has been handled
Prototype:
bool on_match_selected(const TreeModel::iterator& iter)

◆ unset_model()

void Gtk::EntryCompletion::unset_model ( )

Remove the model from the EntryCompletion.

See also
set_model().

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::EntryCompletion > wrap ( GtkEntryCompletion object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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: