]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/bookmarks.cpp
Improvements to preferences
[vlc] / modules / gui / wxwindows / bookmarks.cpp
index bf61f516d1be65232c3373041337eb5d2f9bb6ef..c3effc994ad8e066e6aaa8fb7eecb330014454b9 100644 (file)
@@ -32,9 +32,8 @@
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
 
-#include <wx/dialog.h>
-
 #include "wxwindows.h"
+#include <wx/dialog.h>
 
 /* Callback prototype */
 static int PlaylistChanged( vlc_object_t *, const char *,
@@ -85,6 +84,11 @@ private:
 
     wxListView *list_ctrl;
 };
+
+/*****************************************************************************
+ * Event Table.
+ *****************************************************************************/
+
 DEFINE_LOCAL_EVENT_TYPE( wxEVT_BOOKMARKS );
 
 BEGIN_EVENT_TABLE(BookmarksDialog, wxFrame)
@@ -146,10 +150,10 @@ BookmarkEditDialog::BookmarkEditDialog( intf_thread_t *_p_intf,
                                                p_seekpoint->psz_name : "" ),
                                 wxDefaultPosition, wxSize( 100, 20) );
     time_text = new wxTextCtrl( this, -1, wxString::Format(wxT("%d"),
-                                p_seekpoint->i_time_offset/1000000 ),
+                                (int)(p_seekpoint->i_time_offset / 1000000) ),
                                 wxDefaultPosition, wxSize( 100, 20) );
     bytes_text = new wxTextCtrl( this, -1, wxString::Format(wxT("%d"),
-                                p_seekpoint->i_byte_offset ),
+                                (int)p_seekpoint->i_byte_offset ),
                                 wxDefaultPosition, wxSize( 100, 20) );
 
     sizer->Add( new wxStaticText( this, -1, wxU(_("Name") ) ), 0, wxLEFT, 5 );
@@ -175,10 +179,10 @@ BookmarkEditDialog::~BookmarkEditDialog()
 void BookmarkEditDialog::OnOK( wxCommandEvent &event )
 {
     if( p_seekpoint->psz_name ) free( p_seekpoint->psz_name );
-    p_seekpoint->psz_name = strdup( name_text->GetValue().c_str() );
-    p_seekpoint->i_byte_offset = atoi( bytes_text->GetValue().c_str() );
+    p_seekpoint->psz_name = strdup( name_text->GetValue().mb_str() );
+    p_seekpoint->i_byte_offset = atoi( bytes_text->GetValue().mb_str() );
     p_seekpoint->i_time_offset =  1000000 *
-                                  atoll( time_text->GetValue().c_str() ) ;
+                                  atoll( time_text->GetValue().mb_str() ) ;
     EndModal( wxID_OK );
 }
 
@@ -238,9 +242,11 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf, wxWindow *p_parent )
     panel_sizer->Add( button_add, 0, wxEXPAND );
     panel_sizer->Add( button_del, 0, wxEXPAND );
     panel_sizer->Add( button_clear, 0, wxEXPAND );
+
     panel_sizer->Add( button_edit, 0, wxEXPAND );
     panel_sizer->Add( 0, 0, 1 );
     panel_sizer->Add( button_extract, 0, wxEXPAND );
+
     panel->SetSizerAndFit( panel_sizer );
 
     list_ctrl = new wxListView( main_panel, -1,
@@ -312,10 +318,11 @@ void BookmarksDialog::Update()
     for( int i = 0; i < i_bookmarks; i++ )
     {
         list_ctrl->InsertItem( i, wxL2U( pp_bookmarks[i]->psz_name ) );
+        /* FIXME: see if we can use the 64 bits integer format string */
         list_ctrl->SetItem( i, 1, wxString::Format(wxT("%d"),
-                            pp_bookmarks[i]->i_byte_offset ) );
+                            (int)(pp_bookmarks[i]->i_byte_offset) ) );
         list_ctrl->SetItem( i, 2, wxString::Format(wxT("%d"),
-                            pp_bookmarks[i]->i_time_offset/1000000 ) );
+                            (int)(pp_bookmarks[i]->i_time_offset / 1000000) ) );
     }
 
     vlc_object_release( p_input );
@@ -341,14 +348,16 @@ void BookmarksDialog::OnAdd( wxCommandEvent& event )
 
     seekpoint_t bookmark;
     vlc_value_t pos;
+    bookmark.psz_name = NULL;
+    bookmark.i_byte_offset = 0;
+    bookmark.i_time_offset = 0;
+
     var_Get( p_input, "position", &pos );
     bookmark.psz_name = NULL;
-    bookmark.i_byte_offset =
-      (int64_t)((double)pos.f_float * p_input->stream.p_selected_area->i_size);
+    input_Control( p_input, INPUT_GET_BYTE_POSITION, &bookmark.i_byte_offset );
     var_Get( p_input, "time", &pos );
     bookmark.i_time_offset = pos.i_time;
     input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
-
     vlc_object_release( p_input );
 
     Update();
@@ -425,7 +434,7 @@ void BookmarksDialog::OnExtract( wxCommandEvent& event )
     if( i_first < i_bookmarks && i_second <= i_bookmarks )
     {
         WizardDialog *p_wizard_dialog = new WizardDialog( p_intf, this,
-                               p_input->p_item->psz_uri,
+                               p_input->input.p_item->psz_uri,
                                pp_bookmarks[i_first]->i_time_offset/1000000,
                                pp_bookmarks[i_second]->i_time_offset/1000000 );
         vlc_object_release( p_input );
@@ -490,7 +499,7 @@ void BookmarksDialog::OnEdit( wxCommandEvent& event )
            if( !p_input )
            {
                 wxMessageBox( wxU( _("No input found. The stream must be "
-                                  "playing or paused for bookmarks to work") ),
+                                  "playing or paused for bookmarks to work.") ),
                                wxU( _("No input") ), wxICON_WARNING | wxOK,
                                this );
                 return;