GTK: wrap gtk_widget_set_size_request
[xonotic/netradiant.git] / radiant / texwindow.cpp
index 7d1782e..20c5bd9 100644 (file)
@@ -258,19 +258,19 @@ CopiedString shader;
 
 ui::Window m_parent{ui::null};
 ui::GLArea m_gl_widget{ui::null};
-ui::Widget m_texture_scroll;
-ui::Widget m_treeViewTree;
-ui::Widget m_treeViewTags;
+ui::Widget m_texture_scroll{ui::null};
+ui::TreeView m_treeViewTree{ui::null};
+ui::TreeView m_treeViewTags{ui::null};
 ui::Frame m_tag_frame{ui::null};
 ui::ListStore m_assigned_store{ui::null};
 ui::ListStore m_available_store{ui::null};
-ui::Widget m_assigned_tree;
-ui::Widget m_available_tree;
-ui::Widget m_scr_win_tree;
-ui::Widget m_scr_win_tags;
-ui::Widget m_tag_notebook;
+ui::TreeView m_assigned_tree{ui::null};
+ui::TreeView m_available_tree{ui::null};
+ui::Widget m_scr_win_tree{ui::null};
+ui::Widget m_scr_win_tags{ui::null};
+ui::Widget m_tag_notebook{ui::null};
 ui::Button m_search_button{ui::null};
-ui::Widget m_shader_info_item;
+ui::Widget m_shader_info_item{ui::null};
 
 std::set<CopiedString> m_all_tags;
 ui::ListStore m_all_tags_list{ui::null};
@@ -349,11 +349,11 @@ int getTextureHeight( qtexture_t* tex ){
 TextureBrowser() :
        m_texture_scroll( 0 ),
        m_hideunused_item( TextureBrowserHideUnusedExport() ),
+       m_hidenotex_item( TextureBrowserFilterFallbackExport() ),
        m_showshaders_item( TextureBrowserShowShadersExport() ),
        m_showshaderlistonly_item( TextureBrowserShowShaderlistOnlyExport() ),
        m_fixedsize_item( TextureBrowserFixedSizeExport() ),
        m_filternotex_item( TextureBrowserFilterMissingExport() ),
-       m_hidenotex_item( TextureBrowserFilterFallbackExport() ),
        m_enablealpha_item( TextureBrowserEnableAlphaExport() ),
        m_heightChanged( true ),
        m_originInvalid( true ),
@@ -674,7 +674,7 @@ void TextureBrowser_activeShadersChanged( TextureBrowser& textureBrowser ){
 void TextureBrowser_importShowScrollbar( TextureBrowser& textureBrowser, bool value ){
        textureBrowser.m_showTextureScrollbar = value;
        if ( textureBrowser.m_texture_scroll != 0 ) {
-               widget_set_visible( textureBrowser.m_texture_scroll, textureBrowser.m_showTextureScrollbar );
+               textureBrowser.m_texture_scroll.visible(textureBrowser.m_showTextureScrollbar);
                TextureBrowser_updateScroll( textureBrowser );
        }
 }
@@ -738,7 +738,7 @@ void visit( const char* name ){
 
 void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused );
 
-ui::Widget g_page_textures;
+ui::Widget g_page_textures{ui::null};
 
 void TextureBrowser_toggleShow(){
        GroupDialog_showPage( g_page_textures );
@@ -1299,15 +1299,14 @@ enum
 void BuildStoreAssignedTags( ui::ListStore store, const char* shader, TextureBrowser* textureBrowser ){
        GtkTreeIter iter;
 
-       gtk_list_store_clear( store );
+       store.clear();
 
        std::vector<CopiedString> assigned_tags;
        TagBuilder.GetShaderTags( shader, assigned_tags );
 
        for ( size_t i = 0; i < assigned_tags.size(); i++ )
        {
-               gtk_list_store_append( store, &iter );
-               gtk_list_store_set( store, &iter, TAG_COLUMN, assigned_tags[i].c_str(), -1 );
+               store.append(TAG_COLUMN, assigned_tags[i].c_str());
        }
 }
 
@@ -1320,35 +1319,33 @@ void BuildStoreAvailableTags(   ui::ListStore storeAvailable,
        std::set<CopiedString>::const_iterator iterAll;
        gchar* tag_assigned;
 
-       gtk_list_store_clear( 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 )
                {
-                       gtk_list_store_append( storeAvailable, &iterAvailable );
-                       gtk_list_store_set( storeAvailable, &iterAvailable, TAG_COLUMN, ( *iterAll ).c_str(), -1 );
+                       storeAvailable.append(TAG_COLUMN, (*iterAll).c_str());
                }
        }
        else
        {
                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 )
                        {
                                if ( strcmp( (char*)tag_assigned, ( *iterAll ).c_str() ) != 0 ) {
-                                       gtk_list_store_append( storeAvailable, &iterAvailable );
-                                       gtk_list_store_set( storeAvailable, &iterAvailable, TAG_COLUMN, ( *iterAll ).c_str(), -1 );
+                                       storeAvailable.append(TAG_COLUMN, (*iterAll).c_str());
                                }
                                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 );
                                        }
                                }
                        }
@@ -1382,7 +1379,7 @@ gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event,
 
                        if ( GlobalTextureBrowser().m_tags ) {
                                textureBrowser->m_rmbSelected = false;
-                               gtk_widget_hide( textureBrowser->m_tag_frame );
+                               textureBrowser->m_tag_frame.hide();
                        }
                }
        }
@@ -1483,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;
 
@@ -1540,23 +1537,20 @@ 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<CopiedString>::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(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 );
+       gtk_tree_view_set_model(g_TextureBrowser.m_treeViewTags, model );
 
        g_object_unref( G_OBJECT( store ) );
 }
@@ -1564,7 +1558,7 @@ void TextureBrowser_constructTreeStoreTags(){
 void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeViewColumn* col, gpointer userdata ){
        GtkTreeIter iter;
 
-       GtkTreeModel* model = gtk_tree_view_get_model( GTK_TREE_VIEW( treeview ) );
+       GtkTreeModel* model = gtk_tree_view_get_model(treeview );
 
        if ( gtk_tree_model_get_iter( model, &iter, path ) ) {
                gchar dirName[1024];
@@ -1587,14 +1581,14 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV
 }
 
 void TextureBrowser_createTreeViewTree(){
-       g_TextureBrowser.m_treeViewTree = ui::TreeView();
-       gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE );
+       g_TextureBrowser.m_treeViewTree = ui::TreeView(ui::New);
+       gtk_tree_view_set_enable_search(g_TextureBrowser.m_treeViewTree, FALSE );
 
-       gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE );
+       gtk_tree_view_set_headers_visible(g_TextureBrowser.m_treeViewTree, FALSE );
        g_TextureBrowser.m_treeViewTree.connect( "row-activated", (GCallback) TreeView_onRowActivated, NULL );
 
-       auto renderer = ui::CellRendererText();
-       gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), -1, "", renderer, "text", 0, NULL );
+       auto renderer = ui::CellRendererText(ui::New);
+       gtk_tree_view_insert_column_with_attributes(g_TextureBrowser.m_treeViewTree, -1, "", renderer, "text", 0, NULL );
 
        TextureBrowser_constructTreeStore();
 }
@@ -1604,7 +1598,7 @@ void TextureBrowser_renameTag();
 void TextureBrowser_deleteTag();
 
 void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){
-       ui::Widget menu = ui::Menu();
+       ui::Widget menu = ui::Menu(ui::New);
 
        ui::Widget menuitem = ui::MenuItem( "Add tag" );
        menuitem.connect( "activate", (GCallback)TextureBrowser_addTag, treeview );
@@ -1625,12 +1619,12 @@ void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *even
                                        gdk_event_get_time( (GdkEvent*)event ) );
 }
 
-gboolean TreeViewTags_onButtonPressed( ui::Widget treeview, GdkEventButton *event ){
+gboolean TreeViewTags_onButtonPressed( ui::TreeView treeview, GdkEventButton *event ){
        if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) {
                GtkTreePath *path;
-               GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( treeview ) );
+               GtkTreeSelection* selection = gtk_tree_view_get_selection(treeview );
 
-               if ( gtk_tree_view_get_path_at_pos( GTK_TREE_VIEW( treeview ), event->x, event->y, &path, NULL, NULL, NULL ) ) {
+               if ( gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, &path, NULL, NULL, NULL ) ) {
                        gtk_tree_selection_unselect_all( selection );
                        gtk_tree_selection_select_path( selection, path );
                        gtk_tree_path_free( path );
@@ -1643,15 +1637,15 @@ gboolean TreeViewTags_onButtonPressed( ui::Widget treeview, GdkEventButton *even
 }
 
 void TextureBrowser_createTreeViewTags(){
-       g_TextureBrowser.m_treeViewTags = ui::TreeView();
-       gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE );
+       g_TextureBrowser.m_treeViewTags = ui::TreeView(ui::New);
+       gtk_tree_view_set_enable_search(g_TextureBrowser.m_treeViewTags, FALSE );
 
        g_TextureBrowser.m_treeViewTags.connect( "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL );
 
-       gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE );
+       gtk_tree_view_set_headers_visible(g_TextureBrowser.m_treeViewTags, FALSE );
 
-       auto renderer = ui::CellRendererText();
-       gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), -1, "", renderer, "text", 0, NULL );
+       auto renderer = ui::CellRendererText(ui::New);
+       gtk_tree_view_insert_column_with_attributes(g_TextureBrowser.m_treeViewTags, -1, "", renderer, "text", 0, NULL );
 
        TextureBrowser_constructTreeStoreTags();
 }
@@ -1697,7 +1691,7 @@ ui::MenuItem TextureBrowser_constructViewMenu( ui::Menu menu ){
 
        if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) {
                menu_separator( menu );
-               g_TextureBrowser.m_shader_info_item = ui::Widget(GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) ));
+               g_TextureBrowser.m_shader_info_item = ui::Widget(create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo"  ));
                gtk_widget_set_sensitive( g_TextureBrowser.m_shader_info_item, FALSE );
        }
 
@@ -1749,7 +1743,7 @@ void TextureBrowser_assignTags(){
        GSList* node;
        gchar* tag_assigned;
 
-       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
+       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_available_tree );
 
        gtk_tree_selection_selected_foreach( selection, (GtkTreeSelectionForeachFunc)TextureBrowser_tagMoveHelper, &selected );
 
@@ -1761,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() );
@@ -1781,8 +1775,7 @@ void TextureBrowser_assignTags(){
                                        TagBuilder.AddShaderTag( g_TextureBrowser.shader.c_str(), (char*)tag_assigned, TAG );
 
                                        gtk_list_store_remove( g_TextureBrowser.m_available_store, &iter );
-                                       gtk_list_store_append( g_TextureBrowser.m_assigned_store, &iter );
-                                       gtk_list_store_set( g_TextureBrowser.m_assigned_store, &iter, TAG_COLUMN, (char*)tag_assigned, -1 );
+                                       g_TextureBrowser.m_assigned_store.append(TAG_COLUMN, tag_assigned);
                                }
                        }
                }
@@ -1800,7 +1793,7 @@ void TextureBrowser_removeTags(){
        GSList* node;
        gchar* tag;
 
-       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) );
+       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_assigned_tree );
 
        gtk_tree_selection_selected_foreach( selection, (GtkTreeSelectionForeachFunc)TextureBrowser_tagMoveHelper, &selected );
 
@@ -1812,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 );
                                }
@@ -1832,15 +1825,13 @@ void TextureBrowser_removeTags(){
 }
 
 void TextureBrowser_buildTagList(){
-       GtkTreeIter treeIter;
-       gtk_list_store_clear( g_TextureBrowser.m_all_tags_list );
+       g_TextureBrowser.m_all_tags_list.clear();
 
        std::set<CopiedString>::iterator iter;
 
        for ( iter = g_TextureBrowser.m_all_tags.begin(); iter != g_TextureBrowser.m_all_tags.end(); ++iter )
        {
-               gtk_list_store_append( g_TextureBrowser.m_all_tags_list, &treeIter );
-               gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &treeIter, TAG_COLUMN, ( *iter ).c_str(), -1 );
+               g_TextureBrowser.m_all_tags_list.append(TAG_COLUMN, (*iter).c_str());
        }
 }
 
@@ -1851,7 +1842,7 @@ void TextureBrowser_searchTags(){
        char buffer[256];
        char tags_searched[256];
 
-       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
 
        gtk_tree_selection_selected_foreach( selection, (GtkTreeSelectionForeachFunc)TextureBrowser_tagMoveHelper, &selected );
 
@@ -1866,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 );
@@ -1921,7 +1912,7 @@ void TextureBrowser_toggleSearchButton(){
                gtk_widget_show_all( g_TextureBrowser.m_search_button );
        }
        else {
-               gtk_widget_hide( g_TextureBrowser.m_search_button );
+               g_TextureBrowser.m_search_button.hide();
        }
 }
 
@@ -1940,7 +1931,7 @@ void TextureBrowser_constructTagNotebook(){
 
 void TextureBrowser_constructSearchButton(){
        ui::Widget image = ui::Widget(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR ));
-       g_TextureBrowser.m_search_button = ui::Button();
+       g_TextureBrowser.m_search_button = ui::Button(ui::New);
        g_TextureBrowser.m_search_button.connect( "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL );
        gtk_widget_set_tooltip_text(g_TextureBrowser.m_search_button, "Search with selected tags");
        g_TextureBrowser.m_search_button.add(image);
@@ -1989,7 +1980,7 @@ void TextureBrowser_SetNotex(){
        name << GlobalRadiant().getAppPath() << "bitmaps/" NOTEX_BASENAME ".png";
        g_notex = name.c_str();
 
-       name = NULL;
+       name = StringOutputStream(256);
        name << GlobalRadiant().getAppPath() << "bitmaps/" SHADERNOTEX_BASENAME " .png";
        g_shadernotex = name.c_str();
 }
@@ -2007,31 +1998,30 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
 
        g_TextureBrowser.m_parent = toplevel;
 
-       ui::Widget table = ui::Table( 3, 3, FALSE );
-       ui::Widget frame_table;
-       ui::Widget vbox = ui::VBox( FALSE, 0 );
-       gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 );
+       auto table = ui::Table(3, 3, FALSE);
+       auto vbox = ui::VBox(FALSE, 0);
+       table.attach(vbox, {0, 1, 1, 3}, {GTK_FILL, GTK_FILL});
        vbox.show();
 
-       ui::Widget menu_bar;
+       ui::Widget menu_bar{ui::null};
 
        { // menu bar
                menu_bar = ui::Widget(gtk_menu_bar_new());
-               auto menu_view = ui::Menu();
+               auto menu_view = ui::Menu(ui::New);
                auto view_item = TextureBrowser_constructViewMenu( menu_view );
                gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view );
                gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item );
 
-               auto menu_tools = ui::Menu();
+               auto menu_tools = ui::Menu(ui::New);
                auto tools_item = TextureBrowser_constructToolsMenu( menu_tools );
                gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools );
                gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tools_item );
 
-               gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 );
+               table.attach(menu_bar, {0, 3, 0, 1}, {GTK_FILL, GTK_SHRINK});
                menu_bar.show();
        }
        { // Texture TreeView
-               g_TextureBrowser.m_scr_win_tree = ui::ScrolledWindow();
+               g_TextureBrowser.m_scr_win_tree = ui::ScrolledWindow(ui::New);
                gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 );
 
                // vertical only scrolling for treeview
@@ -2041,19 +2031,19 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
 
                TextureBrowser_createTreeViewTree();
 
-               gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) );
+               gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), g_TextureBrowser.m_treeViewTree  );
                g_TextureBrowser.m_treeViewTree.show();
        }
        { // gl_widget scrollbar
                ui::Widget w = ui::Widget(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) ));
-               gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 1, 2, GTK_SHRINK, GTK_FILL, 0, 0 );
+               table.attach(w, {2, 3, 1, 2}, {GTK_SHRINK, GTK_FILL});
                w.show();
                g_TextureBrowser.m_texture_scroll = w;
 
                auto vadjustment = ui::Adjustment(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) ));
                vadjustment.connect( "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser );
 
-               widget_set_visible( g_TextureBrowser.m_texture_scroll, g_TextureBrowser.m_showTextureScrollbar );
+               g_TextureBrowser.m_texture_scroll.visible(g_TextureBrowser.m_showTextureScrollbar);
        }
        { // gl_widget
                g_TextureBrowser.m_gl_widget = glwidget_new( FALSE );
@@ -2062,7 +2052,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                gtk_widget_set_events( g_TextureBrowser.m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK );
                gtk_widget_set_can_focus( g_TextureBrowser.m_gl_widget, true );
 
-               gtk_table_attach_defaults( GTK_TABLE( table ), g_TextureBrowser.m_gl_widget, 1, 2, 1, 2 );
+               table.attach(g_TextureBrowser.m_gl_widget, {1, 2, 1, 2});
                g_TextureBrowser.m_gl_widget.show();
 
                g_TextureBrowser.m_sizeHandler = g_TextureBrowser.m_gl_widget.connect( "size_allocate", G_CALLBACK( TextureBrowser_size_allocate ), &g_TextureBrowser );
@@ -2085,13 +2075,13 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        TextureBrowser_buildTagList();
                }
                { // tag menu bar
-                       auto menu_tags = ui::Menu();
+                       auto menu_tags = ui::Menu(ui::New);
                        auto tags_item = TextureBrowser_constructTagsMenu( menu_tags );
                        gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags );
                        gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item );
                }
                { // Tag TreeView
-                       g_TextureBrowser.m_scr_win_tags = ui::ScrolledWindow();
+                       g_TextureBrowser.m_scr_win_tags = ui::ScrolledWindow(ui::New);
                        gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), 0 );
 
                        // vertical only scrolling for treeview
@@ -2099,35 +2089,35 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
 
                        TextureBrowser_createTreeViewTags();
 
-                       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+                       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
                        gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
 
-                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) );
+                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), g_TextureBrowser.m_treeViewTags  );
                        g_TextureBrowser.m_treeViewTags.show();
                }
                { // Texture/Tag notebook
                        TextureBrowser_constructTagNotebook();
-                       gtk_box_pack_start( GTK_BOX( vbox ), g_TextureBrowser.m_tag_notebook, TRUE, TRUE, 0 );
+                       vbox.pack_start( g_TextureBrowser.m_tag_notebook, TRUE, TRUE, 0 );
                }
                { // Tag search button
                        TextureBrowser_constructSearchButton();
-                       gtk_box_pack_end( GTK_BOX( vbox ), g_TextureBrowser.m_search_button, FALSE, FALSE, 0 );
+                       vbox.pack_end(g_TextureBrowser.m_search_button, FALSE, FALSE, 0);
                }
+               auto frame_table = ui::Table(3, 3, FALSE);
                { // Tag frame
-                       frame_table = ui::Table( 3, 3, FALSE );
 
                        g_TextureBrowser.m_tag_frame = ui::Frame( "Tag assignment" );
                        gtk_frame_set_label_align( GTK_FRAME( g_TextureBrowser.m_tag_frame ), 0.5, 0.5 );
                        gtk_frame_set_shadow_type( GTK_FRAME( g_TextureBrowser.m_tag_frame ), GTK_SHADOW_NONE );
 
-                       gtk_table_attach( GTK_TABLE( table ), g_TextureBrowser.m_tag_frame, 1, 3, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0 );
+                       table.attach(g_TextureBrowser.m_tag_frame, {1, 3, 2, 3}, {GTK_FILL, GTK_SHRINK});
 
                        frame_table.show();
 
                        g_TextureBrowser.m_tag_frame.add(frame_table);
                }
                { // assigned tag list
-                       ui::Widget scrolled_win = ui::ScrolledWindow();
+                       ui::Widget scrolled_win = ui::ScrolledWindow(ui::New);
                        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 );
 
@@ -2136,27 +2126,27 @@ 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 );
 
-                       auto renderer = ui::CellRendererText();
+                       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 );
+                       gtk_tree_view_set_headers_visible(g_TextureBrowser.m_assigned_tree, FALSE );
 
-                       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) );
+                       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_assigned_tree );
                        gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
 
                        GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
-                       gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), column );
+                       gtk_tree_view_append_column(g_TextureBrowser.m_assigned_tree, column );
                        g_TextureBrowser.m_assigned_tree.show();
 
                        scrolled_win.show();
-                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_assigned_tree ) );
+                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_assigned_tree  );
 
-                       gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 );
+                       frame_table.attach(scrolled_win, {0, 1, 1, 3}, {GTK_FILL, GTK_FILL});
                }
                { // available tag list
-                       ui::Widget scrolled_win = ui::ScrolledWindow();
+                       ui::Widget scrolled_win = ui::ScrolledWindow(ui::New);
                        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 );
 
@@ -2164,39 +2154,39 @@ 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 );
 
-                       auto renderer = ui::CellRendererText();
+                       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 );
+                       gtk_tree_view_set_headers_visible(g_TextureBrowser.m_available_tree, FALSE );
 
-                       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
+                       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_available_tree );
                        gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
 
                        GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
-                       gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), column );
+                       gtk_tree_view_append_column(g_TextureBrowser.m_available_tree, column );
                        g_TextureBrowser.m_available_tree.show();
 
                        scrolled_win.show();
-                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) );
+                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_available_tree  );
 
-                       gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 2, 3, 1, 3, GTK_FILL, GTK_FILL, 0, 0 );
+                       frame_table.attach(scrolled_win, {2, 3, 1, 3}, {GTK_FILL, GTK_FILL});
                }
                { // tag arrow buttons
-                       auto m_btn_left = ui::Button();
-                       auto m_btn_right = ui::Button();
+                       auto m_btn_left = ui::Button(ui::New);
+                       auto m_btn_right = ui::Button(ui::New);
                        auto m_arrow_left = ui::Widget(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT ));
                        auto m_arrow_right = ui::Widget(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT ));
                        m_btn_left.add(m_arrow_left);
                        m_btn_right.add(m_arrow_right);
 
                        // workaround. the size of the tag frame depends of the requested size of the arrow buttons.
-                       gtk_widget_set_size_request( m_arrow_left, -1, 68 );
-                       gtk_widget_set_size_request( m_arrow_right, -1, 68 );
+                       m_arrow_left.dimensions(-1, 68);
+                       m_arrow_right.dimensions(-1, 68);
 
-                       gtk_table_attach( GTK_TABLE( frame_table ), m_btn_left, 1, 2, 1, 2, GTK_SHRINK, GTK_EXPAND, 0, 0 );
-                       gtk_table_attach( GTK_TABLE( frame_table ), m_btn_right, 1, 2, 2, 3, GTK_SHRINK, GTK_EXPAND, 0, 0 );
+                       frame_table.attach(m_btn_left, {1, 2, 1, 2}, {GTK_SHRINK, GTK_EXPAND});
+                       frame_table.attach(m_btn_right, {1, 2, 2, 3}, {GTK_SHRINK, GTK_EXPAND});
 
                        m_btn_left.connect( "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL );
                        m_btn_right.connect( "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL );
@@ -2210,15 +2200,15 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
                        ui::Widget m_lbl_assigned = ui::Label( "Assigned" );
                        ui::Widget m_lbl_unassigned = ui::Label( "Available" );
 
-                       gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_assigned, 0, 1, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 );
-                       gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_unassigned, 2, 3, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 );
+                       frame_table.attach(m_lbl_assigned, {0, 1, 0, 1}, {GTK_EXPAND, GTK_SHRINK});
+                       frame_table.attach(m_lbl_unassigned, {2, 3, 0, 1}, {GTK_EXPAND, GTK_SHRINK});
 
                        m_lbl_assigned.show();
                        m_lbl_unassigned.show();
                }
        }
        else { // no tag support, show the texture tree only
-               gtk_box_pack_start( GTK_BOX( vbox ), g_TextureBrowser.m_scr_win_tree, TRUE, TRUE, 0 );
+               vbox.pack_start( g_TextureBrowser.m_scr_win_tree, TRUE, TRUE, 0 );
        }
 
        // TODO do we need this?
@@ -2268,17 +2258,16 @@ void TextureBrowser_addTag(){
        EMessageBoxReturn result = DoShaderTagDlg( &tag, "Add shader tag" );
 
        if ( result == eIDOK && !tag.empty() ) {
-               GtkTreeIter iter, iter2;
+               GtkTreeIter iter;
                g_TextureBrowser.m_all_tags.insert( tag.c_str() );
                gtk_list_store_append( g_TextureBrowser.m_available_store, &iter );
                gtk_list_store_set( g_TextureBrowser.m_available_store, &iter, TAG_COLUMN, tag.c_str(), -1 );
 
                // Select the currently added tag in the available list
-               GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
+               GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_available_tree );
                gtk_tree_selection_select_iter( selection, &iter );
 
-               gtk_list_store_append( g_TextureBrowser.m_all_tags_list, &iter2 );
-               gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &iter2, TAG_COLUMN, tag.c_str(), -1 );
+               g_TextureBrowser.m_all_tags_list.append(TAG_COLUMN, tag.c_str());
        }
 }
 
@@ -2292,7 +2281,7 @@ void TextureBrowser_renameTag(){
 
        GSList* selected = NULL;
 
-       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
        gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected );
 
        if ( g_slist_length( selected ) == 1 ) { // we only rename a single tag
@@ -2304,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() );
@@ -2327,18 +2316,18 @@ void TextureBrowser_renameTag(){
        }
        else
        {
-               ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for renaming." );
+               g_TextureBrowser.m_parent.alert( "Select a single tag for renaming." );
        }
 }
 
 void TextureBrowser_deleteTag(){
        GSList* selected = NULL;
 
-       GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+       GtkTreeSelection* selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
        gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected );
 
        if ( g_slist_length( selected ) == 1 ) { // we only delete a single tag
-               auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question );
+               auto result = g_TextureBrowser.m_parent.alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question );
 
                if ( result == ui::alert_response::YES ) {
                        GtkTreeIter iterSelected;
@@ -2346,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 );
@@ -2367,7 +2356,7 @@ void TextureBrowser_deleteTag(){
                }
        }
        else {
-               ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for deletion." );
+               g_TextureBrowser.m_parent.alert( "Select a single tag for deletion." );
        }
 }
 
@@ -2419,7 +2408,7 @@ void TextureBrowser_RefreshShaders(){
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
        GlobalShaderSystem().refresh();
        UpdateAllWindows();
-       GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(GlobalTextureBrowser().m_treeViewTree));
+       GtkTreeSelection* selection = gtk_tree_view_get_selection(GlobalTextureBrowser().m_treeViewTree);
        GtkTreeModel* model = NULL;
        GtkTreeIter iter;
        if ( gtk_tree_selection_get_selected (selection, &model, &iter) )
@@ -2459,7 +2448,7 @@ void TextureBrowser_showAll(){
 }
 
 void TextureBrowser_showUntagged(){
-       auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning );
+       auto result = g_TextureBrowser.m_parent.alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning );
 
        if ( result == ui::alert_response::YES ) {
                g_TextureBrowser.m_found_shaders.clear();