2 * widgets/textbutton.c - gtk button with label
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_textbutton_index(lua_State
*L
, luakit_token_t token
)
28 widget_t
*w
= luaH_checkudata(L
, 1, &widget_class
);
32 LUAKIT_WIDGET_INDEX_COMMON
34 /* push string properties */
35 PS_CASE(LABEL
, gtk_button_get_label(GTK_BUTTON(w
->widget
)))
44 luaH_textbutton_newindex(lua_State
*L
, luakit_token_t token
)
47 widget_t
*w
= luaH_checkudata(L
, 1, &widget_class
);
52 gtk_button_set_label(GTK_BUTTON(w
->widget
),
53 luaL_checklstring(L
, 3, &len
));
60 return luaH_object_emit_property_signal(L
, 1);
64 clicked_cb(GtkWidget
*b
, widget_t
*w
)
67 lua_State
*L
= globalconf
.L
;
68 luaH_object_push(L
, w
->ref
);
69 luaH_object_emit_signal(L
, -1, "clicked", 0, 0);
74 widget_textbutton(widget_t
*w
)
76 w
->index
= luaH_textbutton_index
;
77 w
->newindex
= luaH_textbutton_newindex
;
78 w
->destructor
= widget_destructor
;
80 w
->widget
= gtk_button_new();
81 g_object_set_data(G_OBJECT(w
->widget
), "widget", (gpointer
) w
);
82 gtk_button_set_focus_on_click(GTK_BUTTON(w
->widget
), FALSE
);
84 g_object_connect((GObject
*)w
->widget
,
85 "signal::clicked", (GCallback
)clicked_cb
, w
,
86 "signal::focus-in-event", (GCallback
)focus_cb
, w
,
87 "signal::focus-out-event", (GCallback
)focus_cb
, w
,
88 "signal::parent-set", (GCallback
)parent_set_cb
, w
,
91 gtk_widget_show(w
->widget
);
95 // vim: ft=c:et:sw=4:ts=8:sts=4:tw=80