~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/addins/MacPlatform/Dialogs/MacOpenFileDialogHandler.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-02-05 10:49:36 UTC
  • mto: (10.3.1)
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20120205104936-4ujoylapu24cquuo
Tags: upstream-2.8.6.3+dfsg
ImportĀ upstreamĀ versionĀ 2.8.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
                                        var selection = MacSelectFileDialogHandler.GetSelectedFiles (panel);
148
148
                                        bool slnViewerSelected = false;
149
149
                                        if (viewerSelector != null) {
150
 
                                                FillViewers (currentViewers, viewerSelector, selection);
 
150
                                                FillViewers (currentViewers, viewerSelector, closeSolutionButton, selection);
151
151
                                                if (currentViewers.Count == 0 || currentViewers[0] != null) {
152
152
                                                        if (closeSolutionButton != null)
153
153
                                                                closeSolutionButton.Hidden = true;
158
158
                                                        slnViewerSelected = true;
159
159
                                                }
160
160
                                                box.Layout ();
 
161
                                                
 
162
                                                //re-center the accessory view in its parent, Cocoa does this for us initially and after
 
163
                                                //resizing the window, but we need to do it again after altering its layout
 
164
                                                var superFrame = box.View.Superview.Frame;
 
165
                                                var frame = box.View.Frame;
 
166
                                                //not sure why it's ceiling, but this matches the Cocoa layout
 
167
                                                frame.X = (float) Math.Ceiling ((superFrame.Width - frame.Width) / 2);
 
168
                                                frame.Y = (float) Math.Ceiling ((superFrame.Height - frame.Height) / 2);
 
169
                                                box.View.Frame = frame;
161
170
                                        } 
162
171
                                        if (encodingSelector != null)
163
172
                                                encodingSelector.Enabled = !slnViewerSelected;
195
204
                        return true;
196
205
                }
197
206
                
198
 
                static void FillViewers (List<FileViewer> currentViewers, NSPopUpButton button, FilePath[] filenames)
 
207
                static void FillViewers (List<FileViewer> currentViewers, NSPopUpButton button, NSButton closeSolutionButton, FilePath[] filenames)
199
208
                {
200
209
                        button.Menu.RemoveAllItems ();
201
210
                        currentViewers.Clear ();
209
218
                        if (System.IO.Directory.Exists (filename))
210
219
                                return;
211
220
                        
 
221
                        int selected = -1;
 
222
                        int i = 0;
 
223
                        
212
224
                        if (IdeApp.Services.ProjectService.IsWorkspaceItemFile (filename) || IdeApp.Services.ProjectService.IsSolutionItemFile (filename)) {
213
225
                                button.Menu.AddItem (new NSMenuItem () { Title = GettextCatalog.GetString ("Solution Workbench") });
214
226
                                currentViewers.Add (null);
 
227
                                
 
228
                                if (closeSolutionButton != null)
 
229
                                        closeSolutionButton.State = NSCellStateValue.On;
 
230
                                
 
231
                                selected = 0;
 
232
                                i++;
215
233
                        }
 
234
                        
216
235
                        foreach (var vw in DisplayBindingService.GetFileViewers (filename, null)) {
217
236
                                if (!vw.IsExternal) {
218
237
                                        button.Menu.AddItem (new NSMenuItem () { Title = vw.Title });
219
238
                                        currentViewers.Add (vw);
 
239
                                        
 
240
                                        if (vw.CanUseAsDefault && selected == -1)
 
241
                                                selected = i;
 
242
                                        
 
243
                                        i++;
220
244
                                }
221
245
                        }
 
246
                        
 
247
                        if (selected == -1)
 
248
                                selected = 0;
 
249
                        
222
250
                        button.Enabled = currentViewers.Count > 1;
223
 
                        button.SelectItem (0);
 
251
                        button.SelectItem (selected);
224
252
                }
225
253
        }
226
 
        
227
 
 
228
254
}