Exemplo n.º 1
0
static int dt_imageio_load_modules_storage(dt_imageio_t *iio)
{
  iio->plugins_storage = NULL;
  dt_imageio_module_storage_t *module;
  char plugindir[PATH_MAX] = { 0 }, plugin_name[256];
  const gchar *d_name;
  dt_loc_get_plugindir(plugindir, sizeof(plugindir));
  g_strlcat(plugindir, "/plugins/imageio/storage", sizeof(plugindir));
  GDir *dir = g_dir_open(plugindir, 0, NULL);
  if(!dir) return 1;
  const int name_offset = strlen(SHARED_MODULE_PREFIX),
            name_end = strlen(SHARED_MODULE_PREFIX) + strlen(SHARED_MODULE_SUFFIX);
  while((d_name = g_dir_read_name(dir)))
  {
    // get lib*.so
    if(!g_str_has_prefix(d_name, SHARED_MODULE_PREFIX)) continue;
    if(!g_str_has_suffix(d_name, SHARED_MODULE_SUFFIX)) continue;
    strncpy(plugin_name, d_name + name_offset, strlen(d_name) - name_end);
    plugin_name[strlen(d_name) - name_end] = '\0';
    module = (dt_imageio_module_storage_t *)malloc(sizeof(dt_imageio_module_storage_t));
    gchar *libname = g_module_build_path(plugindir, (const gchar *)plugin_name);
    if(dt_imageio_load_module_storage(module, libname, plugin_name))
    {
      free(module);
      continue;
    }
    module->gui_data = NULL;
    module->gui_init(module);
    if(module->widget) g_object_ref(module->widget);
    g_free(libname);
    dt_imageio_insert_storage(module);
  }
  g_dir_close(dir);
  return 0;
}
Exemplo n.º 2
0
int dt_lib_load_modules()
{
  darktable.lib->plugins = NULL;
  GList *res = NULL;
  dt_lib_module_t *module;
  char plugindir[PATH_MAX] = { 0 }, plugin_name[256];
  const gchar *d_name;
  dt_loc_get_plugindir(plugindir, sizeof(plugindir));
  g_strlcat(plugindir, "/plugins/lighttable", sizeof(plugindir));
  GDir *dir = g_dir_open(plugindir, 0, NULL);
  if(!dir) return 1;
  const int name_offset = strlen(SHARED_MODULE_PREFIX),
            name_end = strlen(SHARED_MODULE_PREFIX) + strlen(SHARED_MODULE_SUFFIX);
  while((d_name = g_dir_read_name(dir)))
  {
    // get lib*.(so|dll)
    if(!g_str_has_prefix(d_name, SHARED_MODULE_PREFIX)) continue;
    if(!g_str_has_suffix(d_name, SHARED_MODULE_SUFFIX)) continue;
    strncpy(plugin_name, d_name + name_offset, strlen(d_name) - name_end);
    plugin_name[strlen(d_name) - name_end] = '\0';
    module = (dt_lib_module_t *)malloc(sizeof(dt_lib_module_t));
    gchar *libname = g_module_build_path(plugindir, (const gchar *)plugin_name);

    if(dt_lib_load_module(module, libname, plugin_name))
    {
      free(module);
      continue;
    }
    // TODO: init presets
    g_free(libname);
    res = g_list_insert_sorted(res, module, dt_lib_sort_plugins);

    dt_lib_init_presets(module);
    // Calling the keyboard shortcut initialization callback if present
    // do not init accelerators if there is no gui
    if(darktable.gui)
    {
     if(module->init_key_accels) module->init_key_accels(module);
     module->gui_init(module);
     g_object_ref_sink(module->widget);
    }
  }
  g_dir_close(dir);

  darktable.lib->plugins = res;

  return 0;
}
Exemplo n.º 3
0
int
dt_lib_load_modules ()
{
  darktable.lib->plugins = NULL;
  GList *res = NULL;
  dt_lib_module_t *module;
  char plugindir[1024], plugin_name[256];
  const gchar *d_name;
  dt_loc_get_plugindir(plugindir, 1024);
  g_strlcat(plugindir, "/plugins/lighttable", 1024);
  GDir *dir = g_dir_open(plugindir, 0, NULL);
  if(!dir) return 1;
  while((d_name = g_dir_read_name(dir)))
  {
    // get lib*.so
    if(strncmp(d_name, "lib", 3)) continue;
    if(strncmp(d_name + strlen(d_name) - 3, ".so", 3)) continue;
    strncpy(plugin_name, d_name+3, strlen(d_name)-6);
    plugin_name[strlen(d_name)-6] = '\0';
    module = (dt_lib_module_t *)malloc(sizeof(dt_lib_module_t));
    gchar *libname = g_module_build_path(plugindir, (const gchar *)plugin_name);
    if(dt_lib_load_module(module, libname, plugin_name))
    {
      free(module);
      continue;
    }
    // TODO: init presets
    g_free(libname);
    res = g_list_insert_sorted(res, module, dt_lib_sort_plugins);

    init_presets(module);
    // Calling the keyboard shortcut initialization callback if present
    if(module->init_key_accels)
      module->init_key_accels(module);

  }
  g_dir_close(dir);

  darktable.lib->plugins = res;

  return 0;
}
Exemplo n.º 4
0
static int
dt_imageio_load_modules_storage (dt_imageio_t *iio)
{
    iio->plugins_storage = NULL;
    GList *res = NULL;
    dt_imageio_module_storage_t *module;
    char plugindir[1024], plugin_name[256];
    const gchar *d_name;
    dt_loc_get_plugindir(plugindir, 1024);
    g_strlcat(plugindir, "/plugins/imageio/storage", 1024);
    GDir *dir = g_dir_open(plugindir, 0, NULL);
    if(!dir) return 1;
    while((d_name = g_dir_read_name(dir)))
    {
        // get lib*.so
        if(strncmp(d_name, "lib", 3)) continue;
        if(strncmp(d_name + strlen(d_name) - 3, ".so", 3)) continue;
        strncpy(plugin_name, d_name+3, strlen(d_name)-6);
        plugin_name[strlen(d_name)-6] = '\0';
        module = (dt_imageio_module_storage_t *)malloc(sizeof(dt_imageio_module_storage_t));
        gchar *libname = g_module_build_path(plugindir, (const gchar *)plugin_name);
        if(dt_imageio_load_module_storage(module, libname, plugin_name))
        {
            free(module);
            continue;
        }
        module->gui_data = NULL;
        module->gui_init(module);
        if(module->widget) gtk_widget_ref(module->widget);
        g_free(libname);
        res = g_list_insert_sorted(res, module, dt_imageio_sort_modules_storage);
    }
    g_dir_close(dir);
    iio->plugins_storage = res;
    return 0;
}
Exemplo n.º 5
0
/** load a view module */
int dt_view_load_module(dt_view_t *view, const char *module)
{
    int retval = -1;
    memset(view, 0, sizeof(dt_view_t));
    view->data = NULL;
    view->vscroll_size = view->vscroll_viewport_size = 1.0;
    view->hscroll_size = view->hscroll_viewport_size = 1.0;
    view->vscroll_pos = view->hscroll_pos = 0.0;
    view->height = view->width = 100; // set to non-insane defaults before first expose/configure.
    g_strlcpy(view->module_name, module, 64);
    char plugindir[1024];
    dt_loc_get_plugindir(plugindir, 1024);
    g_strlcat(plugindir, "/views", 1024);
    gchar *libname = g_module_build_path(plugindir, (const gchar *)module);
    view->module = g_module_open(libname, G_MODULE_BIND_LAZY);
    if(!view->module)
    {
        fprintf(stderr, "[view_load_module] could not open %s (%s)!\n", libname, g_module_error());
        retval = -1;
        goto out;
    }
    int (*version)();
    if(!g_module_symbol(view->module, "dt_module_dt_version", (gpointer)&(version))) goto out;
    if(version() != dt_version())
    {
        fprintf(stderr, "[view_load_module] `%s' is compiled for another version of dt (module %d != dt %d) !\n", libname, version(), dt_version());
        goto out;
    }
    if(!g_module_symbol(view->module, "name",            (gpointer)&(view->name)))            view->name = NULL;
    if(!g_module_symbol(view->module, "view",            (gpointer)&(view->view)))            view->view = NULL;
    if(!g_module_symbol(view->module, "init",            (gpointer)&(view->init)))            view->init = NULL;
    if(!g_module_symbol(view->module, "cleanup",         (gpointer)&(view->cleanup)))         view->cleanup = NULL;
    if(!g_module_symbol(view->module, "expose",          (gpointer)&(view->expose)))          view->expose = NULL;
    if(!g_module_symbol(view->module, "try_enter",       (gpointer)&(view->try_enter)))       view->try_enter = NULL;
    if(!g_module_symbol(view->module, "enter",           (gpointer)&(view->enter)))           view->enter = NULL;
    if(!g_module_symbol(view->module, "leave",           (gpointer)&(view->leave)))           view->leave = NULL;
    if(!g_module_symbol(view->module, "reset",           (gpointer)&(view->reset)))           view->reset = NULL;
    if(!g_module_symbol(view->module, "mouse_enter",     (gpointer)&(view->mouse_enter)))     view->mouse_enter= NULL;
    if(!g_module_symbol(view->module, "mouse_leave",     (gpointer)&(view->mouse_leave)))     view->mouse_leave = NULL;
    if(!g_module_symbol(view->module, "mouse_moved",     (gpointer)&(view->mouse_moved)))     view->mouse_moved = NULL;
    if(!g_module_symbol(view->module, "button_released", (gpointer)&(view->button_released))) view->button_released = NULL;
    if(!g_module_symbol(view->module, "button_pressed",  (gpointer)&(view->button_pressed)))  view->button_pressed = NULL;
    if(!g_module_symbol(view->module, "key_pressed",     (gpointer)&(view->key_pressed)))     view->key_pressed = NULL;
    if(!g_module_symbol(view->module, "key_released",    (gpointer)&(view->key_released)))    view->key_released = NULL;
    if(!g_module_symbol(view->module, "configure",       (gpointer)&(view->configure)))       view->configure = NULL;
    if(!g_module_symbol(view->module, "scrolled",        (gpointer)&(view->scrolled)))        view->scrolled = NULL;
    if(!g_module_symbol(view->module, "border_scrolled", (gpointer)&(view->border_scrolled))) view->border_scrolled = NULL;
    if(!g_module_symbol(view->module, "init_key_accels", (gpointer)&(view->init_key_accels))) view->init_key_accels = NULL;
    if(!g_module_symbol(view->module, "connect_key_accels", (gpointer)&(view->connect_key_accels))) view->connect_key_accels = NULL;

    view->accel_closures = NULL;

    if(view->init) view->init(view);
    if(view->init_key_accels) view->init_key_accels(view);

    /* success */
    retval = 0;

out:
    g_free(libname);
    return retval;
}