Esempio n. 1
0
  PyObject* WindowXML_GetListItem(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    int listPos = -1;
    if (!PyArg_ParseTuple(args, (char*)"i", &listPos)) return NULL;

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    PyXBMCGUILock();
    CFileItemPtr fi = pwx->GetListItem(listPos);

    if (fi == NULL)
    {
      PyXBMCGUIUnlock();
      PyErr_SetString(PyExc_TypeError, "Index out of range");
      return NULL;
    }

    ListItem* sListItem = (ListItem*)ListItem_Type.tp_alloc(&ListItem_Type, 0);
    sListItem->item = fi;
    PyXBMCGUIUnlock();

    Py_INCREF(sListItem);
    return (PyObject *)sListItem;
  }
Esempio n. 2
0
  PyObject* WindowXML_SetProperty(WindowXML *self, PyObject *args, PyObject *kwds)
  {
    static const char *keywords[] = { "key", "value", NULL };
    char *key = NULL;
    PyObject *value = NULL;

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"sO",
      (char**)keywords,
      &key,
      &value))
    {
      return NULL;
    }
    if (!key || !value) return NULL;

    CStdString uText;
    if (!PyXBMCGetUnicodeString(uText, value, 1))
      return NULL;

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;
    CStdString lowerKey = key;

    PyXBMCGUILock();
    pwx->SetProperty(lowerKey.ToLower(), uText.c_str());
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 3
0
  PyObject* Control_ControlRight(Control* self, PyObject* args)
  {
    Control* pControl;
    if (!PyArg_ParseTuple(args, (char*)"O", &pControl)) return NULL;
    // type checking, object should be of type Control
    if (!Control_Check(pControl))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type Control");
      return NULL;
    }
    if(self->iControlId == 0)
    {
      PyErr_SetString(PyExc_ReferenceError, "Control has to be added to a window first");
      return NULL;
    }

    self->iControlRight = pControl->iControlId;
    PyXBMCGUILock();
    if (self->pGUIControl) self->pGUIControl->SetNavigation(self->iControlUp,
      self->iControlDown,self->iControlLeft,self->iControlRight);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 4
0
  PyObject* Keyboard_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
    Keyboard *self;

    self = (Keyboard*)type->tp_alloc(type, 0);
    if (!self) return NULL;
    new(&self->strDefault) string();
    new(&self->strHeading) string();

    PyObject *line = NULL;
    PyObject *heading = NULL;
    char bHidden = false;
    if (!PyArg_ParseTuple(args, (char*)"|OOb", &line, &heading, &bHidden)) return NULL;

    string utf8Line;
    if (line && !PyXBMCGetUnicodeString(utf8Line, line, 1)) return NULL;
    string utf8Heading;
    if (heading && !PyXBMCGetUnicodeString(utf8Heading, heading, 2)) return NULL;

    self->strDefault = utf8Line;
    self->strHeading = utf8Heading;
    self->bHidden = (0 != bHidden);
    PyXBMCGUILock();
    self->dlg = (CGUIDialogKeyboard*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD);
    PyXBMCGUIUnlock();

    return (PyObject*)self;
  }
Esempio n. 5
0
 PyObject* XBMCGUI_GetCurrentWindowId(PyObject *self, PyObject *args)
 {
   PyXBMCGUILock();
   int id = g_windowManager.GetActiveWindow();
   PyXBMCGUIUnlock();
   return Py_BuildValue((char*)"l", id);
 }
Esempio n. 6
0
 PyObject* XBMCGUI_GetCurrentWindowDialogId(PyObject *self, PyObject *args)
 {
   PyXBMCGUILock();
   int id = g_windowManager.GetTopMostModalDialogID();
   PyXBMCGUIUnlock();
   return Py_BuildValue((char*)"l", id);
 }
Esempio n. 7
0
  PyObject* Keyboard_DoModal(Keyboard *self, PyObject *args)
  {
    CGUIDialogKeyboard *pKeyboard = ((Keyboard*)self)->dlg;
    if(!pKeyboard)
    {
      PyErr_SetString(PyExc_SystemError, "Unable to load virtual keyboard");
      return NULL;
    }
    int autoClose = 0;

    if (!PyArg_ParseTuple(args, (char*)"|i", &autoClose)) return NULL;

    PyXBMCGUILock();
    pKeyboard->Initialize();
    pKeyboard->SetHeading(self->strHeading);
    CStdString strDefault(self->strDefault);
    pKeyboard->SetText(strDefault);
    pKeyboard->SetHiddenInput(self->bHidden);
    if (autoClose > 0)
      pKeyboard->SetAutoClose(autoClose);

    // do modal of dialog
    PyXBMCGUIUnlock();
    PyXBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, WINDOW_DIALOG_KEYBOARD, g_windowManager.GetActiveWindow());

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 8
0
  PyObject* WindowXML_AddItem(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    PyObject *pObject;
    int itemPosition = INT_MAX;
    if (!PyArg_ParseTuple(args, (char*)"O|i", &pObject, &itemPosition)) return NULL;

    string strText;
    ListItem* pListItem = NULL;

    if (ListItem_CheckExact(pObject))
    {
      // object is a listitem
      pListItem = (ListItem*)pObject;
      Py_INCREF(pListItem);
    }
    else
    {
      // object is probably a text item
      if (!PyXBMCGetUnicodeString(strText, pObject, 1)) return NULL;
      // object is a unicode string now, create a new ListItem
      pListItem = ListItem_FromString(strText);
    }

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    // Tells the window to add the item to FileItem vector
    PyXBMCGUILock();
    pwx->AddItem(pListItem->item, itemPosition);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 9
0
  PyObject* ControlButton_GetLabel2(ControlButton *self, PyObject *args)
  {
    if (!self->pGUIControl) return NULL;

    PyXBMCGUILock();
    CStdString label = ((CGUIButtonControl*) self->pGUIControl)->GetLabel2();
    PyXBMCGUIUnlock();

    return PyUnicode_DecodeUTF8(label.c_str(), label.size(), "replace");
  }
Esempio n. 10
0
  PyObject* ControlButton_SetLabel(ControlButton *self, PyObject *args, PyObject *kwds)
  {
    static const char *keywords[] = {
      "label",
      "font",
      "textColor",
      "disabledColor",
      "shadowColor",
      "focusedColor",
      "label2",
      NULL};
    char *cFont = NULL;
    char *cTextColor = NULL;
    char *cDisabledColor = NULL;
    char *cShadowColor = NULL;
    char *cFocusedColor = NULL;
    PyObject *pObjectText = NULL;
    PyObject *pObjectText2 = NULL;

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"|OsssssO",
      (char**)keywords,
      &pObjectText,
      &cFont,
      &cTextColor,
      &cDisabledColor,
      &cShadowColor,
      &cFocusedColor,
      &pObjectText2))
    {
      return NULL;
    }
    if (pObjectText) PyXBMCGetUnicodeString(self->strText, pObjectText, 1);
    if (pObjectText2) PyXBMCGetUnicodeString(self->strText2, pObjectText2, 1);
    if (cFont) self->strFont = cFont;
    if (cTextColor) sscanf(cTextColor, "%x", &self->textColor);
    if (cDisabledColor) sscanf( cDisabledColor, "%x", &self->disabledColor );
    if (cShadowColor) sscanf(cShadowColor, "%x", &self->shadowColor);
    if (cFocusedColor) sscanf(cFocusedColor, "%x", &self->focusedColor);

    PyXBMCGUILock();
    if (self->pGUIControl)
    {
      ((CGUIButtonControl*)self->pGUIControl)->PythonSetLabel(
        self->strFont, self->strText, self->textColor, self->shadowColor, self->focusedColor);
      ((CGUIButtonControl*)self->pGUIControl)->SetLabel2(self->strText2);
      ((CGUIButtonControl*)self->pGUIControl)->PythonSetDisabledColor(self->disabledColor);
    }
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 11
0
  PyObject* Control_SetHeight(Control* self, PyObject* args)
  {
    if (!PyArg_ParseTuple(args, (char*)"l", &self->dwHeight)) return NULL;

    PyXBMCGUILock();
    if (self->pGUIControl) self->pGUIControl->SetHeight((float)self->dwHeight);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 12
0
  PyObject* Control_SetPosition(Control* self, PyObject* args)
  {
    if (!PyArg_ParseTuple(args, (char*)"ll", &self->dwPosX, &self->dwPosY)) return NULL;

    PyXBMCGUILock();
    if (self->pGUIControl) self->pGUIControl->SetPosition((float)self->dwPosX, (float)self->dwPosY);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 13
0
  PyObject* Control_SetEnabled(Control* self, PyObject* args)
  {
    char enabled;
    if (!PyArg_ParseTuple(args, (char*)"b", &enabled)) return NULL;

    PyXBMCGUILock();
    if (self->pGUIControl)   self->pGUIControl->SetEnabled(0 != enabled);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 14
0
  PyObject* WindowXML_ClearList(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    PyXBMCGUILock();
    pwx->ClearList();
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 15
0
  PyObject* ControlCheckMark_GetSelected( ControlCheckMark *self )
  {
    bool isSelected = 0;

    PyXBMCGUILock();
    if (self->pGUIControl)
    {
      isSelected = ((CGUICheckMarkControl*)self->pGUIControl)->GetSelected();
    }
    PyXBMCGUIUnlock();

    return Py_BuildValue((char*)"b", isSelected);
  }
Esempio n. 16
0
  PyObject* WindowXML_GetListSize(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    PyXBMCGUILock();
    int listSize = pwx->GetListSize();
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_BuildValue((char*)"l", listSize);
  }
Esempio n. 17
0
  PyObject* XBMC_GetCondVisibility(PyObject *self, PyObject *args)
  {
    char *cLine = NULL;
    if (!PyArg_ParseTuple(args, (char*)"s", &cLine)) return NULL;

    PyXBMCGUILock();
    int id = g_windowManager.GetTopMostModalDialogID();
    if (id == WINDOW_INVALID) id = g_windowManager.GetActiveWindow();
    PyXBMCGUIUnlock();

    int ret = g_infoManager.TranslateString(cLine);
    return Py_BuildValue((char*)"b", g_infoManager.GetBool(ret,id));
  }
Esempio n. 18
0
  PyObject* WindowXML_GetCurrentListPosition(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    PyXBMCGUILock();
    int listPos = pwx->GetCurrentListPosition();
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_BuildValue((char*)"i", listPos);
  }
Esempio n. 19
0
  PyObject* Control_SetEnableCondition(Control* self, PyObject* args)
  {
    char *cEnable = NULL;

    if (!PyArg_ParseTuple(args, (char*)"s", &cEnable)) return NULL;

    PyXBMCGUILock();
    if (self->pGUIControl)
      self->pGUIControl->SetEnableCondition(cEnable);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 20
0
  PyObject* Keyboard_IsConfirmed(Keyboard *self, PyObject *args)
  {
    CGUIDialogKeyboard *pKeyboard = ((Keyboard*)self)->dlg;
    if(!pKeyboard)
    {
      PyErr_SetString(PyExc_SystemError, "Unable to load keyboard");
      return NULL;
    }

    PyXBMCGUILock();
    bool result = pKeyboard->IsConfirmed();
    PyXBMCGUIUnlock();
    return Py_BuildValue((char*)"b", result);
  }
Esempio n. 21
0
  PyObject* Keyboard_GetText(Keyboard *self, PyObject *args)
  {
    CGUIDialogKeyboard *pKeyboard = ((Keyboard*)self)->dlg;
    if(!pKeyboard)
    {
      PyErr_SetString(PyExc_SystemError, "Unable to load keyboard");
      return NULL;
    }

    PyXBMCGUILock();
    CStdString result = pKeyboard->GetText();
    PyXBMCGUIUnlock();
    return Py_BuildValue((char*)"s", result.c_str());
  }
Esempio n. 22
0
  PyObject* Control_SetVisibleCondition(Control* self, PyObject* args)
  {
    char *cVisible = NULL;
    char bHidden = false;

    if (!PyArg_ParseTuple(args, (char*)"s|b", &cVisible, &bHidden)) return NULL;

    PyXBMCGUILock();
    if (self->pGUIControl)
      self->pGUIControl->SetVisibleCondition(cVisible, bHidden ? "true" : "false");
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 23
0
  PyObject* Control_SetVisible(Control* self, PyObject* args)
  {
    char visible;
    if (!PyArg_ParseTuple(args, (char*)"b", &visible)) return NULL;

    PyXBMCGUILock();
    if (self->pGUIControl)
    {
      self->pGUIControl->SetVisible(0 != visible);
    }
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlImage_SetImage(ControlImage *self, PyObject *args)
  {
    char *cImage = NULL;

    if (!PyArg_ParseTuple(args, (char*)"s", &cImage)) return NULL;

    self->strFileName = cImage;

    PyXBMCGUILock();
    if (self->pGUIControl)
      ((CGUIImage*)self->pGUIControl)->SetFileName(self->strFileName);

    PyXBMCGUIUnlock();
    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlSpin_SetColor(ControlSpin *self, PyObject *args)
  {
    char *cColor = NULL;

    if (!PyArg_ParseTuple(args, (char*)"s", &cColor)) return NULL;

    if (cColor) sscanf(cColor, "%x", &self->color);

    PyXBMCGUILock();
    //if (self->pGUIControl)
      //((CGUISpinControl*)self->pGUIControl)->SetColor(self->dwDColor);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 26
0
  PyObject* WindowXML_SetCurrentListPosition(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    int listPos = -1;
    if (!PyArg_ParseTuple(args, (char*)"i", &listPos)) return NULL;

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    PyXBMCGUILock();
    pwx->SetCurrentListPosition(listPos);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlImage_SetColorDiffuse(ControlImage *self, PyObject *args)
  {
    char *cColorDiffuse = NULL;

    if (!PyArg_ParseTuple(args, (char*)"s", &cColorDiffuse)) return NULL;

    if (cColorDiffuse) sscanf(cColorDiffuse, "%x", &self->colorDiffuse);
    else self->colorDiffuse = 0;

    PyXBMCGUILock();
    if (self->pGUIControl)
      ((CGUIImage *)self->pGUIControl)->SetColorDiffuse(self->colorDiffuse);

    PyXBMCGUIUnlock();
    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 28
0
  PyObject* Control_SetVisibleCondition(Control* self, PyObject* args)
  {
    char *cVisible = NULL;
    char bHidden = false;

    if (!PyArg_ParseTuple(args, (char*)"s|b", &cVisible, &bHidden)) return NULL;

    int ret = g_infoManager.TranslateString(cVisible);

    PyXBMCGUILock();
    if (self->pGUIControl)
      self->pGUIControl->SetVisibleCondition(ret, 0 != bHidden);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 29
0
  PyObject* WindowXML_RemoveItem(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    int itemPosition;
    if (!PyArg_ParseTuple(args, (char*)"i", &itemPosition)) return NULL;

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    // Tells the window to remove the item at the specified position from the FileItem vector
    PyXBMCGUILock();
    pwx->RemoveItem(itemPosition);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Esempio n. 30
0
  PyObject* ControlCheckMark_SetSelected(ControlCheckMark *self, PyObject *args)
  {
    char isSelected = 0;

    if (!PyArg_ParseTuple(args, (char*)"b", &isSelected))
      return NULL;

    PyXBMCGUILock();
    if (self->pGUIControl)
    {
      ((CGUICheckMarkControl*)self->pGUIControl)->SetSelected(0 != isSelected);
    }
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }