Author Topic: I make a patch for portable CB, only for Win32  (Read 4413 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
I make a patch for portable CB, only for Win32
« on: March 20, 2010, 03:55:01 am »
Code
Index: src/src/app.cpp
===================================================================
--- src/src/app.cpp (revision 6193)
+++ src/src/app.cpp (working copy)
@@ -43,6 +43,10 @@
 
 #include <sqplus.h>
 
+#ifdef __WXMSW__
+#include "portable.h"
+#endif
+
 #ifndef __WXMSW__
     #include "prefix.h" // binreloc
 #endif
Index: src/src/portable.h
===================================================================
--- src/src/portable.h (revision 0)
+++ src/src/portable.h (revision 0)
@@ -0,0 +1,42 @@
+#ifndef QP_PORTABLE_H_
+#define QP_PORTABLE_H_
+
+namespace qp
+{
+
+class Portable
+{
+public:
+    Portable()
+    {
+        wxSetEnv(_T("APPDATA"), wxGetApp().GetAppPath() + _T("\\config"));
+        SupportTempFonts();
+    }
+
+    ~Portable()
+    {
+        SupportTempFonts(false);
+    }
+
+private:
+    void SupportTempFonts(bool enable = true)
+    {
+        wxString path = wxGetApp().GetAppPath() + _T("\\config\\fonts");
+        if (wxDir::Exists(path))
+        {
+            wxString font = wxFindFirstFile(path + _T("\\*.ttf"));
+            while (!font.IsEmpty())
+            {
+                if (enable) ::AddFontResource(font);
+                else ::RemoveFontResource(font);
+                font = wxFindNextFile();
+            }
+            ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
+        }
+    }
+};
+
+static Portable portable;
+
+} // namespace qp
+#endif // QP_PORTABLE_H_

[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: I make a patch for portable CB, only for Win32
« Reply #1 on: March 20, 2010, 06:18:46 am »
Code
Index: src/src/app.cpp
+        wxSetEnv(_T("APPDATA"), wxGetApp().GetAppPath() + _T("\\config"));
+        SupportTempFonts();
I am sorry, but I disagree on that one. Because modifying APPDATA has serious bad side effects. Like: Every tool you run from within C::B will save it's settings into the C::B folder, too. Sorry, but this is not acceptable. Code::Blocks is portable just fine I don't see a need to do this. Also the font handling can be done without modifying APPDATA.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ