Changeset 143 for trunk


Ignore:
Timestamp:
02/15/07 16:10:15 (5 years ago)
Author:
jlee
Message:

Generic sort-of extendable progress dialog and prevent infinite loops on mplayer commands

Location:
trunk/src/org/thestaticvoid/iriverter
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/thestaticvoid/iriverter/Converter.java

    r117 r143  
    320320                progressDialogInfo.setStatus("Gathering information about the input video..."); 
    321321                 
    322                 MPlayerInfo info = new MPlayerInfo("dvd://" + dvdInfo.getTitle(), dvdInfo.getDrive()); 
     322                MPlayerInfo info = new MPlayerInfo("dvd://" + dvdInfo.getTitle(), dvdInfo.getDrive(), ConverterOptions.getMPlayerPath()); 
    323323                 
    324324                List commandList = prepareBaseCommandList("dvd://" + dvdInfo.getTitle(), dvdInfo.getOutputVideo(), info); 
  • trunk/src/org/thestaticvoid/iriverter/ConverterUI.java

    r135 r143  
    394394                                        progressDialog.open(); 
    395395                                        converter.cancel(); 
     396                                         
     397                                        canceled = true; 
    396398                                } catch (MPlayerNotFoundException mpe) { 
    397399                                        canceled = new MPlayerPathDialog(shell, SWT.NONE).open(); 
     
    407409         
    408410                        if (file != null) { 
    409                                 try { 
    410                                         proc = Runtime.getRuntime().exec(new String[]{MPlayerInfo.getMPlayerPath() + "mplayer", file}); 
    411                                 } catch (IOException io) { 
    412                                         io.printStackTrace(); 
    413                                 } catch (MPlayerNotFoundException mpe) { 
    414                                         MPlayerPathDialog dialog = new MPlayerPathDialog(shell, SWT.NONE); 
    415                                         dialog.open(); 
    416                                 } 
     411                                boolean canceled = false; 
     412                                while (!canceled) 
     413                                        try { 
     414                                                proc = Runtime.getRuntime().exec(new String[]{MPlayerInfo.getMPlayerPath() + "mplayer", file}); 
     415                                                canceled = true; 
     416                                        } catch (IOException io) { 
     417                                                io.printStackTrace(); 
     418                                                canceled = true; 
     419                                        } catch (MPlayerNotFoundException mpe) { 
     420                                                canceled = new MPlayerPathDialog(shell, SWT.NONE).open(); 
     421                                        } 
    417422                        } 
    418423                } 
  • trunk/src/org/thestaticvoid/iriverter/DVD.java

    r117 r143  
    244244                                                 
    245245                                                proc = Runtime.getRuntime().exec(command); 
     246                                                 
     247                                                canceled = true; 
    246248                                        } catch (IOException io) { 
    247249                                                io.printStackTrace(); 
     
    338340 
    339341                                setLanguageCombos(); 
     342                                 
     343                                canceled = true; 
    340344                        } catch (MPlayerNotFoundException mpe) { 
    341345                                canceled = new MPlayerPathDialog(getParent().getShell(), SWT.NONE).open(); 
  • trunk/src/org/thestaticvoid/iriverter/DVDInfoReader.java

    r117 r143  
    4040        public void run() { 
    4141                int numberOfTitles = new MPlayerInfo("dvd://", drive, mplayerPath).getNumberOfTitles(); 
    42                 progressDialog.setNumberOfTitles(numberOfTitles); 
     42                progressDialog.setMaximum(numberOfTitles); 
    4343                 
    4444                for (int i = 1; i <= numberOfTitles; i++) { 
    45                         progressDialog.setCurrentTitle(i); 
     45                        progressDialog.setCurrent(i); 
    4646                        MPlayerInfo rawTitleInfo = new MPlayerInfo("dvd://" + i, drive, mplayerPath); 
    4747                         
  • trunk/src/org/thestaticvoid/iriverter/DVDProgressDialog.java

    r117 r143  
    2222package org.thestaticvoid.iriverter; 
    2323 
    24 import org.eclipse.swt.*; 
    2524import org.eclipse.swt.widgets.*; 
    26 import org.eclipse.swt.layout.*; 
    27 import org.eclipse.swt.graphics.*; 
    2825 
    29 public class DVDProgressDialog extends Dialog { 
    30         private Shell shell; 
    31         private int style, syncNumberOfTitles, syncCurrentTitle; 
    32         private Label header, status; 
    33         private ProgressBar progressBar; 
    34          
    35         public DVDProgressDialog(Shell shell, int style) { 
    36                 super(shell, style); 
     26public class DVDProgressDialog extends GenericProgressDialog { 
     27        public DVDProgressDialog(Shell parent, int style) { 
     28                super(parent, style, "Gathering Information About DVD"); 
    3729        } 
    3830         
    39         public void open() {             
    40                 shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 
    41                 shell.setText("Gathering Information About DVD"); 
    42                 GridLayout gridLayout = new GridLayout(); 
    43                 gridLayout.horizontalSpacing = 6; 
    44                 gridLayout.verticalSpacing = 6; 
    45                 gridLayout.marginHeight = 12; 
    46                 gridLayout.marginWidth = 12; 
    47                 shell.setLayout(gridLayout); 
     31        public String getStatusText() { 
     32                if (getMaximum() == 0) 
     33                        return "Getting how many titles are on the DVD"; 
    4834                 
    49                 header = new Label(shell, SWT.NONE); 
    50                 header.setText("Gathering Information About DVD"); 
    51                 FontData[] fontData = header.getFont().getFontData(); 
    52                 fontData[0].setStyle(SWT.BOLD); 
    53                 fontData[0].setHeight(fontData[0].getHeight() + 4); 
    54                 header.setFont(new Font(Display.getDefault(), fontData)); 
    55                  
    56                 progressBar = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH); 
    57                 progressBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
    58                  
    59                 status = new Label(shell, SWT.NONE); 
    60                 status.setText("Getting how many titles are on the DVD"); 
    61                 fontData = status.getFont().getFontData(); 
    62                 fontData[0].setStyle(SWT.ITALIC); 
    63                 status.setFont(new Font(getParent().getDisplay(), fontData)); 
    64                  
    65                 shell.pack(); 
    66                 shell.setSize(400, shell.getSize().y); 
    67                  
    68                 shell.open(); 
    69                 while (!shell.isDisposed()) 
    70                         if (!getParent().getDisplay().readAndDispatch()) 
    71                                 getParent().getDisplay().sleep(); 
    72         } 
    73          
    74         public synchronized void close() { 
    75                 Display.getDefault().syncExec(new Runnable() { 
    76                         public void run() { 
    77                                 shell.dispose(); 
    78                         } 
    79                 }); 
    80         } 
    81          
    82         public synchronized void setNumberOfTitles(int numberOfTitles) { 
    83                 syncNumberOfTitles = numberOfTitles; 
    84          
    85                 Display.getDefault().syncExec(new Runnable() { 
    86                         public void run() { 
    87                                 progressBar.setMaximum(syncNumberOfTitles); 
    88                         } 
    89                 }); 
    90         } 
    91          
    92         public synchronized void setCurrentTitle(int currentTitle) { 
    93                 syncCurrentTitle = currentTitle; 
    94                  
    95                 Display.getDefault().syncExec(new Runnable() { 
    96                         public void run() { 
    97                                 progressBar.setSelection(syncCurrentTitle); 
    98                                 status.setText("Reading title " + syncCurrentTitle + " of " + syncNumberOfTitles); 
    99                                 status.pack(); 
    100                         } 
    101                 }); 
     35                return "Reading title " + getCurrent() + " of " + getMaximum(); 
    10236        } 
    10337} 
  • trunk/src/org/thestaticvoid/iriverter/MPlayerInfo.java

    r117 r143  
    4242                String[] command = null; 
    4343                if (dvdDrive != null) 
    44                         command = new String[]{mplayerPath + "mplayer", "-vo", "null", "-ao", "null", "-frames", "1", "-dvd-device", dvdDrive, video.toString(), "-v", "-identify"}; 
     44                        command = new String[]{mplayerPath + File.separator + "mplayer", "-vo", "null", "-ao", "null", "-frames", "1", "-dvd-device", dvdDrive, video.toString(), "-v", "-identify"}; 
    4545                else 
    46                         command = new String[]{mplayerPath + "mplayer", "-vo", "null", "-ao", "null", "-frames", "1", video.toString(), "-identify"}; 
     46                        command = new String[]{mplayerPath + File.separator + "mplayer", "-vo", "null", "-ao", "null", "-frames", "1", video.toString(), "-identify"}; 
    4747                 
    4848                String commandStr = ""; 
  • trunk/src/org/thestaticvoid/iriverter/ManualSplit.java

    r117 r143  
    187187                                                sec.setText("00"); 
    188188                                                marksList.removeAll(); 
     189                                                 
     190                                                canceled = true; 
    189191                                        } catch (MPlayerNotFoundException mpe) { 
    190192                                                canceled = new MPlayerPathDialog(getParent().getShell(), SWT.NONE).open(); 
Note: See TracChangeset for help on using the changeset viewer.