Beispiel #1
0
/*!
 * \brief Create a new diagram data object only containing the selected objects
 * \memberof _DiagramData
 */
DiagramData *
diagram_data_clone_selected (DiagramData *data)
{
  DiagramData *clone;
  Layer *dest_layer;
  GList *sorted;

  clone = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL);
  
  clone->extents = data->extents;
  clone->bg_color = data->bg_color;
  clone->paper = data->paper; /* so ugly */
  clone->paper.name = g_strdup (data->paper.name);
  clone->is_compressed = data->is_compressed;

  /* the selection - if any - can only be on the active layer */
  dest_layer = g_ptr_array_index(clone->layers, 0);
  g_free (dest_layer->name);
  dest_layer->name = layer_get_name (data->active_layer);

  sorted = data_get_sorted_selected (data);
  dest_layer->objects = object_copy_list (sorted);
  g_list_free (sorted);
  dest_layer->visible = data->active_layer->visible;
  dest_layer->connectable = data->active_layer->connectable;
  
  data_update_extents (clone);
  
  return clone;
}
Beispiel #2
0
static void 
prop_dialog_fill(PropDialog *dialog, GList *objects, gboolean is_default)
{
  const PropDescription *pdesc;
  GPtrArray *props;

  g_return_if_fail(objects_comply_with_stdprop(objects));

  dialog->objects = g_list_copy(objects);
  dialog->copies = object_copy_list(objects);

  pdesc = object_list_get_prop_descriptions(objects, PROP_UNION);
  if (!pdesc) return;

  if (is_default)
    props = prop_list_from_descs(pdesc,pdtpp_is_visible_default);
  else
    props = prop_list_from_descs(pdesc,pdtpp_is_visible);

  if (!props) return;

  _prop_list_extend_for_meta (props);

  dialog->props = props;
  object_list_get_props(objects, props);

  prop_dialog_add_properties(dialog, props);
}
Beispiel #3
0
/*!
 * \brief Create a copy of the whole diagram data
 *
 * This is kind of a deep copy, everything not immutable gets duplicated.
 * Still this is supposed to be relatively fast, because the most expensive
 * objects have immutuable properties, namely the pixbufs in DiaImage are
 * only referenced.
 *
 * \memberof _DiagramData
 */
DiagramData *
diagram_data_clone (DiagramData *data)
{
  DiagramData *clone;
  guint i;
  
  clone = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL);
  
  clone->extents = data->extents;
  clone->bg_color = data->bg_color;
  clone->paper = data->paper; /* so ugly */
  clone->paper.name = g_strdup (data->paper.name);
  clone->is_compressed = data->is_compressed;
  
  layer_destroy(g_ptr_array_index(clone->layers, 0));
  g_ptr_array_remove(clone->layers, clone->active_layer);

  for (i=0; i < data->layers->len; ++i) {
    Layer *src_layer = g_ptr_array_index(data->layers, i);
    Layer *dest_layer = new_layer (layer_get_name (src_layer), clone);
  
    /* copy layer, init the active one */
    dest_layer->extents = src_layer->extents;
    dest_layer->objects = object_copy_list (src_layer->objects);
    dest_layer->visible = src_layer->visible;
    dest_layer->connectable = src_layer->connectable;
    g_ptr_array_add (clone->layers, dest_layer);
    if (src_layer == data->active_layer)
      clone->active_layer = dest_layer;
      
    /* the rest should be initialized by construction */
  }

  return clone;  
}