1 #include "QueueController.h"
3 @implementation QueueController
5 - (void) SetHandle: (hb_handle_t *) handle
10 - (void) AddTextField: (NSString *) string rect: (NSRect *) rect
12 NSTextField * textField;
16 rect->size.height = 17;
17 textField = [[NSTextField alloc] initWithFrame: *rect];
19 [textField setEditable: NO];
20 [textField setSelectable: NO];
21 [textField setDrawsBackground: NO];
22 [textField setBordered: NO];
23 [textField setStringValue: string];
25 [fTaskView addSubview: textField];
28 - (void) removeTask: (id) sender
30 hb_rem( fHandle, hb_job( fHandle, [sender tag] ) );
31 [self performSelectorOnMainThread: @selector( Update: )
32 withObject: sender waitUntilDone: NO];
35 - (void) AddButton: (NSRect *) rect tag: (int) tag
39 rect->origin.x = rect->size.width - 90;
41 rect->size.width = 100;
42 rect->size.height = 20;
43 button = [[NSButton alloc] initWithFrame: *rect];
44 rect->size.width = rect->origin.x + 90;
46 [button setTitle: @"Remove"];
47 [button setBezelStyle: NSRoundedBezelStyle];
48 [button setFont: [NSFont systemFontOfSize:
49 [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
50 [[button cell] setControlSize: NSSmallControlSize];
53 [button setTarget: self];
54 [button setAction: @selector( removeTask: )];
56 [fTaskView addSubview: button];
62 rect->size.width -= 10;
63 rect->size.height = 1;
64 box = [[NSBox alloc] initWithFrame: *rect];
65 [box setBoxType: NSBoxSeparator];
67 rect->size.width += 10;
69 [fTaskView addSubview: box];
72 - (IBAction) Update: (id) sender
78 NSSize size = [fScrollView contentSize];
79 int height = MAX( 20 + 125 * hb_count( fHandle ), size.height );
80 [fTaskView setFrame: NSMakeRect(0,0,size.width,height)];
82 NSRect rect = NSMakeRect(10,height-10,size.width-20,10);
84 NSArray * subviews = [fTaskView subviews];
85 while( [subviews count] > 0 )
87 [[subviews objectAtIndex: 0]
88 removeFromSuperviewWithoutNeedingDisplay];
91 for( i = 0; i < hb_count( fHandle ); i++ )
93 j = hb_job( fHandle, i );
96 [self AddTextField: [NSString stringWithFormat:
97 @"DVD: %s", title->dvd] rect: &rect];
98 [self AddTextField: [NSString stringWithFormat:
99 @"Title: %d", title->index] rect: &rect];
100 [self AddTextField: [NSString stringWithFormat:
101 @"Chapters: %d to %d", j->chapter_start, j->chapter_end]
103 [self AddTextField: [NSString stringWithFormat:
104 @"Pass: %d of %d", MAX( 1, j->pass ), MIN( 2, j->pass + 1 )]
106 [self AddTextField: [NSString stringWithFormat:
107 @"Destination: %s", j->file] rect: &rect];
108 [self AddButton: &rect tag: i];
111 [fTaskView scrollPoint: NSMakePoint(0,height)];
112 [fTaskView setNeedsDisplay: YES];
115 - (IBAction) ClosePanel: (id) sender