Beispiel #1
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;
  }
Beispiel #2
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;
  }
Beispiel #3
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;
  }
Beispiel #4
0
 PyObject* XBMCGUI_GetCurrentWindowDialogId(PyObject *self, PyObject *args)
 {
   PyXBMCGUILock();
   int id = g_windowManager.GetTopMostModalDialogID();
   PyXBMCGUIUnlock();
   return Py_BuildValue((char*)"l", id);
 }
Beispiel #5
0
 PyObject* XBMCGUI_GetCurrentWindowId(PyObject *self, PyObject *args)
 {
   PyXBMCGUILock();
   int id = g_windowManager.GetActiveWindow();
   PyXBMCGUIUnlock();
   return Py_BuildValue((char*)"l", id);
 }
Beispiel #6
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");
  }
Beispiel #7
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;
  }
Beispiel #8
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;
  }
Beispiel #9
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;
  }
Beispiel #10
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;
  }
Beispiel #11
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);
  }
Beispiel #12
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);
  }
Beispiel #13
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);
  }
Beispiel #14
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));
  }
Beispiel #15
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;
  }
Beispiel #16
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;
  }
Beispiel #17
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());
  }
Beispiel #18
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);
  }
Beispiel #19
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;
  }
Beispiel #20
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;
  }
Beispiel #21
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* 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;
  }
  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* 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;
  }
Beispiel #25
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;
  }
Beispiel #26
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;
  }
Beispiel #27
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;
  }
  PyObject* ControlList_GetSelectedPosition(ControlList *self, PyObject *args)
  {
    // create message
    ControlList *pControl = (ControlList*)self;
    CGUIMessage msg(GUI_MSG_ITEM_SELECTED, pControl->iParentId, pControl->iControlId);
    long pos = -1;

    // send message
    PyXBMCGUILock();
    if ((self->vecItems.size() > 0) && pControl->pGUIControl)
    {
      pControl->pGUIControl->OnMessage(msg);
      pos = msg.GetParam1();
    }
    PyXBMCGUIUnlock();

    return Py_BuildValue((char*)"l", pos);
  }
  PyObject* ControlList_GetSelectedItem(ControlList *self, PyObject *args)
  {
    // create message
    ControlList *pControl = (ControlList*)self;
    CGUIMessage msg(GUI_MSG_ITEM_SELECTED, pControl->iParentId, pControl->iControlId);
    PyObject* pListItem = Py_None;

    // send message
    PyXBMCGUILock();
    if ((self->vecItems.size() > 0) && pControl->pGUIControl)
    {
      pControl->pGUIControl->OnMessage(msg);
      pListItem = (PyObject*)self->vecItems[msg.GetParam1()];
    }
    PyXBMCGUIUnlock();

    Py_INCREF(pListItem);
    return pListItem;
  }
Beispiel #30
0
  PyObject* Keyboard_SetHiddenInput(Keyboard *self, PyObject *args)
  {
    char bHidden = false;
    if (!PyArg_ParseTuple(args, (char*)"|b", &bHidden)) return NULL;
    self->bHidden = (0 != bHidden);

    CGUIDialogKeyboard *pKeyboard = ((Keyboard*)self)->dlg;
    if(!pKeyboard)
    {
      PyErr_SetString(PyExc_SystemError, "Unable to load keyboard");
      return NULL;
    }

    PyXBMCGUILock();
    pKeyboard->SetHiddenInput(self->bHidden);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }