gui: allow choosing printer in print dialog

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32654 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2011-03-19 08:24:31 +00:00
parent 3d5d4c8350
commit dcf4511498
7 changed files with 44 additions and 7 deletions

View file

@ -1,3 +1,10 @@
2011-03-19 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSPrintPanel.m:
* Panels/Spanish.lproj/GSPrintPanel.gorm:
* Panels/English.lproj/GSPrintPanel.gorm: Tweak the print panel to
allow the user to choose the printer
2011-03-18 Nicola Pero <nicola.pero@meta-innovation.com>
* Documentation/GNUmakefile (DOCUMENT_TEXT_NAME, TOP_DOC_FILES):

View file

@ -2,6 +2,7 @@
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"_pickedPrinter:",
"orderFrontFontPanel:"
);
Super = NSObject;
@ -10,11 +11,12 @@
Actions = (
"_pickedButton:",
"_pickedPage:",
"_pickedPrintOp:"
"_pickedPrintOp:",
"_pickedPrinter:"
);
Outlets = (
_optionPanel,
_panel
"_optionPanel",
"_panel"
);
Super = NSPanel;
};

View file

@ -2,6 +2,7 @@
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"_pickedPrinter:",
"orderFrontFontPanel:"
);
Super = NSObject;
@ -10,11 +11,12 @@
Actions = (
"_pickedButton:",
"_pickedPage:",
"_pickedPrintOp:"
"_pickedPrintOp:",
"_pickedPrinter:"
);
Outlets = (
_optionPanel,
_panel
"_optionPanel",
"_panel"
);
Super = NSPanel;
};

View file

@ -316,6 +316,16 @@ static NSPrintPanel *shared_instance;
[NSApp stopModalWithCode: (_picked == NSCancelButton) ? NSCancelButton : NSOKButton];
}
- (void) _pickedPrinter: (id)sender
{
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
NSString *name = [sender titleOfSelectedItem];
NSPrinter *printer = [NSPrinter printerWithName: name];
[info setPrinter: printer];
[self updateFromPrintInfo];
}
- (void) _pickedPage: (id)sender
{
id pageMatrix = CONTROL(self, NSPPPageChoiceMatrix);
@ -381,7 +391,23 @@ static NSPrintPanel *shared_instance;
dict = [info dictionary];
/* Setup printer information */
[CONTROL(self, NSPPNameField) setStringValue: [printer name] ];
{
NSArray *printerNames = [NSPrinter printerNames];
NSInteger i;
NSPopUpButton *button = CONTROL(self, NSPPNameField);
[button removeAllItems];
for (i=0; i<[printerNames count]; i++)
{
NSString *printerName = [printerNames objectAtIndex: i];
[button addItemWithTitle: printerName];
if ([[printer name] isEqual: printerName])
{
[button selectItemAtIndex: i];
}
}
}
[CONTROL(self, NSPPNoteField) setStringValue: [printer note] ];
[CONTROL(self, NSPPStatusField) setStringValue: @"Idle" ];