static int vlclua_dialog_delete( lua_State *L );
static int vlclua_dialog_show( lua_State *L );
static int vlclua_dialog_hide( lua_State *L );
-static int vlclua_dialog_flush( lua_State *L );
+static int vlclua_dialog_set_title( lua_State *L );
+static int vlclua_dialog_update( lua_State *L );
static void lua_SetDialogUpdate( lua_State *L, int flag );
static int lua_GetDialogUpdate( lua_State *L );
int lua_DialogFlush( lua_State *L );
static const luaL_Reg vlclua_dialog_reg[] = {
{ "show", vlclua_dialog_show },
{ "hide", vlclua_dialog_hide },
- { "close", vlclua_dialog_delete },
- { "flush", vlclua_dialog_flush },
+ { "delete", vlclua_dialog_delete },
+ { "set_title", vlclua_dialog_set_title },
+ { "update", vlclua_dialog_update },
{ "add_button", vlclua_dialog_add_button },
{ "add_label", vlclua_dialog_add_label },
lua_setfield( L, -2, "__dialog" );
lua_pop( L, 1 );
- extension_dialog_t **pp_dlg = lua_newuserdata( L, sizeof( void* ) );
+ extension_dialog_t **pp_dlg = lua_newuserdata( L, sizeof( extension_dialog_t* ) );
*pp_dlg = p_dlg;
if( luaL_newmetatable( L, "dialog" ) )
}
-/** Flush the dialog */
-static int vlclua_dialog_flush( lua_State *L )
+/** Set the dialog's title */
+static int vlclua_dialog_set_title( lua_State *L )
+{
+ extension_dialog_t **pp_dlg =
+ (extension_dialog_t**) luaL_checkudata( L, 1, "dialog" );
+ if( !pp_dlg || !*pp_dlg )
+ return luaL_error( L, "Can't get pointer to dialog" );
+ extension_dialog_t *p_dlg = *pp_dlg;
+
+ vlc_mutex_lock( &p_dlg->lock );
+
+ const char *psz_title = luaL_checkstring( L, 2 );
+ free( p_dlg->psz_title );
+ p_dlg->psz_title = strdup( psz_title );
+
+ vlc_mutex_unlock( &p_dlg->lock );
+
+ lua_SetDialogUpdate( L, 1 );
+
+ return 1;
+}
+
+/** Update the dialog immediately */
+static int vlclua_dialog_update( lua_State *L )
{
vlc_object_t *p_mgr = vlclua_get_this( L );
return luaL_checkinteger( L, -1 );
}
-/** Manually flush a dialog
+/** Manually update a dialog
* This can be called after a lua_pcall
* @return SUCCESS if there is no dialog or the update was successful
* @todo If there can be multiple dialogs, this function will have to
extension_widget_t *p_widget = calloc( 1, sizeof( extension_widget_t ) );
p_widget->type = EXTENSION_WIDGET_BUTTON;
p_widget->psz_text = strdup( luaL_checkstring( L, 2 ) );
- lua_settop( L, 3 );
+ lua_settop( L, 10 );
lua_pushlightuserdata( L, p_widget );
- lua_insert( L, 3 );
+ lua_pushvalue( L, 3 );
lua_settable( L, LUA_REGISTRYINDEX );
p_widget->p_sys = NULL;
vlc_mutex_unlock( &p_dlg->lock );
/* Create meta table */
- extension_widget_t **pp_widget = lua_newuserdata( L, sizeof( void* ) );
+ extension_widget_t **pp_widget = lua_newuserdata( L, sizeof( extension_widget_t* ) );
*pp_widget = p_widget;
if( luaL_newmetatable( L, "widget" ) )
{
if( !p_widget->p_values )
{
p_widget->p_values = p_new_value;
+ if( p_widget->type == EXTENSION_WIDGET_DROPDOWN )
+ p_new_value->b_selected = true;
}
else
{
/**
* Delete a widget from a dialog
* Remove it from the list once it has been safely destroyed by the interface
- * @note This will always flush the dialog
+ * @note This will always update the dialog
**/
static int vlclua_dialog_delete_widget( lua_State *L )
{