Changeset 5d04943cbd4190513343beffa30e71d31801b052
- Timestamp:
- 14/05/06 16:36:08
(3 years ago)
- Author:
- Felix Paul Kühne <fkuehne@videolan.org>
- git-committer:
- Felix Paul Kühne <fkuehne@videolan.org> 1147617368 +0000
- git-parent:
[c7c309ce04d7f3ed5ec59a01136136d2c5acdf6d]
- git-author:
- Felix Paul Kühne <fkuehne@videolan.org> 1147617368 +0000
- Message:
* new dialogue type to prompt the user for a string
* 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
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r4db8257 |
r5d04943 |
|
| 16 | 16 | "o_auth_title" = id; |
|---|
| 17 | 17 | "o_auth_win" = id; |
|---|
| | 18 | "o_input_cancel_btn" = id; |
|---|
| | 19 | "o_input_description" = id; |
|---|
| | 20 | "o_input_fld" = id; |
|---|
| | 21 | "o_input_ok_btn" = id; |
|---|
| | 22 | "o_input_title" = id; |
|---|
| | 23 | "o_input_win" = id; |
|---|
| 18 | 24 | "o_prog_bar" = id; |
|---|
| 19 | 25 | "o_prog_cancel_btn" = id; |
|---|
| r4db8257 |
r5d04943 |
|
| 9 | 9 | <key>IBOpenObjects</key> |
|---|
| 10 | 10 | <array> |
|---|
| | 11 | <integer>79</integer> |
|---|
| 11 | 12 | <integer>55</integer> |
|---|
| 12 | 13 | </array> |
|---|
| rb67e6fc |
r5d04943 |
|
| 84 | 84 | #define DIALOG_LOGIN_PW_OK_CANCEL 0x20 |
|---|
| 85 | 85 | #define DIALOG_USER_PROGRESS 0x40 |
|---|
| | 86 | #define DIALOG_PSZ_INPUT_OK_CANCEL 0x80 |
|---|
| 86 | 87 | |
|---|
| 87 | 88 | /** |
|---|
| … | … | |
| 177 | 178 | VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) ); |
|---|
| 178 | 179 | |
|---|
| | 180 | #define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d ) |
|---|
| | 181 | VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) ); |
|---|
| | 182 | |
|---|
| 179 | 183 | #define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b ) |
|---|
| 180 | 184 | VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int )); |
|---|
| r4db8257 |
r5d04943 |
|
| 50 | 50 | IBOutlet id o_auth_win; |
|---|
| 51 | 51 | |
|---|
| | 52 | /* string input dialogue */ |
|---|
| | 53 | IBOutlet id o_input_cancel_btn; |
|---|
| | 54 | IBOutlet id o_input_description; |
|---|
| | 55 | IBOutlet id o_input_fld; |
|---|
| | 56 | IBOutlet id o_input_ok_btn; |
|---|
| | 57 | IBOutlet id o_input_title; |
|---|
| | 58 | IBOutlet id o_input_win; |
|---|
| | 59 | |
|---|
| 52 | 60 | interaction_dialog_t * p_dialog; |
|---|
| 53 | 61 | intf_thread_t * p_intf; |
|---|
| rc7c309c |
r5d04943 |
|
| 111 | 111 | -(void)runDialog |
|---|
| 112 | 112 | { |
|---|
| 113 | | int i = 0; |
|---|
| 114 | 113 | id o_window = NULL; |
|---|
| 115 | 114 | if( !p_dialog ) |
|---|
| … | … | |
| 125 | 124 | [o_auth_cancel_btn setTitle: _NS("Cancel")]; |
|---|
| 126 | 125 | [o_auth_ok_btn setTitle: _NS("OK")]; |
|---|
| | 126 | [o_input_ok_btn setTitle: _NS("OK")]; |
|---|
| | 127 | [o_input_cancel_btn setTitle: _NS("Cancel")]; |
|---|
| 127 | 128 | } |
|---|
| 128 | 129 | |
|---|
| … | … | |
| 154 | 155 | if( p_dialog->i_id == DIALOG_ERRORS ) |
|---|
| 155 | 156 | { |
|---|
| 156 | | for( i = 0; i < p_dialog->i_widgets; i++ ) |
|---|
| 157 | | { |
|---|
| 158 | | msg_Err( p_intf, "Error: %s", p_dialog->pp_widgets[i]->psz_text ); |
|---|
| 159 | | } |
|---|
| | 157 | msg_Err( p_intf, "Error: %s", p_dialog->psz_description ); |
|---|
| 160 | 158 | } |
|---|
| 161 | 159 | else |
|---|
| 162 | 160 | { |
|---|
| 163 | | for( i = 0; i < p_dialog->i_widgets; i++ ) |
|---|
| 164 | | { |
|---|
| 165 | | msg_Dbg( p_intf, "widget: %s", p_dialog->pp_widgets[i]->psz_text ); |
|---|
| 166 | | o_description = [o_description stringByAppendingString: \ |
|---|
| 167 | | [NSString stringWithUTF8String: \ |
|---|
| 168 | | p_dialog->pp_widgets[i]->psz_text]]; |
|---|
| 169 | | } |
|---|
| 170 | 161 | if( p_dialog->i_flags & DIALOG_OK_CANCEL ) |
|---|
| 171 | 162 | { |
|---|
| 172 | 163 | msg_Dbg( p_intf, "requested flag: DIALOG_OK_CANCEL" ); |
|---|
| 173 | | NSBeginInformationalAlertSheet( o_title, @"OK" , @"Cancel", nil, \ |
|---|
| 174 | | o_window, self,@selector(sheetDidEnd: returnCode: contextInfo:),\ |
|---|
| 175 | | NULL, nil, o_description ); |
|---|
| | 164 | NSBeginInformationalAlertSheet( o_title, _NS("OK") , _NS("Cancel"), |
|---|
| | 165 | nil, o_window, self, |
|---|
| | 166 | @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil, |
|---|
| | 167 | o_description ); |
|---|
| 176 | 168 | } |
|---|
| 177 | 169 | else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL ) |
|---|
| 178 | 170 | { |
|---|
| 179 | 171 | msg_Dbg( p_intf, "requested flag: DIALOG_YES_NO_CANCEL" ); |
|---|
| 180 | | NSBeginInformationalAlertSheet( o_title, @"Yes", @"No", @"Cancel", \ |
|---|
| 181 | | o_window, self,@selector(sheetDidEnd: returnCode: contextInfo:),\ |
|---|
| 182 | | NULL, nil, o_description ); |
|---|
| | 172 | NSBeginInformationalAlertSheet( o_title, _NS("Yes"), _NS("No"), |
|---|
| | 173 | _NS("Cancel"), o_window, self, |
|---|
| | 174 | @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil, |
|---|
| | 175 | o_description ); |
|---|
| 183 | 176 | } |
|---|
| 184 | 177 | else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) |
|---|
| … | … | |
| 189 | 182 | [o_auth_login_fld setStringValue: @""]; |
|---|
| 190 | 183 | [o_auth_pw_fld setStringValue: @""]; |
|---|
| 191 | | [NSApp beginSheet: o_auth_win modalForWindow: o_window \ |
|---|
| | 184 | [NSApp beginSheet: o_auth_win modalForWindow: o_window |
|---|
| 192 | 185 | modalDelegate: self didEndSelector: nil contextInfo: nil]; |
|---|
| 193 | 186 | [o_auth_win makeKeyWindow]; |
|---|
| … | … | |
| 199 | 192 | [o_prog_description setStringValue: o_description]; |
|---|
| 200 | 193 | [o_prog_bar setDoubleValue: 0]; |
|---|
| 201 | | [NSApp beginSheet: o_prog_win modalForWindow: o_window \ |
|---|
| | 194 | [NSApp beginSheet: o_prog_win modalForWindow: o_window |
|---|
| 202 | 195 | modalDelegate: self didEndSelector: nil contextInfo: nil]; |
|---|
| 203 | 196 | [o_prog_win makeKeyWindow]; |
|---|
| 204 | 197 | } |
|---|
| | 198 | else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL ) |
|---|
| | 199 | { |
|---|
| | 200 | msg_Dbg( p_intf, "requested flag: DIALOG_STRING_INPUT_OK" ); |
|---|
| | 201 | [o_input_title setStringValue: o_title]; |
|---|
| | 202 | [o_input_description setStringValue: o_description]; |
|---|
| | 203 | [o_input_fld setStringValue: @""]; |
|---|
| | 204 | [NSApp beginSheet: o_input_win modalForWindow: o_window |
|---|
| | 205 | modalDelegate: self didEndSelector: nil contextInfo: nil]; |
|---|
| | 206 | [o_input_win makeKeyWindow]; |
|---|
| | 207 | } |
|---|
| 205 | 208 | else |
|---|
| 206 | | msg_Warn( p_intf, "requested dialog type not implemented yet" ); |
|---|
| | 209 | msg_Warn( p_intf, "requested dialog type unknown" ); |
|---|
| 207 | 210 | } |
|---|
| 208 | 211 | } |
|---|
| … | … | |
| 240 | 243 | [o_prog_bar setDoubleValue: \ |
|---|
| 241 | 244 | (double)(p_dialog->val.f_float)]; |
|---|
| 242 | | msg_Dbg( p_intf, "new value: %f", [o_prog_bar doubleValue] ); |
|---|
| 243 | 245 | |
|---|
| 244 | 246 | if( [o_prog_bar doubleValue] == 100.0 ) |
|---|
| … | … | |
| 263 | 265 | [NSApp endSheet: o_auth_win]; |
|---|
| 264 | 266 | [o_auth_win close]; |
|---|
| | 267 | } |
|---|
| | 268 | if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL ) |
|---|
| | 269 | { |
|---|
| | 270 | [NSApp endSheet: o_input_win]; |
|---|
| | 271 | [o_input_win close]; |
|---|
| 265 | 272 | } |
|---|
| 266 | 273 | } |
|---|
| … | … | |
| 290 | 297 | p_dialog->psz_returned[1] = strdup( [[o_auth_pw_fld stringValue] UTF8String] ); |
|---|
| 291 | 298 | } |
|---|
| | 299 | else if( p_dialog->i_flags == DIALOG_PSZ_INPUT_OK_CANCEL ) |
|---|
| | 300 | p_dialog->psz_returned[0] = strdup( [[o_input_fld stringValue] UTF8String] ); |
|---|
| 292 | 301 | p_dialog->i_return = DIALOG_OK_YES; |
|---|
| 293 | 302 | p_dialog->i_status = ANSWERED_DIALOG; |
|---|
| rb67e6fc |
r5d04943 |
|
| 222 | 222 | |
|---|
| 223 | 223 | |
|---|
| 224 | | |
|---|
| 225 | 224 | #define INTERACT_INIT( new ) \ |
|---|
| 226 | 225 | new = (interaction_dialog_t*)malloc( \ |
|---|
| 227 | 226 | sizeof( interaction_dialog_t ) ); \ |
|---|
| 228 | | new->i_widgets = 0; \ |
|---|
| 229 | | new->pp_widgets = NULL; \ |
|---|
| 230 | 227 | new->psz_title = NULL; \ |
|---|
| 231 | 228 | new->psz_description = NULL; \ |
|---|
| … | … | |
| 251 | 248 | va_list args; |
|---|
| 252 | 249 | interaction_dialog_t *p_new = NULL; |
|---|
| 253 | | user_widget_t *p_widget = NULL; |
|---|
| 254 | 250 | int i_id = DIALOG_ERRORS; |
|---|
| 255 | 251 | |
|---|
| … | … | |
| 273 | 269 | p_new->psz_title = strdup( psz_title ); |
|---|
| 274 | 270 | |
|---|
| 275 | | p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); |
|---|
| 276 | | |
|---|
| 277 | | p_widget->i_type = WIDGET_TEXT; |
|---|
| 278 | | p_widget->val.psz_string = NULL; |
|---|
| 279 | | |
|---|
| 280 | 271 | va_start( args, psz_format ); |
|---|
| 281 | | vasprintf( &p_widget->psz_text, psz_format, args ); |
|---|
| | 272 | vasprintf( &p_new->psz_description, psz_format, args ); |
|---|
| 282 | 273 | va_end( args ); |
|---|
| 283 | | |
|---|
| 284 | | INSERT_ELEM ( p_new->pp_widgets, |
|---|
| 285 | | p_new->i_widgets, |
|---|
| 286 | | p_new->i_widgets, |
|---|
| 287 | | p_widget ); |
|---|
| 288 | 274 | |
|---|
| 289 | 275 | p_new->i_flags |= DIALOG_CLEAR_NOSHOW; |
|---|
| … | … | |
| 304 | 290 | int i_ret; |
|---|
| 305 | 291 | interaction_dialog_t *p_new = NULL; |
|---|
| 306 | | user_widget_t *p_widget = NULL; |
|---|
| 307 | 292 | |
|---|
| 308 | 293 | INTERACT_INIT( p_new ); |
|---|
| … | … | |
| 310 | 295 | p_new->i_type = INTERACT_DIALOG_TWOWAY; |
|---|
| 311 | 296 | p_new->psz_title = strdup( psz_title ); |
|---|
| 312 | | |
|---|
| 313 | | /* Text */ |
|---|
| 314 | | p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); |
|---|
| 315 | | p_widget->i_type = WIDGET_TEXT; |
|---|
| 316 | | p_widget->psz_text = strdup( psz_description ); |
|---|
| 317 | | p_widget->val.psz_string = NULL; |
|---|
| 318 | | INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets, |
|---|
| 319 | | p_new->i_widgets, p_widget ); |
|---|
| 320 | | |
|---|
| | 297 | p_new->psz_description = strdup( psz_description ); |
|---|
| 321 | 298 | p_new->i_flags = DIALOG_YES_NO_CANCEL; |
|---|
| 322 | 299 | |
|---|
| … | … | |
| 326 | 303 | } |
|---|
| 327 | 304 | |
|---|
| 328 | | /** Helper function to make a progressbar box |
|---|
| | 305 | /** Helper function to trigger a okay-cancel dialogue |
|---|
| | 306 | * \param p_this Parent vlc_object |
|---|
| | 307 | * \param psz_title Title for the dialog |
|---|
| | 308 | * \param psz_description A description |
|---|
| | 309 | * \return Clicked button code |
|---|
| | 310 | */ |
|---|
| | 311 | int __intf_UserOkayCancel( vlc_object_t *p_this, |
|---|
| | 312 | const char *psz_title, |
|---|
| | 313 | const char *psz_description ) |
|---|
| | 314 | { |
|---|
| | 315 | int i_ret; |
|---|
| | 316 | interaction_dialog_t *p_new = NULL; |
|---|
| | 317 | |
|---|
| | 318 | INTERACT_INIT( p_new ); |
|---|
| | 319 | |
|---|
| | 320 | p_new->i_type = INTERACT_DIALOG_TWOWAY; |
|---|
| | 321 | p_new->psz_title = strdup( psz_title ); |
|---|
| | 322 | p_new->psz_description = strdup( psz_description ); |
|---|
| | 323 | p_new->i_flags = DIALOG_OK_CANCEL; |
|---|
| | 324 | |
|---|
| | 325 | i_ret = intf_Interact( p_this, p_new ); |
|---|
| | 326 | |
|---|
| | 327 | return i_ret; |
|---|
| | 328 | } |
|---|
| | 329 | |
|---|
| | 330 | /** Helper function to create a dialogue showing a progress-bar with some info |
|---|
| 329 | 331 | * \param p_this Parent vlc_object |
|---|
| 330 | 332 | * \param psz_title Title for the dialog |
|---|
| … | … | |
| 355 | 357 | } |
|---|
| 356 | 358 | |
|---|
| 357 | | /** Update a progress bar |
|---|
| | 359 | /** Update a progress bar in a dialogue |
|---|
| 358 | 360 | * \param p_this Parent vlc_object |
|---|
| 359 | 361 | * \param i_id Identifier of the dialog |
|---|
| … | … | |
| 389 | 391 | } |
|---|
| 390 | 392 | |
|---|
| 391 | | /** Helper function to make a login/password box |
|---|
| | 393 | /** Helper function to make a login/password dialogue |
|---|
| 392 | 394 | * \param p_this Parent vlc_object |
|---|
| 393 | 395 | * \param psz_title Title for the dialog |
|---|
| … | … | |
| 421 | 423 | *ppsz_login = strdup( p_new->psz_returned[0] ); |
|---|
| 422 | 424 | *ppsz_password = strdup( p_new->psz_returned[1] ); |
|---|
| | 425 | } |
|---|
| | 426 | return i_ret; |
|---|
| | 427 | } |
|---|
| | 428 | |
|---|
| | 429 | /** Helper function to make a dialogue asking the user for !password string |
|---|
| | 430 | * \param p_this Parent vlc_object |
|---|
| | 431 | * \param psz_title Title for the dialog |
|---|
| | 432 | * \param psz_description A description |
|---|
| | 433 | * \param ppsz_usersString Returned login |
|---|
| | 434 | * \return Clicked button code |
|---|
| | 435 | */ |
|---|
| | 436 | int __intf_UserStringInput( vlc_object_t *p_this, |
|---|
| | 437 | const char *psz_title, |
|---|
| | 438 | const char *psz_description, |
|---|
| | 439 | char **ppsz_usersString ) |
|---|
| | 440 | { |
|---|
| | 441 | |
|---|
| | 442 | int i_ret; |
|---|
| | 443 | interaction_dialog_t *p_new = NULL; |
|---|
| | 444 | |
|---|
| | 445 | INTERACT_INIT( p_new ); |
|---|
| | 446 | |
|---|
| | 447 | p_new->i_type = INTERACT_DIALOG_TWOWAY; |
|---|
| | 448 | p_new->psz_title = strdup( psz_title ); |
|---|
| | 449 | p_new->psz_description = strdup( psz_description ); |
|---|
| | 450 | |
|---|
| | 451 | p_new->i_flags = DIALOG_PSZ_INPUT_OK_CANCEL; |
|---|
| | 452 | |
|---|
| | 453 | i_ret = intf_Interact( p_this, p_new ); |
|---|
| | 454 | |
|---|
| | 455 | if( i_ret != DIALOG_CANCELLED ) |
|---|
| | 456 | { |
|---|
| | 457 | *ppsz_usersString = strdup( p_new->psz_returned[0] ); |
|---|
| 423 | 458 | } |
|---|
| 424 | 459 | return i_ret; |
|---|
| … | … | |
| 630 | 665 | static void intf_InteractionDialogDestroy( interaction_dialog_t *p_dialog ) |
|---|
| 631 | 666 | { |
|---|
| 632 | | int i; |
|---|
| 633 | | for( i = p_dialog->i_widgets - 1 ; i >= 0 ; i-- ) |
|---|
| 634 | | { |
|---|
| 635 | | user_widget_t *p_widget = p_dialog->pp_widgets[i]; |
|---|
| 636 | | FREE( p_widget->psz_text ); |
|---|
| 637 | | if( p_widget->i_type == WIDGET_INPUT_TEXT ) |
|---|
| 638 | | { |
|---|
| 639 | | FREE( p_widget->val.psz_string ); |
|---|
| 640 | | } |
|---|
| 641 | | |
|---|
| 642 | | REMOVE_ELEM( p_dialog->pp_widgets, p_dialog->i_widgets, i ); |
|---|
| 643 | | free( p_widget ); |
|---|
| 644 | | } |
|---|
| | 667 | /* FREE( p_dialog->val.psz_string ); |
|---|
| | 668 | |
|---|
| 645 | 669 | FREE( p_dialog->psz_title ); |
|---|
| 646 | 670 | FREE( p_dialog->psz_description ); |
|---|
| 647 | 671 | |
|---|
| 648 | 672 | FREE( p_dialog->psz_returned[0] ); |
|---|
| 649 | | FREE( p_dialog->psz_returned[1] ); |
|---|
| | 673 | FREE( p_dialog->psz_returned[1] ); */ |
|---|
| 650 | 674 | |
|---|
| 651 | 675 | free( p_dialog ); |
|---|