• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • superkaramba
 

superkaramba

config_python.cpp

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én <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 #include <tqobject.h>
00031 #include "karamba.h"
00032 #include "meter.h"
00033 #include "meter_python.h"
00034 #include "config_python.h"
00035 
00036 // API-Function addMenuConfigOption
00037 long addMenuConfigOption(long widget, TQString key, TQString name)
00038 {
00039   karamba* currTheme = (karamba*)widget;
00040 
00041   currTheme -> addMenuConfigOption(key, name);
00042 
00043   return 1;
00044 }
00045 
00046 PyObject* py_add_menu_config_option(PyObject *, PyObject *args)
00047 {
00048   long widget;
00049   char* key;
00050   PyObject* name;
00051 
00052   if (!PyArg_ParseTuple(args, (char*)"lsO:addMenuConfigOption", &widget, &key, &name))
00053     return NULL;
00054   if (!checkKaramba(widget))
00055     return NULL;
00056 
00057   TQString k, n;
00058   k.setAscii(key);
00059   n = PyString2TQString(name);
00060 
00061   return Py_BuildValue((char*)"l", addMenuConfigOption(widget, k, n));
00062 }
00063 
00064 long setMenuConfigOption(long widget, TQString key, bool value)
00065 {
00066   karamba* currTheme = (karamba*)widget;
00067 
00068   return currTheme -> setMenuConfigOption(key, value);
00069 }
00070 
00071 PyObject* py_set_menu_config_option(PyObject *, PyObject *args)
00072 {
00073   long widget;
00074   char* key;
00075   int value;
00076 
00077   if (!PyArg_ParseTuple(args, (char*)"lsi:setMenuConfigOption", &widget, &key, &value))
00078     return NULL;
00079   if (!checkKaramba(widget))
00080     return NULL;
00081 
00082   TQString k;
00083   k.setAscii(key);
00084 
00085   return Py_BuildValue((char*)"l", setMenuConfigOption(widget, k, (bool)value));
00086 }
00087 
00088 long readMenuConfigOption(long widget, TQString key)
00089 {
00090   karamba* currTheme = (karamba*)widget;
00091 
00092   return currTheme -> readMenuConfigOption(key);
00093 }
00094 
00095 PyObject* py_read_menu_config_option(PyObject *, PyObject *args)
00096 {
00097   long widget;
00098   char* key;
00099 
00100   if (!PyArg_ParseTuple(args, (char*)"ls:readMenuConfigOption", &widget, &key))
00101     return NULL;
00102   if (!checkKaramba(widget))
00103     return NULL;
00104 
00105   TQString k;
00106   k.setAscii(key);
00107 
00108   return Py_BuildValue((char*)"l", readMenuConfigOption(widget, k));
00109 }
00110 
00111 // API-Function writeConfigEntry
00112 long writeConfigEntry(long widget, TQString key, TQString value)
00113 {
00114   karamba* currTheme = (karamba*)widget;
00115 
00116   currTheme -> config -> setGroup("theme");
00117   currTheme -> config -> writeEntry(key, value);
00118 
00119   return 1;
00120 }
00121 
00122 PyObject* py_write_config_entry(PyObject *, PyObject *args)
00123 {
00124   long widget;
00125   char* key;
00126   char* value;
00127 
00128   if (!PyArg_ParseTuple(args, (char*)"lss:writeConfigEntry", &widget, &key, &value))
00129     return NULL;
00130   if (!checkKaramba(widget))
00131     return NULL;
00132   TQString k, v;
00133   k.setAscii(key);
00134   v.setAscii(value);
00135 
00136   return Py_BuildValue((char*)"l", writeConfigEntry(widget, k, value));
00137 }
00138 
00139 // API-Function readConfigEntry
00140 TQVariant readConfigEntry(long widget, TQString key)
00141 {
00142   karamba* currTheme = (karamba*)widget;
00143 
00144   currTheme -> config -> setGroup("theme");
00145   return currTheme -> config -> readEntry(key);
00146 }
00147 
00148 PyObject* py_read_config_entry(PyObject *, PyObject *args)
00149 {
00150   long widget;
00151   char* key;
00152   if (!PyArg_ParseTuple(args, (char*)"ls:readConfigEntry", &widget, &key))
00153     return NULL;
00154   if (!checkKaramba(widget))
00155     return NULL;
00156   TQString k;
00157   k.setAscii(key);
00158 
00159   TQVariant entry = readConfigEntry(widget, k);
00160   TQString type;
00161   type.setAscii(entry.typeName());
00162 
00163   if (type == "Bool")
00164   {
00165     return Py_BuildValue((char*)"l", (int)entry.toBool());
00166   }
00167 
00168   bool isint = false;
00169   int i = entry.toInt(&isint);
00170   if (isint)
00171   {
00172     return Py_BuildValue((char*)"l", i);
00173   }
00174 
00175   if (type == TQSTRING_OBJECT_NAME_STRING)
00176   {
00177     return Py_BuildValue((char*)"s", entry.toString().ascii());
00178   }
00179   // Add more types if needed
00180   return NULL;
00181 }
00182 

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

superkaramba

Skip menu "superkaramba"
  • kcalc
  •   knumber
  • superkaramba
Generated for superkaramba by doxygen 1.6.3
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |