~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Gui/WorkbenchPyImp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (c) 2007 Werner Mayer <wmayer@users.sourceforge.net>        *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This library is free software; you can redistribute it and/or         *
 
7
 *   modify it under the terms of the GNU Library General Public           *
 
8
 *   License as published by the Free Software Foundation; either          *
 
9
 *   version 2 of the License, or (at your option) any later version.      *
 
10
 *                                                                         *
 
11
 *   This library  is distributed in the hope that it will be useful,      *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU Library General Public License for more details.                  *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU Library General Public     *
 
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
 
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
 
 
24
#include "PreCompiled.h"
 
25
 
 
26
#include "Workbench.h"
 
27
#include "WorkbenchManager.h"
 
28
 
 
29
// inclusion of the generated files (generated out of WorkbenchPy.xml)
 
30
#include "WorkbenchPy.h"
 
31
#include "WorkbenchPy.cpp"
 
32
 
 
33
using namespace Gui;
 
34
 
 
35
/** @class WorkbenchPy
 
36
 * The workbench Python base class doesn't allow you to manipulate the C++ workbench class behind.
 
37
 * You're only allowed either to activate the workbench class or get its name.
 
38
 * The WorkbenchPy class is associated to all C++ workbench classes except of PythonWorkbench.
 
39
 * @see Workbench
 
40
 * @see PythonWorkbench
 
41
 * @see PythonWorkbenchPy
 
42
 * @author Werner Mayer
 
43
 */
 
44
 
 
45
// returns a string which represent the object e.g. when printed in python
 
46
const char *WorkbenchPy::representation(void) const
 
47
{
 
48
    return "<Workbench object>";
 
49
}
 
50
 
 
51
/** Retrieves the workbench name */
 
52
PyObject*  WorkbenchPy::name(PyObject *args)
 
53
{
 
54
    PY_TRY {
 
55
        std::string name = getWorkbenchPtr()->name(); 
 
56
        PyObject* pyName = PyString_FromString(name.c_str());
 
57
        return pyName;
 
58
    }PY_CATCH;
 
59
}
 
60
 
 
61
/** Activates the workbench object */
 
62
PyObject*  WorkbenchPy::activate(PyObject *args)
 
63
{
 
64
    PY_TRY {
 
65
        std::string name = getWorkbenchPtr()->name(); 
 
66
        WorkbenchManager::instance()->activate( name, getWorkbenchPtr()->getTypeId().getName() );
 
67
        Py_Return; 
 
68
    }PY_CATCH;
 
69
}
 
70
 
 
71
PyObject *WorkbenchPy::getCustomAttributes(const char* attr) const
 
72
{
 
73
    return 0;
 
74
}
 
75
 
 
76
int WorkbenchPy::setCustomAttributes(const char* attr, PyObject *obj)
 
77
{
 
78
    return 0; 
 
79
}
 
80
 
 
81