~ubuntu-branches/ubuntu/vivid/projectcenter.app/vivid

« back to all changes in this revision

Viewing changes to Framework/PCFileManager.m

  • Committer: Bazaar Package Importer
  • Author(s): Yavor Doganov
  • Date: 2010-06-03 16:04:52 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100603160452-dcsmkjwdtwxuitdo
Tags: 0.5.3~20100601-1
* New upstream release.
* debian/compat: Set to 7.
* debian/control (Section): Change to `gnustep'.
  (Build-Depends): Require debhelper >= 7, remove version constraints
  for libgnustep-gui-dev (obsolete).
  (Depends): Add ${gnustep:Depends}.
  (Standards-Version): Compliant with 3.8.4 as of this release.
  (Vcs-Arch): New field.
  (Description): Do not praise NextStep.
* debian/rules: Export GNUSTEP_MAKEFILES and get rid of gs_make.
  (OPTFLAG): No longer define; rework noopt handling to be compatible
  with gnustep-make/2.4.x (Closes: #581976).
  (build-stamp): Pass GDB=/usr/bin/gdb for the PCDefaultDebugger
  define.
  (install): Replace dh_clean -k with dh_prep.
  (binary-arch): Adjust dh_installchangelogs' argument.  Rework the
  FHS_ME_HARDER snippet; PC's supporting executables are no longer
  installed as Bundles.
* debian/patches/05_link-libs.dpatch: Update; the fix was merged
  upstream, but now -lm is required as well.
* debian/patches/10_bundles-install-dir.dpatch: Remove; obsolete with
  the new way of FHS-compliance handling.
* debian/links: Delete; no longer needed.
* debian/menu: Adjust command.
* debian/source/format:
* debian/README.source:
* debian/preinst: New file.
* debian/copyright: Bump copyright years, add more upstream authors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
24
24
*/
25
25
 
26
 
#include <ProjectCenter/PCDefines.h>
27
 
#include <ProjectCenter/PCFileManager.h>
28
 
#include <ProjectCenter/PCFileCreator.h>
29
 
#include <ProjectCenter/PCProjectManager.h>
30
 
#include <ProjectCenter/PCProject.h>
31
 
#include <ProjectCenter/PCProjectBrowser.h>
32
 
#include <ProjectCenter/PCAddFilesPanel.h>
 
26
#import <ProjectCenter/PCDefines.h>
 
27
#import <ProjectCenter/PCFileManager.h>
 
28
#import <ProjectCenter/PCFileCreator.h>
 
29
#import <ProjectCenter/PCProjectManager.h>
 
30
#import <ProjectCenter/PCProject.h>
 
31
#import <ProjectCenter/PCProjectBrowser.h>
 
32
#import <ProjectCenter/PCAddFilesPanel.h>
33
33
 
34
 
#include <ProjectCenter/PCLogController.h>
 
34
#import <Protocols/Preferences.h>
 
35
#import <ProjectCenter/PCLogController.h>
35
36
 
36
37
@implementation PCFileManager
37
38
 
150
151
      directoryPath = [toFile stringByDeletingLastPathComponent];
151
152
      if ([self createDirectoriesIfNeededAtPath:directoryPath] == NO)
152
153
        {
153
 
          NSLog(@"PCFileManager: createDirectoriesIfNeededAtPath: == NO");
 
154
          NSRunAlertPanel(@"Copy File",
 
155
                          @"Couldn't create directories at path %@",
 
156
                          @"Ok",nil,nil, directoryPath);
154
157
          return NO;
155
158
        }
156
159
 
157
160
      if ([fm copyPath:file toPath:toFile handler:self] == NO)
158
161
        {
159
 
          NSLog(@"PCFileManager: copyPath:toPath: == NO");
 
162
          NSRunAlertPanel(@"Copy File",
 
163
                          @"Couldn't copy file %@ to %@",
 
164
                          @"Ok",nil,nil, file, toFile);
160
165
          return NO;
161
166
        }
162
167
    }
176
181
  path = [directory stringByAppendingPathComponent:[file lastPathComponent]];
177
182
 
178
183
  if (![self copyFile:file toFile:path])
179
 
    {
 
184
    { // No need to open aler panel here
180
185
      return NO;
181
186
    }
182
187
 
234
239
    {
235
240
      if ([fm removeFileAtPath:path handler:nil] == NO)
236
241
        {
 
242
          NSRunAlertPanel(@"Remove Directory",
 
243
                          @"Couldn't remove empty directory at path %@",
 
244
                          @"Ok",nil,nil, path);
237
245
          return NO;
238
246
        }
239
247
      path = [path stringByDeletingLastPathComponent];
257
265
  path = [directory stringByAppendingPathComponent:file];
258
266
  if (![fm removeFileAtPath:path handler:nil])
259
267
    {
260
 
      NSLog(@"PCFileManager: removeFileAtPath: == NO");
 
268
      NSRunAlertPanel(@"Remove File",
 
269
                      @"Couldn't remove file at path %@",
 
270
                      @"Ok",nil,nil, path);
261
271
      return NO;
262
272
    }
263
273
 
310
320
    }
311
321
  else
312
322
    {
 
323
      NSRunAlertPanel(@"Move File",
 
324
                      @"Couldn't move file %@ to %@",
 
325
                      @"Ok",nil,nil, file, directory);
313
326
      return NO;
314
327
    }
315
328
 
328
341
                   title:(NSString *)title
329
342
                 accView:(NSView *)accessoryView
330
343
{
331
 
  NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
332
 
  NSString       *lastOpenDir;
333
 
  id             panel;
 
344
  id <PCPreferences> prefs = [projectManager prefController];
 
345
  NSString           *lastOpenDir;
 
346
  id                 panel;
334
347
 
335
348
  operation = op;
336
349
 
340
353
      panel = [NSOpenPanel openPanel];
341
354
      [panel setCanChooseFiles:YES];
342
355
      [panel setCanChooseDirectories:NO];
343
 
      lastOpenDir = [ud objectForKey:@"FileOpenLastDirectory"];
 
356
      lastOpenDir = [prefs stringForKey:@"FileOpenLastDirectory"];
344
357
      break;
345
358
    case PCSaveFileOperation: 
346
359
      panel = [NSSavePanel savePanel];
347
 
      lastOpenDir = [ud objectForKey:@"FileSaveLastDirectory"];
 
360
      lastOpenDir = [prefs stringForKey:@"FileSaveLastDirectory"];
348
361
      break;
349
362
    case PCOpenProjectOperation: 
350
363
      panel = [NSOpenPanel openPanel];
351
364
      [panel setAllowsMultipleSelection:NO];
352
365
      [panel setCanChooseFiles:YES];
353
366
      [panel setCanChooseDirectories:YES];
354
 
      lastOpenDir = [ud objectForKey:@"ProjectOpenLastDirectory"];
 
367
      lastOpenDir = [prefs stringForKey:@"ProjectOpenLastDirectory"];
 
368
      break;
 
369
    case PCOpenDirectoryOperation: 
 
370
      panel = [NSOpenPanel openPanel];
 
371
      [panel setCanChooseFiles:NO];
 
372
      [panel setCanChooseDirectories:YES];
 
373
      lastOpenDir = [prefs stringForKey:@"FileOpenLastDirectory"];
355
374
      break;
356
375
    case PCAddFileOperation: 
357
376
      if (addFilesPanel == nil)
359
378
          addFilesPanel = [PCAddFilesPanel addFilesPanel];
360
379
        }
361
380
      panel = addFilesPanel;
362
 
      lastOpenDir = [ud objectForKey:@"FileAddLastDirectory"];
 
381
      lastOpenDir = [prefs stringForKey:@"FileAddLastDirectory"];
363
382
      break;
364
383
    default:
365
384
      return nil;
388
407
 
389
408
- (void)_saveLastDirectoryForPanel:(id)panel
390
409
{
391
 
  NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
392
 
  NSString       *key = nil;
 
410
  id <PCPreferences> prefs = [projectManager prefController];
 
411
  NSString           *key = nil;
393
412
 
394
413
  switch (operation)
395
414
    {
411
430
 
412
431
  if (key != nil)
413
432
    {
414
 
      [ud setObject:[panel directory] forKey:key];
 
433
      [prefs setString:[panel directory] forKey:key notify:NO];
415
434
    }
416
435
}
417
436
 
430
449
 
431
450
  panel = [self _panelForOperation:op title:title accView:accessoryView];
432
451
 
433
 
  if ((op == PCOpenFileOperation) || (op == PCOpenProjectOperation))
 
452
  if ((op == PCOpenFileOperation) || 
 
453
      (op == PCOpenProjectOperation) || 
 
454
      (op == PCOpenDirectoryOperation))
434
455
    {
435
456
      [panel setAllowsMultipleSelection:yn];
436
457