+ if (data->GetPrinterName().empty())
+ {
+ wxListItem item2;
+ item2.SetId( item.GetId() );
+ item2.SetMask( wxLIST_MASK_IMAGE );
+ item2.SetImage( 0 );
+ m_printerListCtrl->SetItem( item2 );
+ // also select item
+ m_printerListCtrl->SetItemState( item.GetId(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
+ }
+
+ item.SetId( 1+ item.GetId() );
+
+ wxArrayString errors;
+ wxArrayString output;
+ long res = wxExecute( wxT("lpstat -v"), output, errors, wxEXEC_NODISABLE );
+ if (res >= 0 && errors.GetCount() == 0)
+ {
+ size_t i;
+ for (i = 0; i < output.GetCount(); i++)
+ {
+ wxStringTokenizer tok( output[i], wxT(" ") );
+ wxString tmp = tok.GetNextToken(); // "device"
+ if (tmp != wxT("device"))
+ break; // the lpstat syntax must have changed.
+ tmp = tok.GetNextToken(); // "for"
+ if (tmp != wxT("for"))
+ break; // the lpstat syntax must have changed.
+ tmp = tok.GetNextToken(); // "hp_deskjet930c:"
+ if (tmp[tmp.length()-1] == wxT(':'))
+ tmp.Remove(tmp.length()-1,1);
+ wxString name = tmp;
+ item.SetText( name );
+ item.SetId( m_printerListCtrl->InsertItem( item ) );
+ tmp = tok.GetNextToken(); // "parallel:/dev/lp0"
+ item.SetColumn( 2 );
+ item.SetText( tmp );
+ m_printerListCtrl->SetItem( item );
+ if (data->GetPrinterName() == name)
+ {
+ wxListItem item2;
+ item2.SetId( item.GetId() );
+ item2.SetMask( wxLIST_MASK_IMAGE );
+ item2.SetImage( 0 );
+ m_printerListCtrl->SetItem( item2 );
+ // also select item
+ m_printerListCtrl->SetItemState( item.GetId(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
+ }
+
+ wxString command = wxT("lpstat -p ");
+ command += name;
+ wxArrayString errors2;
+ wxArrayString output2;
+ res = wxExecute( command, output2, errors2, wxEXEC_NODISABLE );
+ if (res >= 0 && errors2.GetCount() == 0 && output2.GetCount() > 0)
+ {
+ tmp = output2[0]; // "printer hp_deskjet930c is idle. enable since ..."
+ int pos = tmp.Find( wxT('.') );
+ if (pos != wxNOT_FOUND)
+ tmp.Remove( (size_t)pos, tmp.length()-(size_t)pos );
+ wxStringTokenizer tok2( tmp, wxT(" ") );
+ tmp = tok2.GetNextToken(); // "printer"
+ tmp = tok2.GetNextToken(); // "hp_deskjet930c"
+ tmp = wxEmptyString;
+ while (tok2.HasMoreTokens())
+ {
+ tmp += tok2.GetNextToken();
+ tmp += wxT(" ");
+ }
+ item.SetColumn( 3 );
+ item.SetText( tmp );
+ m_printerListCtrl->SetItem( item );
+ }
+
+ item.SetColumn( 1 );
+ item.SetId( 1+ item.GetId() );
+ }
+ }
+
+
+ printer_sizer->Add( m_printerListCtrl, 0, wxALL|wxGROW, 5 );
+
+ wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
+ main_sizer->Add( item1, 0, wxALL, 5 );
+
+ // printer options (on the left)
+
+ wxBoxSizer *item2 = new wxBoxSizer( wxVERTICAL );
+
+ wxStaticBox *item4 = new wxStaticBox( this, wxPRINTID_STATIC, _("Paper size") );
+ wxStaticBoxSizer *item3 = new wxStaticBoxSizer( item4, wxVERTICAL );
+
+ m_paperTypeChoice = CreatePaperTypeChoice();
+ item3->Add( m_paperTypeChoice, 0, wxALIGN_CENTER|wxALL, 5 );
+
+ item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
+
+ wxString strs6[] =
+ {
+ _("Portrait"),
+ _("Landscape")
+ };
+ m_orientationRadioBox= new wxRadioBox( this, wxPRINTID_ORIENTATION, _("Orientation"), wxDefaultPosition, wxDefaultSize, 2, strs6, 1, wxRA_SPECIFY_ROWS );
+ item2->Add( m_orientationRadioBox, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ wxStaticBox *item8 = new wxStaticBox( this, wxID_ANY, _("Options") );
+ wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxHORIZONTAL );
+
+ m_colourCheckBox = new wxCheckBox( this, wxPRINTID_PRINTCOLOUR, _("Print in colour") );
+ item7->Add( m_colourCheckBox, 0, wxALIGN_CENTER|wxALL, 5 );