static gint luaH_entry_index(lua_State *L, luakit_token_t token) { widget_t *w = luaH_checkwidget(L, 1); switch(token) { LUAKIT_WIDGET_INDEX_COMMON /* push class methods */ PF_CASE(APPEND, luaH_entry_append) PF_CASE(INSERT, luaH_entry_insert) PF_CASE(SELECT_REGION, luaH_entry_select_region) /* push integer properties */ PI_CASE(POSITION, gtk_editable_get_position(GTK_EDITABLE(w->widget))) /* push string properties */ PS_CASE(TEXT, gtk_entry_get_text(GTK_ENTRY(w->widget))) PS_CASE(FG, g_object_get_data(G_OBJECT(w->widget), "fg")) PS_CASE(BG, g_object_get_data(G_OBJECT(w->widget), "bg")) PS_CASE(FONT, g_object_get_data(G_OBJECT(w->widget), "font")) /* push boolean properties */ PB_CASE(SHOW_FRAME, gtk_entry_get_has_frame(GTK_ENTRY(w->widget))) default: break; } return 0; }
static void get_borders (GtkIconEntry *entry, gint *xborder, gint *yborder) { GtkWidget *widget = GTK_WIDGET (entry); gint focus_width; gboolean interior_focus; gtk_widget_style_get (widget, "interior-focus", &interior_focus, "focus-line-width", &focus_width, NULL); if (gtk_entry_get_has_frame (GTK_ENTRY (entry))) { *xborder = widget->style->xthickness; *yborder = widget->style->ythickness; } else { *xborder = 0; *yborder = 0; } if (!interior_focus) { *xborder += focus_width; *yborder += focus_width; } }
static gint luaH_entry_index(lua_State *L, luakit_token_t token) { widget_t *w = luaH_checkudata(L, 1, &widget_class); switch(token) { case L_TK_DESTROY: lua_pushcfunction(L, luaH_widget_destroy); return 1; case L_TK_TEXT: lua_pushstring(L, gtk_entry_get_text(GTK_ENTRY(w->widget))); return 1; case L_TK_FG: lua_pushstring(L, g_object_get_data(G_OBJECT(w->widget), "fg")); return 1; case L_TK_BG: lua_pushstring(L, g_object_get_data(G_OBJECT(w->widget), "bg")); return 1; case L_TK_APPEND: lua_pushcfunction(L, luaH_entry_append); return 1; case L_TK_INSERT: lua_pushcfunction(L, luaH_entry_insert); return 1; case L_TK_GET_POSITION: lua_pushcfunction(L, luaH_entry_get_position); return 1; case L_TK_SET_POSITION: lua_pushcfunction(L, luaH_entry_set_position); return 1; case L_TK_SHOW_FRAME: lua_pushboolean(L, gtk_entry_get_has_frame(GTK_ENTRY(w->widget))); return 1; case L_TK_FONT: lua_pushstring(L, g_object_get_data(G_OBJECT(w->widget), "font")); return 1; case L_TK_SHOW: lua_pushcfunction(L, luaH_widget_show); return 1; case L_TK_HIDE: lua_pushcfunction(L, luaH_widget_hide); return 1; case L_TK_FOCUS: lua_pushcfunction(L, luaH_widget_focus); return 1; default: warn("unknown property: %s", luaL_checkstring(L, 2)); break; } return 0; }