static gint luaH_label_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(GET_ALIGNMENT, luaH_label_get_alignment); PF_CASE(GET_PADDING, luaH_label_get_padding); PF_CASE(SET_ALIGNMENT, luaH_label_set_alignment); PF_CASE(SET_PADDING, luaH_label_set_padding); PF_CASE(SET_WIDTH, luaH_label_set_width); /* push string properties */ PS_CASE(FG, g_object_get_data(G_OBJECT(w->widget), "fg")) PS_CASE(FONT, g_object_get_data(G_OBJECT(w->widget), "font")) PS_CASE(TEXT, gtk_label_get_label(GTK_LABEL(w->widget))) /* push boolean properties */ PB_CASE(SELECTABLE, gtk_label_get_selectable(GTK_LABEL(w->widget))) default: break; } return 0; }
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 gint luaH_label_index(lua_State *L, widget_t *w, luakit_token_t token) { switch(token) { LUAKIT_WIDGET_INDEX_COMMON(w) case L_TK_PADDING: return luaH_label_get_padding(L, w); case L_TK_ALIGN: return luaH_label_get_align(L, w); /* push string properties */ PS_CASE(FG, g_object_get_data(G_OBJECT(w->widget), "fg")) PS_CASE(FONT, g_object_get_data(G_OBJECT(w->widget), "font")) PS_CASE(TEXT, gtk_label_get_label(GTK_LABEL(w->widget))) /* push boolean properties */ PB_CASE(SELECTABLE, gtk_label_get_selectable(GTK_LABEL(w->widget))) /* push integer properties */ PI_CASE(WIDTH, gtk_label_get_width_chars(GTK_LABEL(w->widget))) default: break; } return 0; }
/* luakit global table. * \param L The Lua VM state. * \return The number of elements pushed on stack. * \luastack * \lfield font The default font. * \lfield font_height The default font height. * \lfield conffile The configuration file which has been loaded. */ static gint luaH_luakit_index(lua_State *L) { if(luaH_usemetatable(L, 1, 2)) return 1; widget_t *w; const gchar *prop = luaL_checkstring(L, 2); luakit_token_t token = l_tokenize(prop); switch(token) { /* push class methods */ PF_CASE(GET_SPECIAL_DIR, luaH_luakit_get_special_dir) PF_CASE(SPAWN, luaH_luakit_spawn) PF_CASE(SPAWN_SYNC, luaH_luakit_spawn_sync) PF_CASE(GET_SELECTION, luaH_luakit_get_selection) PF_CASE(SET_SELECTION, luaH_luakit_set_selection) PF_CASE(EXEC, luaH_exec) /* push string properties */ PS_CASE(CACHE_DIR, globalconf.cache_dir) PS_CASE(CONFIG_DIR, globalconf.config_dir) PS_CASE(DATA_DIR, globalconf.data_dir) PS_CASE(EXECPATH, globalconf.execpath) PS_CASE(CONFPATH, globalconf.confpath) /* push boolean properties */ PB_CASE(VERBOSE, globalconf.verbose) /* push integer properties */ PI_CASE(WEBKIT_MAJOR_VERSION, webkit_major_version()) PI_CASE(WEBKIT_MINOR_VERSION, webkit_minor_version()) PI_CASE(WEBKIT_MICRO_VERSION, webkit_micro_version()) PI_CASE(WEBKIT_USER_AGENT_MAJOR_VERSION, WEBKIT_USER_AGENT_MAJOR_VERSION) PI_CASE(WEBKIT_USER_AGENT_MINOR_VERSION, WEBKIT_USER_AGENT_MINOR_VERSION) case L_TK_WINDOWS: lua_newtable(L); for (guint i = 0; i < globalconf.windows->len; i++) { w = globalconf.windows->pdata[i]; luaH_object_push(L, w->ref); lua_rawseti(L, -2, i+1); } return 1; case L_TK_INSTALL_PATH: lua_pushliteral(L, LUAKIT_INSTALL_PATH); return 1; case L_TK_VERSION: lua_pushliteral(L, VERSION); return 1; default: break; } return 0; }
static gint luaH_window_index(lua_State *L, luakit_token_t token) { widget_t *w = luaH_checkwidget(L, 1); switch(token) { LUAKIT_WIDGET_BIN_INDEX_COMMON LUAKIT_WIDGET_CONTAINER_INDEX_COMMON /* push widget class methods */ PF_CASE(DESTROY, luaH_widget_destroy) PF_CASE(FOCUS, luaH_widget_focus) PF_CASE(HIDE, luaH_widget_hide) /* push window class methods */ PF_CASE(SET_DEFAULT_SIZE, luaH_window_set_default_size) PF_CASE(SHOW, luaH_window_show) /* push string methods */ PS_CASE(TITLE, gtk_window_get_title(GTK_WINDOW(w->widget))) case L_TK_XID: lua_pushnumber(L, GDK_WINDOW_XID(GTK_WIDGET(w->widget)->window)); return 1; default: break; } return 0; }
static gint luaH_window_index(lua_State *L, luapdf_token_t token) { widget_t *w = luaH_checkwidget(L, 1); switch(token) { LUAPDF_WIDGET_BIN_INDEX_COMMON(w) LUAPDF_WIDGET_CONTAINER_INDEX_COMMON(w) /* push widget class methods */ PF_CASE(DESTROY, luaH_widget_destroy) PF_CASE(FOCUS, luaH_widget_focus) PF_CASE(HIDE, luaH_widget_hide) /* push window class methods */ PF_CASE(SET_DEFAULT_SIZE, luaH_window_set_default_size) PF_CASE(SHOW, luaH_window_show) PF_CASE(SET_SCREEN, luaH_window_set_screen) PF_CASE(FULLSCREEN, luaH_window_fullscreen) PF_CASE(UNFULLSCREEN, luaH_window_unfullscreen) PF_CASE(MAXIMIZE, luaH_window_maximize) PF_CASE(UNMAXIMIZE, luaH_window_unmaximize) /* push string methods */ PS_CASE(TITLE, gtk_window_get_title(GTK_WINDOW(w->widget))) /* push boolean properties */ PB_CASE(DECORATED, gtk_window_get_decorated(GTK_WINDOW(w->widget))) case L_TK_XID: lua_pushnumber(L, GDK_WINDOW_XID(GTK_WIDGET(w->widget)->window)); return 1; default: break; } return 0; }
static gint luaH_box_index(lua_State *L, widget_t *w, luakit_token_t token) { switch(token) { LUAKIT_WIDGET_INDEX_COMMON(w) LUAKIT_WIDGET_CONTAINER_INDEX_COMMON(w) /* push class methods */ PF_CASE(PACK, luaH_box_pack) PF_CASE(REORDER, luaH_box_reorder_child) /* push boolean properties */ PB_CASE(HOMOGENEOUS, gtk_box_get_homogeneous(GTK_BOX(w->widget))) /* push string properties */ PN_CASE(SPACING, gtk_box_get_spacing(GTK_BOX(w->widget))) PS_CASE(BG, g_object_get_data(G_OBJECT(w->widget), "bg")) default: break; } return 0; }