X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Ftextureentry.cpp;h=04512f6f6887374ec735eaa4bc92a013c7f811b7;hb=644aa914b3ca91e5a778bf5c1cbf6c018758993d;hp=781dcbe44ca8c96c3e4f233bdfbbec430dbd5e93;hpb=7fc621fc78d0e040dc2c12f38dc53dd9048215dc;p=xonotic%2Fnetradiant.git diff --git a/radiant/textureentry.cpp b/radiant/textureentry.cpp index 781dcbe4..04512f6f 100644 --- a/radiant/textureentry.cpp +++ b/radiant/textureentry.cpp @@ -20,3 +20,53 @@ */ #include "textureentry.h" + +#include + +template +void EntryCompletion::connect(ui::Entry entry) +{ + if (!m_store) { + m_store = ui::ListStore::from(gtk_list_store_new(1, G_TYPE_STRING)); + + fill(); + + StringList().connect(IdleDraw::QueueDrawCaller(m_idleUpdate)); + } + + auto completion = ui::EntryCompletion::from(gtk_entry_completion_new()); + gtk_entry_set_completion(entry, completion); + gtk_entry_completion_set_model(completion, m_store); + gtk_entry_completion_set_text_column(completion, 0); +} + +template +void EntryCompletion::append(const char *string) +{ + m_store.append(0, string); +} + +template +void EntryCompletion::fill() +{ + StringList().forEach(AppendCaller(*this)); +} + +template +void EntryCompletion::clear() +{ + m_store.clear(); +} + +template +void EntryCompletion::update() +{ + clear(); + fill(); +} + +template +class EntryCompletion; + +template +class EntryCompletion;