GTK: wrap gtk_widget_set_size_request
[xonotic/netradiant.git] / radiant / texwindow.cpp
index e306015..20c5bd9 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "texwindow.h"
 
+#include <gtk/gtk.h>
+
 #include "debugging/debugging.h"
 #include "warnings.h"
 
 #include <string>
 #include <vector>
 
-#include <gtk/gtk.h>
-#include <gtk/gtkrange.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkvscrollbar.h>
+#include <uilib/uilib.h>
 
 #include "signal/signal.h"
 #include "math/vector.h"
@@ -89,6 +86,9 @@
 #include "shaders.h"
 #include "commands.h"
 
+#define NOTEX_BASENAME "notex"
+#define SHADERNOTEX_BASENAME "shadernotex"
+
 bool TextureBrowser_showWads(){
        return !string_empty( g_pGameDescription->getKeyValue( "show_wads" ) );
 }
@@ -113,8 +113,53 @@ void TextureGroups_addWad( TextureGroups& groups, const char* archive ){
 }
 typedef ReferenceCaller1<TextureGroups, const char*, TextureGroups_addWad> TextureGroupsAddWadCaller;
 
+namespace
+{
+bool g_TextureBrowser_shaderlistOnly = false;
+bool g_TextureBrowser_fixedSize = true;
+bool g_TextureBrowser_filterMissing = false;
+bool g_TextureBrowser_filterFallback = true;
+bool g_TextureBrowser_enableAlpha = true;
+}
+
+CopiedString g_notex;
+CopiedString g_shadernotex;
+bool isMissing(const char* name);
+bool isNotex(const char* name);
+
+bool isMissing(const char* name){
+       if ( string_equal( g_notex.c_str(), name ) ) {
+               return true;
+       }
+       if ( string_equal( g_shadernotex.c_str(), name ) ) {
+               return true;
+       }
+       return false;
+}
+
+bool isNotex(const char* name){
+       if ( string_equal_suffix( name, "/" NOTEX_BASENAME ) ) {
+               return true;
+       }
+       if ( string_equal_suffix( name, "/" SHADERNOTEX_BASENAME ) ) {
+               return true;
+       }
+       return false;
+}
+
 void TextureGroups_addShader( TextureGroups& groups, const char* shaderName ){
        const char* texture = path_make_relative( shaderName, "textures/" );
+
+       // hide notex / shadernotex images
+       if ( g_TextureBrowser_filterFallback ) {
+               if ( isNotex( shaderName ) ) {
+                       return;
+               }
+               if ( isNotex( texture ) ) {
+                       return;
+               }
+       }
+
        if ( texture != shaderName ) {
                const char* last = path_remove_directory( texture );
                if ( !string_empty( last ) ) {
@@ -129,14 +174,6 @@ void TextureGroups_addDirectory( TextureGroups& groups, const char* directory ){
 }
 typedef ReferenceCaller1<TextureGroups, const char*, TextureGroups_addDirectory> TextureGroupsAddDirectoryCaller;
 
-namespace
-{
-bool g_TextureBrowser_shaderlistOnly = false;
-bool g_TextureBrowser_fixedSize = true;
-bool g_TextureBrowser_filterNotex = false;
-bool g_TextureBrowser_enableAlpha = true;
-}
-
 class DeferredAdjustment
 {
 gdouble m_value;
@@ -170,7 +207,7 @@ void value_changed( gdouble value ){
        }
 }
 static void adjustment_value_changed( GtkAdjustment *adjustment, DeferredAdjustment* self ){
-       self->value_changed( adjustment->value );
+       self->value_changed( gtk_adjustment_get_value(adjustment) );
 }
 };
 
@@ -201,8 +238,11 @@ typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShaderlistOnly
 void TextureBrowser_fixedSize( const BoolImportCallback& importer );
 typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_fixedSize> TextureBrowserFixedSizeExport;
 
-void TextureBrowser_filterNotex( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterNotex> TextureBrowserFilterNotexExport;
+void TextureBrowser_filterMissing( const BoolImportCallback& importer );
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterMissing> TextureBrowserFilterMissingExport;
+
+void TextureBrowser_filterFallback( const BoolImportCallback& importer );
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterFallback> TextureBrowserFilterFallbackExport;
 
 void TextureBrowser_enableAlpha( const BoolImportCallback& importer );
 typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
@@ -216,28 +256,29 @@ int m_nTotalHeight;
 
 CopiedString shader;
 
-GtkWindow* m_parent;
-GtkWidget* m_gl_widget;
-GtkWidget* m_texture_scroll;
-GtkWidget* m_treeViewTree;
-GtkWidget* m_treeViewTags;
-GtkWidget* m_tag_frame;
-GtkListStore* m_assigned_store;
-GtkListStore* m_available_store;
-GtkWidget* m_assigned_tree;
-GtkWidget* m_available_tree;
-GtkWidget* m_scr_win_tree;
-GtkWidget* m_scr_win_tags;
-GtkWidget* m_tag_notebook;
-GtkWidget* m_search_button;
-GtkWidget* m_shader_info_item;
+ui::Window m_parent{ui::null};
+ui::GLArea m_gl_widget{ui::null};
+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::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::null};
 
 std::set<CopiedString> m_all_tags;
-GtkListStore* m_all_tags_list;
+ui::ListStore m_all_tags_list{ui::null};
 std::vector<CopiedString> m_copied_tags;
 std::set<CopiedString> m_found_shaders;
 
 ToggleItem m_hideunused_item;
+ToggleItem m_hidenotex_item;
 ToggleItem m_showshaders_item;
 ToggleItem m_showshaderlistonly_item;
 ToggleItem m_fixedsize_item;
@@ -308,10 +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( TextureBrowserFilterNotexExport() ),
+       m_filternotex_item( TextureBrowserFilterMissingExport() ),
        m_enablealpha_item( TextureBrowserEnableAlphaExport() ),
        m_heightChanged( true ),
        m_originInvalid( true ),
@@ -463,14 +505,23 @@ bool TextureSearch_IsShown( const char* name ){
        }
 }
 
-CopiedString g_notex;
-CopiedString g_shadernotex;
-
 // if texture_showinuse jump over non in-use textures
 bool Texture_IsShown( IShader* shader, bool show_shaders, bool hideUnused ){
-       // filter notex / shadernotex images
-       if ( g_TextureBrowser_filterNotex && ( string_equal( g_notex.c_str(), shader->getTexture()->name ) || string_equal( g_shadernotex.c_str(), shader->getTexture()->name ) ) ) {
-               return false;
+       // filter missing shaders
+       // ugly: filter on built-in fallback name after substitution
+       if ( g_TextureBrowser_filterMissing ) {
+               if ( isMissing( shader->getTexture()->name ) ) {
+                       return false;
+               }
+       }
+       // filter the fallback (notex/shadernotex) for missing shaders or editor image
+       if ( g_TextureBrowser_filterFallback ) {
+               if ( isNotex( shader->getName() ) ) {
+                       return false;
+               }
+               if ( isNotex( shader->getTexture()->name ) ) {
+                       return false;
+               }
        }
 
        if ( g_TextureBrowser_currentDirectory == "Untagged" ) {
@@ -587,12 +638,15 @@ void TextureBrowser_addActiveShadersChangedCallback( const SignalHandler& handle
        g_activeShadersChangedCallbacks.connectLast( handler );
 }
 
+void TextureBrowser_constructTreeStore();
+
 class ShadersObserver : public ModuleObserver
 {
 Signal0 m_realiseCallbacks;
 public:
 void realise(){
        m_realiseCallbacks();
+       TextureBrowser_constructTreeStore();
 }
 void unrealise(){
 }
@@ -620,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 );
        }
 }
@@ -684,7 +738,7 @@ void visit( const char* name ){
 
 void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused );
 
-GtkWidget* g_page_textures;
+ui::Widget g_page_textures{ui::null};
 
 void TextureBrowser_toggleShow(){
        GroupDialog_showPage( g_page_textures );
@@ -829,10 +883,15 @@ void TextureBrowser_fixedSize( const BoolImportCallback& importer ){
 }
 typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_fixedSize> TextureBrowser_FixedSizeExport;
 
-void TextureBrowser_filterNotex( const BoolImportCallback& importer ){
-       importer( g_TextureBrowser_filterNotex );
+void TextureBrowser_filterMissing( const BoolImportCallback& importer ){
+       importer( g_TextureBrowser_filterMissing );
+}
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterMissing> TextureBrowser_filterMissingExport;
+
+void TextureBrowser_filterFallback( const BoolImportCallback& importer ){
+       importer( g_TextureBrowser_filterFallback );
 }
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterNotex> TextureBrowser_filterNotexExport;
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterFallback> TextureBrowser_filterFallbackExport;
 
 void TextureBrowser_enableAlpha( const BoolImportCallback& importer ){
        importer( g_TextureBrowser_enableAlpha );
@@ -1196,7 +1255,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
 }
 
 void TextureBrowser_queueDraw( TextureBrowser& textureBrowser ){
-       if ( textureBrowser.m_gl_widget != 0 ) {
+       if ( textureBrowser.m_gl_widget ) {
                gtk_widget_queue_draw( textureBrowser.m_gl_widget );
        }
 }
@@ -1237,23 +1296,22 @@ 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 );
+       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());
        }
 }
 
-void BuildStoreAvailableTags(   GtkListStore* storeAvailable,
-                                                               GtkListStore* storeAssigned,
+void BuildStoreAvailableTags(   ui::ListStore storeAvailable,
+                                                               ui::ListStore storeAssigned,
                                                                const std::set<CopiedString>& allTags,
                                                                TextureBrowser* textureBrowser ){
        GtkTreeIter iterAssigned;
@@ -1261,35 +1319,33 @@ void BuildStoreAvailableTags(   GtkListStore* 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 );
                                        }
                                }
                        }
@@ -1297,7 +1353,7 @@ void BuildStoreAvailableTags(   GtkListStore* storeAvailable,
        }
 }
 
-gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
        if ( event->type == GDK_BUTTON_PRESS ) {
                if ( event->button == 3 ) {
                        if ( GlobalTextureBrowser().m_tags ) {
@@ -1307,9 +1363,9 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event,
                                BuildStoreAssignedTags( textureBrowser->m_assigned_store, textureBrowser->shader.c_str(), textureBrowser );
                                BuildStoreAvailableTags( textureBrowser->m_available_store, textureBrowser->m_assigned_store, textureBrowser->m_all_tags, textureBrowser );
                                textureBrowser->m_heightChanged = true;
-                               gtk_widget_show( textureBrowser->m_tag_frame );
+                               textureBrowser->m_tag_frame.show();
 
-                               process_gui();
+                ui::process();
 
                                TextureBrowser_Focus( *textureBrowser, textureBrowser->shader.c_str() );
                        }
@@ -1323,14 +1379,14 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event,
 
                        if ( GlobalTextureBrowser().m_tags ) {
                                textureBrowser->m_rmbSelected = false;
-                               gtk_widget_hide( textureBrowser->m_tag_frame );
+                               textureBrowser->m_tag_frame.hide();
                        }
                }
        }
        return FALSE;
 }
 
-gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_button_release( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
        if ( event->type == GDK_BUTTON_RELEASE ) {
                if ( event->button == 3 ) {
                        if ( !GlobalTextureBrowser().m_tags ) {
@@ -1341,11 +1397,11 @@ gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event
        return FALSE;
 }
 
-gboolean TextureBrowser_motion( GtkWidget *widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_motion( ui::Widget widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){
        return FALSE;
 }
 
-gboolean TextureBrowser_scroll( GtkWidget* widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_scroll( ui::Widget widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){
        if ( event->direction == GDK_SCROLL_UP ) {
                TextureBrowser_MouseWheel( *textureBrowser, true );
        }
@@ -1361,7 +1417,7 @@ void TextureBrowser_scrollChanged( void* data, gdouble value ){
 }
 
 static void TextureBrowser_verticalScroll( GtkAdjustment *adjustment, TextureBrowser* textureBrowser ){
-       textureBrowser->m_scrollAdjustment.value_changed( adjustment->value );
+       textureBrowser->m_scrollAdjustment.value_changed( gtk_adjustment_get_value(adjustment) );
 }
 
 void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){
@@ -1372,18 +1428,18 @@ void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){
 
                GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( textureBrowser.m_texture_scroll ) );
 
-               vadjustment->value = -TextureBrowser_getOriginY( textureBrowser );
-               vadjustment->page_size = textureBrowser.height;
-               vadjustment->page_increment = textureBrowser.height / 2;
-               vadjustment->step_increment = 20;
-               vadjustment->lower = 0;
-               vadjustment->upper = totalHeight;
+               gtk_adjustment_set_value(vadjustment, -TextureBrowser_getOriginY( textureBrowser ));
+               gtk_adjustment_set_page_size(vadjustment, textureBrowser.height);
+               gtk_adjustment_set_page_increment(vadjustment, textureBrowser.height / 2);
+               gtk_adjustment_set_step_increment(vadjustment, 20);
+               gtk_adjustment_set_lower(vadjustment, 0);
+               gtk_adjustment_set_upper(vadjustment, totalHeight);
 
                g_signal_emit_by_name( G_OBJECT( vadjustment ), "changed" );
        }
 }
 
-gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_size_allocate( ui::Widget widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){
        textureBrowser->width = allocation->width;
        textureBrowser->height = allocation->height;
        TextureBrowser_heightChanged( *textureBrowser );
@@ -1392,7 +1448,7 @@ gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocat
        return FALSE;
 }
 
-gboolean TextureBrowser_expose( GtkWidget* widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){
        if ( glwidget_make_current( textureBrowser->m_gl_widget ) != FALSE ) {
                GlobalOpenGL_debugAssertNoErrors();
                TextureBrowser_evaluateHeight( *textureBrowser );
@@ -1424,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;
 
@@ -1481,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 ) );
 }
@@ -1505,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];
@@ -1528,15 +1581,14 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV
 }
 
 void TextureBrowser_createTreeViewTree(){
-       GtkCellRenderer* renderer;
-       g_TextureBrowser.m_treeViewTree = GTK_WIDGET( gtk_tree_view_new() );
-       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 );
-       g_signal_connect( g_TextureBrowser.m_treeViewTree, "row-activated", (GCallback) TreeView_onRowActivated, NULL );
+       gtk_tree_view_set_headers_visible(g_TextureBrowser.m_treeViewTree, FALSE );
+       g_TextureBrowser.m_treeViewTree.connect( "row-activated", (GCallback) TreeView_onRowActivated, NULL );
 
-       renderer = gtk_cell_renderer_text_new();
-       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();
 }
@@ -1545,19 +1597,19 @@ void TextureBrowser_addTag();
 void TextureBrowser_renameTag();
 void TextureBrowser_deleteTag();
 
-void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *event ){
-       GtkWidget* menu = gtk_menu_new();
+void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){
+       ui::Widget menu = ui::Menu(ui::New);
 
-       GtkWidget* menuitem = gtk_menu_item_new_with_label( "Add tag" );
-       g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_addTag, treeview );
+       ui::Widget menuitem = ui::MenuItem( "Add tag" );
+       menuitem.connect( "activate", (GCallback)TextureBrowser_addTag, treeview );
        gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem );
 
-       menuitem = gtk_menu_item_new_with_label( "Rename tag" );
-       g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_renameTag, treeview );
+       menuitem = ui::MenuItem( "Rename tag" );
+       menuitem.connect( "activate", (GCallback)TextureBrowser_renameTag, treeview );
        gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem );
 
-       menuitem = gtk_menu_item_new_with_label( "Delete tag" );
-       g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_deleteTag, treeview );
+       menuitem = ui::MenuItem( "Delete tag" );
+       menuitem.connect( "activate", (GCallback)TextureBrowser_deleteTag, treeview );
        gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem );
 
        gtk_widget_show_all( menu );
@@ -1567,12 +1619,12 @@ void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *even
                                        gdk_event_get_time( (GdkEvent*)event ) );
 }
 
-gboolean TreeViewTags_onButtonPressed( GtkWidget *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 );
@@ -1585,22 +1637,21 @@ gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *even
 }
 
 void TextureBrowser_createTreeViewTags(){
-       GtkCellRenderer* renderer;
-       g_TextureBrowser.m_treeViewTags = GTK_WIDGET( gtk_tree_view_new() );
-       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_signal_connect( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL );
+       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 );
 
-       renderer = gtk_cell_renderer_text_new();
-       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();
 }
 
-GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){
-       GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_View" );
+ui::MenuItem TextureBrowser_constructViewMenu( ui::Menu menu ){
+       ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_View" ));
 
        if ( g_Layout_enableDetachableMenus.m_value ) {
                menu_tearoff( menu );
@@ -1608,8 +1659,12 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){
 
        create_check_menu_item_with_mnemonic( menu, "Hide _Unused", "ShowInUse" );
        if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) {
-               create_check_menu_item_with_mnemonic( menu, "Hide Image Missing", "FilterNotex" );
+               create_check_menu_item_with_mnemonic( menu, "Hide Image Missing", "FilterMissing" );
        }
+
+       // hide notex and shadernotex on texture browser: no one wants to apply them
+       create_check_menu_item_with_mnemonic( menu, "Hide Fallback", "FilterFallback" );
+
        menu_separator( menu );
 
        create_menu_item_with_mnemonic( menu, "Show All", "ShowAllTextures" );
@@ -1636,7 +1691,7 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){
 
        if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) {
                menu_separator( menu );
-               g_TextureBrowser.m_shader_info_item = 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 );
        }
 
@@ -1644,8 +1699,8 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){
        return textures_menu_item;
 }
 
-GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){
-       GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_Tools" );
+ui::MenuItem TextureBrowser_constructToolsMenu( ui::Menu menu ){
+       ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" ));
 
        if ( g_Layout_enableDetachableMenus.m_value ) {
                menu_tearoff( menu );
@@ -1657,8 +1712,8 @@ GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){
        return textures_menu_item;
 }
 
-GtkMenuItem* TextureBrowser_constructTagsMenu( GtkMenu* menu ){
-       GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "T_ags" );
+ui::MenuItem TextureBrowser_constructTagsMenu( ui::Menu menu ){
+       ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "T_ags" ));
 
        if ( g_Layout_enableDetachableMenus.m_value ) {
                menu_tearoff( menu );
@@ -1688,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 );
 
@@ -1700,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() );
@@ -1720,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);
                                }
                        }
                }
@@ -1739,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 );
 
@@ -1751,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 );
                                }
@@ -1771,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());
        }
 }
 
@@ -1790,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 );
 
@@ -1805,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 );
@@ -1860,31 +1912,29 @@ void TextureBrowser_toggleSearchButton(){
                gtk_widget_show_all( g_TextureBrowser.m_search_button );
        }
        else {
-               gtk_widget_hide_all( g_TextureBrowser.m_search_button );
+               g_TextureBrowser.m_search_button.hide();
        }
 }
 
 void TextureBrowser_constructTagNotebook(){
-       g_TextureBrowser.m_tag_notebook = gtk_notebook_new();
-       GtkWidget* labelTags = gtk_label_new( "Tags" );
-       GtkWidget* labelTextures = gtk_label_new( "Textures" );
+       g_TextureBrowser.m_tag_notebook = ui::Widget(gtk_notebook_new());
+       ui::Widget labelTags = ui::Label( "Tags" );
+       ui::Widget labelTextures = ui::Label( "Textures" );
 
        gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tree, labelTextures );
        gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tags, labelTags );
 
-       g_signal_connect( G_OBJECT( g_TextureBrowser.m_tag_notebook ), "switch-page", G_CALLBACK( TextureBrowser_toggleSearchButton ), NULL );
+       g_TextureBrowser.m_tag_notebook.connect( "switch-page", G_CALLBACK( TextureBrowser_toggleSearchButton ), NULL );
 
        gtk_widget_show_all( g_TextureBrowser.m_tag_notebook );
 }
 
 void TextureBrowser_constructSearchButton(){
-       GtkTooltips* tooltips = gtk_tooltips_new();
-
-       GtkWidget* image = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR );
-       g_TextureBrowser.m_search_button = gtk_button_new();
-       g_signal_connect( G_OBJECT( g_TextureBrowser.m_search_button ), "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL );
-       gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), g_TextureBrowser.m_search_button, "Search with selected tags", "Search with selected tags" );
-       gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_search_button ), image );
+       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(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);
 }
 
 void TextureBrowser_checkTagFile(){
@@ -1927,15 +1977,15 @@ void TextureBrowser_checkTagFile(){
 
 void TextureBrowser_SetNotex(){
        StringOutputStream name( 256 );
-       name << GlobalRadiant().getAppPath() << "bitmaps/notex.bmp";
+       name << GlobalRadiant().getAppPath() << "bitmaps/" NOTEX_BASENAME ".png";
        g_notex = name.c_str();
 
-       name = NULL;
-       name << GlobalRadiant().getAppPath() << "bitmaps/shadernotex.bmp";
+       name = StringOutputStream(256);
+       name << GlobalRadiant().getAppPath() << "bitmaps/" SHADERNOTEX_BASENAME " .png";
        g_shadernotex = name.c_str();
 }
 
-GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
+ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
        // The gl_widget and the tag assignment frame should be packed into a GtkVPaned with the slider
        // position stored in local.pref. gtk_paned_get_position() and gtk_paned_set_position() don't
        // seem to work in gtk 2.4 and the arrow buttons don't handle GTK_FILL, so here's another thing
@@ -1948,77 +1998,76 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
 
        g_TextureBrowser.m_parent = toplevel;
 
-       GtkWidget* table = gtk_table_new( 3, 3, FALSE );
-       GtkWidget* frame_table = NULL;
-       GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
-       gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 );
-       gtk_widget_show( vbox );
+       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();
 
-       GtkWidget* menu_bar;
+       ui::Widget menu_bar{ui::null};
 
        { // menu bar
-               menu_bar = gtk_menu_bar_new();
-               GtkWidget* menu_view = gtk_menu_new();
-               GtkWidget* view_item = (GtkWidget*)TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) );
+               menu_bar = ui::Widget(gtk_menu_bar_new());
+               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_bar_append( GTK_MENU_BAR( menu_bar ), view_item );
+               gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item );
 
-               GtkWidget* menu_tools = gtk_menu_new();
-               GtkWidget* tools_item = (GtkWidget*)TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) );
+               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_bar_append( GTK_MENU_BAR( menu_bar ), tools_item );
+               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 );
-               gtk_widget_show( menu_bar );
+               table.attach(menu_bar, {0, 3, 0, 1}, {GTK_FILL, GTK_SHRINK});
+               menu_bar.show();
        }
        { // Texture TreeView
-               g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL );
+               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
                gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
 
-               gtk_widget_show( g_TextureBrowser.m_scr_win_tree );
+               g_TextureBrowser.m_scr_win_tree.show();
 
                TextureBrowser_createTreeViewTree();
 
-               gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) );
-               gtk_widget_show( 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
-               GtkWidget* w = gtk_vscrollbar_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,0,1,1,0 ) ) );
-               gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 1, 2, GTK_SHRINK, GTK_FILL, 0, 0 );
-               gtk_widget_show( w );
+               ui::Widget w = ui::Widget(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) ));
+               table.attach(w, {2, 3, 1, 2}, {GTK_SHRINK, GTK_FILL});
+               w.show();
                g_TextureBrowser.m_texture_scroll = w;
 
-               GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) );
-               g_signal_connect( G_OBJECT( vadjustment ), "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser );
+               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 );
-               gtk_widget_ref( g_TextureBrowser.m_gl_widget );
+               g_object_ref( g_TextureBrowser.m_gl_widget._handle );
 
                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_FLAGS( g_TextureBrowser.m_gl_widget, GTK_CAN_FOCUS );
+               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 );
-               gtk_widget_show( g_TextureBrowser.m_gl_widget );
+               table.attach(g_TextureBrowser.m_gl_widget, {1, 2, 1, 2});
+               g_TextureBrowser.m_gl_widget.show();
 
-               g_TextureBrowser.m_sizeHandler = g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "size_allocate", G_CALLBACK( TextureBrowser_size_allocate ), &g_TextureBrowser );
-               g_TextureBrowser.m_exposeHandler = g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "expose_event", G_CALLBACK( TextureBrowser_expose ), &g_TextureBrowser );
+               g_TextureBrowser.m_sizeHandler = g_TextureBrowser.m_gl_widget.connect( "size_allocate", G_CALLBACK( TextureBrowser_size_allocate ), &g_TextureBrowser );
+               g_TextureBrowser.m_exposeHandler = g_TextureBrowser.m_gl_widget.on_render( G_CALLBACK( TextureBrowser_expose ), &g_TextureBrowser );
 
-               g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "button_press_event", G_CALLBACK( TextureBrowser_button_press ), &g_TextureBrowser );
-               g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "button_release_event", G_CALLBACK( TextureBrowser_button_release ), &g_TextureBrowser );
-               g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "motion_notify_event", G_CALLBACK( TextureBrowser_motion ), &g_TextureBrowser );
-               g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "scroll_event", G_CALLBACK( TextureBrowser_scroll ), &g_TextureBrowser );
+               g_TextureBrowser.m_gl_widget.connect( "button_press_event", G_CALLBACK( TextureBrowser_button_press ), &g_TextureBrowser );
+               g_TextureBrowser.m_gl_widget.connect( "button_release_event", G_CALLBACK( TextureBrowser_button_release ), &g_TextureBrowser );
+               g_TextureBrowser.m_gl_widget.connect( "motion_notify_event", G_CALLBACK( TextureBrowser_motion ), &g_TextureBrowser );
+               g_TextureBrowser.m_gl_widget.connect( "scroll_event", G_CALLBACK( TextureBrowser_scroll ), &g_TextureBrowser );
        }
 
        // 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 );
 
@@ -2026,13 +2075,13 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
                        TextureBrowser_buildTagList();
                }
                { // tag menu bar
-                       GtkWidget* menu_tags = gtk_menu_new();
-                       GtkWidget* tags_item = (GtkWidget*)TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) );
+                       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_bar_append( GTK_MENU_BAR( menu_bar ), tags_item );
+                       gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item );
                }
                { // Tag TreeView
-                       g_TextureBrowser.m_scr_win_tags = gtk_scrolled_window_new( NULL, NULL );
+                       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
@@ -2040,126 +2089,126 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* 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_widget_show( 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 = gtk_table_new( 3, 3, FALSE );
 
-                       g_TextureBrowser.m_tag_frame = gtk_frame_new( "Tag assignment" );
+                       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});
 
-                       gtk_widget_show( frame_table );
+                       frame_table.show();
 
-                       gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_tag_frame ), frame_table );
+                       g_TextureBrowser.m_tag_frame.add(frame_table);
                }
                { // assigned tag list
-                       GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL );
+                       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 );
 
-                       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 );
 
-                       GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+                       auto renderer = ui::CellRendererText(ui::New);
 
-                       g_TextureBrowser.m_assigned_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) );
-                       g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) );
-                       g_signal_connect( g_TextureBrowser.m_assigned_tree, "row-activated", (GCallback) TextureBrowser_removeTags, NULL );
-                       gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE );
+                       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(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 = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL );
-                       gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), column );
-                       gtk_widget_show( g_TextureBrowser.m_assigned_tree );
+                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
+                       gtk_tree_view_append_column(g_TextureBrowser.m_assigned_tree, column );
+                       g_TextureBrowser.m_assigned_tree.show();
 
-                       gtk_widget_show( scrolled_win );
-                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_assigned_tree ) );
+                       scrolled_win.show();
+                       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
-                       GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL );
+                       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 );
 
-                       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 );
 
-                       GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+                       auto renderer = ui::CellRendererText(ui::New);
 
-                       g_TextureBrowser.m_available_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) );
-                       g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) );
-                       g_signal_connect( g_TextureBrowser.m_available_tree, "row-activated", (GCallback) TextureBrowser_assignTags, NULL );
-                       gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE );
+                       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(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 = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL );
-                       gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), column );
-                       gtk_widget_show( g_TextureBrowser.m_available_tree );
+                       GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
+                       gtk_tree_view_append_column(g_TextureBrowser.m_available_tree, column );
+                       g_TextureBrowser.m_available_tree.show();
 
-                       gtk_widget_show( scrolled_win );
-                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) );
+                       scrolled_win.show();
+                       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
-                       GtkWidget* m_btn_left = gtk_button_new();
-                       GtkWidget* m_btn_right = gtk_button_new();
-                       GtkWidget* m_arrow_left = gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT );
-                       GtkWidget* m_arrow_right = gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT );
-                       gtk_container_add( GTK_CONTAINER( m_btn_left ), m_arrow_left );
-                       gtk_container_add( GTK_CONTAINER( m_btn_right ), m_arrow_right );
+                       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});
 
-                       g_signal_connect( G_OBJECT( m_btn_left ), "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL );
-                       g_signal_connect( G_OBJECT( m_btn_right ), "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL );
+                       m_btn_left.connect( "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL );
+                       m_btn_right.connect( "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL );
 
-                       gtk_widget_show( m_btn_left );
-                       gtk_widget_show( m_btn_right );
-                       gtk_widget_show( m_arrow_left );
-                       gtk_widget_show( m_arrow_right );
+                       m_btn_left.show();
+                       m_btn_right.show();
+                       m_arrow_left.show();
+                       m_arrow_right.show();
                }
                { // tag fram labels
-                       GtkWidget* m_lbl_assigned = gtk_label_new( "Assigned" );
-                       GtkWidget* m_lbl_unassigned = gtk_label_new( "Available" );
+                       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});
 
-                       gtk_widget_show( m_lbl_assigned );
-                       gtk_widget_show( m_lbl_unassigned );
+                       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?
@@ -2174,7 +2223,7 @@ void TextureBrowser_destroyWindow(){
        g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_sizeHandler );
        g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_exposeHandler );
 
-       gtk_widget_unref( g_TextureBrowser.m_gl_widget );
+       g_TextureBrowser.m_gl_widget.unref();
 }
 
 const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser ){
@@ -2209,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());
        }
 }
 
@@ -2233,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
@@ -2245,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() );
@@ -2268,36 +2316,36 @@ void TextureBrowser_renameTag(){
        }
        else
        {
-               gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "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
-               EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Are you sure you want to delete the selected tag?", "Delete Tag", eMB_YESNO, eMB_ICONQUESTION );
+               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 == eIDYES ) {
+               if ( result == ui::alert_response::YES ) {
                        GtkTreeIter iterSelected;
                        gchar *rowTag;
 
                        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 );
@@ -2308,7 +2356,7 @@ void TextureBrowser_deleteTag(){
                }
        }
        else {
-               gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for deletion." );
+               g_TextureBrowser.m_parent.alert( "Select a single tag for deletion." );
        }
 }
 
@@ -2356,11 +2404,11 @@ void TextureBrowser_pasteTag(){
        BuildStoreAvailableTags( g_TextureBrowser.m_available_store, g_TextureBrowser.m_assigned_store, g_TextureBrowser.m_all_tags, &g_TextureBrowser );
 }
 
-void RefreshShaders(){
+void TextureBrowser_RefreshShaders(){
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
        GlobalShaderSystem().refresh();
        UpdateAllWindows();
-       GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)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) )
@@ -2400,9 +2448,9 @@ void TextureBrowser_showAll(){
 }
 
 void TextureBrowser_showUntagged(){
-       EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", eMB_YESNO, eMB_ICONWARNING );
+       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 == eIDYES ) {
+       if ( result == ui::alert_response::YES ) {
                g_TextureBrowser.m_found_shaders.clear();
                TagBuilder.GetUntagged( g_TextureBrowser.m_found_shaders );
                std::set<CopiedString>::iterator iter;
@@ -2432,10 +2480,18 @@ void TextureBrowser_FixedSize(){
        TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
 }
 
-void TextureBrowser_FilterNotex(){
-       g_TextureBrowser_filterNotex ^= 1;
+void TextureBrowser_FilterMissing(){
+       g_TextureBrowser_filterMissing ^= 1;
        GlobalTextureBrowser().m_filternotex_item.update();
        TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
+       TextureBrowser_RefreshShaders();
+}
+
+void TextureBrowser_FilterFallback(){
+       g_TextureBrowser_filterFallback ^= 1;
+       GlobalTextureBrowser().m_hidenotex_item.update();
+       TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
+       TextureBrowser_RefreshShaders();
 }
 
 void TextureBrowser_EnableAlpha(){
@@ -2563,14 +2619,15 @@ void TextureBrowser_Construct(){
        GlobalCommands_insert( "DeleteTag", FreeCaller<TextureBrowser_deleteTag>() );
        GlobalCommands_insert( "CopyTag", FreeCaller<TextureBrowser_copyTag>() );
        GlobalCommands_insert( "PasteTag", FreeCaller<TextureBrowser_pasteTag>() );
-       GlobalCommands_insert( "RefreshShaders", FreeCaller<RefreshShaders>() );
+       GlobalCommands_insert( "RefreshShaders", FreeCaller<VFS_Refresh>() );
        GlobalToggles_insert( "ShowInUse", FreeCaller<TextureBrowser_ToggleHideUnused>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) );
        GlobalCommands_insert( "ShowAllTextures", FreeCaller<TextureBrowser_showAll>(), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "ToggleTextures", FreeCaller<TextureBrowser_toggleShow>(), Accelerator( 'T' ) );
        GlobalToggles_insert( "ToggleShowShaders", FreeCaller<TextureBrowser_ToggleShowShaders>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaders_item ) );
        GlobalToggles_insert( "ToggleShowShaderlistOnly", FreeCaller<TextureBrowser_ToggleShowShaderListOnly>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaderlistonly_item ) );
        GlobalToggles_insert( "FixedSize", FreeCaller<TextureBrowser_FixedSize>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_fixedsize_item ) );
-       GlobalToggles_insert( "FilterNotex", FreeCaller<TextureBrowser_FilterNotex>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) );
+       GlobalToggles_insert( "FilterMissing", FreeCaller<TextureBrowser_FilterMissing>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) );
+       GlobalToggles_insert( "FilterFallback", FreeCaller<TextureBrowser_FilterFallback>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hidenotex_item ) );
        GlobalToggles_insert( "EnableAlpha", FreeCaller<TextureBrowser_EnableAlpha>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_enablealpha_item ) );
 
        GlobalPreferenceSystem().registerPreference( "TextureScale",
@@ -2587,7 +2644,7 @@ void TextureBrowser_Construct(){
        GlobalPreferenceSystem().registerPreference( "ShowShaders", BoolImportStringCaller( GlobalTextureBrowser().m_showShaders ), BoolExportStringCaller( GlobalTextureBrowser().m_showShaders ) );
        GlobalPreferenceSystem().registerPreference( "ShowShaderlistOnly", BoolImportStringCaller( g_TextureBrowser_shaderlistOnly ), BoolExportStringCaller( g_TextureBrowser_shaderlistOnly ) );
        GlobalPreferenceSystem().registerPreference( "FixedSize", BoolImportStringCaller( g_TextureBrowser_fixedSize ), BoolExportStringCaller( g_TextureBrowser_fixedSize ) );
-       GlobalPreferenceSystem().registerPreference( "FilterNotex", BoolImportStringCaller( g_TextureBrowser_filterNotex ), BoolExportStringCaller( g_TextureBrowser_filterNotex ) );
+       GlobalPreferenceSystem().registerPreference( "FilterMissing", BoolImportStringCaller( g_TextureBrowser_filterMissing ), BoolExportStringCaller( g_TextureBrowser_filterMissing ) );
        GlobalPreferenceSystem().registerPreference( "EnableAlpha", BoolImportStringCaller( g_TextureBrowser_enableAlpha ), BoolExportStringCaller( g_TextureBrowser_enableAlpha ) );
        GlobalPreferenceSystem().registerPreference( "LoadShaders", IntImportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ), IntExportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
        GlobalPreferenceSystem().registerPreference( "WheelMouseInc", SizeImportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ), SizeExportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );