From: TimePath Date: Sat, 30 Dec 2017 04:22:21 +0000 (+1100) Subject: Wrap more GTK X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c9d78eecedad850196f7b2e2b5f5d72e980f3c8e;p=xonotic%2Fnetradiant.git Wrap more GTK --- diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 10a012c1..b00da471 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -915,7 +915,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ // djbob: lists added - auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures)))); + auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(listMainTextures))); gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); hbox.pack_start( comboMain, FALSE, FALSE, 0 ); comboMain.show(); @@ -934,7 +934,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ vbox.pack_start( hbox, FALSE, FALSE, 0 ); hbox.show(); - auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures)))); + auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(listTrimTextures))); gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0); hbox.pack_start( comboTrim, FALSE, FALSE, 0 ); comboTrim.show(); diff --git a/contrib/brushexport/callbacks.cpp b/contrib/brushexport/callbacks.cpp index 1e639dc5..260a8acd 100644 --- a/contrib/brushexport/callbacks.cpp +++ b/contrib/brushexport/callbacks.cpp @@ -34,15 +34,15 @@ void OnExportClicked( ui::Button button, gpointer user_data ){ ui::ListStore list = ui::ListStore::from(gtk_tree_view_get_model( view )); GtkTreeIter iter; - gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( list ), &iter ); + gboolean valid = gtk_tree_model_get_iter_first(list, &iter ); while ( valid ) { gchar* data; - gtk_tree_model_get( GTK_TREE_MODEL( list ), &iter, 0, &data, -1 ); + gtk_tree_model_get(list, &iter, 0, &data, -1 ); globalOutputStream() << data << "\n"; ignore.insert( std::string( data ) ); g_free( data ); - valid = gtk_tree_model_iter_next( GTK_TREE_MODEL( list ), &iter ); + valid = gtk_tree_model_iter_next(list, &iter ); } for ( std::set::iterator it( ignore.begin() ); it != ignore.end(); ++it ) diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index 4bc8a6f1..1a9967bf 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -195,7 +195,7 @@ void CreateWindow( void ){ // list store ui::ListStore ignorelist = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - gtk_tree_view_set_model( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), GTK_TREE_MODEL( ignorelist ) ); + gtk_tree_view_set_model( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), ignorelist ); ignorelist.unref(); gtk_widget_show_all( wnd ); diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 82127e9f..563a9793 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -55,6 +55,8 @@ namespace ui { gtk_editable_set_editable(GTK_EDITABLE(this), value); } + IMPL(TreeModel, GTK_TREE_MODEL); + IMPL(Widget, GTK_WIDGET); Widget::Widget(ui::New_t) : Widget(nullptr) @@ -422,6 +424,8 @@ namespace ui { gtk_list_store_append(this, nullptr); } + IMPL(TreeStore, GTK_TREE_STORE); + // IMPL(TreePath, GTK_TREE_PATH); TreePath::TreePath(ui::New_t) : TreePath(gtk_tree_path_new()) diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index fe03b9d8..1b082456 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -57,6 +57,7 @@ struct _GtkToolItem; struct _GtkTreeModel; struct _GtkTreePath; struct _GtkTreeSelection; +struct _GtkTreeStore; struct _GtkTreeView; struct _GtkTreeViewColumn; struct _GtkVBox; @@ -558,6 +559,10 @@ namespace ui { void append(); ); + WRAP(TreeStore, Object, _GtkTreeStore, (ITreeModel), + , + ); + WRAP(TreeSelection, Object, _GtkTreeSelection, (), , ); diff --git a/radiant/build.cpp b/radiant/build.cpp index 666e04b5..0cc7df8f 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -674,7 +674,7 @@ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gch ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); GtkTreeIter iter; - gtk_tree_model_get_iter( GTK_TREE_MODEL( projectList->m_store ), &iter, path ); + gtk_tree_model_get_iter(projectList->m_store, &iter, path ); Project::iterator i = Project_find( project, gtk_tree_path_get_indices( path )[0] ); if ( i != project.end() ) { @@ -777,7 +777,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" ); GtkTreeIter iter; - gtk_tree_model_get_iter( GTK_TREE_MODEL( store ), &iter, path ); + gtk_tree_model_get_iter(store, &iter, path ); Build::iterator i = Build_find( build, gtk_tree_path_get_indices( path )[0] ); if ( i != build.end() ) { @@ -859,7 +859,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { auto store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - ui::Widget view = ui::TreeView( ui::TreeModel(GTK_TREE_MODEL( store ) )); + ui::Widget view = ui::TreeView( ui::TreeModel( store )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); auto renderer = ui::CellRendererText(ui::New); @@ -894,7 +894,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); + ui::Widget view = ui::TreeView(ui::TreeModel( store )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); auto renderer = ui::CellRendererText(ui::New); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index c92bd23b..46d17b29 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -192,7 +192,7 @@ void accelerator_clear_button_clicked( GtkButton *btn, gpointer dialogptr ){ GValue val; memset( &val, 0, sizeof( val ) ); - gtk_tree_model_get_value( GTK_TREE_MODEL( model ), &iter, 0, &val ); + gtk_tree_model_get_value(model, &iter, 0, &val ); const char *commandName = g_value_get_string( &val );; // clear the ACTUAL accelerator too! @@ -269,7 +269,7 @@ bool accelerator_window_key_press( ui::Window widget, GdkEventKey *event, gpoint // 7. find the name of the accelerator GValue val; memset( &val, 0, sizeof( val ) ); - gtk_tree_model_get_value( GTK_TREE_MODEL( dialog.m_model ), &dialog.m_command_iter, 0, &val ); + gtk_tree_model_get_value(dialog.m_model, &dialog.m_command_iter, 0, &val ); const char *commandName = g_value_get_string( &val );; Shortcuts::iterator thisShortcutIterator = g_shortcuts.find( commandName ); if ( thisShortcutIterator == g_shortcuts.end() ) { @@ -314,18 +314,18 @@ public: accelerator = accelerator_null(); // empty the cell of the key binds dialog GtkTreeIter i; - if ( gtk_tree_model_get_iter_first( GTK_TREE_MODEL( model ), &i ) ) { + if ( gtk_tree_model_get_iter_first(model, &i ) ) { for (;; ) { GValue val; memset( &val, 0, sizeof( val ) ); - gtk_tree_model_get_value( GTK_TREE_MODEL( model ), &i, 0, &val ); + gtk_tree_model_get_value(model, &i, 0, &val ); const char *thisName = g_value_get_string( &val );; if ( !strcmp( thisName, name ) ) { gtk_list_store_set( ui::ListStore::from( model ), &i, 1, "", -1 ); } g_value_unset( &val ); - if ( !gtk_tree_model_iter_next( GTK_TREE_MODEL( model ), &i ) ) { + if ( !gtk_tree_model_iter_next(model, &i ) ) { break; } } @@ -369,9 +369,9 @@ public: GtkTreeIter row; GValue val; if(!model) {g_error("Unable to get model from cell renderer");} - gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model), &row, path_string); + gtk_tree_model_get_iter_from_string(model, &row, path_string); - gtk_tree_model_get_value(GTK_TREE_MODEL(model), &row, 0, &val); + gtk_tree_model_get_value(model, &row, 0, &val); const char *name = g_value_get_string(&val); Shortcuts::iterator i = g_shortcuts.find(name); if(i != g_shortcuts.end()) @@ -405,7 +405,7 @@ void DoCommandListDlg(){ { ui::ListStore store = ui::ListStore(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT )); - auto view = ui::TreeView(ui::TreeModel(GTK_TREE_MODEL(store))); + auto view = ui::TreeView(ui::TreeModel(store)); dialog.m_list = view; gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), false ); // annoying diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 2aefe7d1..02bff914 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -888,7 +888,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ } void EntityClassList_selectEntityClass( EntityClass* eclass ){ - GtkTreeModel* model = GTK_TREE_MODEL( g_entlist_store ); + GtkTreeModel* model = g_entlist_store; GtkTreeIter iter; for ( gboolean good = gtk_tree_model_get_iter_first( model, &iter ); good != FALSE; good = gtk_tree_model_iter_next( model, &iter ) ) { @@ -1316,7 +1316,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ { ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); - auto view = ui::TreeView( ui::TreeModel( GTK_TREE_MODEL( store ) )); + auto view = ui::TreeView( ui::TreeModel(store )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE ); gtk_tree_view_set_headers_visible( view, FALSE ); view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 ); @@ -1400,7 +1400,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ { ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); - ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); + ui::Widget view = ui::TreeView(ui::TreeModel(store )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 602ea1e5..bf2bf0ef 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -61,7 +61,7 @@ WindowPositionTracker m_positionTracker; ui::Window m_window; GtkTreeView* m_tree_view; -GraphTreeModel* m_tree_model; +ui::TreeModel m_tree_model{ui::null}; bool m_selection_disabled; EntityList() : @@ -197,7 +197,7 @@ gboolean treemodel_update_selection( GtkTreeModel* model, GtkTreePath* path, Gtk return FALSE; } -void EntityList_UpdateSelection( GtkTreeModel* model, GtkTreeView* view ){ +void EntityList_UpdateSelection( ui::TreeModel model, GtkTreeView* view ){ EntityList_DisconnectSignals( view ); gtk_tree_model_foreach( model, treemodel_update_selection, view ); EntityList_ConnectSignals( view ); @@ -209,7 +209,7 @@ void RedrawEntityList(){ { case EntityList::eInsertRemove: case EntityList::eSelection: - EntityList_UpdateSelection( GTK_TREE_MODEL( getEntityList().m_tree_model ), getEntityList().m_tree_view ); + EntityList_UpdateSelection( getEntityList().m_tree_model, getEntityList().m_tree_view ); default: break; } @@ -268,13 +268,13 @@ gint graph_tree_model_compare_name( GtkTreeModel *model, GtkTreeIter *a, GtkTree extern GraphTreeModel* scene_graph_get_tree_model(); void AttachEntityTreeModel(){ - getEntityList().m_tree_model = scene_graph_get_tree_model(); + getEntityList().m_tree_model = ui::TreeModel::from(scene_graph_get_tree_model()); - gtk_tree_view_set_model( getEntityList().m_tree_view, GTK_TREE_MODEL( getEntityList().m_tree_model ) ); + gtk_tree_view_set_model( getEntityList().m_tree_view, getEntityList().m_tree_model ); } void DetachEntityTreeModel(){ - getEntityList().m_tree_model = 0; + getEntityList().m_tree_model = ui::TreeModel(ui::null); gtk_tree_view_set_model( getEntityList().m_tree_view, 0 ); } diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index a465ed6c..5edc590b 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -300,7 +300,7 @@ ui::Window CDbgDlg::BuildDialog(){ { ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); - ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); + ui::Widget view = ui::TreeView(ui::TreeModel(store )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { diff --git a/radiant/map.cpp b/radiant/map.cpp index 6ed505fa..03cbc21d 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -835,7 +835,7 @@ void DoMapInfo(){ { ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING )); - ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); + ui::Widget view = ui::TreeView(ui::TreeModel(store )); gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE ); { diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 7d21c16c..6ad88df4 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -633,7 +633,7 @@ inline ui::VBox getVBox( ui::Bin page ){ return ui::VBox::from(gtk_bin_get_child(page)); } -GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, ui::Widget page ){ +GtkTreeIter PreferenceTree_appendPage( ui::TreeStore store, GtkTreeIter* parent, const char* name, ui::Widget page ){ GtkTreeIter group; gtk_tree_store_append( store, &group, parent ); gtk_tree_store_set( store, &group, 0, name, 1, page, -1 ); @@ -663,10 +663,10 @@ class PreferenceTreeGroup : public PreferenceGroup { Dialog& m_dialog; ui::Widget m_notebook; -GtkTreeStore* m_store; +ui::TreeStore m_store; GtkTreeIter m_group; public: -PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, GtkTreeStore* store, GtkTreeIter group ) : +PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, ui::TreeStore store, GtkTreeIter group ) : m_dialog( dialog ), m_notebook( notebook ), m_store( store ), @@ -731,9 +731,9 @@ ui::Window PrefsDlg::BuildDialog(){ { - auto store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); + auto store = ui::TreeStore(gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); - ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); + auto view = ui::TreeView(ui::TreeModel(store)); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { diff --git a/radiant/textureentry.cpp b/radiant/textureentry.cpp index 6e6e9de8..07fb0235 100644 --- a/radiant/textureentry.cpp +++ b/radiant/textureentry.cpp @@ -36,7 +36,7 @@ void EntryCompletion::connect(ui::Entry entry) auto completion = ui::EntryCompletion(gtk_entry_completion_new()); gtk_entry_set_completion(entry, completion); - gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(m_store)); + gtk_entry_completion_set_model(completion, m_store); gtk_entry_completion_set_text_column(completion, 0); } diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 9c89d0b8..2894305c 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1321,7 +1321,7 @@ void BuildStoreAvailableTags( ui::ListStore storeAvailable, storeAvailable.clear(); - bool row = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( storeAssigned ), &iterAssigned ) != 0; + bool row = gtk_tree_model_get_iter_first(storeAssigned, &iterAssigned ) != 0; if ( !row ) { // does the shader have tags assigned? for ( iterAll = allTags.begin(); iterAll != allTags.end(); ++iterAll ) @@ -1333,7 +1333,7 @@ void BuildStoreAvailableTags( ui::ListStore storeAvailable, { while ( row ) // available tags = all tags - assigned tags { - gtk_tree_model_get( GTK_TREE_MODEL( storeAssigned ), &iterAssigned, TAG_COLUMN, &tag_assigned, -1 ); + gtk_tree_model_get(storeAssigned, &iterAssigned, TAG_COLUMN, &tag_assigned, -1 ); for ( iterAll = allTags.begin(); iterAll != allTags.end(); ++iterAll ) { @@ -1342,10 +1342,10 @@ void BuildStoreAvailableTags( ui::ListStore storeAvailable, } else { - row = gtk_tree_model_iter_next( GTK_TREE_MODEL( storeAssigned ), &iterAssigned ) != 0; + row = gtk_tree_model_iter_next(storeAssigned, &iterAssigned ) != 0; if ( row ) { - gtk_tree_model_get( GTK_TREE_MODEL( storeAssigned ), &iterAssigned, TAG_COLUMN, &tag_assigned, -1 ); + gtk_tree_model_get(storeAssigned, &iterAssigned, TAG_COLUMN, &tag_assigned, -1 ); } } } @@ -1480,7 +1480,7 @@ void TextureBrowser_ToggleHideUnused(){ } } -void TextureGroups_constructTreeModel( TextureGroups groups, GtkTreeStore* store ){ +void TextureGroups_constructTreeModel( TextureGroups groups, ui::TreeStore store ){ // put the information from the old textures menu into a treeview GtkTreeIter iter, child; @@ -1537,21 +1537,18 @@ TextureGroups TextureGroups_constructTreeView(){ void TextureBrowser_constructTreeStore(){ TextureGroups groups = TextureGroups_constructTreeView(); - GtkTreeStore* store = gtk_tree_store_new( 1, G_TYPE_STRING ); + auto store = ui::TreeStore(gtk_tree_store_new( 1, G_TYPE_STRING )); TextureGroups_constructTreeModel( groups, store ); - std::set::iterator iter; - - GtkTreeModel* model = GTK_TREE_MODEL( store ); - gtk_tree_view_set_model( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), model ); + gtk_tree_view_set_model(GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), store); g_object_unref( G_OBJECT( store ) ); } void TextureBrowser_constructTreeStoreTags(){ TextureGroups groups; - GtkTreeStore* store = gtk_tree_store_new( 1, G_TYPE_STRING ); - GtkTreeModel* model = GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ); + auto store = ui::TreeStore(gtk_tree_store_new( 1, G_TYPE_STRING )); + GtkTreeModel* model = g_TextureBrowser.m_all_tags_list; gtk_tree_view_set_model( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), model ); @@ -1758,8 +1755,8 @@ void TextureBrowser_assignTags(){ if ( path ) { GtkTreeIter iter; - if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ), &iter, path ) ) { - gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ), &iter, TAG_COLUMN, &tag_assigned, -1 ); + if ( gtk_tree_model_get_iter(g_TextureBrowser.m_available_store, &iter, path ) ) { + gtk_tree_model_get(g_TextureBrowser.m_available_store, &iter, TAG_COLUMN, &tag_assigned, -1 ); if ( !TagBuilder.CheckShaderTag( g_TextureBrowser.shader.c_str() ) ) { // create a custom shader/texture entry IShader* ishader = QERApp_Shader_ForName( g_TextureBrowser.shader.c_str() ); @@ -1808,8 +1805,8 @@ void TextureBrowser_removeTags(){ if ( path ) { GtkTreeIter iter; - if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ), &iter, path ) ) { - gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ), &iter, TAG_COLUMN, &tag, -1 ); + if ( gtk_tree_model_get_iter(g_TextureBrowser.m_assigned_store, &iter, path ) ) { + gtk_tree_model_get(g_TextureBrowser.m_assigned_store, &iter, TAG_COLUMN, &tag, -1 ); TagBuilder.DeleteShaderTag( g_TextureBrowser.shader.c_str(), tag ); gtk_list_store_remove( g_TextureBrowser.m_assigned_store, &iter ); } @@ -1860,8 +1857,8 @@ void TextureBrowser_searchTags(){ if ( path ) { GtkTreeIter iter; - if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iter, path ) ) { - gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iter, TAG_COLUMN, &tag, -1 ); + if ( gtk_tree_model_get_iter(g_TextureBrowser.m_all_tags_list, &iter, path ) ) { + gtk_tree_model_get(g_TextureBrowser.m_all_tags_list, &iter, TAG_COLUMN, &tag, -1 ); strcat( buffer, tag ); strcat( tags_searched, tag ); @@ -2131,7 +2128,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ auto renderer = ui::CellRendererText(ui::New); - g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) )); + g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel(g_TextureBrowser.m_assigned_store )); g_TextureBrowser.m_assigned_store.unref(); g_TextureBrowser.m_assigned_tree.connect( "row-activated", (GCallback) TextureBrowser_removeTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE ); @@ -2159,7 +2156,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ auto renderer = ui::CellRendererText(ui::New); - g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) )); + g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel(g_TextureBrowser.m_available_store )); g_TextureBrowser.m_available_store.unref(); g_TextureBrowser.m_available_tree.connect( "row-activated", (GCallback) TextureBrowser_assignTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE ); @@ -2296,16 +2293,16 @@ void TextureBrowser_renameTag(){ gchar* rowTag; gchar* oldTag = (char*)selected->data; - bool row = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterList ) != 0; + bool row = gtk_tree_model_get_iter_first(g_TextureBrowser.m_all_tags_list, &iterList ) != 0; while ( row ) { - gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterList, TAG_COLUMN, &rowTag, -1 ); + gtk_tree_model_get(g_TextureBrowser.m_all_tags_list, &iterList, TAG_COLUMN, &rowTag, -1 ); if ( strcmp( rowTag, oldTag ) == 0 ) { gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &iterList, TAG_COLUMN, newTag.c_str(), -1 ); } - row = gtk_tree_model_iter_next( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterList ) != 0; + row = gtk_tree_model_iter_next(g_TextureBrowser.m_all_tags_list, &iterList ) != 0; } TagBuilder.RenameShaderTag( oldTag, newTag.c_str() ); @@ -2338,17 +2335,17 @@ void TextureBrowser_deleteTag(){ gchar* tagSelected = (char*)selected->data; - bool row = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterSelected ) != 0; + bool row = gtk_tree_model_get_iter_first(g_TextureBrowser.m_all_tags_list, &iterSelected ) != 0; while ( row ) { - gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterSelected, TAG_COLUMN, &rowTag, -1 ); + gtk_tree_model_get(g_TextureBrowser.m_all_tags_list, &iterSelected, TAG_COLUMN, &rowTag, -1 ); if ( strcmp( rowTag, tagSelected ) == 0 ) { gtk_list_store_remove( g_TextureBrowser.m_all_tags_list, &iterSelected ); break; } - row = gtk_tree_model_iter_next( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterSelected ) != 0; + row = gtk_tree_model_iter_next(g_TextureBrowser.m_all_tags_list, &iterSelected ) != 0; } TagBuilder.DeleteTag( tagSelected ); diff --git a/radiant/treemodel.cpp b/radiant/treemodel.cpp index 97d02265..fc2fbeba 100644 --- a/radiant/treemodel.cpp +++ b/radiant/treemodel.cpp @@ -54,7 +54,7 @@ inline void gtk_tree_model_get_pointer( GtkTreeModel* model, GtkTreeIter* iter, typedef GtkTreeStore GraphTreeModel; -GtkTreeStore* graph_tree_model_new( graph_type* graph ){ +ui::TreeStore graph_tree_model_new( graph_type* graph ){ return gtk_tree_store_new( 2, G_TYPE_POINTER, G_TYPE_POINTER ); } @@ -64,12 +64,12 @@ void graph_tree_model_delete( GraphTreeModel* model ){ bool graph_tree_model_subtree_find_node( GraphTreeModel* model, GtkTreeIter* parent, const scene::Node& node, GtkTreeIter* iter ){ - for ( gboolean success = gtk_tree_model_iter_children( GTK_TREE_MODEL( model ), iter, parent ); + for ( gboolean success = gtk_tree_model_iter_children( model, iter, parent ); success != FALSE; - success = gtk_tree_model_iter_next( GTK_TREE_MODEL( model ), iter ) ) + success = gtk_tree_model_iter_next( model, iter ) ) { scene::Node* current; - gtk_tree_model_get_pointer( GTK_TREE_MODEL( model ), iter, 0, ¤t ); + gtk_tree_model_get_pointer( model, iter, 0, ¤t ); if ( current == node ) { return true; } @@ -475,7 +475,7 @@ static gboolean graph_tree_model_row_draggable( GtkTreeDragSource *drag_source, static gboolean graph_tree_model_drag_data_delete( GtkTreeDragSource *drag_source, GtkTreePath *path ){ GtkTreeIter iter; - if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( drag_source ), &iter, path ) ) { + if ( gtk_tree_model_get_iter( drag_source, &iter, path ) ) { graph_type::iterator i = graph_iterator_read_tree_iter( &iter ); Path_deleteTop( ( *i ).first ); return TRUE; @@ -487,7 +487,7 @@ static gboolean graph_tree_model_drag_data_delete( GtkTreeDragSource *drag_sourc } static gboolean graph_tree_model_drag_data_get( GtkTreeDragSource *drag_source, GtkTreePath *path, GtkSelectionData *selection_data ){ - if ( gtk_tree_set_row_drag_data( selection_data, GTK_TREE_MODEL( drag_source ), path ) ) { + if ( gtk_tree_set_row_drag_data( selection_data, drag_source, path ) ) { return TRUE; } else @@ -505,7 +505,7 @@ static void graph_tree_model_drag_source_init( GtkTreeDragSourceIface *iface ){ } static gboolean graph_tree_model_drag_data_received( GtkTreeDragDest *drag_dest, GtkTreePath *dest, GtkSelectionData *selection_data ){ - GtkTreeModel *tree_model = GTK_TREE_MODEL( drag_dest ); + GtkTreeModel *tree_model = drag_dest; GtkTreeModel *src_model = 0; GtkTreePath *src_path = 0; @@ -535,7 +535,7 @@ static gboolean graph_tree_model_row_drop_possible( GtkTreeDragDest *drag_dest, GtkTreePath *src_path = 0; if ( gtk_tree_get_row_drag_data( selection_data, &src_model, &src_path ) != FALSE ) { /* can only drag to ourselves */ - if ( src_model == GTK_TREE_MODEL( drag_dest ) ) { + if ( src_model == drag_dest ) { /* Can't drop into ourself. */ if ( !gtk_tree_path_is_ancestor( src_path, dest_path ) ) { /* Can't drop if dest_path's parent doesn't exist */ @@ -544,7 +544,7 @@ static gboolean graph_tree_model_row_drop_possible( GtkTreeDragDest *drag_dest, gtk_tree_path_up( tmp ); GtkTreeIter iter; - retval = gtk_tree_model_get_iter( GTK_TREE_MODEL( drag_dest ), &iter, tmp ); + retval = gtk_tree_model_get_iter( drag_dest, &iter, tmp ); gtk_tree_path_free( tmp ); } @@ -677,12 +677,12 @@ void graph_tree_model_row_inserted( GraphTreeModel* model, graph_type::iterator GtkTreeIter iter; graph_iterator_write_tree_iter( i, &iter ); - GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter ); + GtkTreePath* tree_path = graph_tree_model_get_path( model, &iter ); gint depth = gtk_tree_path_get_depth( tree_path ); gint* indices = gtk_tree_path_get_indices( tree_path ); - gtk_tree_model_row_inserted( GTK_TREE_MODEL( model ), tree_path, &iter ); + gtk_tree_model_row_inserted( model, tree_path, &iter ); gtk_tree_path_free( tree_path ); } @@ -691,9 +691,9 @@ void graph_tree_model_row_deleted( GraphTreeModel* model, graph_type::iterator i GtkTreeIter iter; graph_iterator_write_tree_iter( i, &iter ); - GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter ); + GtkTreePath* tree_path = graph_tree_model_get_path( model, &iter ); - gtk_tree_model_row_deleted( GTK_TREE_MODEL( model ), tree_path ); + gtk_tree_model_row_deleted( model, tree_path ); gtk_tree_path_free( tree_path ); } @@ -814,8 +814,6 @@ struct GraphTreeModelClass GObjectClass parent_class; }; -#define GRAPH_TREE_MODEL( p ) ( reinterpret_cast( p ) ) - static GtkTreeModelFlags graph_tree_model_get_flags( GtkTreeModel* tree_model ){ return GTK_TREE_MODEL_ITERS_PERSIST; } @@ -850,14 +848,14 @@ static GType graph_tree_model_get_column_type( GtkTreeModel *tree_model, gint in return G_TYPE_POINTER; } -static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter* iter, GtkTreePath* path ){ +static gboolean graph_tree_model_get_iter( GraphTreeModel* tree_model, GtkTreeIter* iter, GtkTreePath* path ){ ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); gint* indices = gtk_tree_path_get_indices( path ); gint depth = gtk_tree_path_get_depth( path ); g_return_val_if_fail( depth > 0, FALSE ); - GraphTreeNode* graph = GRAPH_TREE_MODEL( tree_model )->m_graph; + GraphTreeNode *graph = tree_model->m_graph; if ( graph->empty() ) { return FALSE; @@ -868,7 +866,7 @@ static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter for ( gint i = 0; i < depth; i++ ) { - if ( !gtk_tree_model_iter_nth_child( tree_model, iter, parent, indices[i] ) ) { + if ( !gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(tree_model), iter, parent, indices[i] ) ) { return FALSE; } tmp = *iter; @@ -878,9 +876,9 @@ static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter return TRUE; } -static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTreeIter* iter ){ +static GtkTreePath* graph_tree_model_get_path( GraphTreeModel* tree_model, GtkTreeIter* iter ){ ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - GraphTreeNode* graph = GRAPH_TREE_MODEL( tree_model )->m_graph; + GraphTreeNode* graph = tree_model->m_graph; GtkTreePath* path = ui::TreePath(ui::New); @@ -934,9 +932,9 @@ static gboolean graph_tree_model_iter_next( GtkTreeModel *tree_model, GtkTreeIt return TRUE; } -static gboolean graph_tree_model_iter_children( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent ){ +static gboolean graph_tree_model_iter_children( GraphTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent ){ ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - GraphTreeNode& node = ( parent == 0 ) ? *GRAPH_TREE_MODEL( tree_model )->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second; + GraphTreeNode& node = ( parent == 0 ) ? *tree_model->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second; if ( !node.empty() ) { graph_iterator_write_tree_iter( node.begin(), iter ); return TRUE; @@ -951,15 +949,15 @@ static gboolean graph_tree_model_iter_has_child( GtkTreeModel *tree_model, GtkTr return !node.empty(); } -static gint graph_tree_model_iter_n_children( GtkTreeModel *tree_model, GtkTreeIter *parent ){ +static gint graph_tree_model_iter_n_children( GraphTreeModel *tree_model, GtkTreeIter *parent ){ ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - GraphTreeNode& node = ( parent == 0 ) ? *GRAPH_TREE_MODEL( tree_model )->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second; + GraphTreeNode& node = ( parent == 0 ) ? *tree_model->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second; return static_cast( node.size() ); } -static gboolean graph_tree_model_iter_nth_child( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n ){ +static gboolean graph_tree_model_iter_nth_child( GraphTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n ){ ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); - GraphTreeNode& node = ( parent == 0 ) ? *GRAPH_TREE_MODEL( tree_model )->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second; + GraphTreeNode& node = ( parent == 0 ) ? *tree_model->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second; if ( static_cast( n ) < node.size() ) { GraphTreeNode::iterator i = node.begin(); std::advance( i, n ); @@ -970,10 +968,10 @@ static gboolean graph_tree_model_iter_nth_child( GtkTreeModel *tree_model, GtkTr return FALSE; } -static gboolean graph_tree_model_iter_parent( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child ){ +static gboolean graph_tree_model_iter_parent( GraphTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child ){ ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" ); GraphTreeNode& node = *( *graph_iterator_read_tree_iter( child ) ).second; - if ( node.m_parent != GRAPH_TREE_MODEL( tree_model )->m_graph ) { + if ( node.m_parent != tree_model->m_graph ) { GraphTreeNode& parentParent = *node.m_parent->m_parent; for ( GraphTreeNode::iterator i = parentParent.begin(); i != parentParent.end(); ++i ) { @@ -1010,7 +1008,7 @@ static void graph_tree_model_init( GraphTreeModel *graph_tree_model ){ } static void graph_tree_model_finalize( GObject* object ){ - GraphTreeModel* graph_tree_model = GRAPH_TREE_MODEL( object ); + auto graph_tree_model = reinterpret_cast(object); delete graph_tree_model->m_graph; @@ -1031,15 +1029,15 @@ static void graph_tree_model_tree_model_init( GtkTreeModelIface *iface ){ iface->get_flags = graph_tree_model_get_flags; iface->get_n_columns = graph_tree_model_get_n_columns; iface->get_column_type = graph_tree_model_get_column_type; - iface->get_iter = graph_tree_model_get_iter; - iface->get_path = graph_tree_model_get_path; + iface->get_iter = reinterpret_cast(graph_tree_model_get_iter); + iface->get_path = reinterpret_cast(graph_tree_model_get_path); iface->get_value = graph_tree_model_get_value; iface->iter_next = graph_tree_model_iter_next; - iface->iter_children = graph_tree_model_iter_children; + iface->iter_children = reinterpret_cast(graph_tree_model_iter_children); iface->iter_has_child = graph_tree_model_iter_has_child; - iface->iter_n_children = graph_tree_model_iter_n_children; - iface->iter_nth_child = graph_tree_model_iter_nth_child; - iface->iter_parent = graph_tree_model_iter_parent; + iface->iter_n_children = reinterpret_cast(graph_tree_model_iter_n_children); + iface->iter_nth_child = reinterpret_cast(graph_tree_model_iter_nth_child); + iface->iter_parent = reinterpret_cast(graph_tree_model_iter_parent); } GType graph_tree_model_get_type( void ){ @@ -1079,7 +1077,7 @@ GType graph_tree_model_get_type( void ){ } GraphTreeModel* graph_tree_model_new(){ - GraphTreeModel* graph_tree_model = GRAPH_TREE_MODEL( g_object_new( graph_tree_model_get_type(), 0 ) ); + auto graph_tree_model = reinterpret_cast(g_object_new( graph_tree_model_get_type(), 0 )); return graph_tree_model; } @@ -1092,7 +1090,7 @@ void graph_tree_model_row_changed( GraphTreeModel* model, GraphTreeNode::iterato GtkTreeIter iter; graph_iterator_write_tree_iter( i, &iter ); - GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter ); + GtkTreePath* tree_path = graph_tree_model_get_path(model, &iter ); gtk_tree_model_row_changed( GTK_TREE_MODEL( model ), tree_path, &iter ); @@ -1103,7 +1101,7 @@ void graph_tree_model_row_inserted( GraphTreeModel* model, GraphTreeNode::iterat GtkTreeIter iter; graph_iterator_write_tree_iter( i, &iter ); - GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter ); + GtkTreePath* tree_path = graph_tree_model_get_path(model, &iter ); gtk_tree_model_row_inserted( GTK_TREE_MODEL( model ), tree_path, &iter ); @@ -1114,7 +1112,7 @@ void graph_tree_model_row_deleted( GraphTreeModel* model, GraphTreeNode::iterato GtkTreeIter iter; graph_iterator_write_tree_iter( i, &iter ); - GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter ); + GtkTreePath* tree_path = graph_tree_model_get_path(model, &iter ); gtk_tree_model_row_deleted( GTK_TREE_MODEL( model ), tree_path ); @@ -1274,7 +1272,7 @@ TestGraphTreeModel(){ rootpath.pop(); rootpath.pop(); - GtkTreeModel* model = GTK_TREE_MODEL( graph_tree_model_new( &graph ) ); + GtkTreeModel* model = graph_tree_model_new( &graph ); { gint n_columns = gtk_tree_model_get_n_columns( model );