From 00e32e2f58f94922f4c257dd8e1f1a8279bec2fd Mon Sep 17 00:00:00 2001 From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Wed, 21 Apr 2010 13:13:28 +0000 Subject: [PATCH] New sip export for python shell git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2080 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gui/pymod/export_gosty.cc | 13 ++---- modules/gui/pymod/export_py_shell.cc | 33 ++++++++----- modules/gui/pymod/python_shell_proxy.hh | 61 ------------------------- 3 files changed, 27 insertions(+), 80 deletions(-) delete mode 100644 modules/gui/pymod/python_shell_proxy.hh diff --git a/modules/gui/pymod/export_gosty.cc b/modules/gui/pymod/export_gosty.cc index 88aacd059..0dc3d1889 100644 --- a/modules/gui/pymod/export_gosty.cc +++ b/modules/gui/pymod/export_gosty.cc @@ -26,11 +26,11 @@ using namespace boost::python; #include <ost/gui/gl_win.hh> #include <ost/gui/perspective.hh> #include <ost/gui/tools/tool_options_win.hh> +#include <ost/gui/python_shell/python_shell.hh> #include "transfer_ownership.hh" #include "sip_handler.hh" -#include "python_shell_proxy.hh" #include "tool_options_win_proxy.hh" #include "scene_win_proxy.hh" #include "sequence_viewer_proxy.hh" @@ -44,11 +44,6 @@ using namespace ost::gui; namespace { -PythonShellProxy app_get_py_shell(GostyApp* app) -{ - return PythonShellProxy(app->GetPyShell()); -} - ToolOptionsWinProxy app_get_tool_options_win(GostyApp* app) { return ToolOptionsWinProxy(app->GetToolOptionsWin()); @@ -100,8 +95,10 @@ void export_Gosty() .def("Instance", &GostyApp::Instance, return_value_policy<reference_existing_object>()).staticmethod("Instance") .def("SetAppTitle", &GostyApp::SetAppTitle) - .def("GetPyShell", &app_get_py_shell) - .add_property("py_shell", &app_get_py_shell) + .def("GetPyShell", &GostyApp::GetPyShell, + return_value_policy<reference_existing_object>()) + .add_property("py_shell", make_function(&GostyApp::GetPyShell, + return_value_policy<reference_existing_object>())) .def("GetGLWin", &GostyApp::GetGLWin, return_value_policy<reference_existing_object>()) .add_property("gl_win", make_function(&GostyApp::GetGLWin, diff --git a/modules/gui/pymod/export_py_shell.cc b/modules/gui/pymod/export_py_shell.cc index 37ab4534d..fc2785a91 100644 --- a/modules/gui/pymod/export_py_shell.cc +++ b/modules/gui/pymod/export_py_shell.cc @@ -17,25 +17,36 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //------------------------------------------------------------------------------ #include <boost/python.hpp> -#include <boost/python/register_ptr_to_python.hpp> -#include <boost/python/suite/indexing/vector_indexing_suite.hpp> -using namespace boost::python; - -#include <iostream> -#include "python_shell_proxy.hh" +#include <ost/gui/python_shell/python_shell.hh> #include <ost/gui/python_shell/python_shell_widget.hh> +#include "sip_handler.hh" +using namespace boost::python; using namespace ost; using namespace ost::gui; +namespace { + +void pyshell_set_tab_width(PythonShell* py_shell, int width) { + py_shell->PyShell()->SetTabWidth(width); +} + +int pyshell_get_tab_width(PythonShell* py_shell) { + return py_shell->PyShell()->GetTabWidth(); +} + +} + void export_PyShell() { - class_<PythonShellProxy, bases<SipHandlerBase> >("PythonShell", no_init) - .def("Show", &PythonShellProxy::Show) - .def("Hide", &PythonShellProxy::Hide) - .def("SetTabWidth", &PythonShellProxy::SetTabWidth) - .def("GetTabWidth", &PythonShellProxy::GetTabWidth) + class_<PythonShell, boost::noncopyable>("PythonShell", no_init) + .def("Show", &PythonShell::show) + .def("Hide", &PythonShell::hide) + .def("SetTabWidth", &pyshell_set_tab_width) + .def("GetTabWidth", &pyshell_get_tab_width) + .def("GetQObject",&get_py_qobject<PythonShell>) + .add_property("qobject", &get_py_qobject<PythonShell>) ; } diff --git a/modules/gui/pymod/python_shell_proxy.hh b/modules/gui/pymod/python_shell_proxy.hh deleted file mode 100644 index 4d834f7fa..000000000 --- a/modules/gui/pymod/python_shell_proxy.hh +++ /dev/null @@ -1,61 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2010 by the OpenStructure authors -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License as published by the Free -// Software Foundation; either version 3.0 of the License, or (at your option) -// any later version. -// This library is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -// details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this library; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ -#ifndef OST_GUI_PYTHON_SHELL_PROXY_HH -#define OST_GUI_PYTHON_SHELL_PROXY_HH - -#include <ost/gui/python_shell/python_shell.hh> -#include <ost/gui/python_shell/python_shell_widget.hh> - -#include "sip_handler.hh" - -namespace ost { namespace gui { - - - -class PythonShellProxy : public SipHandler<PythonShell> { -public: - PythonShellProxy() - : SipHandler<PythonShell>(NULL) {} - - PythonShellProxy(PythonShell* shell) - : SipHandler<PythonShell>(shell) {} - - void Show() - { - Me()->show(); - } - - void Hide() - { - Me()->hide(); - } - - void SetTabWidth(int width) { - Me()->PyShell()->SetTabWidth(width); - } - - int GetTabWidth() { - return Me()->PyShell()->GetTabWidth(); - } - -}; - -}} - -#endif -- GitLab