Changeset 5d04943cbd4190513343beffa30e71d31801b052

Show
Ignore:
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
  • extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib

    r4db8257 r5d04943  
    1616                "o_auth_title" = id;  
    1717                "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;  
    1824                "o_prog_bar" = id;  
    1925                "o_prog_cancel_btn" = id;  
  • extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib

    r4db8257 r5d04943  
    99    <key>IBOpenObjects</key> 
    1010    <array> 
     11        <integer>79</integer> 
    1112        <integer>55</integer> 
    1213    </array> 
  • include/vlc_interaction.h

    rb67e6fc r5d04943  
    8484#define DIALOG_LOGIN_PW_OK_CANCEL   0x20 
    8585#define DIALOG_USER_PROGRESS        0x40 
     86#define DIALOG_PSZ_INPUT_OK_CANCEL      0x80 
    8687 
    8788/** 
     
    177178VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) ); 
    178179 
     180#define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d ) 
     181VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) ); 
     182 
    179183#define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b ) 
    180184VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int )); 
  • modules/gui/macosx/interaction.h

    r4db8257 r5d04943  
    5050    IBOutlet id o_auth_win; 
    5151 
     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 
    5260    interaction_dialog_t * p_dialog; 
    5361    intf_thread_t * p_intf; 
  • modules/gui/macosx/interaction.m

    rc7c309c r5d04943  
    111111-(void)runDialog 
    112112{ 
    113     int i = 0; 
    114113    id o_window = NULL; 
    115114    if( !p_dialog ) 
     
    125124        [o_auth_cancel_btn setTitle: _NS("Cancel")]; 
    126125        [o_auth_ok_btn setTitle: _NS("OK")]; 
     126        [o_input_ok_btn setTitle: _NS("OK")]; 
     127        [o_input_cancel_btn setTitle: _NS("Cancel")]; 
    127128    } 
    128129 
     
    154155    if( p_dialog->i_id == DIALOG_ERRORS ) 
    155156    { 
    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 ); 
    160158    } 
    161159    else 
    162160    { 
    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         } 
    170161        if( p_dialog->i_flags & DIALOG_OK_CANCEL ) 
    171162        { 
    172163            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 ); 
    176168        } 
    177169        else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL ) 
    178170        { 
    179171            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 ); 
    183176        } 
    184177        else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) 
     
    189182            [o_auth_login_fld setStringValue: @""]; 
    190183            [o_auth_pw_fld setStringValue: @""]; 
    191             [NSApp beginSheet: o_auth_win modalForWindow: o_window \ 
     184            [NSApp beginSheet: o_auth_win modalForWindow: o_window 
    192185                modalDelegate: self didEndSelector: nil contextInfo: nil]; 
    193186            [o_auth_win makeKeyWindow]; 
     
    199192            [o_prog_description setStringValue: o_description]; 
    200193            [o_prog_bar setDoubleValue: 0]; 
    201             [NSApp beginSheet: o_prog_win modalForWindow: o_window \ 
     194            [NSApp beginSheet: o_prog_win modalForWindow: o_window 
    202195                modalDelegate: self didEndSelector: nil contextInfo: nil]; 
    203196            [o_prog_win makeKeyWindow]; 
    204197        } 
     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        } 
    205208        else 
    206             msg_Warn( p_intf, "requested dialog type not implemented yet" ); 
     209            msg_Warn( p_intf, "requested dialog type unknown" ); 
    207210    } 
    208211} 
     
    240243        [o_prog_bar setDoubleValue: \ 
    241244            (double)(p_dialog->val.f_float)]; 
    242         msg_Dbg( p_intf, "new value: %f", [o_prog_bar doubleValue] ); 
    243245 
    244246        if( [o_prog_bar doubleValue] == 100.0 ) 
     
    263265        [NSApp endSheet: o_auth_win]; 
    264266        [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]; 
    265272    } 
    266273} 
     
    290297        p_dialog->psz_returned[1] = strdup( [[o_auth_pw_fld stringValue] UTF8String] ); 
    291298    } 
     299    else if( p_dialog->i_flags == DIALOG_PSZ_INPUT_OK_CANCEL ) 
     300        p_dialog->psz_returned[0] = strdup( [[o_input_fld stringValue] UTF8String] ); 
    292301    p_dialog->i_return = DIALOG_OK_YES; 
    293302    p_dialog->i_status = ANSWERED_DIALOG; 
  • src/interface/interaction.c

    rb67e6fc r5d04943  
    222222 
    223223 
    224  
    225224#define INTERACT_INIT( new )                                            \ 
    226225        new = (interaction_dialog_t*)malloc(                            \ 
    227226                        sizeof( interaction_dialog_t ) );               \ 
    228         new->i_widgets = 0;                                             \ 
    229         new->pp_widgets = NULL;                                         \ 
    230227        new->psz_title = NULL;                                          \ 
    231228        new->psz_description = NULL;                                    \ 
     
    251248    va_list args; 
    252249    interaction_dialog_t *p_new = NULL; 
    253     user_widget_t *p_widget = NULL; 
    254250    int i_id = DIALOG_ERRORS; 
    255251 
     
    273269    p_new->psz_title = strdup( psz_title ); 
    274270 
    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  
    280271    va_start( args, psz_format ); 
    281     vasprintf( &p_widget->psz_text, psz_format, args ); 
     272    vasprintf( &p_new->psz_description, psz_format, args ); 
    282273    va_end( args ); 
    283  
    284     INSERT_ELEM ( p_new->pp_widgets, 
    285                   p_new->i_widgets, 
    286                   p_new->i_widgets, 
    287                   p_widget ); 
    288274 
    289275    p_new->i_flags |= DIALOG_CLEAR_NOSHOW; 
     
    304290    int i_ret; 
    305291    interaction_dialog_t *p_new = NULL; 
    306     user_widget_t *p_widget = NULL; 
    307292 
    308293    INTERACT_INIT( p_new ); 
     
    310295    p_new->i_type = INTERACT_DIALOG_TWOWAY; 
    311296    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 ); 
    321298    p_new->i_flags = DIALOG_YES_NO_CANCEL; 
    322299 
     
    326303} 
    327304 
    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 */ 
     311int __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 
    329331 *  \param p_this           Parent vlc_object 
    330332 *  \param psz_title        Title for the dialog 
     
    355357} 
    356358 
    357 /** Update a progress bar 
     359/** Update a progress bar in a dialogue 
    358360 *  \param p_this           Parent vlc_object 
    359361 *  \param i_id             Identifier of the dialog 
     
    389391} 
    390392 
    391 /** Helper function to make a login/password box 
     393/** Helper function to make a login/password dialogue 
    392394 *  \param p_this           Parent vlc_object 
    393395 *  \param psz_title        Title for the dialog 
     
    421423        *ppsz_login = strdup( p_new->psz_returned[0] ); 
    422424        *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 */ 
     436int __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] ); 
    423458    } 
    424459    return i_ret; 
     
    630665static void intf_InteractionDialogDestroy( interaction_dialog_t *p_dialog ) 
    631666{ 
    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 
    645669    FREE( p_dialog->psz_title ); 
    646670    FREE( p_dialog->psz_description ); 
    647671     
    648672    FREE( p_dialog->psz_returned[0] ); 
    649     FREE( p_dialog->psz_returned[1] ); 
     673    FREE( p_dialog->psz_returned[1] ); */ 
    650674 
    651675    free( p_dialog );