]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/textureentry.cpp
Merge commit '020d0244e4239b21dc804d630edff926386ea34f' into master-merge
[xonotic/netradiant.git] / radiant / textureentry.cpp
index 781dcbe44ca8c96c3e4f233bdfbbec430dbd5e93..04512f6f6887374ec735eaa4bc92a013c7f811b7 100644 (file)
  */
 
 #include "textureentry.h"
+
+#include <gtk/gtk.h>
+
+template<class StringList>
+void EntryCompletion<StringList>::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<class StringList>
+void EntryCompletion<StringList>::append(const char *string)
+{
+    m_store.append(0, string);
+}
+
+template<class StringList>
+void EntryCompletion<StringList>::fill()
+{
+    StringList().forEach(AppendCaller(*this));
+}
+
+template<class StringList>
+void EntryCompletion<StringList>::clear()
+{
+    m_store.clear();
+}
+
+template<class StringList>
+void EntryCompletion<StringList>::update()
+{
+    clear();
+    fill();
+}
+
+template
+class EntryCompletion<TextureNameList>;
+
+template
+class EntryCompletion<ShaderList>;