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; }
// Show keyboard with initial value (aTextString) and replace with result string. // Returns: true - successful display and input (empty result may return true or false depending on parameter) // false - unsucessful display of the keyboard or cancelled editing bool CGUIDialogKeyboard::ShowAndGetInput(CStdString& aTextString, const CVariant &heading, bool allowEmptyResult, bool hiddenInput /* = false */) { CGUIDialogKeyboard *pKeyboard = (CGUIDialogKeyboard*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); if (!pKeyboard) return false; // setup keyboard pKeyboard->Initialize(); pKeyboard->SetHeading(heading); pKeyboard->SetHiddenInput(hiddenInput); pKeyboard->SetText(aTextString); // do this using a thread message to avoid render() conflicts ThreadMessage tMsg = {TMSG_DIALOG_DOMODAL, WINDOW_DIALOG_KEYBOARD, g_windowManager.GetActiveWindow()}; g_application.getApplicationMessenger().SendMessage(tMsg, true); pKeyboard->Close(); // If have text - update this. if (pKeyboard->IsConfirmed()) { aTextString = pKeyboard->GetText(); if (!allowEmptyResult && aTextString.IsEmpty()) return false; return true; } else return false; }
PyObject* Keyboard_SetHeading(Keyboard *self, PyObject *args) { PyObject *line = NULL; if (!PyArg_ParseTuple(args, (char*)"|O", &line)) return NULL; string utf8Line; if (line && !PyGetUnicodeString(utf8Line, line, 1)) return NULL; self->strHeading = utf8Line; CGUIDialogKeyboard *pKeyboard = (CGUIDialogKeyboard*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); if(!pKeyboard) { PyErr_SetString(PyExc_SystemError, "Unable to load keyboard"); return NULL; } pKeyboard->SetHeading(self->strHeading); Py_INCREF(Py_None); return Py_None; }
PyObject* Keyboard_SetHeading(Keyboard *self, PyObject *args) { PyObject *line = NULL; if (!PyArg_ParseTuple(args, (char*)"|O", &line)) return NULL; string utf8Line; if (line && !PyXBMCGetUnicodeString(utf8Line, line, 1)) return NULL; self->strHeading = utf8Line; CGUIDialogKeyboard *pKeyboard = ((Keyboard*)self)->dlg; if(!pKeyboard) { PyErr_SetString(PyExc_SystemError, "Unable to load keyboard"); return NULL; } PyXBMCGUILock(); pKeyboard->SetHeading(self->strHeading); PyXBMCGUIUnlock(); Py_INCREF(Py_None); return Py_None; }
PyObject* Keyboard_DoModal(Keyboard *self, PyObject *args) { CGUIDialogKeyboard *pKeyboard = (CGUIDialogKeyboard*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); if(!pKeyboard) { PyErr_SetString(PyExc_SystemError, "Unable to load virtual keyboard"); return NULL; } pKeyboard->Initialize(); pKeyboard->CenterWindow(); pKeyboard->SetHeading(self->strHeading); CStdString strDefault(self->strDefault); pKeyboard->SetText(strDefault); pKeyboard->SetHiddenInput(self->bHidden); // do modal of dialog ThreadMessage tMsg (TMSG_DIALOG_DOMODAL, WINDOW_DIALOG_KEYBOARD, g_windowManager.GetActiveWindow()); g_application.getApplicationMessenger().SendMessage(tMsg, true); Py_INCREF(Py_None); return Py_None; }