Factor out helper AppendToStore() function
Simple refactoring to avoid repeating the same not quite obvious code for appending an item to GtkListStore twice.
This commit is contained in:
@@ -232,14 +232,12 @@ public:
|
|||||||
DoEnableCompletion();
|
DoEnableCompletion();
|
||||||
|
|
||||||
GtkListStore * const store = gtk_list_store_new (1, G_TYPE_STRING);
|
GtkListStore * const store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
for ( wxArrayString::const_iterator i = strings.begin();
|
for ( wxArrayString::const_iterator i = strings.begin();
|
||||||
i != strings.end();
|
i != strings.end();
|
||||||
++i )
|
++i )
|
||||||
{
|
{
|
||||||
gtk_list_store_append (store, &iter);
|
AppendToStore(store, *i);
|
||||||
gtk_list_store_set (store, &iter, 0, (const gchar *)i->utf8_str(), -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_entry_completion_set_model (GetEntryCompletion(), GTK_TREE_MODEL(store));
|
gtk_entry_completion_set_model (GetEntryCompletion(), GTK_TREE_MODEL(store));
|
||||||
@@ -304,6 +302,14 @@ private:
|
|||||||
m_newCompletionsNeeded = m_entry->IsEmpty();
|
m_newCompletionsNeeded = m_entry->IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function for appending a string to GtkListStore.
|
||||||
|
void AppendToStore(GtkListStore* store, const wxString& s)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gtk_list_store_append (store, &iter);
|
||||||
|
gtk_list_store_set (store, &iter, 0, (const gchar *)s.utf8_str(), -1);
|
||||||
|
}
|
||||||
|
|
||||||
void DoEnableCompletion()
|
void DoEnableCompletion()
|
||||||
{
|
{
|
||||||
if ( !GetEntryCompletion() )
|
if ( !GetEntryCompletion() )
|
||||||
@@ -386,7 +392,6 @@ private:
|
|||||||
if ( m_completer->Start(prefix) )
|
if ( m_completer->Start(prefix) )
|
||||||
{
|
{
|
||||||
GtkListStore * const store = gtk_list_store_new (1, G_TYPE_STRING);
|
GtkListStore * const store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -394,8 +399,7 @@ private:
|
|||||||
if ( s.empty() )
|
if ( s.empty() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
gtk_list_store_append (store, &iter);
|
AppendToStore(store, s);
|
||||||
gtk_list_store_set (store, &iter, 0, (const gchar *)s.utf8_str(), -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_entry_completion_set_model (GetEntryCompletion(), GTK_TREE_MODEL(store));
|
gtk_entry_completion_set_model (GetEntryCompletion(), GTK_TREE_MODEL(store));
|
||||||
|
Reference in New Issue
Block a user