Пример #1
0
  void AddinManager::initialize_sharp_addins()
  {
    if (!sharp::directory_exists (m_addins_prefs_dir))
      g_mkdir_with_parents(m_addins_prefs_dir.c_str(), S_IRWXU);

    // get the factory

    REGISTER_BUILTIN_NOTE_ADDIN(NoteRenameWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteSpellChecker);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteUrlWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteLinkWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteWikiWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(MouseHandWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteTagsWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(notebooks::NotebookNoteAddin);
   
    REGISTER_APP_ADDIN(notebooks::NotebookApplicationAddin);

    std::string global_path = utils::get_libdir() + "/"PACKAGE_NAME"/addins/"PACKAGE_VERSION;
    std::string local_path = m_gnote_conf_dir + "/addins";

    load_addin_infos(global_path, local_path);
    std::list<std::string> enabled_addins;
    get_enabled_addins(enabled_addins);
    m_module_manager.load_modules(enabled_addins);

    const sharp::ModuleMap & modules = m_module_manager.get_modules();
    for(sharp::ModuleMap::const_iterator iter = modules.begin();
        iter != modules.end(); ++iter) {

      const std::string & mod_id = get_info_for_module(iter->first).id();
      sharp::DynamicModule* dmod = iter->second;
      if(!dmod) {
        continue;
      }

      dmod->enabled(true); // enable all loaded modules on startup
      add_module_addins(mod_id, dmod);
    }
  }
Пример #2
0
  void AddinManager::initialize_sharp_addins()
  {
    if (!sharp::directory_exists (m_addins_prefs_dir))
      g_mkdir_with_parents(m_addins_prefs_dir.c_str(), S_IRWXU);

    // get the factory

    REGISTER_BUILTIN_NOTE_ADDIN(NoteRenameWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteSpellChecker);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteUrlWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteLinkWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteWikiWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(MouseHandWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(NoteTagsWatcher);
    REGISTER_BUILTIN_NOTE_ADDIN(notebooks::NotebookNoteAddin);
   
    REGISTER_APP_ADDIN(notebooks::NotebookApplicationAddin);

    m_module_manager.add_path(LIBDIR"/"PACKAGE_NAME"/addins/"PACKAGE_VERSION);
    m_module_manager.add_path(m_mnote_conf_dir);

    m_module_manager.load_modules();

    bool global_addins_prefs_loaded = true;
    Glib::KeyFile global_addins_prefs;
    try {
      global_addins_prefs.load_from_file(m_addins_prefs_file);
    }
    catch (Glib::Error & not_loaded) {
      global_addins_prefs_loaded = false;
    }

    const sharp::ModuleList & list = m_module_manager.get_modules();
    for(sharp::ModuleList::const_iterator iter = list.begin();
        iter != list.end(); ++iter) {

      sharp::DynamicModule* dmod = *iter;
      if(!dmod) {
        continue;
      }

      if(global_addins_prefs_loaded &&
         global_addins_prefs.has_key("Enabled", dmod->id())) {
        dmod->enabled(global_addins_prefs.get_boolean("Enabled", dmod->id()));
      }

      sharp::IfaceFactoryBase * f = dmod->query_interface(NoteAddin::IFACE_NAME);
      if(f && dmod->is_enabled()) {
        m_note_addin_infos.insert(std::make_pair(dmod->id(), f));
      }

      f = dmod->query_interface(AddinPreferenceFactoryBase::IFACE_NAME);
      if(f) {
        AddinPreferenceFactoryBase * factory = dynamic_cast<AddinPreferenceFactoryBase*>((*f)());
        m_addin_prefs.insert(std::make_pair(dmod->id(), factory));
      }

      f = dmod->query_interface(ImportAddin::IFACE_NAME);
      if(f) {
        ImportAddin * addin = dynamic_cast<ImportAddin*>((*f)());
        m_import_addins.insert(std::make_pair(dmod->id(), addin));
      }

      f = dmod->query_interface(ApplicationAddin::IFACE_NAME);
      if(f) {
        ApplicationAddin * addin = dynamic_cast<ApplicationAddin*>((*f)());
        m_app_addins.insert(std::make_pair(dmod->id(), addin));
      }
    }
  }