#pragma warning(disable : 4786)
#endif
-#include <glib.h>
-#include <gtk/gtk.h>
-
#include "misc.h"
bool LoadExclusionList( char* filename, std::list<Str>* exclusionList ){
if ( strlen( buffer ) > 0 ) {
char* buffer2 = new char[strlen( buffer ) + 1];
strcpy( buffer2, buffer );
- GtkTreeIter iter;
- gtk_list_store_append(loadlist, &iter);
- gtk_list_store_set(loadlist, &iter, 0, buffer2, -1);
+ loadlist.append(0, buffer2);
}
else{
cnt++;
const gchar* name = gtk_entry_get_text( edit );
if ( g_utf8_strlen( name, -1 ) > 0 ) {
ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ) ) ));
- GtkTreeIter iter;
- gtk_list_store_append( list, &iter );
- gtk_list_store_set( list, &iter, 0, name, -1 );
+ list.append(0, name);
gtk_entry_set_text( edit, "" );
}
}
struct _GtkItem;
struct _GtkLabel;
struct _GtkListStore;
+struct _GtkTreeIter;
struct _GtkMenu;
struct _GtkMenuBar;
struct _GtkMenuItem;
WRAP(ListStore, Object, _GtkListStore, (ITreeModel),
,
void clear();
+
+ template<class... T>
+ void append(T... args);
);
WRAP(TreeSelection, Object, _GtkTreeSelection, (),
gtk_container_foreach(this, cb, &lambda);
}
+ namespace {
+ extern "C" {
+ void gtk_list_store_insert_with_values(_GtkListStore *, _GtkTreeIter *, gint position, ...);
+ }
+ }
+
+ template<class... T>
+ void IListStore::append(T... args) {
+ static_assert(sizeof...(args) % 2 == 0, "received an odd number of arguments");
+ gtk_list_store_insert_with_values(this, NULL, -1, args..., -1);
+ }
+
#undef this
}
for ( Project::iterator i = project.begin(); i != project.end(); ++i )
{
- const char* buildName = ( *i ).first.c_str();
-
- GtkTreeIter buildIter;
- gtk_list_store_append( store, &buildIter );
- gtk_list_store_set( store, &buildIter, 0, const_cast<char*>( buildName ), -1 );
+ store.append(0, (*i).first.c_str());
}
GtkTreeIter lastIter;
for ( Build::iterator i = build.begin(); i != build.end(); ++i )
{
- GtkTreeIter commandIter;
- gtk_list_store_append( store, &commandIter );
- gtk_list_store_set( store, &commandIter, 0, const_cast<char*>( ( *i ).c_str() ), -1 );
+ store.append(0, (*i).c_str());
}
GtkTreeIter lastIter;
gtk_list_store_append( store, &lastIter );
StringOutputStream modifiers;
modifiers << accelerator;
- {
- GtkTreeIter iter;
- gtk_list_store_append( m_store, &iter );
- gtk_list_store_set( m_store, &iter, 0, name, 1, modifiers.c_str(), 2, false, 3, 800, -1 );
- }
+ m_store.append(0, name, 1, modifiers.c_str(), 2, false, 3, 800);
if ( !m_commandList.failed() ) {
int l = strlen( name );
EntityClassListStoreAppend( ui::ListStore store_ ) : store( store_ ){
}
void visit( EntityClass* e ){
- GtkTreeIter iter;
- gtk_list_store_append( store, &iter );
- gtk_list_store_set( store, &iter, 0, e->name(), 1, e, -1 );
+ store.append(0, e->name(), 1, e);
}
};
// Walk through list and add pairs
for ( KeyValues::iterator i = g_selectedKeyValues.begin(); i != g_selectedKeyValues.end(); ++i )
{
- GtkTreeIter iter;
- gtk_list_store_append( store, &iter );
StringOutputStream key( 64 );
key << ( *i ).first.c_str();
StringOutputStream value( 64 );
value << ( *i ).second.c_str();
- gtk_list_store_set( store, &iter, 0, key.c_str(), 1, value.c_str(), -1 );
+ store.append(0, key.c_str(), 1, value.c_str());
}
g_entityKeyEntry.text( strKey.c_str() );
gtk_list_store_clear( m_clist );
for ( std::size_t i = 0; i < static_cast<std::size_t>( m_pFeedbackElements->len ); ++i )
{
- GtkTreeIter iter;
- gtk_list_store_append( m_clist, &iter );
- gtk_list_store_set( m_clist, &iter, 0, GetElement( i )->getName(), -1 );
+ m_clist.append(0, GetElement(i)->getName());
}
ShowDlg();
{
char tmp[16];
sprintf( tmp, "%u", Unsigned( ( *i ).second ) );
- GtkTreeIter iter;
- gtk_list_store_append( GTK_LIST_STORE( EntityBreakdownWalker ), &iter );
- gtk_list_store_set( GTK_LIST_STORE( EntityBreakdownWalker ), &iter, 0, ( *i ).first.c_str(), 1, tmp, -1 );
+ EntityBreakdownWalker.append(0, (*i).first.c_str(), 1, tmp);
}
}
template<class StringList>
void EntryCompletion<StringList>::append(const char *string)
{
- GtkTreeIter iter;
- gtk_list_store_append(m_store, &iter);
- gtk_list_store_set(m_store, &iter, 0, string, -1);
+ m_store.append(0, string);
}
template<class StringList>
for ( size_t i = 0; i < assigned_tags.size(); i++ )
{
- gtk_list_store_append( store, &iter );
- gtk_list_store_set( store, &iter, TAG_COLUMN, assigned_tags[i].c_str(), -1 );
+ store.append(TAG_COLUMN, assigned_tags[i].c_str());
}
}
if ( !row ) { // does the shader have tags assigned?
for ( iterAll = allTags.begin(); iterAll != allTags.end(); ++iterAll )
{
- gtk_list_store_append( storeAvailable, &iterAvailable );
- gtk_list_store_set( storeAvailable, &iterAvailable, TAG_COLUMN, ( *iterAll ).c_str(), -1 );
+ storeAvailable.append(TAG_COLUMN, (*iterAll).c_str());
}
}
else
for ( iterAll = allTags.begin(); iterAll != allTags.end(); ++iterAll )
{
if ( strcmp( (char*)tag_assigned, ( *iterAll ).c_str() ) != 0 ) {
- gtk_list_store_append( storeAvailable, &iterAvailable );
- gtk_list_store_set( storeAvailable, &iterAvailable, TAG_COLUMN, ( *iterAll ).c_str(), -1 );
+ storeAvailable.append(TAG_COLUMN, (*iterAll).c_str());
}
else
{
TagBuilder.AddShaderTag( g_TextureBrowser.shader.c_str(), (char*)tag_assigned, TAG );
gtk_list_store_remove( g_TextureBrowser.m_available_store, &iter );
- gtk_list_store_append( g_TextureBrowser.m_assigned_store, &iter );
- gtk_list_store_set( g_TextureBrowser.m_assigned_store, &iter, TAG_COLUMN, (char*)tag_assigned, -1 );
+ g_TextureBrowser.m_assigned_store.append(TAG_COLUMN, tag_assigned);
}
}
}
}
void TextureBrowser_buildTagList(){
- GtkTreeIter treeIter;
gtk_list_store_clear( g_TextureBrowser.m_all_tags_list );
std::set<CopiedString>::iterator iter;
for ( iter = g_TextureBrowser.m_all_tags.begin(); iter != g_TextureBrowser.m_all_tags.end(); ++iter )
{
- gtk_list_store_append( g_TextureBrowser.m_all_tags_list, &treeIter );
- gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &treeIter, TAG_COLUMN, ( *iter ).c_str(), -1 );
+ g_TextureBrowser.m_all_tags_list.append(TAG_COLUMN, (*iter).c_str());
}
}
EMessageBoxReturn result = DoShaderTagDlg( &tag, "Add shader tag" );
if ( result == eIDOK && !tag.empty() ) {
- GtkTreeIter iter, iter2;
+ GtkTreeIter iter;
g_TextureBrowser.m_all_tags.insert( tag.c_str() );
gtk_list_store_append( g_TextureBrowser.m_available_store, &iter );
gtk_list_store_set( g_TextureBrowser.m_available_store, &iter, TAG_COLUMN, tag.c_str(), -1 );
GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
gtk_tree_selection_select_iter( selection, &iter );
- gtk_list_store_append( g_TextureBrowser.m_all_tags_list, &iter2 );
- gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &iter2, TAG_COLUMN, tag.c_str(), -1 );
+ g_TextureBrowser.m_all_tags_list.append(TAG_COLUMN, tag.c_str());
}
}