]> git.sesse.net Git - vlc/commitdiff
* new dialogue type to prompt the user for a string
authorFelix Paul Kühne <fkuehne@videolan.org>
Sun, 14 May 2006 14:36:08 +0000 (14:36 +0000)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sun, 14 May 2006 14:36:08 +0000 (14:36 +0000)
* 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

extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib
extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib
extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib
include/vlc_interaction.h
modules/gui/macosx/interaction.h
modules/gui/macosx/interaction.m
src/interface/interaction.c

index 1c88a82d039d908d1ff88c419e7dc200e8e92599..e384c091c36bf7a3192dba3cceb3beaa5e0a21d3 100644 (file)
                 "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; 
index 1948872518da02a9414fd2696b6f5f43d27c62ea..cd510a34d2ca85c8072e3d715639c3668cec58c9 100644 (file)
@@ -8,6 +8,7 @@
        <string>443.0</string>
        <key>IBOpenObjects</key>
        <array>
+               <integer>79</integer>
                <integer>55</integer>
        </array>
        <key>IBSystem Version</key>
index 6d5426a777288f7dceca048dfd0a04dc33883ad9..926546adf28b12c6ec3a90c5fd2f32c916d45d99 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib differ
index 25aeb6dfd454f55cb3cad07bb83ca7d71383f3fa..36ec30c0ae992227a9486fce15263ca284b2eec1 100644 (file)
@@ -83,6 +83,7 @@ struct interaction_dialog_t
 #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
@@ -176,6 +177,9 @@ VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*,
 #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 ));
 
index 444b1300156f69cae7ddafcd3cb6eb4a38b92c28..12f21c616b4860ec82eb8d1cf935a598400c3364 100644 (file)
     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;
index 97b90cbdfe39fe3b93faae8b53be40e8c4e63052..4a03f9cbd7633ceadbeda6ac90994c5ca89bff15 100644 (file)
 
 -(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 );
index 466cb14b7f1a6f357bcd11c53465b3f69e55a3f9..214ce959e4481e343c9e41c1ea1d4fa1f4f52406 100644 (file)
@@ -221,12 +221,9 @@ void intf_InteractionManage( playlist_t *p_playlist )
 }
 
 
-
 #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;                                          \
@@ -250,7 +247,6 @@ void __intf_UserFatal( vlc_object_t *p_this,
 {
     va_list args;
     interaction_dialog_t *p_new = NULL;
-    user_widget_t *p_widget = NULL;
     int i_id = DIALOG_ERRORS;
 
     if( i_id > 0 )
@@ -272,20 +268,10 @@ void __intf_UserFatal( vlc_object_t *p_this,
     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 );
@@ -303,29 +289,45 @@ int __intf_UserYesNo( vlc_object_t *p_this,
 {
     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
@@ -354,7 +356,7 @@ int __intf_UserProgress( vlc_object_t *p_this,
     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
@@ -388,7 +390,7 @@ void __intf_UserProgressUpdate( vlc_object_t *p_this, int i_id,
     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
@@ -424,6 +426,39 @@ int __intf_UserLoginPassword( vlc_object_t *p_this,
     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
@@ -629,24 +664,13 @@ static interaction_dialog_t *intf_InteractionGetById( vlc_object_t* p_this,
 
 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 );
 }