/** callback for simconnect data */ void FSC_CALLBACK_DispatchProc(HANDLE hSim, SIMCONNECT_RECV* pRecv) { SIMCONNECT_RECV_(EVENT, pEvent, pRecv); if (pEvent) switch (pEvent->uEventID) { // hide kneeboard on sim stop case EVENT_SIM: if (!pEvent->dwData) pdfview_hide(); break; // timer for joystick background check? case EVENT_TIMER: kneeboard_timer(); break; // menus case EVENT_MENU_SHOW: pdfview_show(); break; case EVENT_MENU_HIDE: pdfview_hide(); break; case EVENT_MENU_OPEN: open_document(); break; case EVENT_MENU_CLOSE: close_document(); break; case EVENT_MENU_SETTINGS: SimConnect_SetSystemState(hSim, "DialogMode", 1, 0, NULL); kneeboard_settings(); SimConnect_SetSystemState(hSim, "DialogMode", 0, 0, NULL); break; } }
static void run (const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals) { static GimpParam values[6]; GimpRunMode run_mode; GimpPDBStatusType status = GIMP_PDB_SUCCESS; gint32 image_ID = -1; PopplerDocument *doc = NULL; GError *error = NULL; run_mode = param[0].data.d_int32; INIT_I18N (); *nreturn_vals = 1; *return_vals = values; values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; if (! g_thread_supported ()) g_thread_init (NULL); if (strcmp (name, LOAD_PROC) == 0) { PdfSelectedPages pages = { 0, NULL }; switch (run_mode) { case GIMP_RUN_INTERACTIVE: /* Possibly retrieve last settings */ gimp_get_data (LOAD_PROC, &loadvals); doc = open_document (param[1].data.d_string, &error); if (!doc) { status = GIMP_PDB_EXECUTION_ERROR; break; } if (load_dialog (doc, &pages)) gimp_set_data (LOAD_PROC, &loadvals, sizeof(loadvals)); else status = GIMP_PDB_CANCEL; break; case GIMP_RUN_WITH_LAST_VALS: /* FIXME: implement last vals mode */ status = GIMP_PDB_EXECUTION_ERROR; break; case GIMP_RUN_NONINTERACTIVE: doc = open_document (param[1].data.d_string, &error); if (doc) { PopplerPage *test_page = poppler_document_get_page (doc, 0); if (test_page) { pages.n_pages = 1; pages.pages = g_new (gint, 1); pages.pages[0] = 0; g_object_unref (test_page); } else { status = GIMP_PDB_EXECUTION_ERROR; g_object_unref (doc); } } else { status = GIMP_PDB_EXECUTION_ERROR; } break; } if (status == GIMP_PDB_SUCCESS) { image_ID = load_image (doc, param[1].data.d_string, run_mode, loadvals.target, loadvals.resolution, &pages); if (image_ID != -1) { *nreturn_vals = 2; values[1].type = GIMP_PDB_IMAGE; values[1].data.d_image = image_ID; } else { status = GIMP_PDB_EXECUTION_ERROR; } } if (doc) g_object_unref (doc); g_free (pages.pages); } else if (strcmp (name, LOAD_THUMB_PROC) == 0) { if (nparams < 2) { status = GIMP_PDB_CALLING_ERROR; } else { gdouble width = 0; gdouble height = 0; gdouble scale; gint32 image = -1; gint num_pages = 0; GdkPixbuf *pixbuf = NULL; /* Possibly retrieve last settings */ gimp_get_data (LOAD_PROC, &loadvals); doc = open_document (param[0].data.d_string, &error); if (doc) { PopplerPage *page = poppler_document_get_page (doc, 0); if (page) { poppler_page_get_size (page, &width, &height); g_object_unref (page); } num_pages = poppler_document_get_n_pages (doc); pixbuf = get_thumbnail (doc, 0, param[1].data.d_int32); g_object_unref (doc); } if (pixbuf) { image = gimp_image_new (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GIMP_RGB); gimp_image_undo_disable (image); layer_from_pixbuf (image, "thumbnail", 0, pixbuf, 0.0, 1.0); g_object_unref (pixbuf); gimp_image_undo_enable (image); gimp_image_clean_all (image); } scale = loadvals.resolution / gimp_unit_get_factor (GIMP_UNIT_POINT); width *= scale; height *= scale; if (image != -1) { *nreturn_vals = 6; values[1].type = GIMP_PDB_IMAGE; values[1].data.d_image = image; values[2].type = GIMP_PDB_INT32; values[2].data.d_int32 = width; values[3].type = GIMP_PDB_INT32; values[3].data.d_int32 = height; values[4].type = GIMP_PDB_INT32; values[4].data.d_int32 = GIMP_RGB_IMAGE; values[5].type = GIMP_PDB_INT32; values[5].data.d_int32 = num_pages; } else { status = GIMP_PDB_EXECUTION_ERROR; } } } else { status = GIMP_PDB_CALLING_ERROR; } if (status != GIMP_PDB_SUCCESS && error) { *nreturn_vals = 2; values[1].type = GIMP_PDB_STRING; values[1].data.d_string = error->message; } values[0].data.d_status = status; }
bool os_initialize( application_t* app ) { // // We only need to set the resource path on Windows. There are no // system events to install handlers for, etc. We say that the // resource path is the folder with the executable inside. // LPWSTR *szArglist; int nArgs; szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); if( NULL == szArglist ) throw std::runtime_error("CommandLineToArgvW failed"); std::string directory_string; if (!hackery::LPCWSTR_to_string(szArglist[0], directory_string)) throw std::runtime_error("Path character conversion failed."); std::string file1; if (nArgs >= 2 && !hackery::LPCWSTR_to_string(szArglist[1], file1)) throw std::runtime_error("Path character conversion failed."); std::string file2; if (nArgs >= 3 && !hackery::LPCWSTR_to_string(szArglist[2], file2)) throw std::runtime_error("Path character conversion failed."); clip_quotes(directory_string); // // Now we need to get a directory from the command line name. // boost::filesystem::path directory( directory_string, boost::filesystem::native ); // // Tell the application... // app->set_resource_directory( directory.branch_path() ); setup_main_window( app ); if (!file1.empty()) { clip_quotes(file1); open_document(app, file1); } if (!file2.empty()) { clip_quotes(file2); open_document(app, file2); } LocalFree(szArglist); return true; }