/**
 * e_xmlhash_new:
 * @filename: the name of an XML file
 *
 * Creates a new #EXmlHash from the file @filename. If @filename does
 * not already exist, an empty #EXmlHash will be created.
 *
 * Returns: The new #EXmlHash structure, or %NULL if unable to parse
 *          @filename.
 **/
EXmlHash *
e_xmlhash_new (const gchar *filename)
{
	EXmlHash *hash;
	xmlDoc *doc = NULL;

	g_return_val_if_fail (filename != NULL, NULL);

	hash = g_new0 (EXmlHash, 1);
	hash->filename = g_strdup (filename);

	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
		doc = e_xml_parse_file (filename);
		if (!doc) {
			e_xmlhash_destroy (hash);

			return NULL;
		}
		hash->objects = e_xml_to_hash (doc, E_XML_HASH_TYPE_OBJECT_UID);
		xmlFreeDoc (doc);
	} else {
		hash->objects = g_hash_table_new (g_str_hash, g_str_equal);
	}

	return hash;
}
Esempio n. 2
0
static void
gal_view_minicard_load (GalView *view,
			const char *filename)
{
	xmlDoc *doc;

	doc = e_xml_parse_file (filename);
	if (doc) {
		xmlNode *root = xmlDocGetRootElement(doc);
		GAL_VIEW_MINICARD (view)->column_width = e_xml_get_double_prop_by_name_with_default (root, (const unsigned char *)"column_width", 150);
		xmlFreeDoc(doc);
	}
}
Esempio n. 3
0
static void
view_minicard_load (GalView *view,
                    const gchar *filename)
{
	GalViewMinicard *view_minicard;
	xmlDoc *doc;
	xmlNode *root;

	view_minicard = GAL_VIEW_MINICARD (view);

	doc = e_xml_parse_file (filename);
	g_return_if_fail (doc != NULL);

	root = xmlDocGetRootElement (doc);
	view_minicard->column_width =
		e_xml_get_double_prop_by_name_with_default (
		root, (guchar *) "column_width", 225);
	xmlFreeDoc (doc);
}
Esempio n. 4
0
static void
e_contact_build_style (EContactPrintStyle *style)
{
	xmlDocPtr styledoc;
	gchar *filename;

	style->title = g_strdup("");
	style->type = E_CONTACT_PRINT_TYPE_CARDS;
	style->sections_start_new_page = TRUE;
	style->num_columns = 2;
	style->blank_forms = 2;
	style->letter_headings = FALSE;

	style->headings_font = pango_font_description_from_string ("Sans Bold 8");
	style->body_font = pango_font_description_from_string ("Sans 6");

	style->print_using_grey = TRUE;
	style->paper_type = 0;
	style->paper_width = 8.5;
	style->paper_height = 11;
	style->paper_source = 0;
	style->top_margin = .5;
	style->left_margin = .5;
	style->bottom_margin = .5;
	style->right_margin = .5;
	style->page_size = 0;
	style->page_width = 2.75;
	style->page_height = 4.25;
#if 0
	style->page_width = 4.25;
	style->page_height = 5.5;
#endif
#if 0
	style->page_width = 5.5;
	style->page_height = 8.5;
#endif
	style->orientation_portrait = FALSE;

	style->header_font = pango_font_description_copy (style->body_font);

	style->left_header = g_strdup("");
	style->center_header = g_strdup("");
	style->right_header = g_strdup("");

	style->footer_font = pango_font_description_copy (style->body_font);

	style->left_footer = g_strdup ("");
	style->center_footer = g_strdup ("");
	style->right_footer = g_strdup ("");
	style->reverse_on_even_pages = FALSE;

	filename = g_build_filename (EVOLUTION_ECPSDIR, "medbook.ecps", NULL);
	styledoc = e_xml_parse_file (filename);
	g_free (filename);

	if (styledoc) {
		xmlNodePtr stylenode = xmlDocGetRootElement (styledoc);
		xmlNodePtr node;
		for (node = stylenode->children; node; node = node->next) {
			gchar *data = (gchar *) xmlNodeGetContent ( node );
			if (!strcmp( (gchar *)node->name, "title" )) {
				get_string (data, &(style->title));
			} else if (!strcmp( (gchar *)node->name, "type" )) {
				if (g_ascii_strcasecmp (data, "cards") == 0)
					style->type = E_CONTACT_PRINT_TYPE_CARDS;
				else if (g_ascii_strcasecmp (data, "memo_style") == 0)
					style->type = E_CONTACT_PRINT_TYPE_MEMO_STYLE;
				else if (g_ascii_strcasecmp (data, "phone_list") == 0)
					style->type = E_CONTACT_PRINT_TYPE_PHONE_LIST;
			} else if (!strcmp( (gchar *)node->name, "sections_start_new_page" )) {
				style->sections_start_new_page = get_bool (data);
			} else if (!strcmp( (gchar *)node->name, "num_columns" )) {
				style->num_columns = get_integer (data);
			} else if (!strcmp( (gchar *)node->name, "blank_forms" )) {
				style->blank_forms = get_integer (data);
			} else if (!strcmp( (gchar *)node->name, "letter_headings" )) {
				style->letter_headings = get_bool (data);
			} else if (!strcmp( (gchar *)node->name, "headings_font" )) {
				get_font ( data, &(style->headings_font) );
			} else if (!strcmp( (gchar *)node->name, "body_font" )) {
				get_font ( data, &(style->body_font) );
			} else if (!strcmp( (gchar *)node->name, "print_using_grey" )) {
				style->print_using_grey = get_bool (data);
			} else if (!strcmp( (gchar *)node->name, "paper_width" )) {
				style->paper_width = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "paper_height" )) {
				style->paper_height = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "top_margin" )) {
				style->top_margin = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "left_margin" )) {
				style->left_margin = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "bottom_margin" )) {
				style->bottom_margin = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "right_margin" )) {
				style->right_margin = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "page_width" )) {
				style->page_width = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "page_height" )) {
				style->page_height = get_float (data);
			} else if (!strcmp( (gchar *)node->name, "orientation" )) {
				if (data) {
					style->orientation_portrait =
						(g_ascii_strcasecmp (data, "landscape") != 0);
				} else {
					style->orientation_portrait = TRUE;
				}
			} else if (!strcmp( (gchar *)node->name, "header_font" )) {
				get_font ( data, &(style->header_font) );
			} else if (!strcmp( (gchar *)node->name, "left_header" )) {
				get_string (data, &(style->left_header));
			} else if (!strcmp( (gchar *)node->name, "center_header" )) {
				get_string (data, &(style->center_header));
			} else if (!strcmp( (gchar *)node->name, "right_header" )) {
				get_string (data, &(style->right_header));
			} else if (!strcmp( (gchar *)node->name, "footer_font" )) {
				get_font ( data, &(style->footer_font) );
			} else if (!strcmp( (gchar *)node->name, "left_footer" )) {
				get_string (data, &(style->left_footer));
			} else if (!strcmp( (gchar *)node->name, "center_footer" )) {
				get_string (data, &(style->center_footer));
			} else if (!strcmp( (gchar *)node->name, "right_footer" )) {
				get_string (data, &(style->right_footer));
			} else if (!strcmp( (gchar *)node->name, "reverse_on_even_pages" )) {
				style->reverse_on_even_pages = get_bool (data);
			}
			if (data)
				xmlFree (data);
		}
		xmlFreeDoc (styledoc);
	}

}