(THIS IS A TRANSITIONAL REVISION, DO NOT USE, WAIT FOR UPDATED DEPS)
[xonotic/netradiant.git] / radiant / mainframe.cpp
index d0b9000..6af2cf8 100644 (file)
@@ -58,6 +58,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "cmdlib.h"
 #include "scenelib.h"
 #include "stream/stringstream.h"
+#include "signal/isignal.h"
 #include "os/path.h"
 #include "os/file.h"
 #include "eclasslib.h"
@@ -181,12 +182,11 @@ void VFS_Destroy()
     Radiant_detachHomePathsObserver(g_VFSModuleObserver);
 }
 
-
 // Home Paths
 
 void HomePaths_Realise()
 {
-#if defined (__linux__) || defined (__APPLE__)
+#if defined(POSIX)
   const char* prefix = g_pGameDescription->getKeyValue("prefix");
   if(!string_empty(prefix)) 
   {
@@ -339,6 +339,19 @@ const char* AppPath_get()
   return g_strAppPath.c_str();
 }
 
+/// the path to the local rc-dir
+const char* LocalRcPath_get(void)
+{
+  static CopiedString rc_path;
+  if(rc_path.empty())
+  {
+    StringOutputStream stream(256);
+       stream << GlobalRadiant().getSettingsPath() << g_pGameDescription->mGameFile.c_str() << "/";
+       rc_path = stream.c_str();
+  }
+  return rc_path.c_str();
+}
+
 /// directory for temp files
 /// NOTE: on *nix this is were we check for .pid
 CopiedString g_strSettingsPath;
@@ -510,10 +523,10 @@ public:
 const char* const c_library_extension =
 #if defined(WIN32)
 "dll"
-#elif defined(__linux__)
-"so"
 #elif defined (__APPLE__)
 "dylib"
+#elif defined(__linux__) || defined (__FreeBSD__)
+"so"
 #endif
 ;
 
@@ -907,8 +920,12 @@ GtkMenuItem* create_colours_menu()
 {
   GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic("Colors");
   GtkMenu* menu_in_menu = GTK_MENU(gtk_menu_item_get_submenu(colours_menu_item));
+  if (g_Layout_enableDetachableMenus.m_value)
+    menu_tearoff (menu_in_menu);
 
   GtkMenu* menu_3 = create_sub_menu_with_mnemonic(menu_in_menu, "Themes");
+  if (g_Layout_enableDetachableMenus.m_value)
+    menu_tearoff (menu_3);
 
   create_menu_item_with_mnemonic(menu_3, "QE4 Original", "ColorSchemeOriginal");
   create_menu_item_with_mnemonic(menu_3, "Q3Radiant Original", "ColorSchemeQER");
@@ -1047,15 +1064,18 @@ public:
   }
 };
 
-FreeCaller1<const BoolImportCallback&, BoolFunctionExport<EdgeMode>::apply> g_edgeMode_button_caller;
+typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
+EdgeModeApplyCaller g_edgeMode_button_caller;
 BoolExportCallback g_edgeMode_button_callback(g_edgeMode_button_caller);
 ToggleItem g_edgeMode_button(g_edgeMode_button_callback);
 
-FreeCaller1<const BoolImportCallback&, BoolFunctionExport<VertexMode>::apply> g_vertexMode_button_caller;
+typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
+VertexModeApplyCaller g_vertexMode_button_caller;
 BoolExportCallback g_vertexMode_button_callback(g_vertexMode_button_caller);
 ToggleItem g_vertexMode_button(g_vertexMode_button_callback);
 
-FreeCaller1<const BoolImportCallback&, BoolFunctionExport<FaceMode>::apply> g_faceMode_button_caller;
+typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
+FaceModeApplyCaller g_faceMode_button_caller;
 BoolExportCallback g_faceMode_button_callback(g_faceMode_button_caller);
 ToggleItem g_faceMode_button(g_faceMode_button_callback);
 
@@ -1964,8 +1984,12 @@ GtkMenuItem* create_edit_menu()
   menu_separator(menu);
   create_menu_item_with_mnemonic(menu, "C_lear Selection", "UnSelectSelection");
   create_menu_item_with_mnemonic(menu, "_Invert Selection", "InvertSelection");
+  create_menu_item_with_mnemonic(menu, "Select i_nside", "SelectInside");
+  create_menu_item_with_mnemonic(menu, "Select _touching", "SelectTouching");
 
   GtkMenu* convert_menu = create_sub_menu_with_mnemonic(menu, "E_xpand Selection");
+  if (g_Layout_enableDetachableMenus.m_value)
+    menu_tearoff (convert_menu);
   create_menu_item_with_mnemonic(convert_menu, "To Whole _Entities", "ExpandSelectionToEntities");
 
   menu_separator(menu);
@@ -2000,7 +2024,7 @@ GtkWidget* g_toggle_entitylist_item = 0;
 GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
 {
   // View menu
-  GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic("_View");
+  GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic("Vie_w");
   GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(view_menu_item));
   if (g_Layout_enableDetachableMenus.m_value)
     menu_tearoff (menu);
@@ -2015,7 +2039,7 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
   if(style == MainFrame::eFloating || style == MainFrame::eSplit)
   {
     create_menu_item_with_mnemonic(menu, "Console View", "ToggleConsole");
-    create_menu_item_with_mnemonic(menu, "Texture Browser", "ViewTextures");
+    create_menu_item_with_mnemonic(menu, "Texture Browser", "ToggleTextures");
     create_menu_item_with_mnemonic(menu, "Entity Inspector", "ToggleEntityInspector");
   }
   else
@@ -2028,6 +2052,8 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
   menu_separator(menu);
   {
     GtkMenu* camera_menu = create_sub_menu_with_mnemonic (menu, "Camera");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (camera_menu);
     create_menu_item_with_mnemonic(camera_menu, "_Center", "CenterView");
     create_menu_item_with_mnemonic(camera_menu, "_Up Floor", "UpFloor");
     create_menu_item_with_mnemonic(camera_menu, "_Down Floor", "DownFloor");
@@ -2044,6 +2070,8 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
   menu_separator(menu);
   {
     GtkMenu* orthographic_menu = create_sub_menu_with_mnemonic(menu, "Orthographic");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (orthographic_menu);
     if(style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating)
     {
       create_menu_item_with_mnemonic(orthographic_menu, "_Next (XY, YZ, XY)", "NextView");
@@ -2062,6 +2090,8 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
 
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Show");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     create_check_menu_item_with_mnemonic(menu_in_menu, "Show _Angles", "ShowAngles");
     create_check_menu_item_with_mnemonic(menu_in_menu, "Show _Names", "ShowNames");
     create_check_menu_item_with_mnemonic(menu_in_menu, "Show Blocks", "ShowBlocks");
@@ -2069,21 +2099,28 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
     create_check_menu_item_with_mnemonic(menu_in_menu, "Show Window Outline", "ShowWindowOutline");
     create_check_menu_item_with_mnemonic(menu_in_menu, "Show Axes", "ShowAxes");
     create_check_menu_item_with_mnemonic(menu_in_menu, "Show Workzone", "ShowWorkzone");
+    create_check_menu_item_with_mnemonic(menu_in_menu, "Show Stats", "ShowStats");
   }
 
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Filter");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     Filters_constructMenu(menu_in_menu);
   }
   menu_separator(menu);
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Hide/Show");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     create_menu_item_with_mnemonic(menu_in_menu, "Hide Selected", "HideSelected");
     create_menu_item_with_mnemonic(menu_in_menu, "Show Hidden", "ShowHidden");
   }
   menu_separator(menu);
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Region");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     create_menu_item_with_mnemonic(menu_in_menu, "_Off", "RegionOff");
     create_menu_item_with_mnemonic(menu_in_menu, "_Set XY", "RegionSetXY");
     create_menu_item_with_mnemonic(menu_in_menu, "Set _Brush", "RegionSetBrush");
@@ -2105,13 +2142,15 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
 GtkMenuItem* create_selection_menu()
 {
   // Selection menu
-  GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic("_Modify");
+  GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic("M_odify");
   GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(selection_menu_item));
   if (g_Layout_enableDetachableMenus.m_value)
     menu_tearoff (menu);
 
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Components");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     create_check_menu_item_with_mnemonic(menu_in_menu, "_Edges", "DragEdges");
     create_check_menu_item_with_mnemonic(menu_in_menu, "_Vertices", "DragVertices");
     create_check_menu_item_with_mnemonic(menu_in_menu, "_Faces", "DragFaces");
@@ -2121,6 +2160,8 @@ GtkMenuItem* create_selection_menu()
 
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic(menu, "Nudge");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     create_menu_item_with_mnemonic(menu_in_menu, "Nudge Left", "SelectNudgeLeft");
     create_menu_item_with_mnemonic(menu_in_menu, "Nudge Right", "SelectNudgeRight");
     create_menu_item_with_mnemonic(menu_in_menu, "Nudge Up", "SelectNudgeUp");
@@ -2128,12 +2169,16 @@ GtkMenuItem* create_selection_menu()
   }
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Rotate");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     create_menu_item_with_mnemonic(menu_in_menu, "Rotate X", "RotateSelectionX");
     create_menu_item_with_mnemonic(menu_in_menu, "Rotate Y", "RotateSelectionY");
     create_menu_item_with_mnemonic(menu_in_menu, "Rotate Z", "RotateSelectionZ");
   }
   {
     GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Flip");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_in_menu);
     create_menu_item_with_mnemonic(menu_in_menu, "Flip _X", "MirrorSelectionX");
     create_menu_item_with_mnemonic(menu_in_menu, "Flip _Y", "MirrorSelectionY");
     create_menu_item_with_mnemonic(menu_in_menu, "Flip _Z", "MirrorSelectionZ");
@@ -2180,44 +2225,6 @@ GtkMenuItem* create_grid_menu()
   return grid_menu_item;
 }
 
-void RefreshShaders()
-{
-  ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Loading Shaders");
-  GlobalShaderSystem().refresh();
-  UpdateAllWindows();
-}
-
-
-GtkMenuItem* create_textures_menu()
-{
-  // Textures menu
-  GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic("_Textures");
-  GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(textures_menu_item));
-  g_textures_menu = menu;
-  if (g_Layout_enableDetachableMenus.m_value)
-    menu_tearoff (menu);
-
-  create_check_menu_item_with_mnemonic(menu, "Hide _Unused", "ShowInUse");
-  create_menu_item_with_mnemonic(menu, "Show All", "ShowAllTextures");
-
-  menu_separator(menu);
-  create_check_menu_item_with_mnemonic(menu, "Show shaders", "ToggleShowShaders");
-  create_menu_item_with_mnemonic(menu, "Flush & Reload Shaders", "RefreshShaders");
-  create_menu_item_with_mnemonic(menu, "Directory list...", "TextureDirectoryList");
-  menu_separator(menu);
-
-  create_menu_item_with_mnemonic(menu, "Find / Replace...", "FindReplaceTextures");
-
-
-  menu_separator(menu);
-  create_check_menu_item_with_mnemonic (menu, "Shaders Only", "ToggleShowShaderlistOnly");
-  g_textures_menu_separator = menu_separator(menu);
-
-  TextureGroupsMenu_Construct();
-
-  return textures_menu_item;
-}
-
 GtkMenuItem* create_misc_menu()
 {
   // Misc menu
@@ -2312,7 +2319,6 @@ GtkMenuBar* create_main_menu(MainFrame::EViewStyle style)
   gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_selection_menu()));
   gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_bsp_menu()));
   gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_grid_menu()));
-  gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_textures_menu()));
   gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_misc_menu()));
   gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_entity_menu()));
   gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_brush_menu()));
@@ -2407,8 +2413,14 @@ void register_shortcuts()
 
 void File_constructToolbar(GtkToolbar* toolbar)
 {
-  toolbar_append_button(toolbar, "Open an existing map", "file_open.bmp", "OpenMap");
-  toolbar_append_button(toolbar, "Save the active map", "file_save.bmp", "SaveMap");
+  toolbar_append_button(toolbar, "Open an existing map (CTRL + O)", "file_open.bmp", "OpenMap");
+  toolbar_append_button(toolbar, "Save the active map (CTRL + S)", "file_save.bmp", "SaveMap");
+}
+
+void UndoRedo_constructToolbar(GtkToolbar* toolbar)
+{
+  toolbar_append_button(toolbar, "Undo (CTRL + Z)", "undo.bmp", "Undo");
+  toolbar_append_button(toolbar, "Redo (CTRL + Y)", "redo.bmp", "Redo");
 }
 
 void RotateFlip_constructToolbar(GtkToolbar* toolbar)
@@ -2421,24 +2433,30 @@ void RotateFlip_constructToolbar(GtkToolbar* toolbar)
   toolbar_append_button(toolbar, "z-axis Rotate", "brush_rotatez.bmp", "RotateSelectionZ");
 }
 
+void Select_constructToolbar(GtkToolbar* toolbar)
+{
+  toolbar_append_button(toolbar, "Select touching", "selection_selecttouching.bmp", "SelectTouching");
+  toolbar_append_button(toolbar, "Select inside", "selection_selectinside.bmp", "SelectInside");
+}
+
 void CSG_constructToolbar(GtkToolbar* toolbar)
 {
-  toolbar_append_button(toolbar, "CSG Subtract", "selection_csgsubtract.bmp", "CSGSubtract");
-  toolbar_append_button(toolbar, "CSG Merge", "selection_csgmerge.bmp", "CSGMerge");
+  toolbar_append_button(toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.bmp", "CSGSubtract");
+  toolbar_append_button(toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.bmp", "CSGMerge");
   toolbar_append_button(toolbar, "Hollow", "selection_makehollow.bmp", "CSGHollow");
 }
 
 void ComponentModes_constructToolbar(GtkToolbar* toolbar)
 {
-  toolbar_append_toggle_button(toolbar, "Select Vertices", "modify_vertices.bmp", "DragVertices");
-  toolbar_append_toggle_button(toolbar, "Select Edges", "modify_edges.bmp", "DragEdges");
-  toolbar_append_toggle_button(toolbar, "Select Faces", "modify_faces.bmp", "DragFaces");
+  toolbar_append_toggle_button(toolbar, "Select Vertices (V)", "modify_vertices.bmp", "DragVertices");
+  toolbar_append_toggle_button(toolbar, "Select Edges (E)", "modify_edges.bmp", "DragEdges");
+  toolbar_append_toggle_button(toolbar, "Select Faces (F)", "modify_faces.bmp", "DragFaces");
 }
 
 void Clipper_constructToolbar(GtkToolbar* toolbar)
 {
 
-  toolbar_append_toggle_button(toolbar, "Clipper", "view_clipper.bmp", "ToggleClipper");
+  toolbar_append_toggle_button(toolbar, "Clipper (X)", "view_clipper.bmp", "ToggleClipper");
 }
 
 void XYWnd_constructToolbar(GtkToolbar* toolbar)
@@ -2448,10 +2466,10 @@ void XYWnd_constructToolbar(GtkToolbar* toolbar)
 
 void Manipulators_constructToolbar(GtkToolbar* toolbar)
 {
-  toolbar_append_toggle_button(toolbar, "Translate", "select_mousetranslate.bmp", "MouseTranslate");
-  toolbar_append_toggle_button(toolbar, "Rotate", "select_mouserotate.bmp", "MouseRotate");
+  toolbar_append_toggle_button(toolbar, "Translate (W)", "select_mousetranslate.bmp", "MouseTranslate");
+  toolbar_append_toggle_button(toolbar, "Rotate (R)", "select_mouserotate.bmp", "MouseRotate");
   toolbar_append_toggle_button(toolbar, "Scale", "select_mousescale.bmp", "MouseScale");
-  toolbar_append_toggle_button(toolbar, "Resize", "select_mouseresize.bmp", "MouseDrag");
+  toolbar_append_toggle_button(toolbar, "Resize (Q)", "select_mouseresize.bmp", "MouseDrag");
 
   Clipper_constructToolbar(toolbar);
 }
@@ -2468,10 +2486,18 @@ GtkToolbar* create_main_toolbar(MainFrame::EViewStyle style)
 
   gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
 
+  UndoRedo_constructToolbar(toolbar);
+
+  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
   RotateFlip_constructToolbar(toolbar);
 
   gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
 
+  Select_constructToolbar(toolbar);
+
+  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
   CSG_constructToolbar(toolbar);
 
   gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
@@ -2502,7 +2528,26 @@ GtkToolbar* create_main_toolbar(MainFrame::EViewStyle style)
 
   gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
 
-  toolbar_append_toggle_button(toolbar, "Texture Lock", "texture_lock.bmp", "TogTexLock");
+  toolbar_append_toggle_button(toolbar, "Texture Lock (SHIFT +T)", "texture_lock.bmp", "TogTexLock");
+
+  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
+  GtkButton* g_view_entities_button = toolbar_append_button(toolbar, "Entities (N)", "entities.bmp", "ToggleEntityInspector");
+  GtkButton* g_view_console_button = toolbar_append_button(toolbar, "Console (O)", "console.bmp", "ToggleConsole");
+  GtkButton* g_view_textures_button = toolbar_append_button(toolbar, "Texture Browser (T)", "texture_browser.bmp", "ToggleTextures");
+  // TODO: call light inspector
+  //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.bmp", "ToggleLightInspector");
+
+  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+  GtkButton* g_refresh_models_button = toolbar_append_button(toolbar, "Refresh Models", "refresh_models.bmp", "RefreshReferences");
+
+
+  // disable the console and texture button in the regular layouts
+  if(style == MainFrame::eRegular || style == MainFrame::eRegularLeft)
+  {
+    gtk_widget_set_sensitive(GTK_WIDGET(g_view_console_button), FALSE);
+       gtk_widget_set_sensitive(GTK_WIDGET(g_view_textures_button), FALSE);
+  }
 
   return toolbar;
 }
@@ -2541,30 +2586,6 @@ GtkWidget* create_main_statusbar(GtkWidget *pStatusLabel[c_count_status])
 
 #if 0
 
-class WidgetFocusPrinter
-{
-  const char* m_name;
-
-  static gboolean focus_in(GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self)
-  {
-    globalOutputStream() << self->m_name << " takes focus\n";
-    return FALSE;
-  }
-  static gboolean focus_out(GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self)
-  {
-    globalOutputStream() << self->m_name << " loses focus\n";
-    return FALSE;
-  }
-public:
-  WidgetFocusPrinter(const char* name) : m_name(name)
-  {
-  }
-  void connect(GtkWindow* window)
-  {
-    g_signal_connect(G_OBJECT(window), "focus_in_event", G_CALLBACK(focus_in), this);
-    g_signal_connect(G_OBJECT(window), "focus_out_event", G_CALLBACK(focus_out), this);
-  }
-};
 
 WidgetFocusPrinter g_mainframeWidgetFocusPrinter("mainframe");
 
@@ -2631,6 +2652,26 @@ public:
 
 MainWindowActive g_MainWindowActive;
 
+SignalHandlerId XYWindowDestroyed_connect(const SignalHandler& handler)
+{
+  return g_pParentWnd->GetXYWnd()->onDestroyed.connectFirst(handler);
+}
+
+void XYWindowDestroyed_disconnect(SignalHandlerId id)
+{
+  g_pParentWnd->GetXYWnd()->onDestroyed.disconnect(id);
+}
+
+MouseEventHandlerId XYWindowMouseDown_connect(const MouseEventHandler& handler)
+{
+  return g_pParentWnd->GetXYWnd()->onMouseDown.connectFirst(handler);
+}
+
+void XYWindowMouseDown_disconnect(MouseEventHandlerId id)
+{
+  g_pParentWnd->GetXYWnd()->onMouseDown.disconnect(id);
+}
+
 // =============================================================================
 // MainFrame class
 
@@ -2849,7 +2890,7 @@ void MainFrame::Create()
 
 #if !defined(WIN32)
   {
-    GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask("icon.bmp");
+    GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask("bitmaps/icon.bmp");
     if(pixbuf != 0)
     {
       gtk_window_set_icon(window, pixbuf);
@@ -2981,7 +3022,6 @@ void MainFrame::Create()
           GtkFrame* texture_window = create_framed_widget(TextureBrowser_constructWindow(window));
 
           gtk_paned_add2(GTK_PANED(vsplit2), GTK_WIDGET(texture_window));
-         
         }
       }
     }
@@ -3165,8 +3205,6 @@ void MainFrame::Shutdown()
 
   EntityList_destroyWindow();
 
-  g_textures_menu = 0;
-
   delete m_pXYWnd;
   m_pXYWnd = 0;
   delete m_pYZWnd;
@@ -3359,6 +3397,8 @@ void MainFrame_Construct()
   GlobalCommands_insert("ParentSelection", FreeCaller<Scene_parentSelected>());
   GlobalCommands_insert("UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator(GDK_Escape));
   GlobalCommands_insert("InvertSelection", FreeCaller<Select_Invert>(), Accelerator('I'));
+  GlobalCommands_insert("SelectInside", FreeCaller<Select_Inside>());
+  GlobalCommands_insert("SelectTouching", FreeCaller<Select_Touching>());
   GlobalCommands_insert("ExpandSelectionToEntities", FreeCaller<Scene_ExpandSelectionToEntities>(), Accelerator('E', (GdkModifierType)(GDK_MOD1_MASK|GDK_CONTROL_MASK)));
   GlobalCommands_insert("Preferences", FreeCaller<PreferencesDialog_showDialog>(), Accelerator('P'));
 
@@ -3421,10 +3461,6 @@ void MainFrame_Construct()
   GlobalCommands_insert("CSGMerge", FreeCaller<CSG_Merge>(), Accelerator('U', (GdkModifierType)GDK_CONTROL_MASK));
   GlobalCommands_insert("CSGHollow", FreeCaller<CSG_MakeHollow>());
 
-  GlobalCommands_insert("TextureDirectoryList", FreeCaller<DoTextureListDlg>());
-
-  GlobalCommands_insert("RefreshShaders", FreeCaller<RefreshShaders>());
-
   Grid_registerCommands();
 
   GlobalCommands_insert("SnapToGrid", FreeCaller<Selection_SnapToGrid>(), Accelerator('G', (GdkModifierType)GDK_CONTROL_MASK));
@@ -3453,7 +3489,8 @@ void MainFrame_Construct()
   Patch_registerCommands();
   XYShow_registerCommands();
 
-  GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, ComponentMode_SelectionChanged>());
+  typedef FreeCaller1<const Selectable&, ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
+  GlobalSelectionSystem().addSelectionChangeCallback(ComponentModeSelectionChangedCaller());
 
   GlobalPreferenceSystem().registerPreference("DetachableMenus", BoolImportStringCaller(g_Layout_enableDetachableMenus.m_latched), BoolExportStringCaller(g_Layout_enableDetachableMenus.m_latched));
   GlobalPreferenceSystem().registerPreference("PatchToolBar", BoolImportStringCaller(g_Layout_enablePatchToolbar.m_latched), BoolExportStringCaller(g_Layout_enablePatchToolbar.m_latched));
@@ -3479,7 +3516,7 @@ void MainFrame_Construct()
     const char* ENGINEPATH_ATTRIBUTE =
 #if defined(WIN32)
       "enginepath_win32"
-#elif defined(__linux__)
+#elif defined(__linux__) || defined (__FreeBSD__)
       "enginepath_linux"
 #elif defined(__APPLE__)
       "enginepath_macos"