Gui: remove Py2 code from several src/Gui .cpp files
This commit is contained in:
@@ -77,11 +77,7 @@ PyObject* CommandPy::listAll(PyObject *args)
|
||||
PyObject* pyList = PyList_New(cmds.size());
|
||||
int i=0;
|
||||
for ( std::vector<Command*>::iterator it = cmds.begin(); it != cmds.end(); ++it ) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject* str = PyUnicode_FromString((*it)->getName());
|
||||
#else
|
||||
PyObject* str = PyString_FromString((*it)->getName());
|
||||
#endif
|
||||
PyList_SetItem(pyList, i++, str);
|
||||
}
|
||||
return pyList;
|
||||
@@ -123,11 +119,7 @@ PyObject* CommandPy::listByShortcut(PyObject *args)
|
||||
PyObject* pyList = PyList_New(matches.size());
|
||||
int i=0;
|
||||
for (std::string match : matches) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject* str = PyUnicode_FromString(match.c_str());
|
||||
#else
|
||||
PyObject* str = PyString_FromString(match.c_str());
|
||||
#endif
|
||||
PyList_SetItem(pyList, i++, str);
|
||||
}
|
||||
return pyList;
|
||||
@@ -178,11 +170,7 @@ PyObject* CommandPy::getShortcut(PyObject *args)
|
||||
|
||||
Command* cmd = this->getCommandPtr();
|
||||
if (cmd) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject* str = PyUnicode_FromString(cmd->getAction() ? cmd->getAction()->shortcut().toString().toStdString().c_str() : "");
|
||||
#else
|
||||
PyObject* str = PyString_FromString(cmd->getAction() ? cmd->getAction()->shortcut().toString().toStdString().c_str() : "");
|
||||
#endif
|
||||
return str;
|
||||
}
|
||||
else {
|
||||
@@ -283,21 +271,12 @@ PyObject* CommandPy::getInfo(PyObject *args)
|
||||
if (action)
|
||||
shortcutTxt = action->shortcut().toString().toStdString();
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject* strMenuTxt = PyUnicode_FromString(menuTxt ? menuTxt : "");
|
||||
PyObject* strTooltipTxt = PyUnicode_FromString(tooltipTxt ? tooltipTxt : "");
|
||||
PyObject* strWhatsThisTxt = PyUnicode_FromString(whatsThisTxt ? whatsThisTxt : "");
|
||||
PyObject* strStatustipTxt = PyUnicode_FromString(statustipTxt ? statustipTxt : "");
|
||||
PyObject* strPixMapTxt = PyUnicode_FromString(pixMapTxt ? pixMapTxt : "");
|
||||
PyObject* strShortcutTxt = PyUnicode_FromString(!shortcutTxt.empty() ? shortcutTxt.c_str() : "");
|
||||
#else
|
||||
PyObject* strMenuTxt = PyString_FromString(menuTxt ? menuTxt : "");
|
||||
PyObject* strTooltipTxt = PyString_FromString(tooltipTxt ? tooltipTxt : "");
|
||||
PyObject* strWhatsThisTxt = PyString_FromString(whatsThisTxt ? whatsThisTxt : "");
|
||||
PyObject* strStatustipTxt = PyString_FromString(statustipTxt ? statustipTxt : "");
|
||||
PyObject* strPixMapTxt = PyString_FromString(pixMapTxt ? pixMapTxt : "");
|
||||
PyObject* strShortcutTxt = PyString_FromString(!shortcutTxt.empty() ? shortcutTxt.c_str() : "");
|
||||
#endif
|
||||
PyList_SetItem(pyList, 0, strMenuTxt);
|
||||
PyList_SetItem(pyList, 1, strTooltipTxt);
|
||||
PyList_SetItem(pyList, 2, strWhatsThisTxt);
|
||||
|
||||
Reference in New Issue
Block a user