Menu

PATCH: Allow different config directories

Help
Anonymous
2003-08-12
2003-08-17
  • Anonymous

    Anonymous - 2003-08-12

    Sorry if this is not the best place to post this, but I am didn't know where else to put it. I am attaching a patch that I created that allow a different configuration directory to be specified instead of ~/.superkaramba. This is very usefull for me where I run  computers with 2 screens at different resolutions and need to move windows around.
    Sorry for the noise.
    Brian

    ---CUT HERE ----
    --- superkaramba-0.29/src/main.cpp    2003-07-10 00:26:21.000000000 -0400
    +++ superkaramba-0.29b/src/main.cpp    2003-08-12 16:15:01.000000000 -0400
    @@ -18,6 +18,8 @@
    #include "karambasessionmanaged.h"
    #include "karamba.h"

    +QDir configDir;
    +QString cfgdir  = I18N_NOOP(QDir::home().absPath() + "/.superkaramba");

    static const char *description =
         I18N_NOOP("A KDE Eye-candy Application");
    @@ -27,6 +29,7 @@
    static KCmdLineOptions options[] =
         {
             //    { "+[URL]", I18N_NOOP( "Document to open." ), 0 },
    +        { "configfile ", I18N_NOOP("Configuration Directory"), cfgdir.ascii() },
             { "+file", I18N_NOOP("A required argument 'file'."), 0 },
             { 0, 0, 0 }

    @@ -36,6 +39,7 @@

    int main(int argc, char **argv)
    {
    +
         KAboutData about("superkaramba", I18N_NOOP("superkaramba"), version, description,
                          KAboutData::License_GPL, "(C) 2003 Adam Geitgey", 0, 0, "adam@rootnode.org");
         about.addAuthor( "Adam Geitgey", 0, "adam@rootnode.org" );
    @@ -50,6 +54,7 @@
         karamba *mainWin = 0;

         KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    +    cfgdir = QString::fromLocal8Bit(args->getOption("configfile"));

         bool OK = false;

    @@ -57,17 +62,18 @@
         app.dcopClient()->registerAs(app.name());

         // Create ~/.superkaramba if necessary
    -    QDir configDir(QDir::home().absPath() + "/.superkaramba");
    +    configDir = QDir::QDir(cfgdir.ascii());
    +   
         if (!configDir.exists())
         {
    -      qWarning("~/.superkaramba doesn't exist");
    -      if(!configDir.mkdir(QDir::home().absPath() + "/.superkaramba"))
    +      qWarning("%s doesn't exist", configDir.absPath().ascii());
    +      if(!configDir.mkdir(configDir.absPath().ascii()))
           {
    -         qWarning("Couldn't create Directory ~/.superkaramba");
    +         qWarning("Couldn't create Directory %s", configDir.absPath().ascii());
           }
           else
           {
    -         qWarning("created ~/.superkaramba");
    +         qWarning("created %s", configDir.absPath().ascii());
           }
         }

    --- superkaramba-0.29/src/karamba.cpp    2003-07-10 00:25:28.000000000 -0400
    +++ superkaramba-0.29b/src/karamba.cpp    2003-08-12 12:38:58.000000000 -0400
    @@ -16,6 +16,7 @@
    // Menu IDs
    #define EDITSCRIPT 1
    #define THEMECONF  2
    +extern QDir configDir;

    // Converts a Python String to a QString with Unicode support
    QString PyString2QString(PyObject* text)
    @@ -1900,7 +1901,8 @@
    //     } else
    //       printf("Unknown theme!");
        
    -    QFile themeConfigFile(QDir::home().absPath() + "/.superkaramba/" + themeName + ".rc");
    +
    +    QFile themeConfigFile(configDir.absPath().ascii() + QString("/") + themeName + ".rc");
         // Tests if config file Exists
         if (!QFileInfo(themeConfigFile).exists())
         {
    @@ -3847,7 +3849,8 @@

         // write changes to DiskSensor
         config -> sync();
    -    qWarning("Config File ~/.superkaramba/%s.rc written.", themeName.ascii());
    +    qWarning("Config File %s/%s.rc written.", configDir.absPath().ascii(),
    +         themeName.ascii());
    }

    void karamba::slotToggleConfigOption(QString key, bool value)

    ---- CUT HERE ----

     
    • Adam Geitgey

      Adam Geitgey - 2003-08-17

      I'll try it out and probably include it in the next version.  Thanks!

       

Log in to post a comment.