Changeset 6cb1101a9144409fe27ffd7984c58f33b66eb78c

Show
Ignore:
Timestamp:
07/29/06 17:07:42 (2 years ago)
Author:
Felix Paul Kühne <fkuehne@videolan.org>
git-committer:
Felix Paul Kühne <fkuehne@videolan.org> 1154185662 +0000
git-parent:

[87a71d24f916ba528c1ec7b545dfb6c58433567c]

git-author:
Felix Paul Kühne <fkuehne@videolan.org> 1154185662 +0000
Message:

* enhanced the interaction core with some method additions/changes
- intf_UserProgress* takes an additional argument now. use it to provide the time to go (in sec) until the process will be finished. Provide 0, if you don't have such info. The interface will hide the respective text-field.
- intf_UserProgressIsCancelled can be called by the module which triggered the interaction dialogue on a regular interval, to check if the user cancelled the dialogue or not. This is for dialogues with an optional cancel-button only (like the modal progress panel), so it doesn't replace p_dialog->i_return = DIALOG_CANCELLED which is for yes/no-style dialogues
- intf_UserOkayCancel was removed in favour of an enhanced intf_UserYesNo
- intf_UserYesNo takes 3 additional arguments now to get the custom captions of the default (~Yes), alternate(~No) and one optional button(~Cancel). This provides a better interface experience for the user and is more compliant with OSX's HIGL. The interface automatically hides the 3rd button, if NULL is given.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib

    r5d04943 r6cb1101  
    33        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },  
    44        { 
    5             ACTIONS = {cancelAndClose = id; okayAndClose = id; };  
     5            ACTIONS = {cancelAndClose = id; cancelDialog = id; okayAndClose = id; };  
    66            CLASS = VLCInteraction;  
    77            LANGUAGE = ObjC;  
     
    2525                "o_prog_cancel_btn" = id;  
    2626                "o_prog_description" = id;  
     27                "o_prog_timeToGo" = id;  
    2728                "o_prog_title" = id;  
    2829                "o_prog_win" = id;  
  • extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib

    r2adf9ed r6cb1101  
    99    <key>IBOpenObjects</key> 
    1010    <array> 
    11         <integer>5</integer> 
    1211        <integer>55</integer> 
    1312        <integer>79</integer> 
     13        <integer>5</integer> 
    1414    </array> 
    1515    <key>IBSystem Version</key> 
  • include/vlc_interaction.h

    r1dcfa0f r6cb1101  
    2525/** 
    2626 * This structure describes an interaction widget 
     27 * WIDGETS ARE OUTDATED! THIS IS ONLY A STUB TO KEEP WX COMPILING! 
    2728 */ 
    2829struct user_widget_t 
     
    3637/** 
    3738 * Possible widget types 
     39 * WIDGETS ARE OUTDATED! THIS IS ONLY A STUB TO KEEP WX COMPILING! 
    3840 */ 
    3941enum 
     
    5355    char           *psz_title;          ///< Title 
    5456    char           *psz_description;    ///< Descriptor string 
     57    char           *psz_defaultButton;  ///< default button title (~OK) 
     58    char           *psz_alternateButton;///< alternate button title (~NO) 
     59    char           *psz_otherButton;    ///< other button title (optional,~Cancel) 
    5560 
    5661    char           *psz_returned[1];    ///< returned responses from the user 
    5762 
    5863    vlc_value_t     val;                ///< a value coming from core for dialogue 
     64    int             i_timeToGo;         ///< time (in sec) until shown progress is finished 
     65    vlc_bool_t      b_cancelled;        ///< was the dialogue cancelled by the user? 
    5966 
    6067    int             i_widgets;          ///< Number of dialog widgets 
     
    7784 */ 
    7885#define DIALOG_REUSABLE             0x01 
    79 #define DIALOG_OK_CANCEL            0x02 
    80 #define DIALOG_YES_NO               0x04 
    8186#define DIALOG_YES_NO_CANCEL        0x04 
    8287#define DIALOG_CLEAR_NOSHOW         0x08 
     
    170175#define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e) 
    171176VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) ); 
    172 #define intf_UserYesNo( a, b, c ) __intf_UserYesNo( VLC_OBJECT(a),b,c ) 
    173 VLC_EXPORT( int, __intf_UserYesNo,( vlc_object_t*, const char*, const char*) ); 
    174 #define intf_UserOkayCancel( a, b, c ) __intf_UserOkayCancel( VLC_OBJECT(a),b,c ) 
    175 VLC_EXPORT( int, __intf_UserOkayCancel,( vlc_object_t*, const char*, const char*) ); 
     177#define intf_UserYesNo( a, b, c, d, e, f ) __intf_UserYesNo( VLC_OBJECT(a),b,c, d, e, f ) 
     178VLC_EXPORT( int, __intf_UserYesNo,( vlc_object_t*, const char*, const char*, const char*, const char*, const char*) ); 
    176179 
    177 #define intf_UserProgress( a, b, c, d ) __intf_UserProgress( VLC_OBJECT(a),b,c, d ) 
    178 VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float) ); 
    179 #define intf_UserProgressUpdate( a, b, c, d ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c, d ) 
    180 VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) ); 
     180#define intf_UserProgress( a, b, c, d, e ) __intf_UserProgress( VLC_OBJECT(a),b,c,d,e ) 
     181VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float, int) ); 
     182#define intf_UserProgressUpdate( a, b, c, d, e ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c,d,e ) 
     183VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float, int) ); 
     184#define intf_UserProgressIsCancelled( a, b ) __intf_UserProgressIsCancelled( VLC_OBJECT(a),b ) 
     185VLC_EXPORT( vlc_bool_t, __intf_UserProgressIsCancelled,( vlc_object_t*, int ) ); 
    181186 
    182187#define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d ) 
     
    185190#define intf_IntfProgress( a, b, c ) __intf_IntfProgress( VLC_OBJECT(a),b,c ) 
    186191VLC_EXPORT( int, __intf_IntfProgress,( vlc_object_t*, const char*, float) ); 
    187 #define intf_IntfProgressUpdate( a, b, c, d ) __intf_IntfProgressUpdate( VLC_OBJECT(a),b,c, d ) 
     192#define intf_IntfProgressUpdate( a, b, c, d ) __intf_IntfProgressUpdate( VLC_OBJECT(a),b,c,d ) 
    188193VLC_EXPORT( void, __intf_IntfProgressUpdate,( vlc_object_t*, int, const char*, float) ); 
    189194 
  • modules/demux/avi/avi.c

    r19f724f r6cb1101  
    559559                        _( "This AVI file is broken. Seeking will not " 
    560560                        "work correctly.\nDo you want to " 
    561                         "try to repair it (this might take a long time) ?" ) ); 
     561                        "try to repair it (this might take a long time) ?" ), 
     562                        _( "Repair" ), _( "Don't repair" ), NULL ); 
    562563            if( i_create == DIALOG_OK_YES ) 
    563564            { 
  • modules/gui/macosx/interaction.h

    r2adf9ed r6cb1101  
    3232@interface VLCInteraction : NSObject 
    3333{ 
    34     /* progress widget */ 
     34    /* progress dialogue */ 
    3535    IBOutlet id o_prog_bar; 
    3636    IBOutlet id o_prog_cancel_btn; 
     
    3838    IBOutlet id o_prog_title; 
    3939    IBOutlet id o_prog_win; 
     40    IBOutlet id o_prog_timeToGo; 
    4041 
    4142    /* authentication dialogue */ 
     
    6667- (IBAction)cancelAndClose:(id)sender; 
    6768- (IBAction)okayAndClose:(id)sender; 
     69- (IBAction)cancelDialog:(id)sender; 
    6870 
    6971-(id)initDialog: (interaction_dialog_t *)_p_dialog; 
  • modules/gui/macosx/interaction.m

    r6d1c28b r6cb1101  
    131131    NSString *o_title = [NSString stringWithUTF8String:p_dialog->psz_title ? p_dialog->psz_title : "title"]; 
    132132    NSString *o_description = [NSString stringWithUTF8String:p_dialog->psz_description ? p_dialog->psz_description : ""]; 
    133      
     133    NSString *o_defaultButton = [NSString stringWithUTF8String:p_dialog->psz_defaultButton]; 
     134    NSString *o_alternateButton = [NSString stringWithUTF8String:p_dialog->psz_alternateButton]; 
     135    NSString *o_otherButton = p_dialog->psz_otherButton ? [NSString stringWithUTF8String:p_dialog->psz_otherButton] : nil; 
     136 
    134137    vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); 
    135138    if( p_vout != NULL ) 
     
    170173    else 
    171174    { 
    172         if( p_dialog->i_flags & DIALOG_OK_CANCEL ) 
    173         { 
    174             msg_Dbg( p_intf, "OK-Cancel-dialog requested" ); 
    175             NSBeginInformationalAlertSheet( o_title, _NS("OK") , _NS("Cancel"), 
    176                 nil, o_window, self, 
    177                 @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,  
    178                 o_description ); 
    179         } 
    180         else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL ) 
     175        if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL ) 
    181176        { 
    182177            msg_Dbg( p_intf, "yes-no-cancel-dialog requested" ); 
    183             NSBeginInformationalAlertSheet( o_title, _NS("Yes"), _NS("No"), 
    184                 _NS("Cancel"), o_window, self, 
     178            NSBeginInformationalAlertSheet( o_title, o_defaultButton,  
     179                o_alternateButton, o_otherButton, o_window, self, 
    185180                @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,  
    186181                o_description ); 
     
    203198            [o_prog_description setStringValue: o_description]; 
    204199            [o_prog_bar setDoubleValue: (double)p_dialog->val.f_float]; 
     200            if( p_dialog->i_timeToGo < 1 ) 
     201                [o_prog_timeToGo setStringValue: @""]; 
     202            else 
     203                [o_prog_timeToGo setStringValue: [NSString stringWithFormat: 
     204                    _NS("Remaining time: %i seconds"), p_dialog->i_timeToGo]]; 
    205205            [NSApp beginSheet: o_prog_win modalForWindow: o_window 
    206206                modalDelegate: self didEndSelector: nil contextInfo: nil]; 
     
    240240        p_dialog->i_return = DIALOG_OK_YES; 
    241241    } 
    242     else if( i_return == NSAlertAlternateReturn && ( p_dialog->i_flags & DIALOG_OK_CANCEL ) ) 
    243     { 
    244         p_dialog->i_return = DIALOG_CANCELLED; 
    245     } 
    246242    else if( i_return == NSAlertAlternateReturn ) 
    247243    { 
     
    269265            [self hideDialog]; 
    270266        } 
     267 
     268        if( p_dialog->i_timeToGo < 1 ) 
     269            [o_prog_timeToGo setStringValue: @""]; 
     270        else 
     271            [o_prog_timeToGo setStringValue: [NSString stringWithFormat: 
     272                    _NS("Remaining time: %i seconds"), p_dialog->i_timeToGo]]; 
     273 
    271274        return; 
    272275    } 
     
    322325- (IBAction)cancelAndClose:(id)sender 
    323326{ 
    324     /* tell the core that the dialog was cancelled */ 
     327    /* tell the core that the dialog was cancelled in a yes/no-style dialogue */ 
    325328    vlc_mutex_lock( &p_dialog->p_interaction->object_lock ); 
    326329    p_dialog->i_return = DIALOG_CANCELLED; 
     
    328331    vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); 
    329332    msg_Dbg( p_intf, "dialog cancelled" ); 
     333} 
     334 
     335- (IBAction)cancelDialog:(id)sender 
     336{ 
     337    /* tell core that the user wishes to cancel the dialogue 
     338     * Use this function if cancelling is optionally like in the progress-dialogue */ 
     339    vlc_mutex_lock( &p_dialog->p_interaction->object_lock ); 
     340    p_dialog->b_cancelled = VLC_TRUE; 
     341    vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); 
     342    msg_Dbg( p_intf, "cancelling dialog, will close it later on" ); 
    330343} 
    331344 
  • modules/services_discovery/shout.c

    ra7e16ca r6cb1101  
    197197    int i_dialog_id; 
    198198 
    199     i_dialog_id = intf_UserProgress( p_sd, "Shoutcast" , "Connecting...", 0.0 ); 
     199    i_dialog_id = intf_UserProgress( p_sd, "Shoutcast" , "Connecting...", 0.0, 0 ); 
    200200 
    201201    p_sys->b_dialog = VLC_TRUE; 
     
    216216                              260 /* gruiiik FIXME */; 
    217217                intf_UserProgressUpdate( p_sd, i_dialog_id, "Downloading", 
    218                                          f_pos ); 
     218                                         f_pos, 0 ); 
    219219            } 
    220220            vlc_object_release( p_input ); 
  • src/interface/interaction.c

    rfa1bf19 r6cb1101  
    144144            // Give default answer 
    145145            p_dialog->i_return = DIALOG_DEFAULT; 
    146             if( p_dialog->i_flags & DIALOG_OK_CANCEL ) 
    147                 p_dialog->i_return = DIALOG_CANCELLED; 
    148146 
    149147            // Pretend we have hidden and destroyed it 
     
    276274} 
    277275 
    278 /** Helper function to ask a yes-no question 
     276/** Helper function to ask a yes-no-cancel question 
    279277 *  \param p_this           Parent vlc_object 
    280278 *  \param psz_title        Title for the dialog 
    281279 *  \param psz_description  A description 
     280 *  \param psz_default      caption for the default button 
     281 *  \param psz_alternate    caption for the alternate button 
     282 *  \param psz_other        caption for the optional 3rd button (== cancel) 
    282283 *  \return                 Clicked button code 
    283284 */ 
    284285int __intf_UserYesNo( vlc_object_t *p_this, 
    285286                      const char *psz_title, 
    286                       const char *psz_description ) 
     287                      const char *psz_description, 
     288                      const char *psz_default, 
     289                      const char *psz_alternate, 
     290                      const char *psz_other ) 
    287291{ 
    288292    int i_ret; 
     
    295299    p_new->psz_description = strdup( psz_description ); 
    296300    p_new->i_flags = DIALOG_YES_NO_CANCEL; 
    297  
    298     i_ret = intf_Interact( p_this, p_new ); 
    299  
    300     return i_ret; 
    301 
    302  
    303 /** Helper function to trigger a okay-cancel dialogue 
    304  *  \param p_this           Parent vlc_object 
    305  *  \param psz_title        Title for the dialog 
    306  *  \param psz_description  A description 
    307  *  \return                 Clicked button code 
    308  */ 
    309 int __intf_UserOkayCancel( vlc_object_t *p_this, 
    310                       const char *psz_title, 
    311                       const char *psz_description ) 
    312 
    313     int i_ret; 
    314     interaction_dialog_t *p_new = NULL; 
    315  
    316     INTERACT_INIT( p_new ); 
    317  
    318     p_new->i_type = INTERACT_DIALOG_TWOWAY; 
    319     p_new->psz_title = strdup( psz_title ); 
    320     p_new->psz_description = strdup( psz_description ); 
    321     p_new->i_flags = DIALOG_OK_CANCEL; 
     301    p_new->psz_defaultButton = strdup( psz_default ); 
     302    p_new->psz_alternateButton = strdup( psz_alternate ); 
     303    if( psz_other ) 
     304        p_new->psz_otherButton = strdup( psz_other ); 
     305    else 
     306        p_new->psz_otherButton = NULL; 
    322307 
    323308    i_ret = intf_Interact( p_this, p_new ); 
     
    331316 *  \param psz_status       Current status 
    332317 *  \param f_position       Current position (0.0->100.0) 
     318 *  \param i_timeToGo       Time (in sec) to go until process is finished 
    333319 *  \return                 Dialog id, to give to UserProgressUpdate 
    334320 */ 
     
    336322                         const char *psz_title, 
    337323                         const char *psz_status, 
    338                          float f_pos ) 
     324                         float f_pos, 
     325                         int i_time ) 
    339326{ 
    340327    int i_ret; 
     
    347334    p_new->psz_description = strdup( psz_status ); 
    348335    p_new->val.f_float = f_pos; 
     336    p_new->i_timeToGo = i_time; 
    349337 
    350338    p_new->i_flags = DIALOG_USER_PROGRESS; 
     
    360348 *  \param psz_status       New status 
    361349 *  \param f_position       New position (0.0->100.0) 
     350 *  \param i_timeToGo       Time (in sec) to go until process is finished 
    362351 *  \return                 nothing 
    363352 */ 
    364353void __intf_UserProgressUpdate( vlc_object_t *p_this, int i_id, 
    365                                 const char *psz_status, float f_pos ) 
     354                                const char *psz_status, float f_pos,  
     355                                int i_time ) 
    366356{ 
    367357    interaction_t *p_interaction = intf_InteractionGet( p_this ); 
     
    384374 
    385375    p_dialog->val.f_float = f_pos; 
     376    p_dialog->i_timeToGo = i_time; 
    386377 
    387378    p_dialog->i_status = UPDATED_DIALOG; 
    388379    vlc_mutex_unlock( &p_interaction->object_lock) ; 
     380} 
     381 
     382/** Helper function to communicate dialogue cancellations between the intf-module and caller 
     383 *  \param p_this           Parent vlc_object 
     384 *  \param i_id             Identifier of the dialogue 
     385 *  \return                 Either true or false 
     386 */ 
     387vlc_bool_t __intf_UserProgressIsCancelled( vlc_object_t *p_this, int i_id ) 
     388{ 
     389    interaction_t *p_interaction = intf_InteractionGet( p_this ); 
     390    interaction_dialog_t *p_dialog; 
     391 
     392    if( !p_interaction ) return VLC_TRUE; 
     393 
     394    vlc_mutex_lock( &p_interaction->object_lock ); 
     395    p_dialog  =  intf_InteractionGetById( p_this, i_id ); 
     396 
     397    if( !p_dialog ) 
     398    { 
     399        vlc_mutex_unlock( &p_interaction->object_lock ) ; 
     400        return VLC_TRUE; 
     401    } 
     402 
     403    vlc_mutex_unlock( &p_interaction->object_lock) ; 
     404    return p_dialog->b_cancelled; 
    389405} 
    390406 
  • src/misc/update.c

    r1c35288 r6cb1101  
    12651265              p_this->psz_status, 0.0 ); 
    12661266    i_progress = intf_UserProgress( p_vlc, "Downloading...", 
    1267                                     psz_status, 0.0 ); 
     1267                                    psz_status, 0.0, 0 ); 
    12681268 
    12691269    p_stream = stream_UrlNew( p_vlc, psz_src ); 
     
    13101310 
    13111311                intf_UserProgressUpdate( p_vlc, i_progress, 
    1312                                          psz_status, f_progress ); 
     1312                                         psz_status, f_progress, 0 ); 
    13131313            } 
    13141314 
     
    13221322                       p_this->psz_status, psz_s2 ); 
    13231323            free( psz_s2 ); 
    1324             intf_UserProgressUpdate( p_vlc, i_progress, psz_status, 100.0 ); 
     1324            intf_UserProgressUpdate( p_vlc, i_progress, psz_status, 100.0, 0 ); 
    13251325            free( psz_status ); 
    13261326        }