Scroom  0.14
loader.hh File Reference
#include <gtk/gtk.h>
#include <scroom/scroominterface.hh>
Include dependency graph for loader.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void create (NewPresentationInterface *interface)
 
void load (const GtkFileFilterInfo &info)
 
void load (const std::string &filename)
 
PresentationInterface::Ptr loadPresentation (const GtkFileFilterInfo &info)
 
PresentationInterface::Ptr loadPresentation (const std::string &filename)
 
void destroyGtkFileFilterList (std::list< GtkFileFilter * > &l)
 

Function Documentation

◆ create()

void create ( NewPresentationInterface interface)
176 {
177  PresentationInterface::Ptr const presentation = interface->createNew();
178  if(presentation)
179  {
180  on_presentation_created(presentation);
181  find_or_create_scroom(presentation);
182  }
183  else
184  {
185  throw std::invalid_argument("Unable to create requested presentation");
186  }
187 }

Referenced by BOOST_AUTO_TEST_CASE(), Operations1bpp::cache(), Operations8bpp::cache(), Operations24bpp::cache(), Operations::cache(), OperationsColormapped::cache(), Operations1bppClipped::cacheZoom(), on_new_activate(), anonymous_namespace{tiledbitmappresentation.cc}::OpenTiledBitmapAsPresentation::open(), TransparentOverlayViewInfo::redraw(), TEST(), and Scroom::TiledBitmap::ToOpenPresentationInterface().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroyGtkFileFilterList()

void destroyGtkFileFilterList ( std::list< GtkFileFilter * > &  l)
47 {
48  while(!l.empty())
49  {
50  GtkFileFilter* f = l.front();
51  g_object_ref_sink(f);
52  g_object_unref(f);
53  l.pop_front();
54  }
55 }

◆ load() [1/2]

void load ( const GtkFileFilterInfo &  info)
239 {
240  const auto pm = PluginManager::getInstance();
241  const auto& openPresentationInterfaces = pm->getOpenPresentationInterfaces();
242  const auto& openInterfaces = pm->getOpenInterfaces();
243 
244  for(auto const& cur: openPresentationInterfaces)
245  {
246  std::list<GtkFileFilter*> filters = cur.first->getFilters();
247  GtkFileFilterListDestroyer const destroyer(filters);
248  if(filterMatchesInfo(info, filters))
249  {
250  PresentationInterface::Ptr const presentation = cur.first->open(info.filename);
251  if(presentation)
252  {
253  on_presentation_created(presentation);
254  find_or_create_scroom(presentation);
255  return;
256  }
257  }
258  }
259  for(auto const& cur: openInterfaces)
260  {
261  std::list<GtkFileFilter*> filters = cur.first->getFilters();
262  GtkFileFilterListDestroyer const destroyer(filters);
263  if(filterMatchesInfo(info, filters))
264  {
265  cur.first->open(info.filename, ScroomInterfaceImpl::instance());
266  return;
267  }
268  }
269 
270  throw std::invalid_argument("Don't know how to open file " + std::string(info.filename));
271 }

Referenced by load(), on_done_loading_plugins(), on_open_activate(), onDragDataReceived(), Tiff::open(), and anonymous_namespace{tiledbitmappresentation.cc}::OpenTiledBitmapAsPresentation::open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load() [2/2]

void load ( const std::string &  filename)
275 { load(filterInfoFromPath(filename)); }
Here is the call graph for this function:

◆ loadPresentation() [1/2]

PresentationInterface::Ptr loadPresentation ( const GtkFileFilterInfo &  info)
195 {
196  static std::map<boost::filesystem::path, PresentationInterface::WeakPtr> loadedPresentations;
197  // Create canonical path from filename
198  const std::map<OpenPresentationInterface::Ptr, std::string>& openPresentationInterfaces =
199  PluginManager::getInstance()->getOpenPresentationInterfaces();
200 
201 #ifdef HAVE_BOOST_FILESYSTEM_CANONICAL
202  boost::filesystem::path key(canonical(boost::filesystem::path(info.filename)));
203 #else
204  boost::filesystem::path const key(absolute(boost::filesystem::path(info.filename)));
205 #endif
206 
207  PresentationInterface::Ptr presentation = loadedPresentations[key].lock();
208 
209  if(!presentation)
210  {
211  for(auto const& cur: openPresentationInterfaces)
212  {
213  std::list<GtkFileFilter*> const filters = cur.first->getFilters();
214  if(filterMatchesInfo(info, filters))
215  {
216  presentation = cur.first->open(info.filename);
217 
218  if(presentation)
219  {
220  loadedPresentations[key] = presentation;
221  on_presentation_created(presentation);
222  break;
223  }
224  }
225  }
226  }
227 
228  if(presentation)
229  {
230  return presentation;
231  }
232 
233  throw std::invalid_argument("Don't know how to load presentation " + std::string(info.filename));
234 }
Here is the call graph for this function:

◆ loadPresentation() [2/2]

PresentationInterface::Ptr loadPresentation ( const std::string &  filename)
190 {
191  return loadPresentation(*filterInfoFromPath(filename));
192 }

Referenced by loadPresentation(), ScroomInterfaceImpl::loadPresentation(), and on_done_loading_plugins().

Here is the call graph for this function:
Here is the caller graph for this function:
find_or_create_scroom
void find_or_create_scroom(const PresentationInterface::Ptr &presentation)
Definition: callbacks.cc:481
load
void load(GtkFileFilterInfo const &info)
Definition: loader.cc:238
loadPresentation
PresentationInterface::Ptr loadPresentation(const std::string &filename)
Definition: loader.cc:189
ScroomInterfaceImpl::instance
static Ptr instance()
Definition: loader.cc:279
GtkFileFilterListDestroyer
Definition: loader.cc:57
on_presentation_created
void on_presentation_created(const PresentationInterface::Ptr &presentation)
Definition: callbacks.cc:623
PresentationInterface::Ptr
boost::shared_ptr< PresentationInterface > Ptr
Definition: presentationinterface.hh:74
NewPresentationInterface::createNew
virtual PresentationInterface::Ptr createNew()=0
filterInfoFromPath
GtkFileFilterInfoPtr filterInfoFromPath(const std::string &filename)
Definition: loader.cc:109
filterMatchesInfo
bool filterMatchesInfo(GtkFileFilterInfo const &info, std::list< GtkFileFilter * > const &filters)
Definition: loader.cc:140
PluginManager::getInstance
static PluginManager::Ptr getInstance()
Definition: pluginmanager.cc:330