コード例 #1
0
ファイル: diagram.c プロジェクト: brunetton/dia
void
diagram_place_under_selected(Diagram *dia)
{
  GList *sorted_list;
  GList *orig_list;

  if (g_list_length (dia->data->selected) == 0)
    return;

  orig_list = g_list_copy(dia->data->active_layer->objects);

  sorted_list = diagram_get_sorted_selected_remove(dia);
  object_add_updates_list(sorted_list, dia);
  layer_add_objects_first(dia->data->active_layer, sorted_list);
  
  undo_reorder_objects(dia, g_list_copy(sorted_list), orig_list);

  diagram_modified(dia);
  diagram_flush(dia);
  undo_set_transactionpoint(dia->undo);
}
コード例 #2
0
ファイル: xfig-import.c プロジェクト: heshanjse/dia
/* imports the given fig-file, returns TRUE if successful */
static gboolean 
import_fig(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data)
{
    FILE *figfile;
    char buf[BUFLEN];
    int figmajor, figminor;	
    int i;

    for (i = 0; i < FIG_MAX_USER_COLORS; i++) {
	fig_colors[i] = color_black;
    }
    for (i = 0; i < FIG_MAX_DEPTHS; i++) {
	depths[i] = NULL;
    }

    figfile = g_fopen(filename,"r");
    if (figfile == NULL) {
	dia_context_add_message_with_errno(ctx, errno, _("Couldn't open: '%s' for reading.\n"), 
		                dia_context_get_filename(ctx));
	return FALSE;
    }
  
    /* First check magic bytes */
    if (fgets(buf, BUFLEN, figfile) == NULL ||
        sscanf(buf, "#FIG %d.%d\n", &figmajor, &figminor) != 2)
    {
	dia_context_add_message_with_errno(ctx, errno, _("Doesn't look like a Fig file"));
	fclose(figfile);
	return FALSE;
    }
	
    if (figmajor != 3 || figminor != 2) {
	dia_context_add_message(ctx, _("This is a Fig version %d.%d file.\n It may not be importable."), 
				figmajor, figminor);
    }

    figversion = figmajor*100+figminor;

    if (!skip_comments(figfile)) {
	if (!feof(figfile)) {
	    dia_context_add_message_with_errno(ctx, errno, _("Error reading Fig file."));
	} else {
	    dia_context_add_message(ctx, _("Premature end of Fig file"));
	}
	fclose(figfile);
	return FALSE;
    }

    if (!fig_read_meta_data(figfile, dia, ctx)) {
	fclose(figfile);
	return FALSE;
    }
  
    compound_stack = NULL;

    do {
	if (!skip_comments(figfile)) {
	    if (!feof(figfile)) {
		dia_context_add_message_with_errno(ctx, errno, _("Error reading Fig file."));
	    } else {
		break;
	    }
	}
	if (! fig_read_object(figfile, ctx)) {
	    fclose(figfile);
	    break;
	}
    } while (TRUE);

    /* Now we can reorder for the depth fields */
    for (i = 0; i < FIG_MAX_DEPTHS; i++) {
	if (depths[i] != NULL)
	    layer_add_objects_first(dia->active_layer, depths[i]);
    }
    return TRUE;
}