2 * widgets/eventbox.c - gtk eventbox widget
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/>.
23 #include "widgets/common.h"
26 luaH_eventbox_index(lua_State
*L
, luakit_token_t token
)
28 widget_t
*w
= luaH_checkudata(L
, 1, &widget_class
);
33 lua_pushcfunction(L
, luaH_widget_set_child
);
37 lua_pushcfunction(L
, luaH_widget_get_child
);
41 lua_pushstring(L
, g_object_get_data(G_OBJECT(w
->widget
), "bg"));
45 lua_pushcfunction(L
, luaH_widget_show
);
49 lua_pushcfunction(L
, luaH_widget_hide
);
59 luaH_eventbox_newindex(lua_State
*L
, luakit_token_t token
)
62 widget_t
*w
= luaH_checkudata(L
, 1, &widget_class
);
69 tmp
= luaL_checklstring(L
, 3, &len
);
70 if (!gdk_color_parse(tmp
, &c
)) {
71 warn("invalid color: %s", tmp
);
75 gtk_widget_modify_bg(GTK_WIDGET(w
->widget
), GTK_STATE_NORMAL
, &c
);
76 g_object_set_data_full(G_OBJECT(w
->widget
), "bg", g_strdup(tmp
), g_free
);
83 return luaH_object_emit_property_signal(L
, 1);
87 eventbox_destructor(widget_t
*w
)
89 gtk_widget_destroy(w
->widget
);
93 widget_eventbox(widget_t
*w
)
95 w
->index
= luaH_eventbox_index
;
96 w
->newindex
= luaH_eventbox_newindex
;
97 w
->destructor
= eventbox_destructor
;
99 w
->widget
= gtk_event_box_new();
100 g_object_set_data(G_OBJECT(w
->widget
), "widget", (gpointer
) w
);
101 gtk_widget_show(w
->widget
);
103 g_object_connect((GObject
*)w
->widget
,
104 "signal::add", (GCallback
)add_cb
, w
,
105 "signal::parent-set", (GCallback
)parent_set_cb
, w
,
106 "signal::remove", (GCallback
)remove_cb
, w
,
112 // vim: ft=c:et:sw=4:ts=8:sts=4:enc=utf-8:tw=80