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 daeb391..19b773f 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 c2b1ed9..96aff19 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 00e5026..7a8ecc1 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 be8d0ba..29fb326 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 c0f18c8..dc37bc8 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 054bece..dc0b93f 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 2849a12..284609d 100644 (file)
@@ -419,6 +419,7 @@ namespace ui {
 
     WRAP(ListStore, Object, _GtkListStore, (),
     ,
+         void clear();
     );
 
     WRAP(TreeModel, Widget, _GtkTreeModel, (),
index 1a41498..a7500ef 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 968d5c5..840a570 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 3c21a47..527e023 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 bb565b8..543c9fc 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 78f4fd0..567f00a 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 8aac9a8..7b7c244 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 4515137..19c72e8 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 eddd84d..01f3c97 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 );