// virtual void LLPreviewNotecard::saveAs() { std::string default_filename("untitled.notecard"); const LLInventoryItem *item = getItem(); if(item) { // gAssetStorage->getAssetData(item->getAssetUUID(), LLAssetType::AT_NOTECARD, LLPreviewNotecard::gotAssetForSave, this, TRUE); default_filename = LLDir::getScrubbedFileName(item->getName()); } LLFilePicker& file_picker = LLFilePicker::instance(); if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_NOTECARD, default_filename ) ) { // User canceled or we failed to acquire save file. return; } // remember the user-approved/edited file name. std::string filename = file_picker.getFirstFile(); LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor"); std::string buffer; if (!editor->exportBuffer(buffer)) { // FIXME: Notify the user! return; } S32 size = buffer.length() + 1; std::ofstream export_file(filename.c_str(), std::ofstream::binary); export_file.write(buffer.c_str(), size); export_file.close(); }
void TestQPrefGeneral::test_struct_get() { // Test struct pref -> get func. auto tst = qPrefGeneral::instance(); prefs.auto_recalculate_thumbnails = true; prefs.default_cylinder = copy_qstring("new base11"); prefs.default_filename = copy_qstring("new base12"); prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE; prefs.defaultsetpoint = 14; prefs.extract_video_thumbnails = true; prefs.extract_video_thumbnails_position = 15; prefs.ffmpeg_executable = copy_qstring("new base16"); prefs.o2consumption = 17; prefs.pscr_ratio = 18; prefs.use_default_file = true; QCOMPARE(tst->auto_recalculate_thumbnails(), prefs.auto_recalculate_thumbnails); QCOMPARE(tst->default_cylinder(), QString(prefs.default_cylinder)); QCOMPARE(tst->default_filename(), QString(prefs.default_filename)); QCOMPARE(tst->default_file_behavior(), prefs.default_file_behavior); QCOMPARE(tst->defaultsetpoint(), prefs.defaultsetpoint); QCOMPARE(tst->extract_video_thumbnails(), prefs.extract_video_thumbnails); QCOMPARE(tst->extract_video_thumbnails_position(), prefs.extract_video_thumbnails_position); QCOMPARE(tst->ffmpeg_executable(), QString(prefs.ffmpeg_executable)); QCOMPARE(tst->o2consumption(), prefs.o2consumption); QCOMPARE(tst->pscr_ratio(), prefs.pscr_ratio); QCOMPARE(tst->use_default_file(), prefs.use_default_file); }
void TestQPrefGeneral::test_oldPreferences() { auto general = qPrefGeneral::instance(); general->set_default_filename("filename"); general->set_default_cylinder("cylinder_2"); general->set_default_file_behavior(LOCAL_DEFAULT_FILE); general->set_defaultsetpoint(0); general->set_o2consumption(0); general->set_pscr_ratio(0); general->set_use_default_file(true); TEST(general->default_filename(), QStringLiteral("filename")); TEST(general->default_cylinder(), QStringLiteral("cylinder_2")); TEST(general->default_file_behavior(), LOCAL_DEFAULT_FILE); // since we have a default file, here it returns TEST(general->defaultsetpoint(), 0); TEST(general->o2consumption(), 0); TEST(general->pscr_ratio(), 0); TEST(general->use_default_file(), true); general->set_default_filename("no_file_name"); general->set_default_cylinder("cylinder_1"); //TODOl: Change this to a enum. general->set_default_file_behavior(CLOUD_DEFAULT_FILE); general->set_defaultsetpoint(1); general->set_o2consumption(1); general->set_pscr_ratio(1); general->set_use_default_file(false); TEST(general->default_filename(), QStringLiteral("no_file_name")); TEST(general->default_cylinder(), QStringLiteral("cylinder_1")); TEST(general->default_file_behavior(), CLOUD_DEFAULT_FILE); TEST(general->defaultsetpoint(), 1); TEST(general->o2consumption(), 1); TEST(general->pscr_ratio(), 1); TEST(general->use_default_file(), false); }
// virtual void LLPreviewNotecard::saveAs() { std::string default_filename("untitled.notecard"); const LLInventoryItem *item = getItem(); if(item) { // gAssetStorage->getAssetData(item->getAssetUUID(), LLAssetType::AT_NOTECARD, LLPreviewNotecard::gotAssetForSave, this, TRUE); default_filename = LLDir::getScrubbedFileName(item->getName()) + ".notecard"; } AIFilePicker* filepicker = AIFilePicker::create(); filepicker->open(default_filename, FFSAVE_NOTECARD); filepicker->run(boost::bind(&LLPreviewNotecard::saveAs_continued, this, filepicker)); }
PyObject * pangolin_load(PyObject* /*self*/, PyObject* args) { Var<std::string> default_filename("pango.console.default_filename"); const char *filename = default_filename.Get().c_str(); const char *prefix = ""; if (!PyArg_ParseTuple(args, "|ss", &filename, &prefix)) { return NULL; } LoadJsonFile(filename, prefix); Py_RETURN_NONE; }
int main(int argc, char **argv) { static int capture = 0, raw = 0; char *socket_path = NULL; char *output = NULL; int framerate = 30; init_log(L_INFO); static struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"capture", no_argument, NULL, 'c'}, {"output", required_argument, NULL, 'o'}, {"version", no_argument, NULL, 'v'}, {"socket", required_argument, NULL, 's'}, {"raw", no_argument, NULL, 'r'}, {"rate", required_argument, NULL, 'R'}, {0, 0, 0, 0} }; const char *usage = "Usage: swaygrab [options] [file]\n" "\n" " -h, --help Show help message and quit.\n" " -c, --capture Capture video.\n" " -o, --output <output> Output source.\n" " -v, --version Show the version number and quit.\n" " -s, --socket <socket> Use the specified socket.\n" " -R, --rate <rate> Specify framerate (default: 30)\n" " -r, --raw Write raw rgba data to stdout.\n"; int c; while (1) { int option_index = 0; c = getopt_long(argc, argv, "hco:vs:r", long_options, &option_index); if (c == -1) { break; } switch (c) { case 's': // Socket socket_path = strdup(optarg); break; case 'r': raw = 1; break; case 'o': // output output = strdup(optarg); break; case 'c': capture = 1; break; case 'R': // Frame rate framerate = atoi(optarg); break; case 'v': #if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE fprintf(stdout, "sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH); #else fprintf(stdout, "version not detected\n"); #endif exit(EXIT_SUCCESS); break; default: fprintf(stderr, "%s", usage); exit(EXIT_FAILURE); } } if (!socket_path) { socket_path = get_socketpath(); if (!socket_path) { sway_abort("Unable to retrieve socket path"); } } char *file = NULL; if (raw) { if (optind >= argc + 1) { sway_abort("Invalid usage. See `man swaygrab` %d %d", argc, optind); } } else if (optind < argc) { file = strdup(argv[optind]); } int socketfd = ipc_open_socket(socket_path); free(socket_path); if (!output) { output = get_focused_output(socketfd); } if (!file) { if (!capture) { file = default_filename("png"); } else { file = default_filename("webm"); } } if (!capture) { grab_and_apply_magick(file, output, socketfd, raw); } else { grab_and_apply_movie_magic(file, output, socketfd, raw, framerate); } free(output); free(file); close(socketfd); return 0; }