Ejemplo n.º 1
0
static int specific_register(any_driver_t * driver)
{
  int err = 0;
  switch(driver->type) {
  case INP_DRIVER:
    {
      inp_driver_t * d = (inp_driver_t *) driver;
      d->id = filetype_add(filetype_major_add("music"),
			   driver->name, d->extensions);
      SDDEBUG("Driver '%s' : filetype %d\n", driver->name, d->id);
    } break;
      
  case IMG_DRIVER:
    {
      img_driver_t * d = (img_driver_t *) driver;
      /* Add to translator */
      err = AddTranslator(d->translator);
      if (!err) {
	/* Add filetype. */
	d->id = filetype_add(filetype_major_add("image"),
			     driver->name, d->extensions);
	SDDEBUG("Driver '%s' : filetype %d\n", driver->name, d->id);
      }
    } break;
  }
  return err;
}
Ejemplo n.º 2
0
/* Create the filetypes array and fill it with the known filetypes.
 * Warning: GTK isn't necessarily initialized yet. */
void filetypes_init_types(void)
{
	filetype_id ft_id;
	gchar *f;

	g_return_if_fail(filetypes_array == NULL);
	g_return_if_fail(filetypes_hash == NULL);

	filetypes_array = g_ptr_array_sized_new(GEANY_MAX_BUILT_IN_FILETYPES);
	filetypes_hash = g_hash_table_new(g_str_hash, g_str_equal);

	/* Create built-in filetypes */
	for (ft_id = 0; ft_id < GEANY_MAX_BUILT_IN_FILETYPES; ft_id++)
	{
		filetypes[ft_id] = filetype_new();
	}
	init_builtin_filetypes();

	/* Add built-in filetypes to the hash now the name fields are set */
	for (ft_id = 0; ft_id < GEANY_MAX_BUILT_IN_FILETYPES; ft_id++)
	{
		filetype_add(filetypes[ft_id]);
	}
	init_custom_filetypes(app->datadir);
	f = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL);
	init_custom_filetypes(f);
	g_free(f);

	/* sort last instead of on insertion to prevent exponential time */
	filetypes_by_title = g_slist_sort_with_data(filetypes_by_title,
		cmp_filetype, GINT_TO_POINTER(FALSE));

	read_filetype_config();
}
Ejemplo n.º 3
0
static void add_custom_filetype(const gchar *filename)
{
	gchar *fn = utils_strdupa(strstr(filename, ".") + 1);
	gchar *dot = g_strrstr(fn, ".conf");
	GeanyFiletype *ft;

	g_return_if_fail(dot);

	*dot = 0x0;

	if (g_hash_table_lookup(filetypes_hash, fn))
		return;

	ft = filetype_new();
	ft->name = g_strdup(fn);
	ft->title = filetype_make_title(ft->name, TITLE_FILE);
	ft->priv->custom = TRUE;
	filetype_add(ft);
	geany_debug("Added filetype %s (%d).", ft->name, ft->id);
}