Added fetching of variants conflicts in the GUI, when the user clicks on Install With Variants

git-svn-id: https://svn.macports.org/repository/macports/branches/gsoc10-gui@70052 d073be05-634f-4543-b044-5fe20cf6d1d6
This commit is contained in:
Vasileios Georgitzikis
2010-07-28 18:12:50 +00:00
parent ad836e63dd
commit c72b412ec8
4 changed files with 81 additions and 15 deletions
+1
View File
@@ -60,6 +60,7 @@ extern BOOL altWasPressed;
- (IBAction)toggleInfoPanel: (id) sender;
-(IBAction)clickCheckbox:(id)sender;
-(void)checkConflicts: (NSString*) portName;
- (void)queueOperation: (NSString*) operation portName: (NSString*) name portObject: (id) port variants: (NSMutableArray*) variants;
+78 -5
View File
@@ -91,6 +91,7 @@
//Testing code
//checkboxes[0].conflictsWith = @"universal";
for(UInt i=0; i< 10;i++)
{
[checkboxes[i] setAlphaValue:0];
@@ -153,6 +154,8 @@
}
//NSLog(@"End of Variants");
[self checkConflicts:[port valueForKey:@"name"]];
[variantsPanel makeKeyAndOrderFront:self];
//[chckbx2 setTitle:@"hehe"];
@@ -271,6 +274,7 @@
-(IBAction)clickCheckbox:(id)sender
{
//Are we checking or unchecking the checkbox?
BOOL enableDisable;
if([sender state]==NSOnState)
@@ -281,14 +285,83 @@
{
enableDisable=YES;
}
//Enable/disable our conflicts depending on what we are doing
for(UInt i=0; i<10; i++)
for(UInt j=0;j<[[sender conflictsWith] count]; j++)
{
if ([[checkboxes[i] title] isEqualToString:[sender conflictsWith]])
//Enable/disable our conflicts depending on what we are doing
for(UInt i=0; i<10; i++)
{
[checkboxes[i] setEnabled:enableDisable];
}
if ([[checkboxes[i] title] isEqualToString:[[sender conflictsWith] objectAtIndex:j]])
{
[checkboxes[i] setEnabled:enableDisable];
if (!enableDisable)
{
[checkboxes[i] setState:NSOffState];
}
}
}
}
}
-(void)checkConflicts: (NSString *) portName
{
char *script= "pbpaste | python -c \"import re,sys;lines=sys.stdin.readlines();print '\\n'.join('%s,%s' % (re.sub(r'[\\W]','',lines[i-1].split()[0].rstrip(':')),','.join(l.strip().split()[3:])) for i, l in enumerate(lines) if l.strip().startswith('* conflicts'))\" >> mpfw_conflict";
//char *script="'''";
char command[256];
strcpy(command,"port variants ");
strcat(command, [portName UTF8String]);
strcat(command, "| pbcopy");
printf("\n%s\n%s\n", command, script);
system(command);
system(script);
//Open the output file
FILE * file = fopen("mpfw_conflict", "r");
//Read all default_variants
char buffer[256];
while(!feof(file))
{
char * temp = fgets(buffer,256,file);
if(temp == NULL) continue;
buffer[strlen(buffer)-1]='\0';
//Add the variant in the Array
printf("buffer:\n%s\n",buffer);
char *token;
char *search = ",";
token = strtok(buffer, search);
printf("token: %s\n",token);
UInt i;
for(i=0; i<10; i++)
{
//NSLog(@"%@ %@",[checkboxes[i] title], [NSString stringWithCString:token]);
if ([[checkboxes[i] title] isEqualToString:[NSString stringWithCString:token]])
{
break;
}
}
[checkboxes[i] setConflictsWith:[NSMutableArray array]];
NSLog(@"checkbox: %i",i);
while ((token = strtok(NULL, search)) != NULL)
{
NSLog(@"token: %@",[NSString stringWithCString:token]);
[[checkboxes[i] conflictsWith] addObject:[NSString stringWithCString:token]];
//NSLog(@"count %i",[[checkboxes[i] conflictsWith] count]);
}
//[defaultVariants addObject:[NSString stringWithCString:buffer]];
}
//Close and delete
fclose(file);
unlink("mpfw_conflict");
}
-(BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem {
+2 -2
View File
@@ -14,10 +14,10 @@
BOOL isDefault;
NSString *conflictsWith;
NSMutableArray *conflictsWith;
}
@property (nonatomic) BOOL isDefault;
@property (nonatomic, retain) NSString *conflictsWith;
@property (nonatomic, retain) NSMutableArray *conflictsWith;
@end
-8
View File
@@ -10,13 +10,5 @@
@implementation MPCheckbox
@synthesize isDefault, conflictsWith;
-(void) performClick: (id) sender
{
NSLog(@"performing click");
[super performClick:sender];
NSLog(@"click performed");
}
@end