News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

I make a patch for portable CB, only for Win32

Started by Loaden, March 20, 2010, 03:55:01 AM

Previous topic - Next topic

Loaden

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]

MortenMacFly

Quote from: Loaden on March 20, 2010, 03:55:01 AM
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]