Revision: 2802
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2802&view=rev
Author:   hofman
Date:     2007-09-01 10:45:59 -0700 (Sat, 01 Sep 2007)

Log Message:
-----------
Define method to find format popup in an NSView category.

Modified Paths:
--------------
    trunk/SKDocument.h
    trunk/SKDocument.m
    trunk/SKPreferenceController.m

Modified: trunk/SKDocument.h
===================================================================
--- trunk/SKDocument.h  2007-09-01 17:02:12 UTC (rev 2801)
+++ trunk/SKDocument.h  2007-09-01 17:45:59 UTC (rev 2802)
@@ -141,6 +141,11 @@
 @end
 
 
[EMAIL PROTECTED] NSView (SKExtensions)
+- (id)subviewOfClass:(Class)aClass;
[EMAIL PROTECTED]
+
+
 @interface NSTask (SKExtensions)
 + (BOOL)runTaskWithLaunchPath:(NSString *)launchPath arguments:(NSArray 
*)arguments currentDirectoryPath:(NSString *)directoryPath;
 @end

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2007-09-01 17:02:12 UTC (rev 2801)
+++ trunk/SKDocument.m  2007-09-01 17:45:59 UTC (rev 2802)
@@ -159,37 +159,23 @@
 
 #pragma mark Document read/write
 
-static NSPopUpButton *popUpButtonSubview(NSView *view)
-{
-       if ([view isKindOfClass:[NSPopUpButton class]])
-               return (NSPopUpButton *)view;
-       
-       NSEnumerator *viewEnum = [[view subviews] objectEnumerator];
-       NSView *subview;
-       NSPopUpButton *popup;
-       
-       while (subview = [viewEnum nextObject]) {
-               if (popup = popUpButtonSubview(subview))
-                       return popup;
-       }
-       return nil;
-}
-
 - (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {
     if (exportUsingPanel) {
-        NSPopUpButton *formatPopup = popUpButtonSubview([savePanel 
accessoryView]);
-        NSString *lastExportedType = [[NSUserDefaults standardUserDefaults] 
stringForKey:@"SKLastExportedType"];
-        if ([[self pdfDocument] allowsPrinting] == NO) {
-            int index = [formatPopup 
indexOfItemWithRepresentedObject:SKEmbeddedPDFDocumentType];
-            if (index != -1)
-                [formatPopup removeItemAtIndex:index];
-        }
-        if (formatPopup && lastExportedType) {
-            int index = [formatPopup 
indexOfItemWithRepresentedObject:lastExportedType];
-            if (index != -1 && index != [formatPopup indexOfSelectedItem]) {
-                [formatPopup selectItemAtIndex:index];
-                [formatPopup sendAction:[formatPopup action] to:[formatPopup 
target]];
+        NSPopUpButton *formatPopup = [[savePanel accessoryView] 
subviewOfClass:[NSPopUpButton class]];
+        if (formatPopup) {
+            NSString *lastExportedType = [[NSUserDefaults 
standardUserDefaults] stringForKey:@"SKLastExportedType"];
+            if ([[self pdfDocument] allowsPrinting] == NO) {
+                int index = [formatPopup 
indexOfItemWithRepresentedObject:SKEmbeddedPDFDocumentType];
+                if (index != -1)
+                    [formatPopup removeItemAtIndex:index];
             }
+            if (lastExportedType) {
+                int index = [formatPopup 
indexOfItemWithRepresentedObject:lastExportedType];
+                if (index != -1 && index != [formatPopup indexOfSelectedItem]) 
{
+                    [formatPopup selectItemAtIndex:index];
+                    [formatPopup sendAction:[formatPopup action] 
to:[formatPopup target]];
+                }
+            }
         }
     }
     return YES;
@@ -1668,6 +1654,25 @@
 @end
 
 
[EMAIL PROTECTED] NSView (SKExtensions)
+
+- (id)subviewOfClass:(Class)aClass {
+       if ([self isKindOfClass:aClass])
+               return self;
+       
+       NSEnumerator *viewEnum = [[self subviews] objectEnumerator];
+       NSView *view, *subview;
+       
+       while (subview = [viewEnum nextObject]) {
+               if (view = [subview subviewOfClass:aClass])
+                       return view;
+       }
+       return nil;
+}
+
[EMAIL PROTECTED]
+
+
 @implementation NSTask (SKExtensions) 
 
 + (BOOL)runTaskWithLaunchPath:(NSString *)launchPath arguments:(NSArray 
*)arguments currentDirectoryPath:(NSString *)directoryPath {

Modified: trunk/SKPreferenceController.m
===================================================================
--- trunk/SKPreferenceController.m      2007-09-01 17:02:12 UTC (rev 2801)
+++ trunk/SKPreferenceController.m      2007-09-01 17:45:59 UTC (rev 2802)
@@ -49,27 +49,27 @@
 static NSString *SKTeXEditorArguments[] = {@"-l %line \"%file\"", @"+%line 
\"%file\"", @"+%line \"%file\"", @"--no-wait +%line \"%file\"", @"--no-wait 
+%line \"%file\"", @"\"%file\" %line"};
 
 
[EMAIL PROTECTED] NSView (SKExtensions)
[EMAIL PROTECTED] NSView (SKPreferenceControllerExtensions)
 - (void)deactivateColorAndLineWells;
 @end
 
[EMAIL PROTECTED] NSView (SKExtensions)
[EMAIL PROTECTED] NSView (SKPreferenceControllerExtensions)
 - (void)deactivateColorAndLineWells {
     [[self subviews] makeObjectsPerformSelector:_cmd];
 }
 @end
 
[EMAIL PROTECTED] NSColorWell (SKExtensions)
[EMAIL PROTECTED] NSColorWell (SKPreferenceControllerExtensions)
 @end
 
[EMAIL PROTECTED] NSColorWell (SKExtensions)
[EMAIL PROTECTED] NSColorWell (SKPreferenceControllerExtensions)
 - (void)deactivateColorAndLineWells {
     [self deactivate];
     [super deactivateColorAndLineWells];
 }
 @end
 
[EMAIL PROTECTED] SKLineWell (SKExtensions)
[EMAIL PROTECTED] SKLineWell (SKPreferenceControllerExtensions)
 - (void)deactivateColorAndLineWells {
     [self deactivate];
     [super deactivateColorAndLineWells];


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to