OSDN Git Service

MacGui:
authorritsuka <ritsuka@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 8 Sep 2007 21:58:49 +0000 (21:58 +0000)
committerritsuka <ritsuka@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 8 Sep 2007 21:58:49 +0000 (21:58 +0000)
- Better menu item validation
- Sheets no long disable  every existing menu item
- Added a check for preset name length when adding a new preset

git-svn-id: svn://localhost/HandBrake/trunk@939 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.h
macosx/Controller.mm
macosx/English.lproj/MainMenu.nib/info.nib
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
macosx/PictureController.mm

index f9a1194..088ce15 100644 (file)
        
        IBOutlet NSDrawer            * fPresetDrawer;
        IBOutlet NSTextField         * fPresetNewName;
-       IBOutlet NSTextField          * fPresetNewDesc;
+       IBOutlet NSTextField         * fPresetNewDesc;
        IBOutlet NSPopUpButton       * fPresetNewPicSettingsPopUp;
        IBOutlet NSTextField         * fPresetSelectedDisplay;
        
index 9e06c49..0b7df1e 100644 (file)
@@ -521,15 +521,18 @@ static int hb_group_count(hb_handle_t * h)
     
     if (fHandle)
     {
-
-        if (action == @selector(addToQueue:) || action == @selector(showPicturePanel:))
-            return SuccessfulScan;
-            
+        if (action == @selector(addToQueue:) || action == @selector(showPicturePanel:) || action == @selector(showAddPresetPanel:))
+            return SuccessfulScan && [fWindow attachedSheet] == nil;
+        
         if (action == @selector(showScanPanel:))
         {
             if (s.state == HB_STATE_SCANNING)
                 return NO;
+            else
+                return [fWindow attachedSheet] == nil;
         }
+        if (action == @selector(selectDefaultPreset:))
+            return [tableView selectedRow] >= 0 && [fWindow attachedSheet] == nil;
         if (action == @selector(Pause:))
         {
             if (s.state == HB_STATE_WORKING)
@@ -558,12 +561,11 @@ static int hb_group_count(hb_handle_t * h)
             {
                 if(![[menuItem title] isEqualToString:@"Start Encoding"])
                     [menuItem setTitle:@"Start Encoding"];
-                return YES;
+                return [fWindow attachedSheet] == nil;
             }
             else
                 return NO;
         }
-
     
     return YES;
 }
@@ -574,13 +576,14 @@ static int hb_group_count(hb_handle_t * h)
 #define SERVICE_NAME @"Encode Done"
 - (NSDictionary *)registrationDictionaryForGrowl 
 { 
-NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: 
-[NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL, 
-[NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT, 
-nil]; 
+    NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: 
+    [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL, 
+    [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT, 
+    nil]; 
 
-return registrationDictionary; 
+    return registrationDictionary; 
 } 
+
 - (void) TranslateStrings
 {
     [fSrcTitleField     setStringValue: _( @"Title:" )];
@@ -2687,8 +2690,6 @@ the user is using "Custom" settings by determining the sender*/
                [fPresetSelectedDisplay setStringValue: @"Custom"];
                
                curUserPresetChosenNum = nil;
-
-               
        }
 
 }
@@ -2751,40 +2752,40 @@ the user is using "Custom" settings by determining the sender*/
 - (IBAction) showAddPresetPanel: (id) sender
 {
     /* Deselect the currently selected Preset if there is one*/
-               [tableView deselectRow:[tableView selectedRow]];
+    [tableView deselectRow:[tableView selectedRow]];
 
-       /* Populate the preset picture settings popup here */
-       [fPresetNewPicSettingsPopUp removeAllItems];
-       [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
-       [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
-       [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
-       [fPresetNewPicSettingsPopUp selectItemAtIndex: 0];      
+    /* Populate the preset picture settings popup here */
+    [fPresetNewPicSettingsPopUp removeAllItems];
+    [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
+    [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
+    [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
+    [fPresetNewPicSettingsPopUp selectItemAtIndex: 0]; 
        
-               /* Erase info from the input fields fPresetNewDesc*/
+    /* Erase info from the input fields fPresetNewDesc*/
        [fPresetNewName setStringValue: @""];
        [fPresetNewDesc setStringValue: @""];
        /* Show the panel */
-       [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow
-        modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
-    [NSApp runModalForWindow: fAddPresetPanel];
-    [NSApp endSheet: fAddPresetPanel];
-    [fAddPresetPanel orderOut: self];
+       [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
 }
 
 - (IBAction) closeAddPresetPanel: (id) sender
 {
-       [NSApp stopModal];
+    [NSApp endSheet: fAddPresetPanel];
+    [fAddPresetPanel orderOut: self];
 }
 
-
 - (IBAction)addUserPreset:(id)sender
 {
-    /* Here we create a custom user preset */
-    [UserPresets addObject:[self createPreset]];
-    
-       /* We stop the modal window for the new preset */
-       [NSApp stopModal];
-    [self addPreset];
+    if (![[fPresetNewName stringValue] length])
+            NSRunAlertPanel(@"Warning!", @"You need to insert a name for the preset.", @"OK", nil , nil);
+    else
+    {
+        /* Here we create a custom user preset */
+        [UserPresets addObject:[self createPreset]];
+        [self addPreset];
+        
+        [self closeAddPresetPanel:NULL];
+    }
 }
 - (void)addPreset
 {
index 05de1f8..f7c6e6b 100644 (file)
@@ -27,8 +27,9 @@
        <integer>4</integer>
        <key>IBOpenObjects</key>
        <array>
-               <integer>29</integer>
                <integer>21</integer>
+               <integer>1843</integer>
+               <integer>29</integer>
                <integer>1867</integer>
        </array>
        <key>IBSystem Version</key>
index 86a3c3b..337f96f 100644 (file)
Binary files a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib and b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib differ
index a8ae974..c274c19 100644 (file)
@@ -346,7 +346,8 @@ static int GetAlignedSize( int size )
 
 - (IBAction) ClosePanel: (id) sender
 {
-       [NSApp stopModal];
+    [NSApp endSheet: fPicturePanel];
+    [fPicturePanel orderOut: self];
 }
 
 - (BOOL) autoCrop
@@ -399,9 +400,6 @@ static int GetAlignedSize( int size )
 
     [NSApp beginSheet: fPicturePanel modalForWindow: fWindow
         modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
-    [NSApp runModalForWindow: fPicturePanel];
-    [NSApp endSheet: fPicturePanel];
-    [fPicturePanel orderOut: self];
 }
 
 - (BOOL) loadMyNibFile