File: patch1

package info (click to toggle)
sudoku.app 0.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 196 kB
  • sloc: objc: 1,728; makefile: 9
file content (195 lines) | stat: -rw-r--r-- 5,124 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
--- Controller.m	2011-06-16 10:35:03.000000000 +0200
+++ /home/multix/Desktop/Controller.m	2011-06-16 10:38:09.000000000 +0200
@@ -42,9 +42,11 @@
 
 + (NSPanel *)prog_ind
 {
-    if(_prog_ind_panel==nil){
+    if(_prog_ind_panel==nil)
+      {
 	NSRect pi_frame =
 	    NSMakeRect(0, 0, PROG_IND_WIDTH, PROG_IND_HEIGHT);
+	KnobView *_prog_ind;
 
         _prog_ind_panel = 
             [[NSPanel alloc]
@@ -54,8 +56,7 @@
                 defer:NO];
         [_prog_ind_panel setReleasedWhenClosed:NO];
         
-	KnobView *_prog_ind =
-	    [[KnobView alloc] initWithFrame:pi_frame];
+	_prog_ind = [[KnobView alloc] initWithFrame:pi_frame];
         [_prog_ind_panel setContentView:_prog_ind];
 
 	[_prog_ind_panel setTitle:_(@"Computing Sudoku")];
@@ -184,12 +188,14 @@
 - makeInputPanel
 {
   int m = NSTitledWindowMask;
-
-  NSRect frame = 
-      {{ 0, BUTTON_HEIGHT + DIGIT_FIELD_DIM},  { SDK_DIM, SDK_DIM} };
+  int x;
+  float margin;
+  NSButton *button;
+  NSRect allframe ;
+  NSRect frame = {{ 0, BUTTON_HEIGHT + DIGIT_FIELD_DIM},  { SDK_DIM, SDK_DIM} };
   sdkview  = [[SudokuView alloc] initWithFrame:frame];
 
-  NSRect allframe = frame;
+  allframe = frame;
   allframe.size.height += BUTTON_HEIGHT + DIGIT_FIELD_DIM;
 
   enterPanel = 
@@ -202,10 +208,9 @@
 
   [[enterPanel contentView] addSubview:sdkview];
 
-  float margin = (SDK_DIM - DIGIT_FIELD_DIM*10)/2;
+  margin = (SDK_DIM - DIGIT_FIELD_DIM*10)/2;
   assert(margin>0);
 
-  int x;
   for(x=1; x<=10; x++){
       DigitSource *dgs =
 	[[DigitSource alloc] 
@@ -216,13 +221,12 @@
   }
 
 
-  NSButton *button = [NSButton new];
+  button = [NSButton new];
   [button setTitle:_(@"Enter")];
   [button setTarget:self];
   [button setAction:@selector(actionEnter:)];
 
-  [button 
-      setFrame:NSMakeRect(0, 0, SDK_DIM/3, BUTTON_HEIGHT)];
+  [button setFrame:NSMakeRect(0, 0, SDK_DIM/3, BUTTON_HEIGHT)];
   
   [[enterPanel contentView] addSubview:button];
 
@@ -231,8 +235,7 @@
   [button setTarget:self];
   [button setAction:@selector(actionReset:)];
 
-  [button 
-      setFrame:NSMakeRect(SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
+  [button setFrame:NSMakeRect(SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
   
   [[enterPanel contentView] addSubview:button];
 
@@ -241,8 +244,7 @@
   [button setTarget:self];
   [button setAction:@selector(actionCancel:)];
 
-  [button 
-      setFrame:NSMakeRect(2*SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
+  [button setFrame:NSMakeRect(2*SDK_DIM/3, 0, SDK_DIM/3, BUTTON_HEIGHT)];
   
   [[enterPanel contentView] addSubview:button];
 
@@ -255,40 +257,50 @@
 
 - actionEnter:(id)sender
 {
-    [[NSApplication sharedApplication]
-        stopModal];
+  BOOL success;
+  NSDocumentController *dc;
+  Document *doc;
+  Sudoku *sdk;
+  Sudoku *user;
+  NSPanel *pi_panel;
+  KnobView *pi;
+  NSModalSession solveSession;
+  float percent, dir;
+  NSDate *end;
+
+    [[NSApplication sharedApplication] stopModal];
     [enterPanel orderOut:self];
 
     [palette orderFront:self];
 
-    NSApplication *app = [NSApplication sharedApplication];
-
-    NSDocumentController *dc =
-        [NSDocumentController sharedDocumentController];
+    dc = [NSDocumentController sharedDocumentController];
     [dc newDocument:self];
 
-    Document *doc = [dc currentDocument];
-    Sudoku *sdk = [doc sudoku], *user = [sdkview sudoku];
+    doc = [dc currentDocument];
+    sdk = [doc sudoku];
+    user = [sdkview sudoku];
 
     [sdk copyStateFromSource:user];
     [sdk guessToClues];
     // [sdk cluesToPuzzle];
 
-    NSPanel *pi_panel = [Controller prog_ind];
-    KnobView *pi = [pi_panel contentView];
+    pi_panel = [Controller prog_ind];
+    pi = [pi_panel contentView];
     
     [pi_panel makeKeyAndOrderFront:self];
 
-    NSModalSession solveSession;
-    solveSession = [app beginModalSessionForWindow:pi_panel];
+    solveSession = [[NSApplication sharedApplication] beginModalSessionForWindow:pi_panel];
 
-    float percent = 0, dir = 1;
+    percent = 0;
+    dir = 1;
 
-    BOOL success;
-    NSDate *end = [NSDate dateWithTimeIntervalSinceNow:MAX_SOLVE_SECS];
+    end = [NSDate dateWithTimeIntervalSinceNow:MAX_SOLVE_SECS];
 
+    success = NO;
     do {
 	int tick;
+	NSDate *now;
+
 	for(tick=0; tick<TICK_ITER; tick++){
 	    [pi setPercent:percent];
 	    [pi display];
@@ -305,9 +317,9 @@
 	    dir = +1;
 	}
 
-	[app runModalSession:solveSession];
+	[[NSApplication sharedApplication] runModalSession:solveSession];
 
-	NSDate *now = [NSDate date];
+	now = [NSDate date];
 	if([now laterDate:end]==now){
 	    break;
 	}
@@ -316,7 +328,7 @@
     } while(success==NO);
 
     [pi_panel orderOut:self];
-    [app endModalSession:solveSession];
+    [[NSApplication sharedApplication] endModalSession:solveSession];
 
     if(success==NO){
 	NSRunAlertPanel(_(@"Solve failed"),
@@ -401,6 +413,7 @@
 
 - makeDigitPalette
 {
+  int x, y;
   NSRect pbounds = 
     NSMakeRect(0, 0, 2*DIGIT_FIELD_DIM, 5*DIGIT_FIELD_DIM);
 
@@ -425,7 +438,6 @@
   [palette setFrameAutosaveName: @"SudokuDigitPalette"];
 
 
-  int x, y;
   for(x=0; x<2; x++){
     for(y=0; y<5; y++){
       DigitSource *dgs =