Example #1
0
static GsfOutput *
gsf_outfile_open_pkg_new_child (GsfOutfile *parent,
				char const *name, gboolean is_dir,
				char const *first_property_name, va_list args)
{
	GsfOutfileOpenPkg *child, *open_pkg = GSF_OUTFILE_OPEN_PKG (parent);
	GsfOutput *sink;

	if (!open_pkg->is_dir)
		return NULL;

	child = (GsfOutfileOpenPkg *)g_object_new_valist (
		GSF_OUTFILE_OPEN_PKG_TYPE, first_property_name, args);
	gsf_output_set_name (GSF_OUTPUT (child), name);
	gsf_output_set_container (GSF_OUTPUT (child), parent);
	child->is_dir = is_dir;

	sink = gsf_outfile_new_child (GSF_OUTFILE (open_pkg->sink), name, is_dir);
	gsf_outfile_open_pkg_set_sink (child, sink);
	g_object_unref (sink);

	open_pkg->children = g_slist_prepend (open_pkg->children, child);
	g_object_ref (child);

	return GSF_OUTPUT (child);
}
Example #2
0
static GsfOutput *
gsf_outfile_open_pkg_new_child (GsfOutfile *parent,
				char const *name, gboolean is_dir,
				char const *first_property_name, va_list args)
{
	GsfOutfileOpenPkg *child, *open_pkg = GSF_OUTFILE_OPEN_PKG (parent);
	GsfOutput *sink;

	if (!open_pkg->is_dir)
		return NULL;

	child = (GsfOutfileOpenPkg *)g_object_new_valist (
		GSF_OUTFILE_OPEN_PKG_TYPE, first_property_name, args);
	gsf_output_set_name (GSF_OUTPUT (child), name);
	gsf_output_set_container (GSF_OUTPUT (child), parent);
	child->is_dir = is_dir;

	sink = gsf_outfile_new_child (GSF_OUTFILE (open_pkg->sink), name, is_dir);
	gsf_outfile_open_pkg_set_sink (child, sink);
	g_object_unref (sink);

	/*
	 * Holding a ref here is not ideal.  It means we won't release any of the
	 * children until the package is closed.
	 */
	open_pkg->children = g_slist_prepend (open_pkg->children, g_object_ref (child));

	return GSF_OUTPUT (child);
}
Example #3
0
/**
 * gsf_output_set_name_from_filename:
 * @output: the output stream
 * @filename: the (fs-sys encoded) filename
 *
 * <note>This is a utility routine that should only be used by derived
 * outputs.</note>
 *
 * Returns: %TRUE if the assignment was ok.
 **/
gboolean
gsf_output_set_name_from_filename (GsfOutput *output, char const *filename)
{
	char *name;
	gboolean res;

	g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE);

	name = filename
		? g_filename_to_utf8 (filename, -1, NULL, NULL, NULL)
		: NULL;
	res = gsf_output_set_name (output, name);
	g_free (name);
	return res;
}
Example #4
0
static GsfOutput *
gsf_outfile_zip_new_child (GsfOutfile *parent,
			   char const *name, gboolean is_dir,
			   char const *first_property_name, va_list args)
{
	GsfOutfileZip *zip_parent = (GsfOutfileZip *)parent;
	GsfOutfileZip *child;
	size_t n_params = 0;
	GParameter *params = NULL;
	char *display_name;

	g_return_val_if_fail (zip_parent != NULL, NULL);
	g_return_val_if_fail (zip_parent->vdir, NULL);
	g_return_val_if_fail (zip_parent->vdir->is_directory, NULL);
	g_return_val_if_fail (name && *name, NULL);

	gsf_property_settings_collect (GSF_OUTFILE_ZIP_TYPE,
				       &params, &n_params,
				       "sink", zip_parent->sink,
				       "entry-name", name,
				       NULL);
	gsf_property_settings_collect_valist (GSF_OUTFILE_ZIP_TYPE,
					      &params, &n_params,
					      first_property_name,
					      args);
	child = (GsfOutfileZip *)g_object_newv (GSF_OUTFILE_ZIP_TYPE,
						n_params,
						params);
	gsf_property_settings_free (params, n_params);

	child->vdir = gsf_vdir_new (name, is_dir, NULL);

	/* FIXME: It isn't clear what encoding name is in.  */
	display_name = g_filename_display_name (name);
	gsf_output_set_name (GSF_OUTPUT (child), display_name);
	g_free (display_name);

	gsf_output_set_container (GSF_OUTPUT (child), parent);
	gsf_vdir_add_child (zip_parent->vdir, child->vdir);
	root_register_child (zip_parent->root, child);

	return GSF_OUTPUT (child);
}
Example #5
0
static void
gsf_output_dispose (GObject *obj)
{
	GsfOutput *output = GSF_OUTPUT (obj);

	if (!output->is_closed) {
		/* g_warning ("Disposing of an unclosed stream"); */
		gsf_output_close (output);
	}

	gsf_output_set_container (output, NULL);
	gsf_output_set_name (output, NULL);

	g_free (output->printf_buf);
	output->printf_buf = NULL;

	g_clear_error (&output->err);

	parent_class->dispose (obj);
}
Example #6
0
static GObject *
gsf_outfile_zip_constructor (GType                  type,
			     guint                  n_construct_properties,
			     GObjectConstructParam *construct_params)
{
	GsfOutfileZip *zip =(GsfOutfileZip *)
		(parent_class->constructor (type,
					    n_construct_properties,
					    construct_params));

	if (!zip->entry_name) {
		zip->vdir = gsf_vdir_new ("", TRUE, NULL);
		zip->root_order = g_ptr_array_new ();
		zip->root = zip;

		/* The names are the same */
		gsf_output_set_name (GSF_OUTPUT (zip), gsf_output_name (zip->sink));
		gsf_output_set_container (GSF_OUTPUT (zip), NULL);
	}

	return (GObject *)zip;
}
Example #7
0
static void
gsf_output_set_property (GObject      *object,
			 guint         property_id,
			 GValue const *value,
			 GParamSpec   *pspec)
{
	GsfOutput *output = GSF_OUTPUT (object);

	switch (property_id) {
	case PROP_NAME:
		gsf_output_set_name (output, g_value_get_string (value));
		break;
	case PROP_MODTIME:
		gsf_output_set_modtime (output, g_value_get_boxed (value));
		break;
	case PROP_CONTAINER:
		gsf_output_set_container (output, g_value_get_object (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}