* the core is widget-free now (except for the header to keep wx compiling, hopefully)
* updated the OSX-implementation to reflect the recent changes
more clean up is necessary; testing and any feedback is welcomed
refs #553
"o_auth_pw_txt" = id;
"o_auth_title" = id;
"o_auth_win" = id;
+ "o_input_cancel_btn" = id;
+ "o_input_description" = id;
+ "o_input_fld" = id;
+ "o_input_ok_btn" = id;
+ "o_input_title" = id;
+ "o_input_win" = id;
"o_prog_bar" = id;
"o_prog_cancel_btn" = id;
"o_prog_description" = id;
<string>443.0</string>
<key>IBOpenObjects</key>
<array>
+ <integer>79</integer>
<integer>55</integer>
</array>
<key>IBSystem Version</key>
#define DIALOG_GOT_ANSWER 0x10
#define DIALOG_LOGIN_PW_OK_CANCEL 0x20
#define DIALOG_USER_PROGRESS 0x40
+#define DIALOG_PSZ_INPUT_OK_CANCEL 0x80
/**
* Possible return codes
#define intf_UserProgressUpdate( a, b, c, d ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c, d )
VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) );
+#define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d )
+VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) );
+
#define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b )
VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int ));
IBOutlet id o_auth_title;
IBOutlet id o_auth_win;
+ /* string input dialogue */
+ IBOutlet id o_input_cancel_btn;
+ IBOutlet id o_input_description;
+ IBOutlet id o_input_fld;
+ IBOutlet id o_input_ok_btn;
+ IBOutlet id o_input_title;
+ IBOutlet id o_input_win;
+
interaction_dialog_t * p_dialog;
intf_thread_t * p_intf;
BOOL nib_interact_loaded;
-(void)runDialog
{
- int i = 0;
id o_window = NULL;
if( !p_dialog )
msg_Err( p_intf, "no available interaction framework" );
[o_auth_pw_txt setStringValue: _NS("Password:")];
[o_auth_cancel_btn setTitle: _NS("Cancel")];
[o_auth_ok_btn setTitle: _NS("OK")];
+ [o_input_ok_btn setTitle: _NS("OK")];
+ [o_input_cancel_btn setTitle: _NS("Cancel")];
}
NSString *o_title = [NSString stringWithUTF8String:p_dialog->psz_title ? p_dialog->psz_title : "title"];
msg_Dbg( p_intf, "Description: %s", [o_description UTF8String] );
if( p_dialog->i_id == DIALOG_ERRORS )
{
- for( i = 0; i < p_dialog->i_widgets; i++ )
- {
- msg_Err( p_intf, "Error: %s", p_dialog->pp_widgets[i]->psz_text );
- }
+ msg_Err( p_intf, "Error: %s", p_dialog->psz_description );
}
else
{
- for( i = 0; i < p_dialog->i_widgets; i++ )
- {
- msg_Dbg( p_intf, "widget: %s", p_dialog->pp_widgets[i]->psz_text );
- o_description = [o_description stringByAppendingString: \
- [NSString stringWithUTF8String: \
- p_dialog->pp_widgets[i]->psz_text]];
- }
if( p_dialog->i_flags & DIALOG_OK_CANCEL )
{
msg_Dbg( p_intf, "requested flag: DIALOG_OK_CANCEL" );
- NSBeginInformationalAlertSheet( o_title, @"OK" , @"Cancel", nil, \
- o_window, self,@selector(sheetDidEnd: returnCode: contextInfo:),\
- NULL, nil, o_description );
+ NSBeginInformationalAlertSheet( o_title, _NS("OK") , _NS("Cancel"),
+ nil, o_window, self,
+ @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
+ o_description );
}
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
msg_Dbg( p_intf, "requested flag: DIALOG_YES_NO_CANCEL" );
- NSBeginInformationalAlertSheet( o_title, @"Yes", @"No", @"Cancel", \
- o_window, self,@selector(sheetDidEnd: returnCode: contextInfo:),\
- NULL, nil, o_description );
+ NSBeginInformationalAlertSheet( o_title, _NS("Yes"), _NS("No"),
+ _NS("Cancel"), o_window, self,
+ @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
+ o_description );
}
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
[o_auth_description setStringValue: o_description];
[o_auth_login_fld setStringValue: @""];
[o_auth_pw_fld setStringValue: @""];
- [NSApp beginSheet: o_auth_win modalForWindow: o_window \
+ [NSApp beginSheet: o_auth_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_auth_win makeKeyWindow];
}
[o_prog_title setStringValue: o_title];
[o_prog_description setStringValue: o_description];
[o_prog_bar setDoubleValue: 0];
- [NSApp beginSheet: o_prog_win modalForWindow: o_window \
+ [NSApp beginSheet: o_prog_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_prog_win makeKeyWindow];
}
+ else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
+ {
+ msg_Dbg( p_intf, "requested flag: DIALOG_STRING_INPUT_OK" );
+ [o_input_title setStringValue: o_title];
+ [o_input_description setStringValue: o_description];
+ [o_input_fld setStringValue: @""];
+ [NSApp beginSheet: o_input_win modalForWindow: o_window
+ modalDelegate: self didEndSelector: nil contextInfo: nil];
+ [o_input_win makeKeyWindow];
+ }
else
- msg_Warn( p_intf, "requested dialog type not implemented yet" );
+ msg_Warn( p_intf, "requested dialog type unknown" );
}
}
[NSString stringWithUTF8String: p_dialog->psz_description]];
[o_prog_bar setDoubleValue: \
(double)(p_dialog->val.f_float)];
- msg_Dbg( p_intf, "new value: %f", [o_prog_bar doubleValue] );
if( [o_prog_bar doubleValue] == 100.0 )
{
[NSApp endSheet: o_auth_win];
[o_auth_win close];
}
+ if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
+ {
+ [NSApp endSheet: o_input_win];
+ [o_input_win close];
+ }
}
-(void)destroyDialog
p_dialog->psz_returned[0] = strdup( [[o_auth_login_fld stringValue] UTF8String] );
p_dialog->psz_returned[1] = strdup( [[o_auth_pw_fld stringValue] UTF8String] );
}
+ else if( p_dialog->i_flags == DIALOG_PSZ_INPUT_OK_CANCEL )
+ p_dialog->psz_returned[0] = strdup( [[o_input_fld stringValue] UTF8String] );
p_dialog->i_return = DIALOG_OK_YES;
p_dialog->i_status = ANSWERED_DIALOG;
vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
}
-
#define INTERACT_INIT( new ) \
new = (interaction_dialog_t*)malloc( \
sizeof( interaction_dialog_t ) ); \
- new->i_widgets = 0; \
- new->pp_widgets = NULL; \
new->psz_title = NULL; \
new->psz_description = NULL; \
new->p_private = NULL; \
{
va_list args;
interaction_dialog_t *p_new = NULL;
- user_widget_t *p_widget = NULL;
int i_id = DIALOG_ERRORS;
if( i_id > 0 )
p_new->i_type = INTERACT_DIALOG_ONEWAY;
p_new->psz_title = strdup( psz_title );
- p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) );
-
- p_widget->i_type = WIDGET_TEXT;
- p_widget->val.psz_string = NULL;
-
va_start( args, psz_format );
- vasprintf( &p_widget->psz_text, psz_format, args );
+ vasprintf( &p_new->psz_description, psz_format, args );
va_end( args );
- INSERT_ELEM ( p_new->pp_widgets,
- p_new->i_widgets,
- p_new->i_widgets,
- p_widget );
-
p_new->i_flags |= DIALOG_CLEAR_NOSHOW;
intf_Interact( p_this, p_new );
{
int i_ret;
interaction_dialog_t *p_new = NULL;
- user_widget_t *p_widget = NULL;
INTERACT_INIT( p_new );
p_new->i_type = INTERACT_DIALOG_TWOWAY;
p_new->psz_title = strdup( psz_title );
+ p_new->psz_description = strdup( psz_description );
+ p_new->i_flags = DIALOG_YES_NO_CANCEL;
- /* Text */
- p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) );
- p_widget->i_type = WIDGET_TEXT;
- p_widget->psz_text = strdup( psz_description );
- p_widget->val.psz_string = NULL;
- INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets,
- p_new->i_widgets, p_widget );
+ i_ret = intf_Interact( p_this, p_new );
- p_new->i_flags = DIALOG_YES_NO_CANCEL;
+ return i_ret;
+}
+
+/** Helper function to trigger a okay-cancel dialogue
+ * \param p_this Parent vlc_object
+ * \param psz_title Title for the dialog
+ * \param psz_description A description
+ * \return Clicked button code
+ */
+int __intf_UserOkayCancel( vlc_object_t *p_this,
+ const char *psz_title,
+ const char *psz_description )
+{
+ int i_ret;
+ interaction_dialog_t *p_new = NULL;
+
+ INTERACT_INIT( p_new );
+
+ p_new->i_type = INTERACT_DIALOG_TWOWAY;
+ p_new->psz_title = strdup( psz_title );
+ p_new->psz_description = strdup( psz_description );
+ p_new->i_flags = DIALOG_OK_CANCEL;
i_ret = intf_Interact( p_this, p_new );
return i_ret;
}
-/** Helper function to make a progressbar box
+/** Helper function to create a dialogue showing a progress-bar with some info
* \param p_this Parent vlc_object
* \param psz_title Title for the dialog
* \param psz_status Current status
return p_new->i_id;
}
-/** Update a progress bar
+/** Update a progress bar in a dialogue
* \param p_this Parent vlc_object
* \param i_id Identifier of the dialog
* \param psz_status New status
vlc_mutex_unlock( &p_interaction->object_lock) ;
}
-/** Helper function to make a login/password box
+/** Helper function to make a login/password dialogue
* \param p_this Parent vlc_object
* \param psz_title Title for the dialog
* \param psz_description A description
return i_ret;
}
+/** Helper function to make a dialogue asking the user for !password string
+ * \param p_this Parent vlc_object
+ * \param psz_title Title for the dialog
+ * \param psz_description A description
+ * \param ppsz_usersString Returned login
+ * \return Clicked button code
+ */
+int __intf_UserStringInput( vlc_object_t *p_this,
+ const char *psz_title,
+ const char *psz_description,
+ char **ppsz_usersString )
+{
+
+ int i_ret;
+ interaction_dialog_t *p_new = NULL;
+
+ INTERACT_INIT( p_new );
+
+ p_new->i_type = INTERACT_DIALOG_TWOWAY;
+ p_new->psz_title = strdup( psz_title );
+ p_new->psz_description = strdup( psz_description );
+
+ p_new->i_flags = DIALOG_PSZ_INPUT_OK_CANCEL;
+
+ i_ret = intf_Interact( p_this, p_new );
+
+ if( i_ret != DIALOG_CANCELLED )
+ {
+ *ppsz_usersString = strdup( p_new->psz_returned[0] );
+ }
+ return i_ret;
+}
+
/** Hide an interaction dialog
* \param p_this the parent vlc object
* \param i_id the id of the item to hide
static void intf_InteractionDialogDestroy( interaction_dialog_t *p_dialog )
{
- int i;
- for( i = p_dialog->i_widgets - 1 ; i >= 0 ; i-- )
- {
- user_widget_t *p_widget = p_dialog->pp_widgets[i];
- FREE( p_widget->psz_text );
- if( p_widget->i_type == WIDGET_INPUT_TEXT )
- {
- FREE( p_widget->val.psz_string );
- }
+ /* FREE( p_dialog->val.psz_string );
- REMOVE_ELEM( p_dialog->pp_widgets, p_dialog->i_widgets, i );
- free( p_widget );
- }
FREE( p_dialog->psz_title );
FREE( p_dialog->psz_description );
FREE( p_dialog->psz_returned[0] );
- FREE( p_dialog->psz_returned[1] );
+ FREE( p_dialog->psz_returned[1] ); */
free( p_dialog );
}