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
);
33 lua_pushcfunction(L
, luaH_widget_destroy
);
37 lua_pushstring(L
, gtk_button_get_label(GTK_BUTTON(w
->widget
)));
41 lua_pushcfunction(L
, luaH_widget_show
);
45 lua_pushcfunction(L
, luaH_widget_hide
);
55 luaH_textbutton_newindex(lua_State
*L
, luakit_token_t token
)
58 widget_t
*w
= luaH_checkudata(L
, 1, &widget_class
);
63 gtk_button_set_label(GTK_BUTTON(w
->widget
),
64 luaL_checklstring(L
, 3, &len
));
71 return luaH_object_emit_property_signal(L
, 1);
75 clicked_cb(GtkWidget
*b
, widget_t
*w
)
78 lua_State
*L
= globalconf
.L
;
79 luaH_object_push(L
, w
->ref
);
80 luaH_object_emit_signal(L
, -1, "clicked", 0, 0);
85 widget_textbutton(widget_t
*w
)
87 w
->index
= luaH_textbutton_index
;
88 w
->newindex
= luaH_textbutton_newindex
;
89 w
->destructor
= widget_destructor
;
91 w
->widget
= gtk_button_new();
92 g_object_set_data(G_OBJECT(w
->widget
), "widget", (gpointer
) w
);
93 gtk_button_set_focus_on_click(GTK_BUTTON(w
->widget
), FALSE
);
95 g_object_connect((GObject
*)w
->widget
,
96 "signal::clicked", (GCallback
)clicked_cb
, w
,
97 "signal::focus-in-event", (GCallback
)focus_cb
, w
,
98 "signal::focus-out-event", (GCallback
)focus_cb
, w
,
99 "signal::parent-set", (GCallback
)parent_set_cb
, w
,
102 gtk_widget_show(w
->widget
);
106 // vim: ft=c:et:sw=4:ts=8:sts=4:tw=80