Ejemplo n.º 1
0
static gboolean
workspace_load( Model *model, 
	ModelLoadState *state, Model *parent, xmlNode *xnode )
{
	Workspace *ws = WORKSPACE( model );
	char buf[FILENAME_MAX];
	char *txt;

	g_assert( IS_WORKSPACEGROUP( parent ) );

	/* "view" is optional, for backwards compatibility.
	 */
	if( get_sprop( xnode, "view", buf, FILENAME_MAX ) ) {
		WorkspaceMode mode = char_to_workspacemode( buf );

		if( (int) mode >= 0 )
			/* Could call workspace_set_mode(), but this is only a
			 * load, so so what.
			 */
			ws->mode = mode;
	}

	/* Also optional.
	 */
	(void) get_dprop( xnode, "scale", &ws->scale );
	(void) get_dprop( xnode, "offset", &ws->offset );

	(void) get_bprop( xnode, "locked", &ws->locked );

	(void) get_bprop( xnode, "lpane_open", &ws->lpane_open );
	(void) get_iprop( xnode, "lpane_position", &ws->lpane_position );
	(void) get_bprop( xnode, "rpane_open", &ws->rpane_open );
	(void) get_iprop( xnode, "rpane_position", &ws->rpane_position );

	if( get_sprop( xnode, "name", buf, FILENAME_MAX ) ) {
		IM_SETSTR( IOBJECT( ws )->name, buf );
	}
	if( get_sprop( xnode, "caption", buf, FILENAME_MAX ) ) {
		IM_SETSTR( IOBJECT( ws )->caption, buf );
	}

	/* Don't use get_sprop() and avoid a limit on def size.
	 */
	if( (txt = (char *) xmlGetProp( xnode, (xmlChar *) "local_defs" )) ) {
		(void) workspace_local_set( ws, txt );
		IM_FREEF( xmlFree, txt );
	}

	(void) get_iprop( xnode, "major", &ws->compat_major );
	(void) get_iprop( xnode, "minor", &ws->compat_minor );

	if( !MODEL_CLASS( parent_class )->load( model, state, parent, xnode ) )
		return( FALSE );

	return( TRUE );
}
Ejemplo n.º 2
0
/* Re-read the text in a tally entry. 
 */
static void *
stringview_scan( View *view )
{
	Stringview *stringview = STRINGVIEW( view );
	String *string = STRING( VOBJECT( stringview )->iobject );
    	Expr *expr = HEAPMODEL( string )->row->expr;
	char value[MAX_STRSIZE];
	char value2[MAX_STRSIZE];

#ifdef DEBUG
	Row *row = HEAPMODEL( string )->row;

	printf( "stringview_scan: " );
	row_name_print( row );
	printf( "\n" );
#endif /*DEBUG*/

	expr_error_clear( expr );

	if( !get_geditable_string( EDITVIEW( stringview )->text, 
		value, MAX_STRSIZE ) ) {
		expr_error_set( expr );
		return( view );
	}
	my_strccpy( value2, value );

	if( strcmp( string->value, value2 ) != 0 ) {
		IM_SETSTR( string->value, value2 );
		classmodel_update( CLASSMODEL( string ) ) ;
	}

	return( VIEW_CLASS( parent_class )->scan( view ) );
}
Ejemplo n.º 3
0
Archivo: iimage.c Proyecto: DINKIN/nip2
/* Need to implement _update_heap(), as not all model fields are directly
 * editable ... some are set only from expr. See also iregion.c.
 */
static void *
iimage_update_heap( Heapmodel *heapmodel )
{
	Expr *expr = heapmodel->row->expr;
        iImage *iimage = IIMAGE( heapmodel );
	ImageValue *value = &iimage->value;

	PElement pe;
	Imageinfo *ii;

#ifdef DEBUG
	printf( "iimage_update_heap: " );
	row_name_print( HEAPMODEL( iimage )->row );
	printf( "\n" );
#endif /*DEBUG*/

	/* Read the heap into the model, over the top of the unapplied edits.
	 */
	if( !class_get_exact( &expr->root, IOBJECT( heapmodel )->name, &pe ) )
		return( FALSE );
	if( !class_get_member_image( &pe, MEMBER_VALUE, &ii ) )
		return( FALSE );
	image_value_set( value, ii );

	IM_FREE( CLASSMODEL( iimage )->filename );

        if( value->ii && imageinfo_is_from_file( value->ii ) ) 
                IM_SETSTR( CLASSMODEL( iimage )->filename, 
                        IOBJECT( value->ii )->name );

	/* Classmodel _update_heap() will do _instance_new() from the fixed up
	 * model.
	 */
	return( HEAPMODEL_CLASS( parent_class )->update_heap( heapmodel ) );
}
Ejemplo n.º 4
0
/* edvips.c needs this
 */
VipsImage *
im_init( const char *filename )
{
	VipsImage *image;

	image = vips_image_new();
	IM_SETSTR( image->filename, filename );

	return( image );
}
Ejemplo n.º 5
0
Archivo: row.c Proyecto: imclab/nip2
static gboolean
row_load( Model *model, 
	ModelLoadState *state, Model *parent, xmlNode *xnode )
{
	Row *row = ROW( model );
	Subcolumn *scol = SUBCOLUMN( parent );

	char name[256];

	g_assert( IS_SUBCOLUMN( parent ) );

	if( !get_sprop( xnode, "name", name, 256 ) ) 
		return( FALSE );
	IM_SETSTR( IOBJECT( row )->name, name );

#ifdef DEBUG
	printf( "row_load: loading row %s (xmlNode %p)\n", name, xnode );
#endif /*DEBUG*/

	/* Popup is optional (top level only)
	 */
	(void) get_bprop( xnode, "popup", &row->popup );

	if( scol->is_top ) {
		Column *col = scol->top_col;
		Workspace *ws = col->ws;

		Symbol *sym;

		sym = symbol_new( ws->sym->expr->compile, name );
		symbol_user_init( sym );
		(void) compile_new_local( sym->expr );
		row_link_symbol( row, sym, NULL );

		/* We can't symbol_made() here, we've not parsed our value
		 * yet. See below ... we just make sure we're on the recomp
		 * lists.
		 */
	}

	if( !MODEL_CLASS( parent_class )->load( model, state, parent, xnode ) )
		return( FALSE );

	/* If we've loaded a complete row system, mark this row plus any 
	 * edited subrows dirty, and make sure this sym is dirty too.
	 */
	if( scol->is_top ) {
		row_dirty_set( row, TRUE );
		expr_dirty( row->sym->expr, link_serial_new() );
	}

	return( TRUE );
}
Ejemplo n.º 6
0
static gboolean
column_load( Model *model, 
	ModelLoadState *state, Model *parent, xmlNode *xnode )
{
	Column *col = COLUMN( model );
	int x = col->x;
	int y = col->y;

	char buf[256];

	g_assert( IS_WORKSPACE( parent ) );

	if( !get_iprop( xnode, "x", &x ) ||
		!get_iprop( xnode, "y", &y ) ||
		!get_bprop( xnode, "open", &col->open ) ||
		!get_bprop( xnode, "selected", &col->selected ) ||
		!get_iprop( xnode, "next", &col->next ) )
		return( FALSE );

	col->x = x + column_left_offset;
	col->y = y + column_top_offset;

	/* Don't use iobject_set(): we don't want to trigger _changed during
	 * load.
	 */
	if( get_sprop( xnode, "caption", buf, 256 ) ) {
		IM_SETSTR( IOBJECT( col )->caption, buf );
	}
	if( get_sprop( xnode, "name", buf, 256 ) ) {
		IM_SETSTR( IOBJECT( col )->name, buf );
	}

	column_set_last_new( col );

	return( MODEL_CLASS( parent_class )->load( model, 
		state, parent, xnode ) );
}
Ejemplo n.º 7
0
Archivo: iimage.c Proyecto: DINKIN/nip2
/* Update iImage from heap.
 */
static gboolean
iimage_class_get( Classmodel *classmodel, PElement *root )
{
        iImage *iimage = IIMAGE( classmodel );
	ImageValue *value = &iimage->value;

	Imageinfo *ii;

#ifdef DEBUG
	printf( "iimage_class_get: " );
	row_name_print( HEAPMODEL( iimage )->row );
	printf( "\n" );
#endif /*DEBUG*/

	if( !class_get_member_image( root, MEMBER_VALUE, &ii ) )
		return( FALSE );
	image_value_set( value, ii );

	/* Try to update the filename for this row ... get from the meta if we
	 * can.
	 */
	IM_FREE( classmodel->filename );
        if( ii ) {
		IMAGE *im;
		char *filename;

		if( (im = imageinfo_get( FALSE, ii )) &&
			im_header_get_typeof( im, ORIGINAL_FILENAME ) != 0 ) {
			if( im_header_string( im, 
				ORIGINAL_FILENAME, &filename ) )
				return( FALSE );
		}
		else if( imageinfo_is_from_file( ii ) )
			filename = IOBJECT( ii )->name;
		else
			filename = NULL;

		IM_SETSTR( classmodel->filename, filename ); 
	}

	return( CLASSMODEL_CLASS( parent_class )->class_get( 
		classmodel, root ) );
}