AppWebGuiPy.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <Python.h>
00027 # include <QUrl>
00028 #endif
00029 
00030 #include "BrowserView.h"
00031 #include <Gui/Application.h>
00032 #include <Gui/MainWindow.h>
00033 
00034 /* module functions */
00035 static PyObject * 
00036 openBrowser(PyObject *self, PyObject *args) 
00037 {
00038     const char* Url;
00039     if (! PyArg_ParseTuple(args, "s",&Url))
00040         return NULL; 
00041     
00042     PY_TRY {
00043 
00044         WebGui::BrowserView* pcBrowserView;
00045 
00046         pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());   
00047         pcBrowserView->setWindowTitle(QObject::tr("Browser"));
00048         pcBrowserView->resize(400, 300);
00049         pcBrowserView->load(Url);
00050         Gui::getMainWindow()->addWindow(pcBrowserView);
00051 
00052      } PY_CATCH;
00053 
00054         Py_Return; 
00055 }
00056 
00057 static PyObject * 
00058 openBrowserHTML(PyObject *self, PyObject *args) 
00059 {
00060     const char* HtmlCode;
00061     const char* BaseUrl;
00062     const char* TabName = "Browser";
00063     if (! PyArg_ParseTuple(args, "ss|s",&HtmlCode,&BaseUrl,&TabName))
00064         return NULL; 
00065     
00066     PY_TRY {
00067 
00068         WebGui::BrowserView* pcBrowserView;
00069 
00070         pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());   
00071         pcBrowserView->resize(400, 300);
00072         pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromAscii(BaseUrl)),QString::fromUtf8(TabName));
00073         Gui::getMainWindow()->addWindow(pcBrowserView);
00074 
00075      } PY_CATCH;
00076 
00077         Py_Return; 
00078 }
00079 
00080 /* registration table  */
00081 struct PyMethodDef WebGui_Import_methods[] = {
00082     {"openBrowser"       ,openBrowser     ,  1},                                /* method name, C func ptr, always-tuple */
00083     {"openBrowserHTML"   ,openBrowserHTML ,  1},                                /* method name, C func ptr, always-tuple */
00084     {NULL, NULL}                   /* end of table marker */
00085 };

Generated on Wed Nov 23 18:59:57 2011 for FreeCAD by  doxygen 1.6.1