• 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
menu.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 * menu_python.h - Functions for menu 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/menu.h"
30 
31 #include <Python.h>
32 #include <QObject>
33 
34 #include <kmenu.h>
35 
36 #include "../karamba.h"
37 #include "meters/meter.h"
38 #include "python/meter.h"
39 
40 long createMenu(long widget)
41 {
42  Karamba* currTheme = (Karamba*)widget;
43 
44  //KMenu* tmp = new KMenu();
45  KMenu *tmp = currTheme->addPopupMenu();
46  /*
47  currTheme->connect(tmp, SIGNAL(triggered(QAction*)), currTheme,
48  SLOT(passMenuItemClicked(QAction*)));
49  */
50  return (long)tmp;
51 }
52 
53 PyObject* py_create_menu(PyObject *, PyObject *args)
54 {
55  long widget;
56  if (!PyArg_ParseTuple(args, (char*)"l:createMenu", &widget))
57  return NULL;
58  return Py_BuildValue((char*)"l", createMenu(widget));
59 }
60 
61 bool menuExists(Karamba* currTheme, KMenu* menu)
62 {
63  return currTheme->popupMenuExisting(menu);
64 }
65 
66 long deleteMenu(long widget, long menu)
67 {
68  Karamba* currTheme = (Karamba*)widget;
69  KMenu* tmp = (KMenu*)menu;
70 
71  //currTheme->removePopupMenu(tmp);
72  if (menuExists(currTheme, tmp))
73  currTheme->deletePopupMenu(tmp);
74 
75  return 1;
76 }
77 
78 PyObject* py_delete_menu(PyObject *, PyObject *args)
79 {
80  long widget, menu;
81  if (!PyArg_ParseTuple(args, (char*)"ll:deleteMenu", &widget, &menu))
82  return NULL;
83  return Py_BuildValue((char*)"l", deleteMenu(widget, menu));
84 }
85 
86 QAction *addMenuItem(long widget, long menu, QString text, QString icon)
87 {
88  Karamba* currTheme = (Karamba*)widget;
89  KMenu* tmp = (KMenu*)menu;
90 
91  QAction *action = 0;
92  if (menuExists(currTheme, tmp)) {
93  //action = tmp->addAction(KIcon(icon), text);
94  action = currTheme->addMenuItem(tmp, text, icon);
95  }
96  return action;
97 }
98 
99 PyObject* py_add_menu_item(PyObject *, PyObject *args)
100 {
101  long widget, menu;
102  char* i;
103  PyObject* t;
104  if (!PyArg_ParseTuple(args, (char*)"llOs:addMenuItem", &widget, &menu, &t, &i))
105  return NULL;
106  QString icon;
107  QString text;
108  icon = QString::fromAscii(i);
109  text = PyString2QString(t);
110  return Py_BuildValue((char*)"l", addMenuItem(widget, menu, text, icon));
111 }
112 
113 QAction* addMenuSeparator(long widget, long menu)
114 {
115  Karamba* currTheme = (Karamba*)widget;
116  KMenu* tmp = (KMenu*)menu;
117 
118  QAction *sep = 0;
119  if (menuExists(currTheme, tmp)) {
120  sep = tmp->addSeparator();
121  }
122 
123  return sep;
124 }
125 
126 PyObject* py_add_menu_separator(PyObject *, PyObject *args)
127 {
128  long widget, menu;
129 
130  if (!PyArg_ParseTuple(args, (char*)"ll:addMenuSeparator", &widget, &menu))
131  return NULL;
132 
133  return Py_BuildValue((char*)"l", addMenuSeparator(widget, menu));
134 }
135 
136 long removeMenuItem(long widget, long menu, QAction *action)
137 {
138  Karamba* currTheme = (Karamba*)widget;
139  KMenu* tmp = (KMenu*)menu;
140 
141  if (menuExists(currTheme, tmp)) {
142  //tmp->removeAction(action);
143  currTheme->deleteMenuItem(action);
144  return 1;
145  } else {
146  return 0;
147  }
148 }
149 
150 PyObject* py_remove_menu_item(PyObject *, PyObject *args)
151 {
152  long widget, menu, id;
153  if (!PyArg_ParseTuple(args, (char*)"lll:removeMenuItem", &widget, &menu, &id))
154  return NULL;
155  return Py_BuildValue((char*)"l", removeMenuItem(widget, menu, (QAction*)id));
156 }
157 
158 long popupMenu(long widget, long menu, long x, long y)
159 {
160  Karamba* currTheme = (Karamba*)widget;
161  KMenu* tmp = (KMenu*)menu;
162 
163  if (menuExists(currTheme, tmp)) {
165  currTheme->popupMenu(tmp, QPoint(x, y));
166  return 1;
167  } else {
168  return 0;
169  }
170 }
171 
172 PyObject* py_popup_menu(PyObject *, PyObject *args)
173 {
174  long widget, menu, x, y;
175  if (!PyArg_ParseTuple(args, (char*)"llll:popupMenu", &widget, &menu, &x, &y))
176  return NULL;
177  return Py_BuildValue((char*)"l", popupMenu(widget, menu, x, y));
178 }
179 
Karamba::deletePopupMenu
void deletePopupMenu(KMenu *menu)
Definition: karamba.cpp:1625
PyObject
struct _object PyObject
Definition: python/karamba.h:35
popupMenu
long popupMenu(long widget, long menu, long x, long y)
Definition: menu.cpp:158
PyString2QString
QString PyString2QString(PyObject *text)
Definition: python/meter.cpp:92
meter.h
meter.h
Karamba::addPopupMenu
KMenu * addPopupMenu()
Definition: karamba.cpp:1599
py_popup_menu
PyObject * py_popup_menu(PyObject *, PyObject *args)
Menu/popupMenu.
Definition: menu.cpp:172
Karamba
Definition: karamba.h:52
py_add_menu_item
PyObject * py_add_menu_item(PyObject *, PyObject *args)
Menu/addMenuItem.
Definition: menu.cpp:99
Karamba::popupMenuExisting
bool popupMenuExisting(const KMenu *menu) const
Definition: karamba.cpp:1644
Karamba::addMenuItem
QAction * addMenuItem(KMenu *menu, const QString &text, const QString &icon)
Definition: karamba.cpp:1610
menuExists
bool menuExists(Karamba *currTheme, KMenu *menu)
Definition: menu.cpp:61
Karamba::popupMenu
void popupMenu(KMenu *menu, const QPoint &pos) const
Definition: karamba.cpp:1616
py_create_menu
PyObject * py_create_menu(PyObject *, PyObject *args)
Menu/createMenu.
Definition: menu.cpp:53
Karamba::deleteMenuItem
void deleteMenuItem(QAction *action)
Definition: karamba.cpp:1633
removeMenuItem
long removeMenuItem(long widget, long menu, QAction *action)
Definition: menu.cpp:136
addMenuItem
QAction * addMenuItem(long widget, long menu, QString text, QString icon)
Definition: menu.cpp:86
menu.h
addMenuSeparator
QAction * addMenuSeparator(long widget, long menu)
Definition: menu.cpp:113
deleteMenu
long deleteMenu(long widget, long menu)
Definition: menu.cpp:66
py_add_menu_separator
PyObject * py_add_menu_separator(PyObject *, PyObject *args)
Menu/addMenuSeparator.
Definition: menu.cpp:126
py_delete_menu
PyObject * py_delete_menu(PyObject *, PyObject *args)
Menu/deleteMenu.
Definition: menu.cpp:78
py_remove_menu_item
PyObject * py_remove_menu_item(PyObject *, PyObject *args)
Menu/removeMenuItem.
Definition: menu.cpp:150
createMenu
long createMenu(long widget)
Definition: menu.cpp:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 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