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

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • src
  • python
config.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 * config_python.cpp - Functions for config python api
3 *
4 * Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
5 * Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org>
6 * Copyright (c) 2004 Petri Damstén <damu@iki.fi>
7 *
8 * This file is part of SuperKaramba.
9 *
10 * SuperKaramba is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * SuperKaramba is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with SuperKaramba; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 ****************************************************************************/
24 
25 #if defined(_XOPEN_SOURCE) && !defined(__SUNPRO_CC)
26 #undef _XOPEN_SOURCE
27 #endif
28 
29 #include "python/config.h"
30 
31 #include <Python.h>
32 
33 #include <QObject>
34 
35 #include <kconfig.h>
36 
37 #include "meters/meter.h"
38 
39 #include "python/meter.h"
40 
41 #include <kconfiggroup.h>
42 
43 #include "../karamba.h"
44 
45 // API-Function addMenuConfigOption
46 long addMenuConfigOption(long widget, QString key, QString name)
47 {
48  Karamba* currTheme = (Karamba*)widget;
49 
50  currTheme->addMenuConfigOption(key, name);
51 
52  return 1;
53 }
54 
55 PyObject* py_add_menu_config_option(PyObject *, PyObject *args)
56 {
57  long widget;
58  char* key;
59  PyObject* name;
60 
61  if (!PyArg_ParseTuple(args, (char*)"lsO:addMenuConfigOption", &widget, &key, &name))
62  return NULL;
63  if (!checkKaramba(widget))
64  return NULL;
65 
66  QString k, n;
67  k = QString::fromAscii(key);
68  n = PyString2QString(name);
69 
70  return Py_BuildValue((char*)"l", addMenuConfigOption(widget, k, n));
71 }
72 
73 long setMenuConfigOption(long widget, QString key, bool value)
74 {
75  Karamba* currTheme = (Karamba*)widget;
76 
77  return currTheme->setMenuConfigOption(key, value);
78 }
79 
80 PyObject* py_set_menu_config_option(PyObject *, PyObject *args)
81 {
82  long widget;
83  char* key;
84  int value;
85 
86  if (!PyArg_ParseTuple(args, (char*)"lsi:setMenuConfigOption", &widget, &key, &value))
87  return NULL;
88  if (!checkKaramba(widget))
89  return NULL;
90 
91  QString k;
92  k = QString::fromAscii(key);
93 
94  return Py_BuildValue((char*)"l", setMenuConfigOption(widget, k, (bool)value));
95 }
96 
97 long readMenuConfigOption(long widget, QString key)
98 {
99  Karamba* currTheme = (Karamba*)widget;
100 
101  return currTheme -> readMenuConfigOption(key);
102 }
103 
104 PyObject* py_read_menu_config_option(PyObject *, PyObject *args)
105 {
106  long widget;
107  char* key;
108 
109  if (!PyArg_ParseTuple(args, (char*)"ls:readMenuConfigOption", &widget, &key))
110  return NULL;
111  if (!checkKaramba(widget))
112  return NULL;
113 
114  QString k;
115  k = QString::fromAscii(key);
116 
117  return Py_BuildValue((char*)"l", readMenuConfigOption(widget, k));
118 }
119 
120 // API-Function writeConfigEntry
121 long writeConfigEntry(long widget, QString key, QString value)
122 {
123  Karamba* currTheme = (Karamba*)widget;
124 
125  currTheme->getConfig()->group("theme").writeEntry(key, value);
126 
127  return 1;
128 }
129 
130 PyObject* py_write_config_entry(PyObject *, PyObject *args)
131 {
132  long widget;
133  char* key;
134  char* value;
135 
136  if (!PyArg_ParseTuple(args, (char*)"lss:writeConfigEntry", &widget, &key, &value))
137  return NULL;
138  if (!checkKaramba(widget))
139  return NULL;
140  QString k, v;
141  k = QString::fromAscii(key);
142  v = QString::fromAscii(value);
143 
144  return Py_BuildValue((char*)"l", writeConfigEntry(widget, k, value));
145 }
146 
147 // API-Function readConfigEntry
148 QString readConfigEntry(long widget, QString key)
149 {
150  Karamba* currTheme = (Karamba*)widget;
151 
152  return currTheme->getConfig()->group("theme").readEntry(key, QString());
153 }
154 
155 PyObject* py_read_config_entry(PyObject *, PyObject *args)
156 {
157  long widget;
158  char* key;
159  if (!PyArg_ParseTuple(args, (char*)"ls:readConfigEntry", &widget, &key))
160  return NULL;
161  if (!checkKaramba(widget))
162  return NULL;
163 
164  QString k;
165  k = QString::fromAscii(key);
166 
167  QString entry = readConfigEntry(widget, k);
168 
169  if (entry.isEmpty())
170  return Py_BuildValue((char*)"");
171 
172  if (entry.startsWith("false", Qt::CaseInsensitive))
173  return Py_BuildValue((char*)"l", 0);
174 
175  if (entry.startsWith("true", Qt::CaseInsensitive))
176  return Py_BuildValue((char*)"l", 0);
177 
178  bool ok;
179  if (entry.toInt(&ok))
180  return Py_BuildValue((char*)"l", entry.toInt());
181 
182  return Py_BuildValue((char*)"s",
183  entry.toAscii().constData());
184 
185  return NULL;
186 }
187 
writeConfigEntry
long writeConfigEntry(long widget, QString key, QString value)
Definition: config.cpp:121
PyObject
struct _object PyObject
Definition: python/karamba.h:35
PyString2QString
QString PyString2QString(PyObject *text)
Definition: python/meter.cpp:92
py_set_menu_config_option
PyObject * py_set_menu_config_option(PyObject *, PyObject *args)
Config/setMenuConfigOption.
Definition: config.cpp:80
meter.h
meter.h
config.h
readMenuConfigOption
long readMenuConfigOption(long widget, QString key)
Definition: config.cpp:97
Karamba
Definition: karamba.h:52
setMenuConfigOption
long setMenuConfigOption(long widget, QString key, bool value)
Definition: config.cpp:73
readConfigEntry
QString readConfigEntry(long widget, QString key)
Definition: config.cpp:148
py_add_menu_config_option
PyObject * py_add_menu_config_option(PyObject *, PyObject *args)
Config/addMenuConfigOption.
Definition: config.cpp:55
py_read_config_entry
PyObject * py_read_config_entry(PyObject *, PyObject *args)
Config/readConfigEntry.
Definition: config.cpp:155
checkKaramba
bool checkKaramba(long widget)
Definition: python/meter.cpp:26
py_write_config_entry
PyObject * py_write_config_entry(PyObject *, PyObject *args)
Config/writeConfigEntry.
Definition: config.cpp:130
addMenuConfigOption
long addMenuConfigOption(long widget, QString key, QString name)
Definition: config.cpp:46
Karamba::getConfig
KConfig * getConfig() const
Definition: karamba.cpp:1389
Karamba::setMenuConfigOption
bool setMenuConfigOption(const QString &key, bool value)
Definition: karamba.cpp:1572
Karamba::addMenuConfigOption
void addMenuConfigOption(const QString &key, const QString &name)
Definition: karamba.cpp:1543
py_read_menu_config_option
PyObject * py_read_menu_config_option(PyObject *, PyObject *args)
Config/readMenuConfigOption.
Definition: config.cpp:104
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

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

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal