Can return NULL if the printer cannot be found due to: - Printer list out of sync with printer dialog UI. - Querying for non-existant printers like 'Print to PDF'.
| 114 | // - Printer list out of sync with printer dialog UI. |
| 115 | // - Querying for non-existant printers like 'Print to PDF'. |
| 116 | GtkPrinter* GetPrinterWithName(const std::string& name) { |
| 117 | if (name.empty()) |
| 118 | return NULL; |
| 119 | |
| 120 | for (std::vector<GtkPrinter*>::iterator it = printers_.begin(); |
| 121 | it < printers_.end(); ++it) { |
| 122 | if (gtk_printer_get_name(*it) == name) { |
| 123 | return *it; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | return NULL; |
| 128 | } |
| 129 | |
| 130 | private: |
| 131 | // Callback function used by gtk_enumerate_printers() to get all printer. |