コード例 #1
0
ファイル: xml.c プロジェクト: toxicgumbo/MegaTunix
void export_dash_xml(gchar * filename)
{
	GtkWidget *dash = NULL;
	GList *children = NULL;
	GtkFixedChild *child = NULL;
	gchar * tmpbuf = NULL;
	guint i = 0;
	xmlDocPtr doc = NULL;       /* document pointer */


	xmlNodePtr root_node = NULL;/* node pointers */


	xmlNodePtr node = NULL;/* node pointers */


	xmlDtdPtr dtd = NULL;       /* DTD pointer */


	GtkTreeIter parent;
	GtkTreeIter iter;
	GtkTreeModel *model = NULL;
	gboolean state = FALSE;
	gchar * iname = NULL;
	gchar ** vector = NULL;
	GtkAllocation allocation;

	g_return_if_fail(filename);

	doc = xmlNewDoc(BAD_CAST "1.0");
	root_node = xmlNewNode(NULL,BAD_CAST "dashboard");
	xmlDocSetRootElement(doc,root_node);
	/*
	 * Creates a DTD declaration. Isn't mandatory. 
	 */


	dtd = xmlCreateIntSubset(doc, BAD_CAST "dashboard", NULL, BAD_CAST "mtxdashboard.dtd");

	dash = GTK_WIDGET(gtk_builder_get_object(toplevel,"dashboard"));

	gtk_widget_get_allocation(dash, &allocation);
	node = xmlNewChild(root_node,NULL,BAD_CAST "dash_geometry", NULL);
	generic_xml_gint_export(node,"width",&allocation.width);
	generic_xml_gint_export(node,"height",&allocation.height);

	children = GTK_FIXED(dash)->children;
	for(i=0;i<g_list_length(GTK_FIXED(dash)->children);i++)
	{
		child = g_list_nth_data(GTK_FIXED(dash)->children,i);
		node = xmlNewChild(root_node,NULL,BAD_CAST "gauge", NULL);
		gtk_widget_get_allocation(child->widget, &allocation);

		generic_xml_gint_export(node,"width",&allocation.width);
		generic_xml_gint_export(node,"height",&allocation.height);
		generic_xml_gint_export(node,"x_offset",&child->x);
		generic_xml_gint_export(node,"y_offset",&child->y);
		tmpbuf = g_strrstr(mtx_gauge_face_get_xml_filename(MTX_GAUGE_FACE(child->widget)),"Gauges");
		vector = g_strsplit(tmpbuf,PSEP,2);
		
		generic_xml_gchar_export(node,"gauge_xml_name",&vector[1]);
		g_strfreev(vector);
		state = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(OBJ_GET((child->widget),"combo")),&iter);
		model = gtk_combo_box_get_model(GTK_COMBO_BOX(OBJ_GET((child->widget),"combo")));
		gtk_tree_model_get(model,&iter,DATASOURCE_COL,&iname,-1);
		generic_xml_gchar_export(node,"datasource",&iname);
	}
	xmlSaveFormatFileEnc(filename, doc, "utf-8", 1);

	/*free the document */


	xmlFreeDoc(doc);

	/*
	 *Free the global variables that may
	 *have been allocated by the parser.
	 */


	xmlCleanupParser();

	/*
	 * this is to debug memory for regression tests
	 */


	xmlMemoryDump();

	return ;
}
コード例 #2
0
ファイル: gauge-xml.c プロジェクト: bigamil/MegaTunix
void mtx_gauge_gint_export(MtxDispatchHelper * helper)
{
	g_return_if_fail(helper);
	generic_xml_gint_export(helper->root_node,helper->element_name,(gint *)helper->src);
}