Debian Codegraph @

swig/Fl_Help_View.i

raw
1 /* File : Fl_Help_View.i */
2 //%module Fl_Help_View
3
4 %feature("docstring") ::Fl_Help_View
5 """
6 The Fl_Help_View widget displays HTML text. Most HTML 2.0 elements are
7 supported, as well as a primitive implementation of tables. GIF, JPEG,
8 and PNG images are displayed inline.
9 """ ;
10
11 %{
12 #include "FL/Fl_Help_View.H"
13 %}
14
15 %include "macros.i"
16
17 CHANGE_OWNERSHIP(Fl_Help_View)
18
19 %{
20 #include "CallbackStruct.h"
21 #include <FL/Fl_Button.H>
22
23 //static PyObject *my_pycallback = NULL;
24
25 static const char* PythonLink(Fl_Widget *widget, const char *uri)
26 {
27 PyObject *func, *arglist;
28 PyObject *result;
29 PyObject *obj;
30
31 CallbackStruct *cb = (CallbackStruct *)(widget->user_data());
32
33 if (cb == NULL)
34 return NULL;
35
36 // This is the function ....
37 func = (PyObject *)( cb->link);
38 if (func == NULL) {
39 PyErr_SetString(PyExc_NotImplementedError, "Callable link not found!");
40 return NULL;
41 }
42
43 // always of the same type: Fl_Help_View
44 //obj = SWIG_NewPointerObj(widget, SWIGTYPE_p_Fl_Help_View, 0);
45 // the parent widget
46 obj = (PyObject *)( cb->widget);
47
48 // build arument list
49 arglist = Py_BuildValue("(Os)", obj, uri );
50
51 // call the callback
52 result = PyObject_CallObject(func, arglist);
53
54
55 Py_DECREF(arglist); // Trash arglist
56 Py_XDECREF(result);
57 if (PyErr_Occurred())
58 {
59 PyErr_Print();
60 }
61 #ifndef PYTHON3
62 if (result == Py_None)
63 return NULL;
64 else
65 return PyString_AsString(result); /*void*/;
66 #else
67 return NULL;
68 #endif
69 }
70 %}
71
72 %include "FL/Fl_Help_View.H"
73
74
75 %extend Fl_Help_View {
76 //#include <FL/Fl_Window.H>
77
78 void
79 link(PyObject *PyFunc, PyObject *PyWidget)
80 {
81 // get existing callback structure
82 CallbackStruct *cb = (CallbackStruct*)self->user_data();
83
84 // use the link member to hold the callback
85 if (cb) {
86 cb->link = PyFunc;
87 }
88 else {
89 cb = new CallbackStruct( 0, 0, PyWidget, PyFunc );
90 self->user_data((void*)cb);
91 }
92
93 // Add a reference to new callback
94 Py_INCREF(PyFunc);
95 Py_XINCREF(PyWidget);
96
97 self->link(&PythonLink);
98
99
100 }
101
102 }
103
104
105 %typemap(in) PyObject *PyFunc {
106 if (!PyCallable_Check($input)) {
107 PyErr_SetString(PyExc_TypeError, "Need a callable object!");
108 return NULL;
109 }
110 $1 = $input;
111 }
112
113