systray_python.cpp

00001 /****************************************************************************
00002 *  systray_python.h  -  Functions for systray 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 <qobject.h>
00031 #include "karamba.h"
00032 #include "meter.h"
00033 #include "meter_python.h"
00034 #include "systray_python.h"
00035 
00036 long moveSystray(long widget, long x, long y, long w, long h)
00037 {
00038   karamba* currTheme = (karamba*)widget;
00039 
00040   if (currTheme->systray != 0) {
00041     currTheme->systray->move((int)x,(int)y);
00042     currTheme->systray->setMinimumSize((int)w,(int)h);
00043     currTheme->systray->layoutSystray();
00044     currTheme->systray->show();
00045   }
00046   return 1;
00047 }
00048 
00049 PyObject* py_move_systray(PyObject *, PyObject *args)
00050 {
00051   long widget, x, y, w, h;
00052   if (!PyArg_ParseTuple(args, (char*)"lllll:moveSystray", &widget, &x, &y, &w, &h))
00053     return NULL;
00054   if (!checkKaramba(widget))
00055     return NULL;
00056   return Py_BuildValue((char*)"l", moveSystray(widget, x, y, w, h));
00057 }
00058 
00059 /* now a method we need to expose to Python */
00060 long showSystray(long widget)
00061 {
00062   karamba* currTheme = (karamba*)widget;
00063 
00064   if (currTheme->systray != 0)
00065   {
00066     currTheme->systray->show();
00067   }
00068   return 1;
00069 }
00070 
00071 PyObject* py_show_systray(PyObject *, PyObject *args)
00072 {
00073   long widget;
00074   if (!PyArg_ParseTuple(args, (char*)"l:showSystray", &widget))
00075     return NULL;
00076   if (!checkKaramba(widget))
00077     return NULL;
00078   return Py_BuildValue((char*)"l", showSystray(widget));
00079 }
00080 
00081 /* now a method we need to expose to Python */
00082 long hideSystray(long widget)
00083 {
00084   karamba* currTheme = (karamba*)widget;
00085 
00086   if (currTheme->systray != 0)
00087   {
00088     currTheme->systray->hide();
00089   }
00090   return 1;
00091 }
00092 
00093 PyObject* py_hide_systray(PyObject *, PyObject *args)
00094 {
00095   long widget;
00096   if (!PyArg_ParseTuple(args, (char*)"l:hideSystray", &widget))
00097     return NULL;
00098   if (!checkKaramba(widget))
00099     return NULL;
00100   return Py_BuildValue((char*)"l", hideSystray(widget));
00101 }
00102 
00103 /* now a method we need to expose to Python */
00104 long createSystray(long widget, long x, long y, long w, long h)
00105 {
00106   karamba* currTheme = (karamba*)widget;
00107 
00108   //Don't create more than one systray
00109   if (currTheme->systray == 0) {
00110     currTheme->systray = new Systemtray(currTheme);
00111     currTheme->systray->move((int)x,(int)y);
00112     currTheme->systray->setMinimumSize((int)w,(int)h);
00113     currTheme->systray->initSystray();
00114     QObject::connect(currTheme->systray,SIGNAL(updated()),
00115                      currTheme,SLOT(systrayUpdated()));
00116     currTheme->systray->show();
00117   }
00118 
00119   return 1;
00120 }
00121 
00122 PyObject* py_create_systray(PyObject *, PyObject *args)
00123 {
00124   long widget, x, y, w, h;
00125   if (!PyArg_ParseTuple(args, (char*)"lllll:createSystray", &widget, &x, &y, &w, &h))
00126     return NULL;
00127   if (!checkKaramba(widget))
00128     return NULL;
00129   return Py_BuildValue((char*)"l", createSystray(widget, x, y, w, h));
00130 }
00131 
00132 /* now a method we need to expose to Python */
00133 long getCurrentWindowCount(long widget)
00134 {
00135   karamba* currTheme = (karamba*)widget;
00136   int num;
00137 
00138   num = 0;
00139 
00140   if (currTheme->systray != 0)
00141   {
00142     num = currTheme->systray->getCurrentWindowCount();
00143   }
00144   return num;
00145 }
00146 
00147 PyObject* py_get_current_window_count(PyObject *, PyObject *args)
00148 {
00149   long widget;
00150   if (!PyArg_ParseTuple(args, (char*)"l:getCurrentWindowCount", &widget ))
00151     return NULL;
00152   if (!checkKaramba(widget))
00153     return NULL;
00154   return Py_BuildValue((char*)"l", getCurrentWindowCount(widget));
00155 }
00156 
00157 /* now a method we need to expose to Python */
00158 long updateSystrayLayout(long widget)
00159 {
00160   karamba* currTheme = (karamba*)widget;
00161 
00162   if (currTheme->systray != 0)
00163   {
00164     currTheme->systray->layoutSystray();
00165   }
00166   return 1;
00167 }
00168 
00169 PyObject* py_update_systray_layout(PyObject *, PyObject *args)
00170 {
00171   long widget;
00172   if (!PyArg_ParseTuple(args, (char*)"l:updateSystrayLayout", &widget ))
00173     return NULL;
00174   if (!checkKaramba(widget))
00175     return NULL;
00176   return Py_BuildValue((char*)"l", updateSystrayLayout(widget));
00177 }
00178 
00179 /* get the systray size from python */
00180 int getSystraySize(long widget) {
00181     karamba* currTheme = (karamba*)widget;
00182     if(currTheme->systray == 0) {
00183         return 0;
00184     } else {
00185         return currTheme->systray->getTraySize();
00186     }
00187 }
00188 
00189 // Returns the size of the systray
00190 PyObject* py_get_systray_size(PyObject*, PyObject* args)
00191 {
00192     long widget;
00193 
00194     if (!PyArg_ParseTuple(args, "l:getSystraySize", &widget))
00195         return NULL;
00196 
00197     return Py_BuildValue("l", getSystraySize(widget));
00198 }
00199 
KDE Home | KDE Accessibility Home | Description of Access Keys