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

Unified Diff: chrome/browser/printing/print_dialog_gtk.cc

Issue 9379039: GTK: implement "print selection". (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/printing/print_dialog_gtk.h ('k') | printing/print_dialog_gtk_interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/print_dialog_gtk.cc
diff --git a/chrome/browser/printing/print_dialog_gtk.cc b/chrome/browser/printing/print_dialog_gtk.cc
index 789ded4a8164fc5f30d96654b41a3a52bad763e9..2326de2be3ddfbedc109188e6c28b38722930245 100644
--- a/chrome/browser/printing/print_dialog_gtk.cc
+++ b/chrome/browser/printing/print_dialog_gtk.cc
@@ -231,6 +231,7 @@ bool PrintDialogGtk::UpdateSettings(const DictionaryValue& job_settings,
}
void PrintDialogGtk::ShowDialog(
+ bool has_selection,
const PrintingContextGtk::PrintSettingsCallback& callback) {
callback_ = callback;
@@ -256,6 +257,10 @@ void PrintDialogGtk::ShowDialog(
cap);
gtk_print_unix_dialog_set_embed_page_setup(GTK_PRINT_UNIX_DIALOG(dialog_),
TRUE);
+ gtk_print_unix_dialog_set_support_selection(GTK_PRINT_UNIX_DIALOG(dialog_),
+ TRUE);
+ gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_),
+ has_selection);
g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this);
gtk_widget_show(dialog_);
}
@@ -326,21 +331,33 @@ void PrintDialogGtk::OnResponse(GtkWidget* dialog, int response_id) {
// Handle page ranges.
PageRanges ranges_vector;
gint num_ranges;
- GtkPageRange* gtk_range =
- gtk_print_settings_get_page_ranges(gtk_settings_, &num_ranges);
- if (gtk_range) {
- for (int i = 0; i < num_ranges; ++i) {
- printing::PageRange range;
- range.from = gtk_range[i].start;
- range.to = gtk_range[i].end;
- ranges_vector.push_back(range);
+ bool print_selection_only = false;
+ switch (gtk_print_settings_get_print_pages(gtk_settings_)) {
+ case GTK_PRINT_PAGES_RANGES: {
+ GtkPageRange* gtk_range =
+ gtk_print_settings_get_page_ranges(gtk_settings_, &num_ranges);
+ if (gtk_range) {
+ for (int i = 0; i < num_ranges; ++i) {
+ printing::PageRange range;
+ range.from = gtk_range[i].start;
+ range.to = gtk_range[i].end;
+ ranges_vector.push_back(range);
+ }
+ g_free(gtk_range);
+ }
+ break;
}
- g_free(gtk_range);
+ case GTK_PRINT_PAGES_SELECTION:
+ print_selection_only = true;
+ break;
+ default:
Lei Zhang 2012/02/13 22:41:17 Would you mind changing this to: case GTK_PRINT_P
peter1 2012/02/14 01:52:54 Done.
+ break;
}
PrintSettings settings;
printing::PrintSettingsInitializerGtk::InitPrintSettings(
- gtk_settings_, page_setup_, ranges_vector, false, &settings);
+ gtk_settings_, page_setup_, ranges_vector, print_selection_only,
+ &settings);
context_->InitWithSettings(settings);
callback_.Run(PrintingContextGtk::OK);
callback_.Reset();
« no previous file with comments | « chrome/browser/printing/print_dialog_gtk.h ('k') | printing/print_dialog_gtk_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698