Esempio n. 1
0
static void
_diagram_change (DiaApplication   *app,
                 Diagram          *dia,
		 guint             flags,
		 gpointer          object,
	         DiagramTreeModel *dtm)
{
  GtkTreePath *path;
  GtkTreeIter _iter = {0,};
  GtkTreeIter *iter = &_iter;
  
  NODE_DIAGRAM(iter) = DIA_DIAGRAM_DATA(dia);

  if (flags & DIAGRAM_CHANGE_NAME)
    /* nothing special */;
  if (flags & DIAGRAM_CHANGE_LAYER)
    NODE_LAYER(iter) = object;
  if (flags & DIAGRAM_CHANGE_OBJECT) {
    NODE_OBJECT(iter) = object;
    NODE_LAYER(iter) = dia_object_get_parent_layer (object);
  }

  path = _dtm_get_path (GTK_TREE_MODEL (dtm), iter);
  gtk_tree_model_row_changed (GTK_TREE_MODEL (dtm), path, iter);
  gtk_tree_path_free (path);
}
Esempio n. 2
0
static gboolean
_dtm_iter_children (GtkTreeModel *tree_model,
		    GtkTreeIter  *iter,
		    GtkTreeIter  *parent)
{
  if (parent) {
    if (NODE_OBJECT(parent))
      return FALSE;
    else if (NODE_LAYER(parent)) {
      NODE_OBJECT(iter) = layer_object_get_nth(NODE_LAYER(parent), 0);
      if (NODE_OBJECT(iter)) {
        NODE_LAYER(iter) = dia_object_get_parent_layer(NODE_OBJECT(iter));
	NODE_DIAGRAM(iter) = layer_get_parent_diagram (NODE_LAYER(iter));
	return TRUE;
      }
    } else if (NODE_DIAGRAM(parent)) {
      NODE_LAYER(iter) = data_layer_get_nth(NODE_DIAGRAM(parent), 0);
      if (NODE_LAYER(iter)) {
	NODE_DIAGRAM(iter) = layer_get_parent_diagram (NODE_LAYER(iter));
	NODE_OBJECT(iter) = NULL;
	return TRUE;
      }
    } else {
      /* deliver root's children */
      parent = NULL;
    }
  }
  if (!parent) {
    /* the first diagram */
    GList *list = dia_open_diagrams();
    NODE_DIAGRAM(iter) = list ? list->data : NULL;
    NODE_LAYER(iter) = NULL;
    NODE_OBJECT(iter) = NULL;
    return NODE_DIAGRAM(iter) != NULL;
  }
  return FALSE;
}
Esempio n. 3
0
static GtkTreePath *
_dtm_get_path (GtkTreeModel *tree_model,
	       GtkTreeIter  *iter)
{
  GtkTreePath *result;
  int index = 0;

  if (!NODE_DIAGRAM(iter) && !NODE_LAYER(iter) && !NODE_OBJECT(iter)) {
    /* the root path */
    return gtk_tree_path_new_first ();
  }

  result = gtk_tree_path_new ();

  if (NODE_DIAGRAM(iter)) {
    GList *list = dia_open_diagrams();
    gtk_tree_path_append_index (result, g_list_index (list, NODE_DIAGRAM(iter)));
  }
  if (NODE_LAYER(iter)) {
    g_return_val_if_fail (NODE_DIAGRAM(iter) == layer_get_parent_diagram (NODE_LAYER(iter)), NULL);
    index = data_layer_get_index (NODE_DIAGRAM(iter), NODE_LAYER(iter));
    if (index >= 0)
      gtk_tree_path_append_index (result, index);
  }
  if (index >= 0 && NODE_OBJECT(iter)) {
    g_return_val_if_fail (NODE_LAYER(iter) == dia_object_get_parent_layer (NODE_OBJECT(iter)), NULL);
    index = layer_object_get_index (NODE_LAYER(iter), NODE_OBJECT(iter));
    if (index >= 0)
      gtk_tree_path_append_index (result, index);
  }

  if (index < 0) {
    gtk_tree_path_free (result);
    return NULL;
  }
  return result;
}
Esempio n. 4
0
static void
newgroup_update_data(NewGroup *group)
{
  Element *elem = &group->element;
  /* ElementBBExtras *extra = &elem->extra_spacing; */
  DiaObject *obj = &elem->object;

  /* Update connections: */
  group->connections[0].pos.x = elem->corner.x;
  group->connections[0].pos.y = elem->corner.y;
  group->connections[1].pos.x = elem->corner.x + elem->width / 2.0;
  group->connections[1].pos.y = elem->corner.y;
  group->connections[2].pos.x = elem->corner.x + elem->width;
  group->connections[2].pos.y = elem->corner.y;
  group->connections[3].pos.x = elem->corner.x;
  group->connections[3].pos.y = elem->corner.y + elem->height / 2.0;
  group->connections[4].pos.x = elem->corner.x + elem->width;
  group->connections[4].pos.y = elem->corner.y + elem->height / 2.0;
  group->connections[5].pos.x = elem->corner.x;
  group->connections[5].pos.y = elem->corner.y + elem->height;
  group->connections[6].pos.x = elem->corner.x + elem->width / 2.0;
  group->connections[6].pos.y = elem->corner.y + elem->height;
  group->connections[7].pos.x = elem->corner.x + elem->width;
  group->connections[7].pos.y = elem->corner.y + elem->height;
  group->connections[8].pos.x = elem->corner.x + elem->width / 2.0;
  group->connections[8].pos.y = elem->corner.y + elem->height / 2.0;

  group->connections[0].directions = DIR_NORTH|DIR_WEST;
  group->connections[1].directions = DIR_NORTH;
  group->connections[2].directions = DIR_NORTH|DIR_EAST;
  group->connections[3].directions = DIR_WEST;
  group->connections[4].directions = DIR_EAST;
  group->connections[5].directions = DIR_SOUTH|DIR_WEST;
  group->connections[6].directions = DIR_SOUTH;
  group->connections[7].directions = DIR_SOUTH|DIR_EAST;
  group->connections[8].directions = DIR_ALL;

  element_update_boundingbox(elem);
  
  obj->position = elem->corner;
  
  element_update_handles(elem);

  if (group->is_open) {
    obj->flags &= ~DIA_OBJECT_GRABS_CHILD_INPUT;
  } else {
    gboolean newlySet = FALSE;
    Layer *layer;
    if (!object_flags_set(obj, DIA_OBJECT_GRABS_CHILD_INPUT)) {
      newlySet = TRUE;
    }
    obj->flags |= DIA_OBJECT_GRABS_CHILD_INPUT;
    if (newlySet) {
      layer = dia_object_get_parent_layer(obj);
      if (layer != NULL) { /* Placed in diagram already */
	GList *children = g_list_prepend(NULL, obj);
	children = parent_list_affected(children);
	/* Remove the group object that stayed at the start of the list,
	   leaving only the children */
	children = g_list_remove_link(children, children);
#if 0 /* this introduces a crircular dependency, does not work on win32 and is bad style everywhere */
	diagram_unselect_objects(layer_get_parent_diagram(layer), children);
#else
	g_warning ("used to call diagram_unselect_objects()");
#endif
	g_list_free(children);
      }
    }
  }
}
Esempio n. 5
0
static gint
fnr_respond (GtkWidget *widget, gint response_id, gpointer data)
{
  const gchar *search = gtk_entry_get_text (g_object_get_data (G_OBJECT (widget), "search-entry")); 
  const gchar *replace;
  DDisplay *ddisp = (DDisplay*)data;
  SearchData sd = { 0, };
  sd.diagram = ddisp->diagram;
  sd.flags =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( 
                  g_object_get_data (G_OBJECT (widget), "match-case"))) ? MATCH_CASE : 0;
  sd.flags |= gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( 
                  g_object_get_data (G_OBJECT (widget), "match-word"))) ? MATCH_WORD : 0;
  sd.flags |= gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON ( 
		  g_object_get_data (G_OBJECT (widget), "match-all-properties"))) ? MATCH_ALL_PROPERTIES : 0;
  

  switch (response_id) {
  case RESPONSE_FIND :
    sd.key = search;
    sd.last = g_object_get_data (G_OBJECT (widget), "last-found");
    if (!_matches (sd.last, &sd))
      sd.last = NULL; /* reset if we start a new search */
    diagram_remove_all_selected (ddisp->diagram, TRUE);
    data_foreach_object (ddisp->diagram->data, find_func, &sd);
    /* remember it */
    sd.last = sd.found ? sd.found : sd.first;
    g_object_set_data (G_OBJECT (widget), "last-found", sd.last);
    if (sd.last) {
      if (dia_object_get_parent_layer(sd.last) != ddisp->diagram->data->active_layer) {
        /* can only select objects in the active layer */
        data_set_active_layer(ddisp->diagram->data, dia_object_get_parent_layer(sd.last));
        diagram_add_update_all(ddisp->diagram);
        diagram_flush(ddisp->diagram);
      }
      diagram_select (ddisp->diagram, sd.last);
      ddisplay_present_object (ddisp, sd.last);
    }
    break;
  case RESPONSE_REPLACE :
    replace = gtk_entry_get_text (g_object_get_data (G_OBJECT (widget), "replace-entry"));
    sd.key = search;
    sd.last = g_object_get_data (G_OBJECT (widget), "last-found");
    if (!_matches (sd.last, &sd)) {
      sd.last = NULL; /* reset if we start a new search */
      data_foreach_object (ddisp->diagram->data, find_func, &sd);
    }
    sd.last = sd.found ? sd.found : sd.first;
    g_object_set_data (G_OBJECT (widget), "last-found", sd.last);
    if (sd.last) {
      _replace (sd.last, &sd, replace);
      undo_set_transactionpoint(ddisp->diagram->undo);
    }
    g_object_set_data (G_OBJECT (widget), "last-found", sd.last);
    break;
  case RESPONSE_REPLACE_ALL :
    replace = gtk_entry_get_text (g_object_get_data (G_OBJECT (widget), "replace-entry"));
    sd.key = search;
    sd.last = g_object_get_data (G_OBJECT (widget), "last-found");
    do {
      if (!_matches (sd.last, &sd)) {
        sd.last = NULL; /* reset if we start a new search */
	sd.first = NULL;
        data_foreach_object (ddisp->diagram->data, find_func, &sd);
      }
      sd.last = sd.found ? sd.found : sd.first;
      if (sd.last)
        if (!_replace (sd.last, &sd, replace))
	  sd.last = NULL;
    } while (sd.last);
    g_object_set_data (G_OBJECT (widget), "last-found", sd.last);
    undo_set_transactionpoint(ddisp->diagram->undo);
    break;
  default:
    gtk_widget_hide (widget);
  }
  return 0;
}