Set destructor = NULL in destroy func to prevent it being called twice
[luakit.git] / widget.h
blob9cc183c18e99e32bd0e0346fe58f2f22ff070e14
1 /*
2 * widget.h - widget managing header
4 * Copyright (C) 2010 Mason Larobina <mason.larobina@gmail.com>
5 * Copyright (C) 2007-2009 Julien Danjou <julien@danjou.info>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef LUAKIT_WIDGET_H
23 #define LUAKIT_WIDGET_H
25 typedef struct widget_t widget_t;
27 #include <gtk/gtk.h>
28 #include "luakit.h"
29 #include "common/util.h"
30 #include "common/luaclass.h"
31 #include "common/luaobject.h"
32 #include "luah.h"
34 typedef widget_t *(widget_constructor_t)(widget_t *);
35 typedef void (widget_destructor_t)(widget_t *);
37 widget_constructor_t widget_entry;
38 widget_constructor_t widget_eventbox;
39 widget_constructor_t widget_hbox;
40 widget_constructor_t widget_label;
41 widget_constructor_t widget_notebook;
42 widget_constructor_t widget_textbutton;
43 widget_constructor_t widget_vbox;
44 widget_constructor_t widget_webview;
45 widget_constructor_t widget_window;
47 typedef const struct {
48 luakit_token_t tok;
49 const gchar *name;
50 widget_constructor_t *wc;
51 } widget_info_t;
53 /* Widget */
54 struct widget_t
56 LUA_OBJECT_HEADER
57 /* Widget type information */
58 widget_info_t *info;
59 /* Widget destructor */
60 widget_destructor_t *destructor;
61 /* Index function */
62 gint (*index)(lua_State *, luakit_token_t);
63 /* Newindex function */
64 gint (*newindex)(lua_State *, luakit_token_t);
65 /* Lua object ref */
66 gpointer ref;
67 /* Main gtk widget */
68 GtkWidget *widget;
69 /* Misc private data */
70 gpointer data;
73 lua_class_t widget_class;
74 void widget_class_setup(lua_State *);
76 #endif
78 // vim: ft=c:et:sw=4:ts=8:sts=4:tw=80