JNIEXPORT jobject JNICALL Java_org_cef_misc_CefPrintSettings_1N_N_1GetColorModel (JNIEnv *env, jobject obj) { jobject result = GetJNIEnumValue(env, "org/cef/misc/CefPrintSettings$ColorModel", "COLOR_MODEL_UNKNOWN"); CefRefPtr<CefPrintSettings> settings = GetCefFromJNIObject<CefPrintSettings>(env, obj, "CefPrintSettings"); if (!settings) return result; switch (settings->GetColorModel()) { JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_GRAY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_COLOR, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_CMYK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_CMY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_KCMY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_CMY_K, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_BLACK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_GRAYSCALE, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_RGB, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_RGB16, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_RGBA, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_COLORMODE_COLOR, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_COLORMODE_MONOCHROME, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_HP_COLOR_COLOR, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_HP_COLOR_BLACK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PRINTOUTMODE_NORMAL, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PROCESSCOLORMODEL_CMYK, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE, result); JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_PROCESSCOLORMODEL_RGB, result); default: JNI_CASE(env, "org/cef/misc/CefPrintSettings$ColorModel", COLOR_MODEL_UNKNOWN, result); } return result; }
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); }