Skip to content

Commit e508f30

Browse files
committed
Checkpointing work on editable Annotator save file.
1 parent d71c541 commit e508f30

18 files changed

+426
-68
lines changed

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ dependencies = [
5757
dependency('libxml-2.0'),
5858
dependency('libportal-gtk4'),
5959
dependency('pangocairo'),
60+
dependency('libarchive'),
6061
math_dep
6162
]
6263

src/Canvas.vala

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public class Canvas : DrawingArea {
118118
set_cursor( cursor );
119119
}
120120

121-
/* Opens a new image and displays it in the drawing area */
121+
//-------------------------------------------------------------
122+
// Opens a new image and displays it in the drawing area.
122123
public bool open_image( string filename ) {
123124

124125
try {
@@ -494,6 +495,38 @@ public class Canvas : DrawingArea {
494495

495496
}
496497

498+
/****************************************************************************/
499+
// SAVE/LOAD
500+
/****************************************************************************/
501+
502+
//-------------------------------------------------------------
503+
// Saves this canvas and all canvas items in XML format.
504+
public Xml.Node* save( string? image_dir = null ) {
505+
506+
Xml.Node* node = new Xml.Node( null, "canvas" );
507+
508+
node->add_child( image.save( editor.filename, image_dir ) );
509+
node->add_child( items.save( image_dir ) );
510+
511+
return( node );
512+
513+
}
514+
515+
//-------------------------------------------------------------
516+
// Loads this canvas and the canvas items from XML format.
517+
public void load( Xml.Node* node ) {
518+
519+
for( Xml.Node* it=node->children; it!=null; it=it->next ) {
520+
if( it->type == Xml.ElementType.ELEMENT_NODE ) {
521+
switch( it->name ) {
522+
case "image" : image.load( it ); break;
523+
case "items" : items.load( it ); break;
524+
}
525+
}
526+
}
527+
528+
}
529+
497530
/****************************************************************************/
498531
// DRAWING FUNCTIONS
499532
/****************************************************************************/

0 commit comments

Comments
 (0)