Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: chrome/browser/printing/print_dialog_gtk.cc

Issue 10920004: Fix the prototype of the callback passed to gtk_enumerate_printers(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/printing/print_dialog_gtk.h" 5 #include "chrome/browser/printing/print_dialog_gtk.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <gtk/gtkunixprint.h> 8 #include <gtk/gtkunixprint.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 22 matching lines...) Expand all
33 // CUPS Duplex attribute and values. 33 // CUPS Duplex attribute and values.
34 const char kCUPSDuplex[] = "cups-Duplex"; 34 const char kCUPSDuplex[] = "cups-Duplex";
35 const char kDuplexNone[] = "None"; 35 const char kDuplexNone[] = "None";
36 const char kDuplexTumble[] = "DuplexTumble"; 36 const char kDuplexTumble[] = "DuplexTumble";
37 const char kDuplexNoTumble[] = "DuplexNoTumble"; 37 const char kDuplexNoTumble[] = "DuplexNoTumble";
38 38
39 // Helper class to track GTK printers. 39 // Helper class to track GTK printers.
40 class GtkPrinterList { 40 class GtkPrinterList {
41 public: 41 public:
42 GtkPrinterList() : default_printer_(NULL) { 42 GtkPrinterList() : default_printer_(NULL) {
43 gtk_enumerate_printers((GtkPrinterFunc)SetPrinter, this, NULL, TRUE); 43 gtk_enumerate_printers(SetPrinter, this, NULL, TRUE);
44 } 44 }
45 45
46 ~GtkPrinterList() { 46 ~GtkPrinterList() {
47 for (std::vector<GtkPrinter*>::iterator it = printers_.begin(); 47 for (std::vector<GtkPrinter*>::iterator it = printers_.begin();
48 it < printers_.end(); ++it) { 48 it < printers_.end(); ++it) {
49 g_object_unref(*it); 49 g_object_unref(*it);
50 } 50 }
51 } 51 }
52 52
53 // Can return NULL if there's no default printer. E.g. Printer on a laptop 53 // Can return NULL if there's no default printer. E.g. Printer on a laptop
(...skipping 14 matching lines...) Expand all
68 if (strcmp(name, gtk_printer_get_name(*it)) == 0) { 68 if (strcmp(name, gtk_printer_get_name(*it)) == 0) {
69 return *it; 69 return *it;
70 } 70 }
71 } 71 }
72 72
73 return NULL; 73 return NULL;
74 } 74 }
75 75
76 private: 76 private:
77 // Callback function used by gtk_enumerate_printers() to get all printer. 77 // Callback function used by gtk_enumerate_printers() to get all printer.
78 static bool SetPrinter(GtkPrinter* printer, GtkPrinterList* printer_list) { 78 static gboolean SetPrinter(GtkPrinter* printer, gpointer data) {
79 GtkPrinterList *printer_list = (GtkPrinterList*)data;
79 if (gtk_printer_is_default(printer)) 80 if (gtk_printer_is_default(printer))
80 printer_list->default_printer_ = printer; 81 printer_list->default_printer_ = printer;
81 82
82 g_object_ref(printer); 83 g_object_ref(printer);
83 printer_list->printers_.push_back(printer); 84 printer_list->printers_.push_back(printer);
84 85
85 return false; 86 return FALSE;
86 } 87 }
87 88
88 std::vector<GtkPrinter*> printers_; 89 std::vector<GtkPrinter*> printers_;
89 GtkPrinter* default_printer_; 90 GtkPrinter* default_printer_;
90 }; 91 };
91 92
92 } // namespace 93 } // namespace
93 94
94 // static 95 // static
95 printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog( 96 printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog(
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 // Printing finished. Matches AddRef() in PrintDocument(); 420 // Printing finished. Matches AddRef() in PrintDocument();
420 Release(); 421 Release();
421 } 422 }
422 423
423 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, 424 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges,
424 PrintSettings* settings) { 425 PrintSettings* settings) {
425 printing::PrintSettingsInitializerGtk::InitPrintSettings( 426 printing::PrintSettingsInitializerGtk::InitPrintSettings(
426 gtk_settings_, page_setup_, page_ranges, false, settings); 427 gtk_settings_, page_setup_, page_ranges, false, settings);
427 context_->InitWithSettings(*settings); 428 context_->InitWithSettings(*settings);
428 } 429 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698