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

« back to all changes in this revision

Viewing changes to Framework/PCSaveModified.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:
 
1
/*
 
2
   GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
 
3
 
 
4
   Copyright (C) 2000-2004 Free Software Foundation
 
5
 
 
6
   Authors: Philippe C.D. Robert
 
7
            Serg Stoyan
 
8
 
 
9
   This file is part of GNUstep.
 
10
 
 
11
   This application is free software; you can redistribute it and/or
 
12
   modify it under the terms of the GNU General Public
 
13
   License as published by the Free Software Foundation; either
 
14
   version 2 of the License, or (at your option) any later version.
 
15
 
 
16
   This application is distributed in the hope that it will be useful,
 
17
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
   Library General Public License for more details.
 
20
 
 
21
   You should have received a copy of the GNU General Public
 
22
   License along with this library; if not, write to the Free
 
23
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
 
24
*/
 
25
 
 
26
#import <ProjectCenter/PCEditorManager.h>
 
27
 
 
28
#import <ProjectCenter/PCSaveModified.h>
 
29
 
 
30
BOOL PCRunSaveModifiedFilesPanel(PCEditorManager *manager,
 
31
                                 NSString *defaultText,
 
32
                                 NSString *alternateText,
 
33
                                 NSString *otherText)
 
34
{
 
35
  PCSaveModified *saveModifiedPanel;
 
36
  BOOL           result;
 
37
 
 
38
  if (!(saveModifiedPanel = [[PCSaveModified alloc] init]))
 
39
    {
 
40
      return NO;
 
41
    }
 
42
 
 
43
  result = [saveModifiedPanel saveFilesWithEditorManager:manager
 
44
                                       defaultButtonText:defaultText
 
45
                                     alternateButtonText:alternateText
 
46
                                         otherButtonText:otherText];
 
47
  RELEASE(saveModifiedPanel);
 
48
 
 
49
  return result;
 
50
}
 
51
 
 
52
 
 
53
@implementation PCSaveModified
 
54
 
 
55
- (BOOL)saveFilesWithEditorManager:(PCEditorManager *)manager
 
56
                 defaultButtonText:(NSString *)defaultText
 
57
               alternateButtonText:(NSString *)alternateText
 
58
                   otherButtonText:(NSString *)otherText
 
59
{
 
60
  if ([NSBundle loadNibNamed:@"SaveModified" owner:self] == NO)
 
61
    {
 
62
      NSLog(@"Error loading SaveModified NIB file!");
 
63
      return NO;
 
64
    }
 
65
 
 
66
  editorManager = manager;
 
67
 
 
68
  // Table
 
69
  [filesList setCornerView:nil];
 
70
  [filesList setHeaderView:nil];
 
71
  [filesList setDataSource:self];
 
72
  [filesList setTarget:self];
 
73
  [filesList selectAll:self];
 
74
  [filesList reloadData];
 
75
 
 
76
  // Buttons
 
77
  [defaultButton setTitle:defaultText];
 
78
  [alternateButton setTitle:alternateText];
 
79
  [otherButton setTitle:otherText];
 
80
 
 
81
  [panel makeKeyAndOrderFront:self];
 
82
 
 
83
  [NSApp runModalForWindow:panel];
 
84
 
 
85
  if (clickedButton == defaultButton)
 
86
    {
 
87
      [self saveSelectedFiles];
 
88
      return YES;
 
89
    }
 
90
  else if (clickedButton == alternateButton)
 
91
    {
 
92
      return YES;
 
93
    }
 
94
  else if (clickedButton == otherButton)
 
95
    {
 
96
      return NO;
 
97
    }
 
98
 
 
99
  return YES;
 
100
}
 
101
 
 
102
- (void)dealloc
 
103
{
 
104
#ifdef DEBUG
 
105
  NSLog(@"PCSaveModified: dealloc");
 
106
#endif
 
107
  RELEASE(panel);
 
108
 
 
109
  [super dealloc];
 
110
}
 
111
 
 
112
- (BOOL)saveSelectedFiles
 
113
{
 
114
  NSArray      *modifiedFiles = [editorManager modifiedFiles];
 
115
  NSIndexSet   *selectedRows = [filesList selectedRowIndexes];
 
116
  NSArray      *filesToSave = [modifiedFiles objectsAtIndexes:selectedRows];
 
117
  NSEnumerator *enumerator = [filesToSave objectEnumerator];
 
118
  NSString     *filePath = nil;
 
119
 
 
120
  NSLog(@"SaveModified|filesToSave: %@", filesToSave);
 
121
 
 
122
  while ((filePath = [enumerator nextObject]))
 
123
    {
 
124
      [[editorManager editorForFile:filePath] saveFileIfNeeded];
 
125
    }
 
126
 
 
127
  return YES;
 
128
}
 
129
 
 
130
- (void)buttonClicked:(id)sender
 
131
{
 
132
  clickedButton = sender;
 
133
  [NSApp stopModal];
 
134
  [panel close];
 
135
}
 
136
 
 
137
// ============================================================================
 
138
// ==== TableView delegate
 
139
// ============================================================================
 
140
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
 
141
{
 
142
  if (aTableView != filesList)
 
143
    {
 
144
      return 0;
 
145
    }
 
146
  
 
147
  return [[editorManager modifiedFiles] count];
 
148
}
 
149
 
 
150
- (id)            tableView:(NSTableView *)aTableView
 
151
  objectValueForTableColumn:(NSTableColumn *)aTableColumn
 
152
                        row:(int)rowIndex
 
153
{
 
154
  if (aTableView != filesList)
 
155
    {
 
156
      return nil;
 
157
    }
 
158
 
 
159
  return [[[editorManager modifiedFiles] objectAtIndex:rowIndex] lastPathComponent];
 
160
}
 
161
 
 
162
@end
 
163