• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

superkaramba

config.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 *  config_python.cpp  -  Functions for config python api
00003 *
00004 *  Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
00005 *  Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org>
00006 *  Copyright (c) 2004 Petri Damst� <damu@iki.fi>
00007 *
00008 *  This file is part of SuperKaramba.
00009 *
00010 *  SuperKaramba is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  SuperKaramba is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with SuperKaramba; if not, write to the Free Software
00022 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023 ****************************************************************************/
00024 
00025 #ifdef _XOPEN_SOURCE
00026 #undef _XOPEN_SOURCE
00027 #endif
00028 
00029 #include <Python.h>
00030 
00031 #include <QObject>
00032 
00033 #include <kconfig.h>
00034 
00035 #include "meters/meter.h"
00036 
00037 #include "python/meter.h"
00038 #include "python/config.h"
00039 
00040 #include <kconfiggroup.h>
00041 
00042 #include "../karamba.h"
00043 
00044 // API-Function addMenuConfigOption
00045 long addMenuConfigOption(long widget, QString key, QString name)
00046 {
00047     Karamba* currTheme = (Karamba*)widget;
00048 
00049     currTheme->addMenuConfigOption(key, name);
00050 
00051     return 1;
00052 }
00053 
00054 PyObject* py_add_menu_config_option(PyObject *, PyObject *args)
00055 {
00056     long widget;
00057     char* key;
00058     PyObject* name;
00059 
00060     if (!PyArg_ParseTuple(args, (char*)"lsO:addMenuConfigOption", &widget, &key, &name))
00061         return NULL;
00062     if (!checkKaramba(widget))
00063         return NULL;
00064 
00065     QString k, n;
00066     k = QString::fromAscii(key);
00067     n = PyString2QString(name);
00068 
00069     return Py_BuildValue((char*)"l", addMenuConfigOption(widget, k, n));
00070 }
00071 
00072 long setMenuConfigOption(long widget, QString key, bool value)
00073 {
00074     Karamba* currTheme = (Karamba*)widget;
00075 
00076     return currTheme->setMenuConfigOption(key, value);
00077 }
00078 
00079 PyObject* py_set_menu_config_option(PyObject *, PyObject *args)
00080 {
00081     long widget;
00082     char* key;
00083     int value;
00084 
00085     if (!PyArg_ParseTuple(args, (char*)"lsi:setMenuConfigOption", &widget, &key, &value))
00086         return NULL;
00087     if (!checkKaramba(widget))
00088         return NULL;
00089 
00090     QString k;
00091     k = QString::fromAscii(key);
00092 
00093     return Py_BuildValue((char*)"l", setMenuConfigOption(widget, k, (bool)value));
00094 }
00095 
00096 long readMenuConfigOption(long widget, QString key)
00097 {
00098     Karamba* currTheme = (Karamba*)widget;
00099 
00100     return currTheme -> readMenuConfigOption(key);
00101 }
00102 
00103 PyObject* py_read_menu_config_option(PyObject *, PyObject *args)
00104 {
00105     long widget;
00106     char* key;
00107 
00108     if (!PyArg_ParseTuple(args, (char*)"ls:readMenuConfigOption", &widget, &key))
00109         return NULL;
00110     if (!checkKaramba(widget))
00111         return NULL;
00112 
00113     QString k;
00114     k = QString::fromAscii(key);
00115 
00116     return Py_BuildValue((char*)"l", readMenuConfigOption(widget, k));
00117 }
00118 
00119 // API-Function writeConfigEntry
00120 long writeConfigEntry(long widget, QString key, QString value)
00121 {
00122     Karamba* currTheme = (Karamba*)widget;
00123 
00124     currTheme->getConfig()->group("theme").writeEntry(key, value);
00125 
00126     return 1;
00127 }
00128 
00129 PyObject* py_write_config_entry(PyObject *, PyObject *args)
00130 {
00131     long widget;
00132     char* key;
00133     char* value;
00134 
00135     if (!PyArg_ParseTuple(args, (char*)"lss:writeConfigEntry", &widget, &key, &value))
00136         return NULL;
00137     if (!checkKaramba(widget))
00138         return NULL;
00139     QString k, v;
00140     k = QString::fromAscii(key);
00141     v = QString::fromAscii(value);
00142 
00143     return Py_BuildValue((char*)"l", writeConfigEntry(widget, k, value));
00144 }
00145 
00146 // API-Function readConfigEntry
00147 QString readConfigEntry(long widget, QString key)
00148 {
00149     Karamba* currTheme = (Karamba*)widget;
00150 
00151     return currTheme->getConfig()->group("theme").readEntry(key, QString());
00152 }
00153 
00154 PyObject* py_read_config_entry(PyObject *, PyObject *args)
00155 {
00156     long widget;
00157     char* key;
00158     if (!PyArg_ParseTuple(args, (char*)"ls:readConfigEntry", &widget, &key))
00159         return NULL;
00160     if (!checkKaramba(widget))
00161         return NULL;
00162 
00163     QString k;
00164     k = QString::fromAscii(key);
00165 
00166     QString entry = readConfigEntry(widget, k);
00167 
00168     if (entry.isEmpty())
00169         return Py_BuildValue((char*)"");
00170 
00171     if (entry.startsWith("false", Qt::CaseInsensitive))
00172         return Py_BuildValue((char*)"l", 0);
00173 
00174     if (entry.startsWith("true", Qt::CaseInsensitive))
00175         return Py_BuildValue((char*)"l", 0);
00176 
00177     bool ok;
00178     if (entry.toInt(&ok))
00179         return Py_BuildValue((char*)"l", entry.toInt());
00180 
00181     return Py_BuildValue((char*)"s",
00182                          entry.toAscii().constData());
00183 
00184     return NULL;
00185 }
00186 

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal