From: TimePath Date: Wed, 17 Feb 2016 05:26:48 +0000 (+1100) Subject: Wrap GtkTreePath X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3262a20a517546f4722589bf87b493177f9cd890;p=xonotic%2Fnetradiant.git Wrap GtkTreePath --- diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 667ca91e..9989601b 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -140,6 +140,12 @@ namespace ui { Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table(GTK_TABLE(gtk_table_new(rows, columns, homogenous))) { } + TreePath::TreePath() : TreePath(gtk_tree_path_new()) + { } + + TreePath::TreePath(const char *path) : TreePath(gtk_tree_path_new_from_string(path)) + { } + TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model))) { } diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 432db2be..6f58a2e0 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -24,6 +24,7 @@ using ui_scrolledwindow = struct _GtkScrolledWindow; using ui_spinbutton = struct _GtkSpinButton; using ui_table = struct _GtkTable; using ui_treemodel = struct _GtkTreeModel; +using ui_treepath = struct _GtkTreePath; using ui_treeview = struct _GtkTreeView; using ui_typeinst = struct _GTypeInstance; using ui_vbox = struct _GtkVBox; @@ -192,6 +193,11 @@ namespace ui { WRAP(TreeModel, Widget, ui_treemodel,); + WRAP(TreePath, Object, ui_treepath, + TreePath(); + TreePath(const char *path); + ); + WRAP(TreeView, Widget, ui_treeview, TreeView(TreeModel model); ); diff --git a/radiant/build.cpp b/radiant/build.cpp index a81ad53f..2bad89c1 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -680,7 +680,7 @@ ProjectList( Project& project ) : m_project( project ), m_changed( false ){ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){ Project& project = projectList->m_project; - GtkTreePath* path = gtk_tree_path_new_from_string( path_string ); + GtkTreePath* path = ui::TreePath( path_string ); ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); @@ -787,7 +787,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc } Build& build = *g_current_build; - GtkTreePath* path = gtk_tree_path_new_from_string( path_string ); + GtkTreePath* path = ui::TreePath( path_string ); ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); diff --git a/radiant/treemodel.cpp b/radiant/treemodel.cpp index ebd68d66..7c6cae68 100644 --- a/radiant/treemodel.cpp +++ b/radiant/treemodel.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "iscenegraph.h" #include "nameable.h" @@ -280,7 +281,7 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph; graph_type::iterator i = graph_iterator_read_tree_iter( iter ); - GtkTreePath* path = gtk_tree_path_new(); + GtkTreePath* path = ui::TreePath(); for ( std::size_t depth = ( *i ).first.get().size(); depth != 0; --depth ) { @@ -874,7 +875,7 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); GraphTreeNode* graph = GRAPH_TREE_MODEL( tree_model )->m_graph; - GtkTreePath* path = gtk_tree_path_new(); + GtkTreePath* path = ui::TreePath(); for ( GraphTreeNode* node = ( *graph_iterator_read_tree_iter( iter ) ).second; node != graph; node = node->m_parent ) { @@ -1358,7 +1359,7 @@ TestGraphTreeModel(){ { GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "0" ); + GtkTreePath* path = ui::TreePath( "0" ); gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_path_free( path ); @@ -1368,7 +1369,7 @@ TestGraphTreeModel(){ { GtkTreeIter iter; - GtkTreePath* path = gtk_tree_path_new_from_string( "1" ); + GtkTreePath* path = ui::TreePath( "1" ); gtk_tree_model_get_iter( model, &iter, path ); gtk_tree_path_free( path );