JNIEXPORT jint JNICALL Java_org_cef_misc_CefPrintSettings_1N_N_1GetCopies (JNIEnv *env, jobject obj) { CefRefPtr<CefPrintSettings> settings = GetCefFromJNIObject<CefPrintSettings>(env, obj, "CefPrintSettings"); if (!settings) return 0; return (jint)settings->GetCopies(); }
void ClientPrintHandlerGtk::OnPrintSettings( CefRefPtr<CefPrintSettings> settings, bool get_defaults) { if (get_defaults) { DCHECK(!page_setup_); DCHECK(!printer_); // |gtk_settings_| is a new copy. gtk_settings_ = gtk_print_settings_copy(GetLastUsedSettings()->settings()); page_setup_ = gtk_page_setup_new(); } else { if (!gtk_settings_) { gtk_settings_ = gtk_print_settings_copy(GetLastUsedSettings()->settings()); } GtkPrinterList* printer_list = new GtkPrinterList; printer_ = printer_list->GetPrinterWithName(settings->GetDeviceName()); if (printer_) { g_object_ref(printer_); gtk_print_settings_set_printer(gtk_settings_, gtk_printer_get_name(printer_)); if (!page_setup_) { page_setup_ = gtk_printer_get_default_page_size(printer_); } } gtk_print_settings_set_n_copies(gtk_settings_, settings->GetCopies()); gtk_print_settings_set_collate(gtk_settings_, settings->WillCollate()); std::string color_value; std::string color_setting_name; GetColorModelForMode(settings->GetColorModel(), &color_setting_name, &color_value); gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(), color_value.c_str()); if (settings->GetDuplexMode() != DUPLEX_MODE_UNKNOWN) { const char* cups_duplex_mode = NULL; switch (settings->GetDuplexMode()) { case DUPLEX_MODE_LONG_EDGE: cups_duplex_mode = kDuplexNoTumble; break; case DUPLEX_MODE_SHORT_EDGE: cups_duplex_mode = kDuplexTumble; break; case DUPLEX_MODE_SIMPLEX: cups_duplex_mode = kDuplexNone; break; default: // UNKNOWN_DUPLEX_MODE NOTREACHED(); break; } gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode); } if (!page_setup_) page_setup_ = gtk_page_setup_new(); gtk_print_settings_set_orientation( gtk_settings_, settings->IsLandscape() ? GTK_PAGE_ORIENTATION_LANDSCAPE : GTK_PAGE_ORIENTATION_PORTRAIT); delete printer_list; } InitPrintSettings(gtk_settings_, page_setup_, settings); }