]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/textureentry.cpp
Remove <gtk/gtk.h> from radiant/textureentry.h
[xonotic/netradiant.git] / radiant / textureentry.cpp
1 /*
2    Copyright (C) 2001-2006, William Joseph.
3    All Rights Reserved.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #include "textureentry.h"
23
24 #include <gtk/gtk.h>
25
26 template
27 class EntryCompletion<TextureNameList>;
28
29 template
30 class EntryCompletion<ShaderList>;
31
32 template<class StringList>
33 void EntryCompletion<StringList>::connect(ui::Entry entry)
34 {
35     if (!m_store) {
36         m_store = ui::ListStore(gtk_list_store_new(1, G_TYPE_STRING));
37
38         fill();
39
40         StringList().connect(IdleDraw::QueueDrawCaller(m_idleUpdate));
41     }
42
43     auto completion = ui::EntryCompletion(gtk_entry_completion_new());
44     gtk_entry_set_completion(entry, completion);
45     gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(m_store));
46     gtk_entry_completion_set_text_column(completion, 0);
47 }
48
49 template<class StringList>
50 void EntryCompletion<StringList>::append(const char *string)
51 {
52     GtkTreeIter iter;
53     gtk_list_store_append(m_store, &iter);
54     gtk_list_store_set(m_store, &iter, 0, string, -1);
55 }
56
57 template<class StringList>
58 void EntryCompletion<StringList>::fill()
59 {
60     StringList().forEach(AppendCaller(*this));
61 }
62
63 template<class StringList>
64 void EntryCompletion<StringList>::clear()
65 {
66     gtk_list_store_clear(m_store);
67 }
68
69 template<class StringList>
70 void EntryCompletion<StringList>::update()
71 {
72     clear();
73     fill();
74 }