]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Wrap GtkListStore
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 21 Jul 2017 12:24:28 +0000 (22:24 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 12:35:47 +0000 (22:35 +1000)
15 files changed:
contrib/bobtoolz/dialogs/dialogs-gtk.cpp
contrib/bobtoolz/lists.cpp
contrib/bobtoolz/lists.h
contrib/brushexport/callbacks.cpp
contrib/brushexport/interface.cpp
libs/uilib/uilib.cpp
libs/uilib/uilib.h
radiant/build.cpp
radiant/commands.cpp
radiant/entityinspector.cpp
radiant/feedback.cpp
radiant/feedback.h
radiant/map.cpp
radiant/textureentry.h
radiant/texwindow.cpp

index daeb391383f810225063b86897aa67274e35e47f..19b773fadf3aa65e3146c68da80c64b90747f360 100644 (file)
@@ -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 );
 
index c2b1ed9e30672e50ebacdc7aa02fd85ead8dcc85..96aff1976aabe0c309917ac322b2678ae8976e8c 100644 (file)
@@ -55,7 +55,7 @@ bool LoadExclusionList( char* filename, std::list<Str>* 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];
index 00e50266f0d9e0db2b1c50756c0d0b420645ac68..7a8ecc1802dabb503b8c33ccc6f86d7a67ed56cf 100644 (file)
@@ -18,9 +18,9 @@
  */
 
 #include <list>
-#include <gtk/gtk.h>
+#include <uilib/uilib.h>
 #include "str.h"
 typedef struct _GList GList;
 
 bool LoadExclusionList( char* filename, std::list<Str>* exclusionList );
-bool LoadGList( char* filename, GtkListStore* loadlist );
+bool LoadGList( char* filename, ui::ListStore loadlist );
index be8d0bae54f45be693f482c9620fe9fa685a8f1f..29fb3263aeb1abe6542961424ddff6f7f87460f2 100644 (file)
@@ -31,7 +31,7 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){
        std::set<std::string> 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;
index c0f18c82b29db4d62370e5d9a7183fc6940a6097..dc37bc8c5de22723104ec75865f51ff0cd4f65c2 100644 (file)
@@ -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 );
 
index 054beced85cac9ee8797329bc05608fe49985b4b..dc0b93f29e9bfa9e81fdb9fe0a77f82c9690c699 100644 (file)
@@ -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())
     {}
 
index 2849a12a88a77b6984ef771eb5b2e354374c39db..284609d630d571cf640f304ac4c23c9f3000cd46 100644 (file)
@@ -419,6 +419,7 @@ namespace ui {
 
     WRAP(ListStore, Object, _GtkListStore, (),
     ,
+         void clear();
     );
 
     WRAP(TreeModel, Widget, _GtkTreeModel, (),
index 1a4149882e12b739e44e89804dab4518cffb1f38..a7500ef4d1b91d1edaa56f37ccdf33ff2ddc184d 100644 (file)
@@ -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 );
index 968d5c55f7357994db3926c29c31ef87c328dd01..840a570de72dff8fb4968ad25922e503f7103851 100644 (file)
@@ -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;
index 3c21a47d20620fe0116d5455dbceab8965a34c74..527e0239ad683a1778dc7d496bab60ec05916235 100644 (file)
@@ -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 );
index bb565b843db58c585cc4e2323b26016bc174ce57..543c9fc42685f736ada61dd8deb45e95d7be916a 100644 (file)
@@ -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 );
index 78f4fd045f0ad85546dd7066447dc8efb552d9eb..567f00afd11a691e3a66f259c2b5461f93a96058 100644 (file)
@@ -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:
index 8aac9a8f4c6bc52cf157d2b1ce6aaacbeb691865..7b7c2441aa4fc184fb8ba5715aa48a5e119322ef 100644 (file)
@@ -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 );
index 451513735351206cf515c71529680a2a229ad4b4..19c72e84a6964efc3678e70e044f31908da168e2 100644 (file)
 template<typename StringList>
 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();
 
index eddd84deecfad5022e9b975f53d887d56fa0c454..01f3c979f83c775981b7059a3b47d4e05bce9fc0 100644 (file)
@@ -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<CopiedString> m_all_tags;
-GtkListStore* m_all_tags_list;
+ui::ListStore m_all_tags_list{nullptr};
 std::vector<CopiedString> m_copied_tags;
 std::set<CopiedString> 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<CopiedString>& 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 );