]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Wrap GtkTreePath
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 05:26:48 +0000 (16:26 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 05:26:48 +0000 (16:26 +1100)
libs/uilib/uilib.cpp
libs/uilib/uilib.h
radiant/build.cpp
radiant/treemodel.cpp

index 667ca91ea1a6517b14d31a87457300e76168bdbc..9989601ba1273dc796097002c36d6a0b03e98b39 100644 (file)
@@ -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)))
     { }
 
index 432db2be097ec53dd0cdf7ee62afa36ff867c766..6f58a2e0ac3b98ec0e0dabe072b3ad39d31f17b8 100644 (file)
@@ -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);
     );
index a81ad53fae98c041dc2e3dc3e07ee391362c5489..2bad89c153f4ead9804db9ed1074a8fcdf0c0ad2 100644 (file)
@@ -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" );
 
index ebd68d66eaba9e916c0380d9281e0e2b6809fd5e..7c6cae68c984ddf90486014ec7948bde9d87e83a 100644 (file)
@@ -27,6 +27,7 @@
 #include <gtk/gtktreemodel.h>
 #include <gtk/gtktreednd.h>
 #include <gtk/gtkmain.h>
+#include <uilib/uilib.h>
 
 #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 );