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
);
32 LUAKIT_WIDGET_INDEX_COMMON
33 LUAKIT_WIDGET_BIN_INDEX_COMMON
35 /* push string properties */
36 PS_CASE(BG
, g_object_get_data(G_OBJECT(w
->widget
), "bg"))
45 luaH_eventbox_newindex(lua_State
*L
, luakit_token_t token
)
48 widget_t
*w
= luaH_checkudata(L
, 1, &widget_class
);
55 tmp
= luaL_checklstring(L
, 3, &len
);
56 if (!gdk_color_parse(tmp
, &c
))
57 luaL_argerror(L
, 3, "unable to parse colour");
58 gtk_widget_modify_bg(GTK_WIDGET(w
->widget
), GTK_STATE_NORMAL
, &c
);
59 g_object_set_data_full(G_OBJECT(w
->widget
), "bg", g_strdup(tmp
), g_free
);
66 return luaH_object_emit_property_signal(L
, 1);
70 widget_eventbox(widget_t
*w
)
72 w
->index
= luaH_eventbox_index
;
73 w
->newindex
= luaH_eventbox_newindex
;
74 w
->destructor
= widget_destructor
;
76 w
->widget
= gtk_event_box_new();
77 g_object_set_data(G_OBJECT(w
->widget
), "widget", (gpointer
) w
);
78 gtk_widget_show(w
->widget
);
80 g_object_connect((GObject
*)w
->widget
,
81 "signal::add", (GCallback
)add_cb
, w
,
82 "signal::button-release-event", (GCallback
)button_release_cb
, w
,
83 "signal::parent-set", (GCallback
)parent_set_cb
, w
,
84 "signal::remove", (GCallback
)remove_cb
, w
,
90 // vim: ft=c:et:sw=4:ts=8:sts=4:tw=80