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

superkaramba

  • superkaramba
  • src
misc_python.cpp
1 /****************************************************************************
2 * misc_python.cpp - Misc Functions for 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 * Copyright (C) 2004, 2005 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
8 *
9 * This file is part of SuperKaramba.
10 *
11 * SuperKaramba is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * SuperKaramba is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with SuperKaramba; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 ****************************************************************************/
25 
26 #ifdef _XOPEN_SOURCE
27 #undef _XOPEN_SOURCE
28 #endif
29 
30 #include <Python.h>
31 #include <tqglobal.h>
32 #include <tqobject.h>
33 
34 #include <tdeglobal.h>
35 #include <tdelocale.h>
36 
37 #include "kdebug.h"
38 #include "karamba.h"
39 #include "karambaapp.h"
40 #include "themefile.h"
41 #include "themelocale.h"
42 #include "meter.h"
43 #include "meter_python.h"
44 #include "misc_python.h"
45 
46 /* now a method we need to expose to Python */
47 long acceptDrops(long widget)
48 {
49  karamba* currTheme = (karamba*)widget;
50 
51  currTheme->setAcceptDrops(true);
52 
53  return 1;
54 }
55 
56 PyObject* py_accept_drops(PyObject *, PyObject *args)
57 {
58  long widget;
59 
60  if (!PyArg_ParseTuple(args, (char*)"l", &widget))
61  return NULL;
62  if (!checkKaramba(widget))
63  return NULL;
64  return Py_BuildValue((char*)"l", acceptDrops(widget));
65 }
66 
67 // Runs a command, returns 0 if it could not start command
68 PyObject* py_run_command(PyObject*, PyObject* args)
69 {
70  char* name;
71  char* command;
72  char* icon;
73  PyObject *lst;
74  if (!PyArg_ParseTuple(args, (char*)"sssO:run", &name, &command, &icon, &lst) ||
75  lst == NULL || !PyList_Check(lst))
76  return NULL;
77 
78  TQString n;
79  TQString c;
80  TQString i;
81 
82  n.setAscii(name);
83  c.setAscii(command);
84  i.setAscii(icon);
85 
86  KService svc(n, c, i);
87  KURL::List l;
88 
89  for (int i = 0; i < PyList_Size(lst); i++)
90  {
91  l.append(PyString2TQString(PyList_GetItem(lst, i)));
92  }
93  KRun::run(svc, l);
94  return Py_BuildValue("l", 1);
95 }
96 
97 // Runs a command, returns 0 if it could not start command
98 PyObject* py_execute_command(PyObject *, PyObject* args)
99 {
100  PyObject* s;
101 
102  if (!PyArg_ParseTuple(args, (char*)"O:execute", &s))
103  return NULL;
104  return Py_BuildValue((char*)"l", KRun::runCommand(PyString2TQString(s)));
105 }
106 
107 // Runs a command, returns 0 if it could not start command
108 PyObject* py_execute_command_interactive(PyObject *, PyObject* args)
109 {
110  long widget;
111  //if (!PyArg_ParseTuple(args, (char*)"ls", &widget, &command))
112  // return NULL;
113 
114  int numLines; /* how many lines we passed for parsing */
115  TQString line; /* pointer to the line as a string */
116 
117  PyObject * listObj; /* the list of strings */
118  PyObject * strObj; /* one string in the list */
119 
120  /* the O! parses for a Python object (listObj) checked
121  to be of type PyList_Type */
122  if (! PyArg_ParseTuple(args, (char*)"lO!", &widget, &PyList_Type, &listObj))
123  return NULL;
124  if (!checkKaramba(widget))
125  return NULL;
126 
127  karamba* currTheme = (karamba*)widget;
128 
129  currTheme->currProcess = new TDEProcess;
130 
131  /* get the number of lines passed to us */
132  numLines = PyList_Size(listObj);
133 
134  /* should raise an error here. */
135  if (numLines < 0) return NULL; /* Not a list */
136 
137  /* iterate over items of the list, grabbing strings, and parsing
138  for numbers */
139  for (int i=0; i<numLines; i++){
140 
141  /* grab the string object from the next element of the list */
142  strObj = PyList_GetItem(listObj, i); /* Can't fail */
143 
144  /* make it a string */
145  line = PyString2TQString(strObj);
146 
147  /* now do the parsing */
148  *(currTheme->currProcess) << line;
149 
150  }
151  TQApplication::connect(currTheme->currProcess,
152  TQ_SIGNAL(processExited(TDEProcess *)),
153  currTheme,
154  TQ_SLOT(processExited(TDEProcess *)));
155  TQApplication::connect(currTheme->currProcess,
156  TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)),
157  currTheme,
158  TQ_SLOT(receivedStdout(TDEProcess *, char *, int)));
159  currTheme->currProcess->start(TDEProcess::NotifyOnExit, TDEProcess::Stdout);
160 
161  return Py_BuildValue((char*)"l", (int)(currTheme->currProcess->pid()));
162 }
163 
164 long attachClickArea(long widget, long meter, TQString LeftButton, TQString MiddleButton, TQString RightButton)
165 {
166  karamba* currTheme = (karamba*) widget;
167  Meter* currMeter = (Meter*) meter;
168 
169  // Look if currMeter has an ClickArea attached.
170  bool meterAlreadyClickable = currTheme->clickList->containsRef(currMeter);
171 
172  // if currMeter is of type ImageLabel*
173  if (ImageLabel* image = dynamic_cast<ImageLabel*>(currMeter))
174  {
175  image -> attachClickArea(LeftButton, MiddleButton, RightButton);
176  if (!meterAlreadyClickable)
177  {
178  //tqWarning("attachClickArea : meter is image");
179  currTheme -> clickList -> append(image);
180  }
181  }
182  // else if currMeter is of type TextLabel*
183  else if (TextLabel* text = dynamic_cast<TextLabel*>(currMeter))
184  {
185  text -> attachClickArea(LeftButton, MiddleButton, RightButton);
186  if (!meterAlreadyClickable)
187  {
188  //tqWarning("attachClickArea : meter is text");
189  currTheme -> clickList -> append(text);
190  }
191  }
192  else
193  {
194  //The given meter does not support attached clickAreas.
195  tqWarning("The given meter is not of type image or text");
196  return 0;
197  }
198  return 1;
199 }
200 
201 PyObject* py_attach_clickArea(PyObject*, PyObject* args, PyObject* dict)
202 {
203  long widget;
204  long meter;
205  char* LeftButton = NULL;
206  char* MiddleButton = NULL;
207  char* RightButton = NULL;
208  const char* mouseButtons[] = {"Widget", "Meter", "LeftButton", "MiddleButton",
209  "RightButton", NULL};
210  if (!PyArg_ParseTupleAndKeywords(args, dict, (char*)"ll|sss:attachClickArea",
211  (char**)mouseButtons, &widget, &meter, &LeftButton, &MiddleButton, &RightButton))
212  return NULL;
213  if (!checkKaramba(widget))
214  return NULL;
215  TQString lB, mB, rB;
216  if (LeftButton != NULL)
217  {
218  lB.setAscii(LeftButton);
219  }
220  else
221  {
222  lB.setAscii("");
223  }
224  if (MiddleButton != NULL)
225  {
226  mB.setAscii(MiddleButton);
227  }
228  else
229  {
230  mB.setAscii("");
231  }
232  if (RightButton != NULL)
233  {
234  rB.setAscii(RightButton);
235  }
236  else
237  {
238  rB.setAscii("");
239  }
240  return Py_BuildValue((char*)"l", attachClickArea(widget, meter, lB, mB, rB));
241 }
242 
243 /* now a method we need to expose to Python */
244 long toggleShowDesktop(long)
245 {
246  ShowDesktop *s = ShowDesktop::the();
247  s->toggle();
248  return 1;
249 }
250 
251 PyObject* py_toggle_show_desktop(PyObject *, PyObject *args)
252 {
253  long widget;
254  if (!PyArg_ParseTuple(args, (char*)"l:toggleShowDesktop", &widget))
255  return NULL;
256  if (!checkKaramba(widget))
257  return NULL;
258  return Py_BuildValue((char*)"l", toggleShowDesktop(widget));
259 }
260 
261 /* now a method we need to expose to Python */
262 const char* getPrettyName(long widget) {
263  karamba* currTheme = (karamba*)widget;
264 
265  return currTheme->prettyName.ascii();
266 }
267 
268 PyObject* py_get_pretty_name(PyObject *, PyObject *args)
269 {
270  long widget;
271  if (!PyArg_ParseTuple(args, (char*)"l:getPrettyThemeName", &widget))
272  return NULL;
273  return Py_BuildValue((char*)"s", getPrettyName(widget));
274 }
275 
276 /* now a method we need to expose to Python */
277 const char* getThemePath(long widget) {
278  karamba* currTheme = (karamba*)widget;
279 
280  return currTheme->theme().path().ascii();
281 }
282 
283 PyObject* py_get_theme_path(PyObject *, PyObject *args)
284 {
285  long widget;
286  if (!PyArg_ParseTuple(args, (char*)"l:getThemePath", &widget))
287  return NULL;
288  if (!checkKaramba(widget))
289  return NULL;
290  return Py_BuildValue((char*)"s", getThemePath(widget));
291 }
292 
293 PyObject* py_language(PyObject *, PyObject *args)
294 {
295  long widget;
296  if (!PyArg_ParseTuple(args, (char*)"l:language", &widget))
297  return NULL;
298  if (!checkKaramba(widget))
299  return NULL;
300  return Py_BuildValue((char*)"s",
301  ((karamba*)widget)->theme().locale()->language().ascii());
302 }
303 
304 PyObject* py_userLanguage(PyObject *, PyObject *args)
305 {
306  long widget;
307  if (!PyArg_ParseTuple(args, (char*)"l:language", &widget))
308  return NULL;
309  if (!checkKaramba(widget))
310  return NULL;
311  return Py_BuildValue((char*)"s", TDEGlobal::locale()->language().ascii());
312 }
313 
314 PyObject* py_userLanguages(PyObject *, PyObject *args)
315 {
316  long widget;
317  if (!PyArg_ParseTuple(args, (char*)"l:language", &widget))
318  return NULL;
319  if (!checkKaramba(widget))
320  return NULL;
321 
322  unsigned int noOfLangs = TDEGlobal::locale()->languageList().count();
323 
324  PyObject *list, *item;
325  list = PyList_New(noOfLangs);
326 
327  for(unsigned int i = 0; i < noOfLangs; i++)
328  {
329  item = Py_BuildValue((char*)"s", TDEGlobal::locale()->languageList()[i].ascii());
330  PyList_SetItem(list, i, item);
331  }
332 
333  return list;
334 }
335 
336 PyObject* py_read_theme_file(PyObject *, PyObject *args)
337 {
338  long widget;
339  char *file;
340  if (!PyArg_ParseTuple(args, (char*)"ls:readThemeFile", &widget, &file))
341  return NULL;
342  if (!checkKaramba(widget))
343  return NULL;
344  karamba* k = (karamba*)widget;
345  TQByteArray ba = k->theme().readThemeFile(file);
346  return PyBytes_FromStringAndSize(ba.data(), ba.size());
347 }
348 
349 /* now a method we need to expose to Python */
350 long removeClickArea(long widget, long click) {
351 
352  karamba* currTheme = (karamba*)widget;
353  ClickArea *tmp = (ClickArea*)click;
354 
355  currTheme -> clickList -> remove(tmp);
356 
357  delete tmp;
358  return (long)tmp;
359 }
360 
361 /* now a method we need to expose to Python */
362 long createServiceClickArea(long widget, long x, long y, long w, long h, char *name, char* exec, char *icon) {
363 
364  karamba* currTheme = (karamba*)widget;
365  ClickArea *tmp = new ClickArea( currTheme, x, y, w, h );
366  TQString n;
367  TQString e;
368  TQString i;
369 
370  n.setAscii(name);
371  e.setAscii(exec);
372  i.setAscii(icon);
373 
374  tmp->setServiceOnClick(n, e, i);
375 
376  currTheme -> clickList -> append(tmp);
377  return (long)tmp;
378 }
379 
380 long createClickArea(long widget, long x, long y, long w, long h, char* text) {
381 
382  karamba* currTheme = (karamba*)widget;
383  ClickArea *tmp = new ClickArea(currTheme, x, y, w, h );
384  TQString onclick;
385 
386  onclick.setAscii(text);
387 
388  tmp->setOnClick(onclick );
389 
390  currTheme -> clickList -> append(tmp);
391  return (long)tmp;
392 }
393 
394 PyObject* py_remove_click_area(PyObject *, PyObject *args)
395 {
396  long widget, click;
397  if (!PyArg_ParseTuple(args, (char*)"ll:removeClickArea", &widget, &click))
398  return NULL;
399  return Py_BuildValue((char*)"l", removeClickArea(widget, click));
400 }
401 
402 PyObject* py_create_service_click_area(PyObject *, PyObject *args)
403 {
404  long widget, x, y, w, h;
405  char *name;
406  char *exec;
407  char *icon;
408  if (!PyArg_ParseTuple(args, (char*)"lllllsss:createServiceClickArea", &widget, &x, &y,
409  &w, &h, &name, &exec, &icon))
410  return NULL;
411  return Py_BuildValue((char*)"l", createServiceClickArea(widget, x, y, w, h, name, exec, icon));
412 }
413 
414 PyObject* py_create_click_area(PyObject *, PyObject *args)
415 {
416  long widget, x, y, w, h;
417  char *text;
418  if (!PyArg_ParseTuple(args, (char*)"llllls:createClickArea", &widget, &x, &y,
419  &w, &h, &text))
420  return NULL;
421  if (!checkKaramba(widget))
422  return NULL;
423  return Py_BuildValue((char*)"l", createClickArea(widget, x, y, w, h, text));
424 }
425 
426 static long callTheme(long widget, char* path, char *str)
427 {
428  karamba* currTheme = (karamba*) widget;
429 
430  if (currTheme)
431  currTheme->callTheme(TQString(path), TQString(str));
432 
433  return (long)currTheme;
434 }
435 
436 static long setIncomingData(long widget, char* path, char *obj)
437 {
438  karamba* currTheme = (karamba*) widget;
439 
440  if (currTheme)
441  currTheme->setIncomingData(TQString(path), TQString(obj));
442 
443  return (long)currTheme;
444 }
445 
446 static TQString getIncomingData(long widget)
447 {
448  karamba* currTheme = (karamba*) widget;
449 
450  if (currTheme)
451  return currTheme->getIncomingData();
452 
453  return TQString("");
454 }
455 
456 /*
457  * openNamedTheme. this function checks to see whether the theme
458  * being opened is unique or not (against all running karamba widgets).
459  * this is important, as loading themes with the same name causes
460  * grief.
461  */
462 long openNamedTheme(char* path, char *name, bool is_sub_theme) {
463 
464  TQString filename;
465  karamba* currTheme = 0;
466 
467  filename.setAscii(path);
468 
469  TQFileInfo file( filename );
470 
471  if( file.exists() )
472  {
473  TQCString prettyName(name);
474  KarambaApplication* app = (KarambaApplication*)tqApp;
475  if (!app->themeExists(prettyName))
476  {
477  currTheme = new karamba( filename, prettyName, false ,
478  -1, is_sub_theme);
479  currTheme->show();
480  }
481  }
482  return (long)currTheme;
483 }
484 
485 /* now a method we need to expose to Python */
486 long openTheme(char* path)
487 {
488 
489  TQString filename;
490  karamba* currTheme = 0;
491 
492  filename.setAscii(path);
493 
494  TQFileInfo file( filename );
495 
496  if( file.exists() )
497  {
498  currTheme = new karamba( filename, TQString() );
499  currTheme->show();
500  }
501 
502  return (long)currTheme;
503 }
504 
505 PyObject* py_get_incoming_data(PyObject *, PyObject *args)
506 {
507  long widget;
508  if (!PyArg_ParseTuple(args, (char*)"l:getIncomingData", &widget))
509  return NULL;
510  return Py_BuildValue((char*)"O", TQString2PyString(getIncomingData(widget)));
511 }
512 
513 PyObject* py_set_incoming_data(PyObject *, PyObject *args)
514 {
515  char *themePath;
516  long widget;
517  char *obj;
518  if (!PyArg_ParseTuple(args, (char*)"lss:setIncomingData", &widget, &themePath, &obj))
519  return NULL;
520  return Py_BuildValue((char*)"l", setIncomingData(widget, themePath, obj));
521 }
522 
523 PyObject* py_call_theme(PyObject *, PyObject *args)
524 {
525  char *themePath;
526  char *str;
527  long widget;
528  if (!PyArg_ParseTuple(args, (char*)"lss:callTheme", &widget, &themePath, &str))
529  return NULL;
530  return Py_BuildValue((char*)"l", callTheme(widget, themePath, str));
531 }
532 
533 PyObject* py_open_named_theme(PyObject *, PyObject *args)
534 {
535  char *themePath;
536  char *themeName;
537  long is_sub_theme;
538  if (!PyArg_ParseTuple(args, (char*)"ssl:openNamedTheme", &themePath, &themeName, &is_sub_theme))
539  return NULL;
540  return Py_BuildValue((char*)"l", openNamedTheme(themePath, themeName, is_sub_theme ? true : false));
541 }
542 
543 PyObject* py_open_theme(PyObject *, PyObject *args)
544 {
545  char *themePath;
546  if (!PyArg_ParseTuple(args, (char*)"s:openTheme", &themePath))
547  return NULL;
548  return Py_BuildValue((char*)"l", openTheme(themePath));
549 }
550 
551 PyObject* py_reload_theme(PyObject *, PyObject *args)
552 {
553  long widget;
554  if (!PyArg_ParseTuple(args, (char*)"l:reloadTheme", &widget))
555  return NULL;
556  if (!checkKaramba(widget))
557  return NULL;
558  ((karamba*)widget)->reloadConfig();
559  return Py_BuildValue((char*)"l", 1);
560 }
561 
562 /* now a method we need to expose to Python */
563 int getNumberOfDesktops(long widget)
564 {
565  karamba* currTheme = (karamba*)widget;
566 
567  return currTheme->kWinModule->numberOfDesktops();
568 }
569 
570 PyObject* py_get_number_of_desktops(PyObject *, PyObject *args)
571 {
572  long widget;
573  if (!PyArg_ParseTuple(args, (char*)"l:getNumberOfDesktops", &widget))
574  return NULL;
575  if (!checkKaramba(widget))
576  return NULL;
577  return Py_BuildValue((char*)"l", getNumberOfDesktops(widget));
578 }
579 
580 /* now a method we need to expose to Python */
581 int translateAll(long widget, int x, int y)
582 {
583  karamba* currTheme = (karamba*)widget;
584 
585  TQObjectListIt it2( *currTheme->meterList ); // iterate over meters
586 
587  while ( it2 != 0 )
588  {
589  ((Meter*) *it2)->setSize(((Meter*) *it2)->getX()+x,
590  ((Meter*) *it2)->getY()+y,
591  ((Meter*) *it2)->getWidth(),
592  ((Meter*) *it2)->getHeight());
593  ++it2;
594  }
595 
596  if (currTheme->systray != 0)
597  {
598  currTheme->systray->move(currTheme->systray->x()+x,
599  currTheme->systray->y()+y);
600  }
601  return 0;
602 }
603 
604 PyObject* py_translate_all(PyObject *, PyObject *args)
605 {
606  long widget;
607  int x, y;
608  if (!PyArg_ParseTuple(args, (char*)"lii:translateAll", &widget, &x, &y))
609  return NULL;
610  if (!checkKaramba(widget))
611  return NULL;
612  return Py_BuildValue((char*)"lii", translateAll(widget, x, y));
613 }
614 
615 /* now a method we need to expose to Python */
616 int show(long widget)
617 {
618  karamba* currTheme = (karamba*)widget;
619  currTheme->show();
620  return 0;
621 }
622 
623 PyObject* py_show(PyObject *, PyObject *args)
624 {
625  long widget;
626  if (!PyArg_ParseTuple(args, (char*)"l:show", &widget))
627  return NULL;
628  if (!checkKaramba(widget))
629  return NULL;
630  return Py_BuildValue((char*)"l", show(widget));
631 }
632 
633 /* now a method we need to expose to Python */
634 int hide(long widget)
635 {
636  karamba* currTheme = (karamba*)widget;
637  currTheme->hide();
638  return 0;
639 }
640 
641 PyObject* py_hide(PyObject *, PyObject *args)
642 {
643  long widget;
644  if (!PyArg_ParseTuple(args, (char*)"l:hide", &widget))
645  return NULL;
646  if (!checkKaramba(widget))
647  return NULL;
648  return Py_BuildValue((char*)"l", hide(widget));
649 }
650 
651 /*Putting includes here to show the dependency for the call(s) below (if we ever decide to move the networking callbacks into a separate file*/
652 #include <sys/socket.h>
653 #include <sys/ioctl.h>
654 #include <net/if.h>
655 #include <arpa/inet.h>
656 #if defined(__FreeBSD__) || defined(__DragonFly__)
657 #include <netinet/in.h>
658 #endif
659 #if defined(Q_OS_SOLARIS)
660 #include <sys/sockio.h>
661 #endif
662 /* now a method we need to expose to Python */
663 TQString getIp(char *device_name)
664 {
665  int i, sd, numdevs;
666  struct ifconf ifc_conf;
667  char ifc_conf_buf[sizeof ( struct ifreq ) * 32];
668  struct ifreq *devptr;
669  int ifc_conf_buf_size;
670  static struct in_addr host;
671  TQString retval;
672 
673  retval = "Disconnected";
674 
675  /*
676  * Open a socket, any type will do so we choose UDP, and ask it with
677  * an ioctl call what devices are behind it.
678  */
679  if ((sd = socket(AF_INET,SOCK_DGRAM,0)) < 0)
680  {
681  tqWarning("Error: Unable to create socket (socket)");
682  return "Error";
683  }
684 
685  /*
686  * Fill the buffer with our static buffer, probably big enough, and get
687  * the interface configuration.
688  */
689  ifc_conf_buf_size = sizeof ifc_conf_buf;
690  ifc_conf.ifc_len = ifc_conf_buf_size;
691  ifc_conf.ifc_buf = ifc_conf_buf;
692  if (ioctl(sd,SIOCGIFCONF,&ifc_conf) < 0)
693  {
694  tqWarning("Error: Unable to get network interface conf (ioctl)");
695  close(sd);
696  return "Error";
697  }
698 
699  /*
700  * An array of devices were returned. Which ones are up right now and
701  * have broadcast capability?
702  */
703  numdevs = ifc_conf.ifc_len / sizeof (struct ifreq);
704  //tqDebug("numdevs = %d", numdevs);
705  for (i = 0; i < numdevs; i++)
706  {
707  //tqDebug("iterations: %d", i);
708  /* devptr points into an array of ifreq structs. */
709  devptr = &ifc_conf.ifc_req[i];
710 
711  if (ioctl(sd, SIOCGIFADDR, devptr) < 0 || devptr->ifr_addr.sa_family != AF_INET)
712  continue;
713 
714  if (ioctl(sd,SIOCGIFFLAGS,devptr) < 0)
715  {
716  tqWarning("Error: Unable to get device interface flags (ioctl).");
717  close(sd);
718  return "Error";
719  }
720 
721  //We generally don't want probing of the loopback devices
722  if ((devptr->ifr_flags & IFF_LOOPBACK) != 0)
723  continue;
724 
725  if ((devptr->ifr_flags & IFF_UP) == 0)
726  continue;
727 
728  if ((devptr->ifr_flags & IFF_BROADCAST) == 0)
729  continue;
730 
731  /* Get the broadcast address. */
732  if (ioctl(sd,SIOCGIFFLAGS,devptr) < 0)
733  {
734  tqWarning("Error: Unable to get device interface flags (ioctl).");
735  close(sd);
736  return "Error";
737  }
738  else
739  {
740  if (!strcmp((char*)devptr->ifr_name, device_name))
741  {
742  host.s_addr = ((struct sockaddr_in*)&devptr->ifr_addr)->sin_addr.s_addr;
743  retval = inet_ntoa(host);
744  break;
745  }
746  }
747  }
748  close(sd);
749  return retval;
750 }
751 
752 PyObject* py_set_update_time(PyObject *, PyObject *args)
753 {
754  long widget;
755  double time;
756  if (!PyArg_ParseTuple(args, (char*)"ld:setUpdateTime", &widget, &time))
757  return NULL;
758  karamba* currTheme = (karamba*)widget;
759  currTheme->setUpdateTime(time);
760  return Py_BuildValue((char*)"l", 1);
761 }
762 
763 PyObject* py_get_update_time(PyObject *, PyObject *args)
764 {
765  long widget;
766  double time;
767  if (!PyArg_ParseTuple(args, (char*)"l:getUpdateTime", &widget, &time))
768  return NULL;
769  karamba* currTheme = (karamba*)widget;
770  return Py_BuildValue((char*)"d", currTheme->getUpdateTime());
771 }
772 
773 PyObject* py_get_ip(PyObject *, PyObject *args)
774 {
775  long widget;
776  char *interface;
777  if (!PyArg_ParseTuple(args, (char*)"ls:getIp", &widget, &interface))
778  return NULL;
779  if (!checkKaramba(widget))
780  return NULL;
781  return Py_BuildValue((char*)"O", TQString2PyString(getIp(interface)));
782 }
783 
784 static void management_popup(long widget)
785 {
786  karamba* currTheme = (karamba*)widget;
787  currTheme->management_popup();
788 }
789 
790 PyObject* py_management_popup(PyObject *, PyObject *args)
791 {
792  long widget;
793  if (!PyArg_ParseTuple(args, (char*)"l:managementPopup", &widget))
794  return NULL;
795  if (!checkKaramba(widget))
796  return NULL;
797  management_popup(widget);
798  return Py_BuildValue((char*)"l", 1);
799 }
800 
801 static void set_want_right_button(long widget, long yesno)
802 {
803  karamba* currTheme = (karamba*)widget;
804  currTheme->setWantRightButton(yesno);
805 }
806 
807 PyObject* py_want_right_button(PyObject *, PyObject *args)
808 {
809  long widget, i;
810  if (!PyArg_ParseTuple(args, (char*)"ll:setWantRightButton", &widget, &i))
811  return NULL;
812  if (!checkKaramba(widget))
813  return NULL;
814  set_want_right_button(widget, i);
815  return Py_BuildValue((char*)"l", 1);
816 }
817 
818 static void set_want_wheel_event(long widget, long yesno)
819 {
820  karamba* currTheme = (karamba*)widget;
821  currTheme->setWantMeterWheelEvent(yesno);
822 }
823 
824 PyObject* py_want_wheel_event(PyObject *, PyObject *args)
825 {
826  long widget, i;
827  if (!PyArg_ParseTuple(args, (char*)"ll:setWantMeterWheelEvent", &widget, &i))
828  return NULL;
829  if (!checkKaramba(widget))
830  return NULL;
831  set_want_wheel_event(widget, i);
832  return Py_BuildValue((char*)"l", 1);
833 }
834 
835 static void changeInterval(long widget, long interval)
836 {
837  karamba* currTheme = (karamba*)widget;
838  currTheme->changeInterval(interval);
839 }
840 
841 PyObject* py_change_interval(PyObject *, PyObject *args)
842 {
843  long widget, i;
844  if (!PyArg_ParseTuple(args, (char*)"ll:changeInterval", &widget, &i))
845  return NULL;
846  if (!checkKaramba(widget))
847  return NULL;
848  changeInterval(widget, i);
849  return Py_BuildValue((char*)"l", 1);
850 }
851 
852 
py_hide
PyObject * py_hide(PyObject *self, PyObject *args)
Misc/hide.
Definition: misc_python.cpp:641
py_reload_theme
PyObject * py_reload_theme(PyObject *self, PyObject *args)
Misc/reloadTheme.
Definition: misc_python.cpp:551
py_get_theme_path
PyObject * py_get_theme_path(PyObject *self, PyObject *args)
Misc/getThemePath.
Definition: misc_python.cpp:283
py_show
PyObject * py_show(PyObject *self, PyObject *args)
Misc/show.
Definition: misc_python.cpp:623
py_execute_command_interactive
PyObject * py_execute_command_interactive(PyObject *self, PyObject *args)
Misc/executeInteractive.
Definition: misc_python.cpp:108
py_attach_clickArea
PyObject * py_attach_clickArea(PyObject *self, PyObject *args, PyObject *dict)
Misc/attachClickArea.
Definition: misc_python.cpp:201
py_management_popup
PyObject * py_management_popup(PyObject *self, PyObject *args)
Misc/managementPopup.
Definition: misc_python.cpp:790
py_remove_click_area
PyObject * py_remove_click_area(PyObject *self, PyObject *args)
Misc/removeClickArea.
Definition: misc_python.cpp:394
py_toggle_show_desktop
PyObject * py_toggle_show_desktop(PyObject *self, PyObject *args)
Misc/toggleShowDesktop.
Definition: misc_python.cpp:251
py_get_ip
PyObject * py_get_ip(PyObject *self, PyObject *args)
Misc/getIp.
Definition: misc_python.cpp:773
py_get_update_time
PyObject * py_get_update_time(PyObject *self, PyObject *args)
Misc/getUpdateTime.
Definition: misc_python.cpp:763
py_create_click_area
PyObject * py_create_click_area(PyObject *self, PyObject *args)
Misc/createClickArea.
Definition: misc_python.cpp:414
py_set_incoming_data
PyObject * py_set_incoming_data(PyObject *self, PyObject *args)
Misc/setIncomingData.
Definition: misc_python.cpp:513
py_userLanguages
PyObject * py_userLanguages(PyObject *self, PyObject *args)
Misc/userLanguages.
Definition: misc_python.cpp:314
py_userLanguage
PyObject * py_userLanguage(PyObject *self, PyObject *args)
Misc/userLanguage.
Definition: misc_python.cpp:304
py_change_interval
PyObject * py_change_interval(PyObject *self, PyObject *args)
Misc/changeInterval.
Definition: misc_python.cpp:841
py_set_update_time
PyObject * py_set_update_time(PyObject *self, PyObject *args)
Misc/setUpdateTime.
Definition: misc_python.cpp:752
misc_python.h
These are global functions that are used to interpret certain Python calls.
py_execute_command
PyObject * py_execute_command(PyObject *self, PyObject *args)
Misc/execute.
Definition: misc_python.cpp:98
py_run_command
PyObject * py_run_command(PyObject *self, PyObject *args)
Misc/run.
Definition: misc_python.cpp:68
py_open_named_theme
PyObject * py_open_named_theme(PyObject *self, PyObject *args)
Misc/openNamedTheme.
Definition: misc_python.cpp:533
ClickArea
Hans Karlsson.
Definition: clickarea.h:40
ShowDesktop
Singleton class that handles desktop access (minimizing all windows)
Definition: showdesktop.h:30
py_get_number_of_desktops
PyObject * py_get_number_of_desktops(PyObject *self, PyObject *args)
Misc/getNumberOfDesktop.
Definition: misc_python.cpp:570
py_accept_drops
PyObject * py_accept_drops(PyObject *self, PyObject *args)
Misc/acceptDrops.
Definition: misc_python.cpp:56
py_get_pretty_name
PyObject * py_get_pretty_name(PyObject *self, PyObject *args)
Misc/getPrettyThemeName.
Definition: misc_python.cpp:268
py_want_right_button
PyObject * py_want_right_button(PyObject *self, PyObject *args)
Misc/setWantRightButton.
Definition: misc_python.cpp:807
py_want_wheel_event
PyObject * py_want_wheel_event(PyObject *, PyObject *args)
Misc/setWantMeterWheelEvent.
Definition: misc_python.cpp:824
py_open_theme
PyObject * py_open_theme(PyObject *self, PyObject *args)
Misc/openTheme.
Definition: misc_python.cpp:543
py_read_theme_file
PyObject * py_read_theme_file(PyObject *self, PyObject *args)
Misc/readThemeFile.
Definition: misc_python.cpp:336
py_create_service_click_area
PyObject * py_create_service_click_area(PyObject *self, PyObject *args)
Misc/createServiceClickArea.
Definition: misc_python.cpp:402
py_language
PyObject * py_language(PyObject *self, PyObject *args)
Misc/language.
Definition: misc_python.cpp:293
py_get_incoming_data
PyObject * py_get_incoming_data(PyObject *self, PyObject *args)
Misc/getIncomingData.
Definition: misc_python.cpp:505
py_translate_all
PyObject * py_translate_all(PyObject *self, PyObject *args)
Misc/translateAll.
Definition: misc_python.cpp:604
py_call_theme
PyObject * py_call_theme(PyObject *self, PyObject *args)
Misc/callTheme.
Definition: misc_python.cpp:523

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.8.13
This website is maintained by Timothy Pearson.