MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / onProcessMessage

Method onProcessMessage

src/app/modules/gui.cpp:351–520  ·  view source on GitHub ↗

Manager event handler.

Source from the content-addressed store, hash-verified

349
350// Manager event handler.
351bool CustomizedGuiManager::onProcessMessage(Message* msg)
352{
353 switch (msg->type()) {
354
355 case kCloseDisplayMessage:
356 {
357 // Execute the "Exit" command.
358 Command* command = CommandsModule::instance()->getCommandByName(CommandId::Exit);
359 UIContext::instance()->executeCommand(command);
360 }
361 break;
362
363 case kDropFilesMessage:
364 {
365 const DropFilesMessage::Files& files = static_cast<DropFilesMessage*>(msg)->files();
366
367 // Open all files
368 Command* cmd_open_file = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
369 Command* cmd_install_script = CommandsModule::instance()->getCommandByName(CommandId::InstallScript);
370 Params params;
371
372 UIContext* ctx = UIContext::instance();
373
374 auto& engines = script::Engine::getRegistry();
375
376 for (const auto& fn : files) {
377 // If the document is already open, select it.
378 Document* doc = static_cast<Document*>(ctx->documents().getByFileName(fn));
379 if (doc) {
380 DocumentView* docView = ctx->getFirstDocumentView(doc);
381 if (docView)
382 ctx->setActiveView(docView);
383 else {
384 ASSERT(false); // Must be some DocumentView available
385 }
386 continue;
387 }
388
389 auto cmd = cmd_open_file;
390
391 auto extension = base::string_to_lower(base::get_file_extension(fn));
392 for (auto& entry : engines) {
393 std::cout << entry.first << " == " << extension << std::endl;
394 if (entry.first == extension || entry.second.hasFlag(extension) ) {
395 cmd = cmd_install_script;
396 break;
397 }
398 }
399
400 // Load the file
401 params.set("filename", fn.c_str());
402 ctx->executeCommand(cmd, params);
403 }
404 }
405 break;
406
407 case kKeyDownMessage: {
408#ifdef _DEBUG

Callers

nothing calls this directly

Calls 15

instanceFunction · 0.85
string_to_lowerFunction · 0.85
get_file_extensionFunction · 0.85
getCommandByNameMethod · 0.80
executeCommandMethod · 0.80
getByFileNameMethod · 0.80
getFirstDocumentViewMethod · 0.80
ctrlPressedMethod · 0.80
shiftPressedMethod · 0.80
cancelMenuLoopMethod · 0.80
getMenuBarMethod · 0.80
mainWindowMethod · 0.80

Tested by

no test coverage detected