Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: jmccay on February 23, 2007, 06:53:57 pm

Title: personalities
Post by: jmccay on February 23, 2007, 06:53:57 pm
I tried the tests explained in the wiki documentation for personalities.  I created the '--personality="Lite"' as described in the instructions.  Then I crated another desktop shortcut with --personality="ask".  After running the lite version, I ran the ask version.  The were no personalities listed.  Did I do something wrong?  Also, is there a way to edit these from the menu?
jmccay
Title: Re: personalities
Post by: stahta01 on February 23, 2007, 08:12:26 pm
No, you did it right. I am trying to find why the code is not looking in the right folder to find the .conf files. I just have not had the time to determine where the code is wrong.

Tim S
Title: Re: personalities
Post by: stahta01 on February 23, 2007, 10:34:58 pm
Partial untested patch. Tim S
I ran it once and it gave me a list of configs, but picking one did not seem to work.

Code
Index: src/sdk/personalitymanager.cpp
===================================================================
--- src/sdk/personalitymanager.cpp (revision 3635)
+++ src/sdk/personalitymanager.cpp (working copy)
@@ -55,7 +55,7 @@
 const wxArrayString PersonalityManager::GetPersonalitiesList()
 {
  wxArrayString list;
- wxDir::GetAllFiles(ConfigManager::GetConfigFolder(), &list, _T("*.conf"), wxDIR_FILES);
+ wxDir::GetAllFiles(ConfigManager::GetFolder(sdConfig), &list, _T("*.conf"), wxDIR_FILES);
 
  for(size_t i = 0; i < list.GetCount(); ++i)
         list[i] = wxFileName(list[i]).GetName();
Title: Re: personalities
Post by: stahta01 on February 24, 2007, 12:56:37 am
I am giving up for tonight may or may not try tomorrow, the problem is it is being set to default before the selected config can be set and it never looks for the set config that I can find.

Edit: Thought of something else to try, it failed, but the next thing worked.
Working on finding out what of the several changes I did are needed.

Tim S
Title: Re: personalities
Post by: stahta01 on February 24, 2007, 04:45:22 am
Here's the patch that works for me.

Submitted [ Patch #1897 ] Windows XP --personality=ask not working
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1897&group_id=5358

File 1: src/sdk/personalitymanager.cpp
Problem 1: ConfigManager::GetConfigFolder() returns empty string or null string.
Solution 1: Replaced with ConfigManager::GetFolder(sdConfig).

File 2: src/src/app.cpp
Problem 2: Under windows XP SP2, my guess is that wxSingleChoiceDialog has some unknown side effect that prevents code from working.
Solution 2: re-wrote logic using wxGetSingleChoiceIndex

Code
Index: src/sdk/personalitymanager.cpp
===================================================================
--- src/sdk/personalitymanager.cpp (revision 3639)
+++ src/sdk/personalitymanager.cpp (working copy)
@@ -55,7 +55,7 @@
 const wxArrayString PersonalityManager::GetPersonalitiesList()
 {
  wxArrayString list;
- wxDir::GetAllFiles(ConfigManager::GetConfigFolder(), &list, _T("*.conf"), wxDIR_FILES);
+ wxDir::GetAllFiles(ConfigManager::GetFolder(sdConfig), &list, _T("*.conf"), wxDIR_FILES);

  for(size_t i = 0; i < list.GetCount(); ++i)
         list[i] = wxFileName(list[i]).GetName();
Index: src/src/app.cpp
===================================================================
--- src/src/app.cpp (revision 3639)
+++ src/src/app.cpp (working copy)
@@ -880,6 +880,7 @@
 {
     if (personality.CmpNoCase(_T("ask")) == 0)
     {
+/* This Code failed to work under windows XP SP2 reason unkwown
 #if (wxMAJOR_VERSION == 2) && (wxMINOR_VERSION < 5)
         // wx < 2.5.x single choice dialog wants wxString*
         const wxArrayString& list = Manager::Get()->GetPersonalityManager()->GetPersonalitiesList();
@@ -902,6 +903,21 @@
 #if (wxMAJOR_VERSION == 2) && (wxMINOR_VERSION < 5)
         delete[] strings;
 #endif
+*/
+        wxArrayString persNames = Manager::Get()->GetPersonalityManager()->GetPersonalitiesList();
+        int persIndex;
+        persIndex = wxGetSingleChoiceIndex
+              (
+                _("Please choose which personality (profile) to load:"),
+                _("Personalities (profiles)"),
+                persNames
+              );
+
+        if ( persIndex != -1 )
+            Manager::Get()->GetPersonalityManager()->SetPersonality(persNames[persIndex]);
+        else
+            Manager::Get()->GetPersonalityManager()->SetPersonality(_T("default"));
+
     }
     else
         Manager::Get()->GetPersonalityManager()->SetPersonality(personality, true);
Title: Re: personalities
Post by: jmccay on February 27, 2007, 02:11:50 am
Cool.  Thanks for your work.  Now if we could get the patch applied to the SVN code.
jmccay
Title: Re: personalities
Post by: stahta01 on March 13, 2007, 03:15:27 pm
I updated the patch to work with the changes to SVN.

Tim S