]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Wrap GtkTreeViewColumn
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 06:07:24 +0000 (17:07 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 06:07:24 +0000 (17:07 +1100)
12 files changed:
contrib/brushexport/interface.cpp
libs/uilib/uilib.cpp
libs/uilib/uilib.h
radiant/build.cpp
radiant/commands.cpp
radiant/entityinspector.cpp
radiant/entitylist.cpp
radiant/feedback.cpp
radiant/main.cpp
radiant/map.cpp
radiant/preferences.cpp
radiant/texwindow.cpp

index 5d1f99829287ff9d0d9e175e30683fcae5c0a309..2ac8f9770145a052d94325a8cc496e0d6dc52b75 100644 (file)
@@ -214,7 +214,7 @@ void CreateWindow( void ){
        GtkTreeViewColumn* col = gtk_tree_view_column_new();
        gtk_tree_view_column_set_title( col, "materials" );
        gtk_tree_view_append_column( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), col );
-       GtkCellRenderer* renderer = ui::CellRendererText();
+       auto renderer = ui::CellRendererText();
        gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), -1, "", renderer, "text", 0, NULL );
 
        // list store
index 763029b26abc19cca6d1358331e66d5678286882..bfcca620b690fa3763962864a661a30acf1c3dde 100644 (file)
@@ -91,7 +91,8 @@ namespace ui {
                            double lower, double upper,
                            double step_increment, double page_increment,
                            double page_size)
-            : Adjustment(GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size)))
+            : Adjustment(
+            GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size)))
     { }
 
     Alignment::Alignment(float xalign, float yalign, float xscale, float yscale)
@@ -107,8 +108,8 @@ namespace ui {
     CellRendererText::CellRendererText() : CellRendererText(GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new()))
     { }
 
-    ComboBoxText::ComboBoxText() : ComboBoxText(GTK_COMBO_BOX(gtk_combo_box_new_text()))
-    { }
+    ComboBox ComboBoxText()
+    { return ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_text())); }
 
     CheckButton::CheckButton(const char *label) : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_label(label)))
     { }
@@ -131,16 +132,19 @@ namespace ui {
     Menu::Menu() : Menu(GTK_MENU(gtk_menu_new()))
     { }
 
-    MenuItem::MenuItem(const char *label, bool mnemonic) : MenuItem(GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label)))
+    MenuItem::MenuItem(const char *label, bool mnemonic) : MenuItem(
+            GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label)))
     { }
 
     ScrolledWindow::ScrolledWindow() : ScrolledWindow(GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(nullptr, nullptr)))
     { }
 
-    SpinButton::SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits) : SpinButton(GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits)))
+    SpinButton::SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits) : SpinButton(
+            GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits)))
     { }
 
-    Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table(GTK_TABLE(gtk_table_new(rows, columns, homogenous)))
+    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())
@@ -152,6 +156,15 @@ namespace ui {
     TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model)))
     { }
 
+    TreeViewColumn::TreeViewColumn(const char *title, CellRenderer renderer,
+                                   std::initializer_list<TreeViewColumnAttribute> attributes)
+            : TreeViewColumn(gtk_tree_view_column_new_with_attributes(title, renderer, nullptr))
+    {
+        for (auto &it : attributes) {
+            gtk_tree_view_column_add_attribute(*this, renderer, it.attribute, it.column);
+        }
+    };
+
     VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing)))
     { }
 
index f9b996c648409987cf10aac8bed62f541db08fe1..5a6e1a58657a4bf1762a479496b68e2a7fa8498d 100644 (file)
@@ -10,7 +10,6 @@ using ui_box = struct _GtkBox;
 using ui_button = struct _GtkButton;
 using ui_checkbutton = struct _GtkCheckButton;
 using ui_combobox = struct _GtkComboBox;
-using ui_comboboxtext = ui_combobox;
 using ui_cellrenderer = struct _GtkCellRenderer;
 using ui_cellrenderertext = struct _GtkCellRendererText;
 using ui_entry = struct _GtkEntry;
@@ -28,6 +27,7 @@ using ui_table = struct _GtkTable;
 using ui_treemodel = struct _GtkTreeModel;
 using ui_treepath = struct _GtkTreePath;
 using ui_treeview = struct _GtkTreeView;
+using ui_treeviewcolumn = struct _GtkTreeViewColumn;
 using ui_typeinst = struct _GTypeInstance;
 using ui_vbox = struct _GtkVBox;
 using ui_widget = struct _GtkWidget;
@@ -158,9 +158,7 @@ namespace ui {
 
     WRAP(ComboBox, Widget, ui_combobox,);
 
-    WRAP(ComboBoxText, ComboBox, ui_comboboxtext,
-         ComboBoxText();
-    );
+    ComboBox ComboBoxText();
 
     WRAP(Entry, Widget, ui_entry,
          Entry();
@@ -210,6 +208,14 @@ namespace ui {
          TreeView(TreeModel model);
     );
 
+    struct TreeViewColumnAttribute {
+        const char *attribute;
+        int column;
+    };
+    WRAP(TreeViewColumn, Widget, ui_treeviewcolumn,
+         TreeViewColumn(const char *title, CellRenderer renderer, std::initializer_list<TreeViewColumnAttribute> attributes);
+    );
+
     WRAP(VBox, Box, ui_vbox,
          VBox(bool homogenous, int spacing);
     );
index 2bad89c153f4ead9804db9ed1074a8fcdf0c0ad2..03ebf652462ebf082ccdbe0fbed65d29e0864988 100644 (file)
@@ -882,11 +882,11 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
                                        ui::Widget view = ui::TreeView( ui::TreeModel(GTK_TREE_MODEL( store ) ));
                                        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
 
-                                       GtkCellRenderer* renderer = ui::CellRendererText();
+                                       auto renderer = ui::CellRendererText();
                                        object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
                                        g_signal_connect( renderer, "edited", G_CALLBACK( project_cell_edited ), &projectList );
 
-                                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 );
+                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
                                        gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
 
                                        GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
@@ -919,11 +919,11 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
                                        ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
                                        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
 
-                                       GtkCellRenderer* renderer = ui::CellRendererText();
+                                       auto renderer = ui::CellRendererText();
                                        object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
                                        g_signal_connect( renderer, "edited", G_CALLBACK( commands_cell_edited ), store );
 
-                                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 );
+                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
                                        gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
 
                                        GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
index b220e3b5f3060e626c2535c1ba5511039afe9c1e..a431257acf9a5c856cf576823a7f30f6faa6aa1e 100644 (file)
@@ -412,14 +412,14 @@ void DoCommandListDlg(){
                        gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), false ); // annoying
 
                        {
-                               GtkCellRenderer* renderer = ui::CellRendererText();
-                               GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Command", renderer, "text", 0, "weight-set", 2, "weight", 3, NULL );
+                               auto renderer = ui::CellRendererText();
+                               GtkTreeViewColumn* column = ui::TreeViewColumn( "Command", renderer, {{"text", 0}, {"weight-set", 2}, {"weight", 3}} );
                                gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                        }
 
                        {
-                               GtkCellRenderer* renderer = ui::CellRendererText();
-                               GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 1, "weight-set", 2, "weight", 3, NULL );
+                               auto renderer = ui::CellRendererText();
+                               GtkTreeViewColumn* column = ui::TreeViewColumn( "Key", renderer, {{"text", 1}, {"weight-set", 2}, {"weight", 3}} );
                                gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                        }
 
index 8db78f1c0973dbf9accbfba8cb53078b4f6a450f..8b1944977ab4b2da8ecceb2d6648a5f5b348a2df 100644 (file)
@@ -679,7 +679,7 @@ ListAttribute( const char* key, const ListAttributeType& type ) :
        m_combo( 0 ),
        m_nonModal( ApplyCaller( *this ) ),
        m_type( type ){
-       GtkComboBox* combo = ui::ComboBoxText();
+       auto combo = ui::ComboBoxText();
 
        for ( ListAttributeType::const_iterator i = type.begin(); i != type.end(); ++i )
        {
@@ -1344,8 +1344,8 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                        g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 );
 
                                        {
-                                               GtkCellRenderer* renderer = ui::CellRendererText();
-                                               GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 0, 0 );
+                                               auto renderer = ui::CellRendererText();
+                                               GtkTreeViewColumn* column = ui::TreeViewColumn( "Key", renderer, {{"text", 0}} );
                                                gtk_tree_view_append_column( view, column );
                                        }
 
@@ -1426,14 +1426,14 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
                                                gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
 
                                                {
-                                                       GtkCellRenderer* renderer = ui::CellRendererText();
-                                                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 );
+                                                       auto renderer = ui::CellRendererText();
+                                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
                                                        gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                                                }
 
                                                {
-                                                       GtkCellRenderer* renderer = ui::CellRendererText();
-                                                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 1, 0 );
+                                                       auto renderer = ui::CellRendererText();
+                                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 1}} );
                                                        gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                                                }
 
index 96de418cd57e00d2a2204eb0294fb4e16fcd87aa..a93d9698a6fe04fb1d75bfa163aa522f3fd27224 100644 (file)
@@ -303,7 +303,7 @@ void EntityList_constructWindow( ui::Window main_window ){
                        ui::Widget view = ui::Widget(gtk_tree_view_new());
                        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
 
-                       GtkCellRenderer* renderer = ui::CellRendererText();
+                       auto renderer = ui::CellRendererText();
                        GtkTreeViewColumn* column = gtk_tree_view_column_new();
                        gtk_tree_view_column_pack_start( column, renderer, TRUE );
                        gtk_tree_view_column_set_cell_data_func( column, renderer, entitylist_treeviewcolumn_celldatafunc, 0, 0 );
index 45bcf9c64d0ea243797c61da04854c24d79eb714..54679a53af0df04ff81cabd2e89c2b60309be8d2 100644 (file)
@@ -311,8 +311,8 @@ ui::Window CDbgDlg::BuildDialog(){
                gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
 
                {
-                       GtkCellRenderer* renderer = ui::CellRendererText();
-                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, NULL );
+                       auto renderer = ui::CellRendererText();
+                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
                        gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                }
 
index 65a45497c2a0603f3a1a107cc0814aa74030a9e1..d72aa6c87e27ad1d507014e61311839202f8c4a3 100644 (file)
@@ -310,7 +310,7 @@ bool handleMessage(){
                ScopedLock lock( m_lock );
 #if defined _DEBUG
                m_buffer << "Break into the debugger?\n";
-               bool handled = ui::alert( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_YESNO, eMB_ICONERROR ) == eIDNO;
+               bool handled = ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::ERROR ) == ui::alert_response::NO;
                m_buffer.clear();
                return handled;
 #else
index 10b6075451a05319f7675754137d1e44f910444e..0dcf97913e9a7b6eb778abd6c7e4b6941b800d83 100644 (file)
@@ -850,15 +850,15 @@ void DoMapInfo(){
                                gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE );
 
                                {
-                                       GtkCellRenderer* renderer = ui::CellRendererText();
-                                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Entity", renderer, "text", 0, 0 );
+                                       auto renderer = ui::CellRendererText();
+                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "Entity", renderer, {{"text", 0}} );
                                        gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                                        gtk_tree_view_column_set_sort_column_id( column, 0 );
                                }
 
                                {
-                                       GtkCellRenderer* renderer = ui::CellRendererText();
-                                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Count", renderer, "text", 1, 0 );
+                                       auto renderer = ui::CellRendererText();
+                                       GtkTreeViewColumn* column = ui::TreeViewColumn( "Count", renderer, {{"text", 1}} );
                                        gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                                        gtk_tree_view_column_set_sort_column_id( column, 1 );
                                }
index 7b62beef45d948751928c4ccf29c2b716c68e9ad..86454c66e01f65c2bf8ec7555bbbd5ba4521fd52 100644 (file)
@@ -755,8 +755,8 @@ ui::Window PrefsDlg::BuildDialog(){
                                        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
 
                                        {
-                                               GtkCellRenderer* renderer = ui::CellRendererText();
-                                               GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Preferences", renderer, "text", 0, NULL );
+                                               auto renderer = ui::CellRendererText();
+                                               GtkTreeViewColumn* column = ui::TreeViewColumn( "Preferences", renderer, {{"text", 0}} );
                                                gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
                                        }
 
index 9ddc26a8caf7b98df515b76c1ba5618cc1579c06..2aad7a3c54d4594b86024b3aa2cae9cc403ed777 100644 (file)
@@ -1529,14 +1529,13 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV
 }
 
 void TextureBrowser_createTreeViewTree(){
-       GtkCellRenderer* renderer;
        g_TextureBrowser.m_treeViewTree = ui::Widget(GTK_WIDGET( gtk_tree_view_new() ));
        gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE );
 
        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE );
        g_signal_connect( g_TextureBrowser.m_treeViewTree, "row-activated", (GCallback) TreeView_onRowActivated, NULL );
 
-       renderer = ui::CellRendererText();
+       auto renderer = ui::CellRendererText();
        gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), -1, "", renderer, "text", 0, NULL );
 
        TextureBrowser_constructTreeStore();
@@ -1586,7 +1585,6 @@ gboolean TreeViewTags_onButtonPressed( ui::Widget treeview, GdkEventButton *even
 }
 
 void TextureBrowser_createTreeViewTags(){
-       GtkCellRenderer* renderer;
        g_TextureBrowser.m_treeViewTags = ui::Widget(GTK_WIDGET( gtk_tree_view_new() ));
        gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE );
 
@@ -1594,7 +1592,7 @@ void TextureBrowser_createTreeViewTags(){
 
        gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE );
 
-       renderer = ui::CellRendererText();
+       auto renderer = ui::CellRendererText();
        gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), -1, "", renderer, "text", 0, NULL );
 
        TextureBrowser_constructTreeStoreTags();
@@ -2078,7 +2076,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store );
                        gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
 
-                       GtkCellRenderer* renderer = ui::CellRendererText();
+                       auto renderer = ui::CellRendererText();
 
                        g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) ));
                        g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) );
@@ -2088,7 +2086,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) );
                        gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
 
-                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL );
+                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
                        gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), column );
                        gtk_widget_show( g_TextureBrowser.m_assigned_tree );
 
@@ -2106,7 +2104,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store );
                        gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
 
-                       GtkCellRenderer* renderer = ui::CellRendererText();
+                       auto renderer = ui::CellRendererText();
 
                        g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) ));
                        g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) );
@@ -2116,7 +2114,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
                        gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
 
-                       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL );
+                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
                        gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), column );
                        gtk_widget_show( g_TextureBrowser.m_available_tree );