From: TimePath Date: Fri, 21 Jul 2017 12:24:28 +0000 (+1000) Subject: Wrap GtkListStore X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=335990b4b52a2f97a879afb68cff9bea05f05884;p=xonotic%2Fnetradiant.git Wrap GtkListStore --- diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index daeb3913..19b773fa 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -869,8 +869,8 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_widget_realize( window ); char buffer[256]; - GtkListStore *listMainTextures = gtk_list_store_new( 1, G_TYPE_STRING ); - GtkListStore *listTrimTextures = gtk_list_store_new( 1, G_TYPE_STRING ); + ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); + ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures ); LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures ); diff --git a/contrib/bobtoolz/lists.cpp b/contrib/bobtoolz/lists.cpp index c2b1ed9e..96aff197 100644 --- a/contrib/bobtoolz/lists.cpp +++ b/contrib/bobtoolz/lists.cpp @@ -55,7 +55,7 @@ bool LoadExclusionList( char* filename, std::list* exclusionList ){ return FALSE; } -bool LoadGList( char* filename, GtkListStore* loadlist ){ +bool LoadGList( char* filename, ui::ListStore loadlist ){ FILE* eFile = fopen( filename, "r" ); if ( eFile ) { char buffer[256]; diff --git a/contrib/bobtoolz/lists.h b/contrib/bobtoolz/lists.h index 00e50266..7a8ecc18 100644 --- a/contrib/bobtoolz/lists.h +++ b/contrib/bobtoolz/lists.h @@ -18,9 +18,9 @@ */ #include -#include +#include #include "str.h" typedef struct _GList GList; bool LoadExclusionList( char* filename, std::list* exclusionList ); -bool LoadGList( char* filename, GtkListStore* loadlist ); +bool LoadGList( char* filename, ui::ListStore loadlist ); diff --git a/contrib/brushexport/callbacks.cpp b/contrib/brushexport/callbacks.cpp index be8d0bae..29fb3263 100644 --- a/contrib/brushexport/callbacks.cpp +++ b/contrib/brushexport/callbacks.cpp @@ -31,7 +31,7 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){ std::set ignore; GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ); - GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) ); + ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) )); GtkTreeIter iter; gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( list ), &iter ); @@ -113,7 +113,7 @@ void OnAddMaterial( GtkButton* button, gpointer user_data ){ const gchar* name = gtk_entry_get_text( edit ); if ( g_utf8_strlen( name, -1 ) > 0 ) { - GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ) ) ); + 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 ); @@ -123,7 +123,7 @@ void OnAddMaterial( GtkButton* button, gpointer user_data ){ void OnRemoveMaterial( GtkButton* button, gpointer user_data ){ GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ); - GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) ); + ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) )); GtkTreeSelection* sel = gtk_tree_view_get_selection( view ); GtkTreeIter iter; diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index c0f18c82..dc37bc8c 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -215,7 +215,7 @@ void CreateWindow( void ){ gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), -1, "", renderer, "text", 0, NULL ); // list store - GtkListStore* ignorelist = gtk_list_store_new( 1, G_TYPE_STRING ); + 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 ) ); g_object_unref( ignorelist ); diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 054beced..dc0b93f2 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -226,6 +226,10 @@ namespace ui { AccelGroup::AccelGroup() : AccelGroup(GTK_ACCEL_GROUP(gtk_accel_group_new())) {} + void IListStore::clear() { + gtk_list_store_clear(this); + } + TreePath::TreePath() : TreePath(gtk_tree_path_new()) {} diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 2849a12a..284609d6 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -419,6 +419,7 @@ namespace ui { WRAP(ListStore, Object, _GtkListStore, (), , + void clear(); ); WRAP(TreeModel, Widget, _GtkTreeModel, (), diff --git a/radiant/build.cpp b/radiant/build.cpp index 1a414988..a7500ef4 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -643,8 +643,8 @@ void build_commands_write( const char* filename ){ void Build_refreshMenu( GtkMenu* menu ); -void BSPCommandList_Construct( GtkListStore* store, Project& project ){ - gtk_list_store_clear( store ); +void BSPCommandList_Construct( ui::ListStore store, Project& project ){ + store.clear(); for ( Project::iterator i = project.begin(); i != project.end(); ++i ) { @@ -663,7 +663,7 @@ class ProjectList { public: Project& m_project; -GtkListStore* m_store; +ui::ListStore m_store{nullptr}; bool m_changed; ProjectList( Project& project ) : m_project( project ), m_changed( false ){ } @@ -735,7 +735,7 @@ gboolean project_key_press( ui::Widget widget, GdkEventKey* event, ProjectList* Build* g_current_build = 0; -gboolean project_selection_changed( GtkTreeSelection* selection, GtkListStore* store ){ +gboolean project_selection_changed( GtkTreeSelection* selection, ui::ListStore store ){ Project& project = g_build_project; gtk_list_store_clear( store ); @@ -773,7 +773,7 @@ gboolean project_selection_changed( GtkTreeSelection* selection, GtkListStore* s return FALSE; } -gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, GtkListStore* store ){ +gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ui::ListStore store ){ if ( g_current_build == 0 ) { return FALSE; } @@ -810,7 +810,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc return FALSE; } -gboolean commands_key_press( ui::Widget widget, GdkEventKey* event, GtkListStore* store ){ +gboolean commands_key_press( ui::Widget widget, GdkEventKey* event, ui::ListStore store ){ if ( g_current_build == 0 ) { return FALSE; } @@ -869,7 +869,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) ); { - GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); + auto store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); ui::Widget view = ui::TreeView( ui::TreeModel(GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); @@ -906,7 +906,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) ); { - GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 968d5c55..840a570d 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -403,7 +403,7 @@ void DoCommandListDlg(){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 ); { - GtkListStore* store = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT )); ui::Widget view = ui::TreeView(ui::TreeModel(GTK_TREE_MODEL(store))); dialog.m_list = GTK_TREE_VIEW( view ); @@ -433,9 +433,9 @@ void DoCommandListDlg(){ class BuildCommandList : public CommandVisitor { TextFileOutputStream m_commandList; - GtkListStore* m_store; + ui::ListStore m_store; public: - BuildCommandList( const char* filename, GtkListStore* store ) : m_commandList( filename ), m_store( store ){ + BuildCommandList( const char* filename, ui::ListStore store ) : m_commandList( filename ), m_store( store ){ } void visit( const char* name, Accelerator& accelerator ){ StringOutputStream modifiers; diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 3c21a47d..527e0239 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -717,8 +717,8 @@ GtkCheckButton* g_entitySpawnflagsCheck[MAX_FLAGS]; GtkEntry* g_entityKeyEntry; GtkEntry* g_entityValueEntry; -GtkListStore* g_entlist_store; -GtkListStore* g_entprops_store; +ui::ListStore g_entlist_store{nullptr}; +ui::ListStore g_entprops_store{nullptr}; const EntityClass* g_current_flags = 0; const EntityClass* g_current_comment = 0; const EntityClass* g_current_attributes = 0; @@ -804,9 +804,9 @@ const char* keyvalues_valueforkey( KeyValues& keyvalues, const char* key ){ class EntityClassListStoreAppend : public EntityClassVisitor { -GtkListStore* store; +ui::ListStore store; public: -EntityClassListStoreAppend( GtkListStore* store_ ) : store( store_ ){ +EntityClassListStoreAppend( ui::ListStore store_ ) : store( store_ ){ } void visit( EntityClass* e ){ GtkTreeIter iter; @@ -1034,7 +1034,7 @@ void EntityInspector_updateKeyValues(){ EntityInspector_updateSpawnflags(); - GtkListStore* store = g_entprops_store; + ui::ListStore store = g_entprops_store; // save current key/val pair around filling epair box // row_select wipes it and sets to first in list @@ -1318,7 +1318,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER )); GtkTreeView* view = ui::TreeView( ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE ); @@ -1402,7 +1402,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); + 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 ) )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE ); diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index bb565b84..543c9fc4 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -300,7 +300,7 @@ ui::Window CDbgDlg::BuildDialog(){ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); { - GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); + ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); diff --git a/radiant/feedback.h b/radiant/feedback.h index 78f4fd04..567f00af 100644 --- a/radiant/feedback.h +++ b/radiant/feedback.h @@ -149,7 +149,7 @@ class CDbgDlg : public Dialog { GPtrArray *m_pFeedbackElements; // the list widget we use in the dialog -GtkListStore* m_clist; +ui::ListStore m_clist{nullptr}; ISAXHandler *m_pHighlight; IGL2DWindow* m_pDraw2D; public: diff --git a/radiant/map.cpp b/radiant/map.cpp index 8aac9a8f..7b7c2441 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -764,7 +764,7 @@ void DoMapInfo(){ ModalDialog dialog; GtkEntry* brushes_entry; GtkEntry* entities_entry; - GtkListStore* EntityBreakdownWalker; + ui::ListStore EntityBreakdownWalker{nullptr}; ui::Window window = MainFrame_getWindow().create_dialog_window("Map Info", G_CALLBACK(dialog_delete_callback ), &dialog ); @@ -840,7 +840,7 @@ void DoMapInfo(){ gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 ); { - GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); + 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 ) )); gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE ); diff --git a/radiant/textureentry.h b/radiant/textureentry.h index 45151373..19c72e84 100644 --- a/radiant/textureentry.h +++ b/radiant/textureentry.h @@ -35,15 +35,15 @@ template class EntryCompletion { -GtkListStore* m_store; +ui::ListStore m_store; IdleDraw m_idleUpdate; public: EntryCompletion() : m_store( 0 ), m_idleUpdate( UpdateCaller( *this ) ){ } void connect( GtkEntry* entry ){ - if ( m_store == 0 ) { - m_store = gtk_list_store_new( 1, G_TYPE_STRING ); + if ( !m_store ) { + m_store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); fill(); diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index eddd84de..01f3c979 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -261,8 +261,8 @@ ui::Widget m_texture_scroll; ui::Widget m_treeViewTree; ui::Widget m_treeViewTags; ui::Widget m_tag_frame; -GtkListStore* m_assigned_store; -GtkListStore* m_available_store; +ui::ListStore m_assigned_store{nullptr}; +ui::ListStore m_available_store{nullptr}; ui::Widget m_assigned_tree; ui::Widget m_available_tree; ui::Widget m_scr_win_tree; @@ -272,7 +272,7 @@ ui::Widget m_search_button; ui::Widget m_shader_info_item; std::set m_all_tags; -GtkListStore* m_all_tags_list; +ui::ListStore m_all_tags_list{nullptr}; std::vector m_copied_tags; std::set m_found_shaders; @@ -1295,7 +1295,7 @@ enum N_COLUMNS }; -void BuildStoreAssignedTags( GtkListStore* store, const char* shader, TextureBrowser* textureBrowser ){ +void BuildStoreAssignedTags( ui::ListStore store, const char* shader, TextureBrowser* textureBrowser ){ GtkTreeIter iter; gtk_list_store_clear( store ); @@ -1310,8 +1310,8 @@ void BuildStoreAssignedTags( GtkListStore* store, const char* shader, TextureBro } } -void BuildStoreAvailableTags( GtkListStore* storeAvailable, - GtkListStore* storeAssigned, +void BuildStoreAvailableTags( ui::ListStore storeAvailable, + ui::ListStore storeAssigned, const std::set& allTags, TextureBrowser* textureBrowser ){ GtkTreeIter iterAssigned; @@ -2076,7 +2076,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ // tag stuff if ( g_TextureBrowser.m_tags ) { { // fill tag GtkListStore - g_TextureBrowser.m_all_tags_list = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); + g_TextureBrowser.m_all_tags_list = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_all_tags_list ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); @@ -2130,7 +2130,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); - g_TextureBrowser.m_assigned_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); + g_TextureBrowser.m_assigned_store = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); @@ -2159,7 +2159,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); - g_TextureBrowser.m_available_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); + g_TextureBrowser.m_available_store = ui::ListStore(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );