[dia] layers: become a GObject
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] layers: become a GObject
- Date: Sat, 21 Sep 2019 11:09:18 +0000 (UTC)
commit b1d237db5c7b784f48baec34dd1c693470a3eb74
Author: Zander Brown <zbrown gnome org>
Date: Fri Sep 20 19:58:28 2019 +0100
layers: become a GObject
app/app_procs.c | 27 +-
app/diagram.c | 100 ++--
app/diagram_tree_model.c | 20 +-
app/diagram_tree_view.c | 7 +-
app/display.c | 2 +-
app/dynamic_refresh.c | 2 +-
app/highlight.c | 4 +-
app/layer_dialog.c | 170 +++---
app/layer_dialog.h | 2 +-
app/load_save.c | 64 ++-
app/select.c | 65 +--
app/undo.c | 52 +-
lib/arrows.c | 2 +-
lib/arrows.h | 28 +-
lib/attributes.h | 8 +-
lib/dia-layer.h | 91 ++--
lib/diagramdata.c | 213 ++++----
lib/diagramdata.h | 28 +-
lib/diarenderer.c | 10 +-
lib/diarenderer.h | 5 +-
lib/diatypes.h | 15 +-
lib/focus.c | 8 +-
lib/focus.h | 10 +-
lib/font.h | 39 +-
lib/layer.c | 883 +++++++++++++++++++++++++-------
lib/object.c | 212 +++++---
lib/object.h | 4 +-
plug-ins/cgm/cgm.c | 1 +
plug-ins/drs/dia-render-script-import.c | 18 +-
plug-ins/drs/dia-render-script.c | 19 +-
plug-ins/dxf/dxf-export.c | 19 +-
plug-ins/dxf/dxf-import.c | 254 ++++-----
plug-ins/hpgl/hpgl.c | 1 +
plug-ins/pstricks/render_pstricks.c | 1 +
plug-ins/python/pydia-diagramdata.c | 49 +-
plug-ins/python/pydia-layer.c | 40 +-
plug-ins/python/pydia-layer.h | 6 +-
plug-ins/python/pydia-render.c | 6 +-
plug-ins/svg/render_svg.c | 19 +-
plug-ins/svg/svg-import.c | 8 +-
plug-ins/vdx/vdx-export.c | 10 +-
plug-ins/vdx/vdx-import.c | 49 +-
plug-ins/wpg/wpg-import.c | 1 +
plug-ins/wpg/wpg.c | 1 +
plug-ins/xfig/xfig-export.c | 16 +-
45 files changed, 1595 insertions(+), 994 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index 776cef77..4b8c7e65 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -165,10 +165,12 @@ show_layers_parse_numbers (DiagramData *diagdata,
/* Set the visible layers */
for ( i = low; i < high; i++ ) {
- Layer *lay = (Layer *) g_ptr_array_index (diagdata->layers, i);
+ DiaLayer *lay = DIA_LAYER (g_ptr_array_index (diagdata->layers, i));
if (visible_layers[i] == TRUE) {
- g_warning (_("Layer %lu (%s) selected more than once."), i, lay->name);
+ g_warning (_("Layer %lu (%s) selected more than once."),
+ i,
+ dia_layer_get_name (lay));
}
visible_layers[i] = TRUE;
}
@@ -186,19 +188,22 @@ show_layers_parse_word (DiagramData *diagdata,
/* Apply --show-layers=LAYER,LAYER,... switch. 13.3.2004 sampo iki fi */
if (layers) {
int len, k = 0;
- Layer *lay;
+ DiaLayer *lay;
char *p;
+ const char *name;
+
for (k = 0; k < layers->len; k++) {
- lay = (Layer *) g_ptr_array_index (layers, k);
+ lay = DIA_LAYER (g_ptr_array_index (layers, k));
+ name = dia_layer_get_name (lay);
- if (lay->name) {
- len = strlen (lay->name);
- if ((p = strstr (str, lay->name)) != NULL) {
+ if (name) {
+ len = strlen (name);
+ if ((p = strstr (str, name)) != NULL) {
if (((p == str) || (p[-1] == ',')) /* zap false positives */
&& ((p[len] == 0) || (p[len] == ','))){
found = TRUE;
if (visible_layers[k] == TRUE) {
- g_warning (_("Layer %d (%s) selected more than once."), k, lay->name);
+ g_warning (_("Layer %d (%s) selected more than once."), k, name);
}
visible_layers[k] = TRUE;
}
@@ -250,7 +255,7 @@ handle_show_layers (DiagramData *diagdata,
const char *show_layers)
{
gboolean *visible_layers;
- Layer *layer;
+ DiaLayer *layer;
int i;
visible_layers = g_new (gboolean, diagdata->layers->len);
@@ -270,9 +275,9 @@ handle_show_layers (DiagramData *diagdata,
layer = g_ptr_array_index (diagdata->layers, i);
if (visible_layers[i] == TRUE) {
- layer->visible = TRUE;
+ dia_layer_set_visible (layer, TRUE);
} else {
- layer->visible = FALSE;
+ dia_layer_set_visible (layer, FALSE);
}
}
g_free(visible_layers);
diff --git a/app/diagram.c b/app/diagram.c
index dd0ff09c..efb0cda5 100644
--- a/app/diagram.c
+++ b/app/diagram.c
@@ -170,21 +170,24 @@ dia_open_diagrams(void)
static void
_object_add (Diagram *dia,
- Layer *layer,
+ DiaLayer *layer,
DiaObject *obj,
- gpointer user_data)
+ gpointer user_data)
{
- if (obj)
- object_add_updates(obj, dia);
+ if (obj) {
+ object_add_updates (obj, dia);
+ }
}
+
static void
-_object_remove(Diagram *dia,
- Layer *layer,
- DiaObject *obj,
- gpointer user_data)
+_object_remove (Diagram *dia,
+ DiaLayer *layer,
+ DiaObject *obj,
+ gpointer user_data)
{
- if (obj)
- object_add_updates(obj, dia);
+ if (obj) {
+ object_add_updates (obj, dia);
+ }
}
/** Initializes a diagram with standard info and sets it to be called
@@ -997,18 +1000,18 @@ diagram_find_closest_handle(Diagram *dia, Handle **closest,
}
real
-diagram_find_closest_connectionpoint(Diagram *dia,
- ConnectionPoint **closest,
- Point *pos,
- DiaObject *notthis)
+diagram_find_closest_connectionpoint (Diagram *dia,
+ ConnectionPoint **closest,
+ Point *pos,
+ DiaObject *notthis)
{
real dist = 100000000.0;
guint i;
- for (i=0;i<dia->data->layers->len;i++) {
- Layer *layer = (Layer*)g_ptr_array_index(dia->data->layers, i);
+ for (i = 0; i < dia->data->layers->len; i++) {
+ DiaLayer *layer = DIA_LAYER (g_ptr_array_index (dia->data->layers, i));
ConnectionPoint *this_cp;
real this_dist;
- if (layer->connectable) {
+ if (dia_layer_is_connectable (layer)) {
this_dist = dia_layer_find_closest_connectionpoint (layer,
&this_cp,
pos,
@@ -1210,7 +1213,8 @@ void diagram_unparent_children_selected(Diagram *dia)
}
}
-void diagram_group_selected(Diagram *dia)
+void
+diagram_group_selected (Diagram *dia)
{
GList *list;
GList *group_list;
@@ -1219,8 +1223,8 @@ void diagram_group_selected(Diagram *dia)
GList *orig_list;
Change *change;
- if (g_list_length(dia->data->selected) < 1) {
- message_error(_("Trying to group with no selected objects."));
+ if (g_list_length (dia->data->selected) < 1) {
+ message_error (_("Trying to group with no selected objects."));
return;
}
@@ -1231,39 +1235,39 @@ void diagram_group_selected(Diagram *dia)
dia->data->selected = parent_list_affected(dia->data->selected);
#endif
- orig_list = g_list_copy(dia->data->active_layer->objects);
+ orig_list = g_list_copy (dia_layer_get_object_list (DIA_DIAGRAM_DATA (dia)->active_layer));
/* We have to rebuild the selection list so that it is the same
order as in the Diagram list. */
- group_list = diagram_get_sorted_selected_remove(dia);
+ group_list = diagram_get_sorted_selected_remove (dia);
list = group_list;
while (list != NULL) {
- obj = (DiaObject *)list->data;
+ obj = DIA_OBJECT (list->data);
/* Remove connections from obj to objects outside created group. */
/* strip_connections sets up its own undo info. */
/* The connections aren't reattached by ungroup. */
- strip_connections(obj, dia->data->selected, dia);
+ strip_connections (obj, dia->data->selected, dia);
- list = g_list_next(list);
+ list = g_list_next (list);
}
/* Remove list of selected objects */
- textedit_remove_focus_all(dia);
- data_remove_all_selected(dia->data);
+ textedit_remove_focus_all (dia);
+ data_remove_all_selected (dia->data);
- group = group_create(group_list);
- change = undo_group_objects(dia, group_list, group, orig_list);
- (change->apply)(change, dia);
+ group = group_create (group_list);
+ change = undo_group_objects (dia, group_list, group, orig_list);
+ (change->apply) (change, dia);
/* Select the created group */
- diagram_select(dia, group);
+ diagram_select (dia, group);
- diagram_modified(dia);
- diagram_flush(dia);
+ diagram_modified (dia);
+ diagram_flush (dia);
- undo_set_transactionpoint(dia->undo);
+ undo_set_transactionpoint (dia->undo);
}
void diagram_ungroup_selected(Diagram *dia)
@@ -1329,7 +1333,7 @@ diagram_get_sorted_selected_remove(Diagram *dia)
}
void
-diagram_place_under_selected(Diagram *dia)
+diagram_place_under_selected (Diagram *dia)
{
GList *sorted_list;
GList *orig_list;
@@ -1337,17 +1341,17 @@ diagram_place_under_selected(Diagram *dia)
if (g_list_length (dia->data->selected) == 0)
return;
- orig_list = g_list_copy(dia->data->active_layer->objects);
+ orig_list = g_list_copy (dia_layer_get_object_list (DIA_DIAGRAM_DATA (dia)->active_layer));
- sorted_list = diagram_get_sorted_selected_remove(dia);
- object_add_updates_list(sorted_list, dia);
+ sorted_list = diagram_get_sorted_selected_remove (dia);
+ object_add_updates_list (sorted_list, dia);
dia_layer_add_objects_first (dia->data->active_layer, sorted_list);
- undo_reorder_objects(dia, g_list_copy(sorted_list), orig_list);
+ undo_reorder_objects (dia, g_list_copy (sorted_list), orig_list);
- diagram_modified(dia);
- diagram_flush(dia);
- undo_set_transactionpoint(dia->undo);
+ diagram_modified (dia);
+ diagram_flush (dia);
+ undo_set_transactionpoint (dia->undo);
}
void
@@ -1359,7 +1363,7 @@ diagram_place_over_selected(Diagram *dia)
if (g_list_length (dia->data->selected) == 0)
return;
- orig_list = g_list_copy(dia->data->active_layer->objects);
+ orig_list = g_list_copy (dia_layer_get_object_list (dia->data->active_layer));
sorted_list = diagram_get_sorted_selected_remove (dia);
object_add_updates_list (sorted_list, dia);
@@ -1383,7 +1387,7 @@ diagram_place_up_selected(Diagram *dia)
if (g_list_length (dia->data->selected) == 0)
return;
- orig_list = g_list_copy(dia->data->active_layer->objects);
+ orig_list = g_list_copy (dia_layer_get_object_list (DIA_DIAGRAM_DATA (dia)->active_layer));
sorted_list = diagram_get_sorted_selected(dia);
object_add_updates_list(orig_list, dia);
@@ -1416,7 +1420,7 @@ diagram_place_up_selected(Diagram *dia)
}
void
-diagram_place_down_selected(Diagram *dia)
+diagram_place_down_selected (Diagram *dia)
{
GList *sorted_list;
GList *orig_list;
@@ -1426,10 +1430,10 @@ diagram_place_down_selected(Diagram *dia)
if (g_list_length (dia->data->selected) == 0)
return;
- orig_list = g_list_copy(dia->data->active_layer->objects);
+ orig_list = g_list_copy (dia_layer_get_object_list (DIA_DIAGRAM_DATA (dia)->active_layer));
- sorted_list = diagram_get_sorted_selected(dia);
- object_add_updates_list(orig_list, dia);
+ sorted_list = diagram_get_sorted_selected (dia);
+ object_add_updates_list (orig_list, dia);
/* Sanity check */
g_assert(g_list_length (dia->data->selected) == g_list_length(sorted_list));
diff --git a/app/diagram_tree_model.c b/app/diagram_tree_model.c
index 7009af9e..b2f19b79 100644
--- a/app/diagram_tree_model.c
+++ b/app/diagram_tree_model.c
@@ -407,9 +407,9 @@ _recurse_row_inserted (GtkTreeModel *model, GtkTreeIter *parent)
/* listen on the diagram for object add/remove */
static void
_object_add (DiagramData *dia,
- Layer *layer,
+ DiaLayer *layer,
DiaObject *obj,
- DiagramTreeModel *dtm)
+ DiagramTreeModel *dtm)
{
GtkTreePath *path;
GtkTreeIter _iter;
@@ -434,11 +434,12 @@ _object_add (DiagramData *dia,
gtk_tree_path_free (path);
}
}
+
static void
-_object_remove(DiagramData *dia,
- Layer *layer,
- DiaObject *obj,
- DiagramTreeModel *dtm)
+_object_remove (DiagramData *dia,
+ DiaLayer *layer,
+ DiaObject *obj,
+ DiagramTreeModel *dtm)
{
GtkTreePath *path;
GtkTreeIter _iter;
@@ -599,8 +600,8 @@ static gint
cmp_layer (GtkTreeIter *a,
GtkTreeIter *b)
{
- Layer *pa = NODE_LAYER(a), *pb = NODE_LAYER(b);
- gchar *na, *nb;
+ DiaLayer *pa = NODE_LAYER(a), *pb = NODE_LAYER(b);
+ const char *na, *nb;
gint ret;
if (pa == pb)
return 0;
@@ -609,8 +610,7 @@ cmp_layer (GtkTreeIter *a,
if (!na || !nb)
return (na > nb) ? -1 : 1;
ret = strcmp (na, nb);
- g_free (na);
- g_free (nb);
+
return ret;
}
static gint
diff --git a/app/diagram_tree_view.c b/app/diagram_tree_view.c
index 86be9afb..79fc0ac9 100644
--- a/app/diagram_tree_view.c
+++ b/app/diagram_tree_view.c
@@ -152,7 +152,7 @@ _dtv_query_tooltip (GtkWidget *widget,
if (gtk_tree_model_get_iter (model, &iter, path)) {
/* show some useful information */
Diagram *diagram;
- Layer *layer;
+ DiaLayer *layer;
DiaObject *object;
@@ -169,11 +169,10 @@ _dtv_query_tooltip (GtkWidget *widget,
}
if (layer) {
- gchar *name = dia_layer_get_name (layer);
+ const char *name = dia_layer_get_name (layer);
gchar *em = g_markup_printf_escaped ("<b>%s</b>: %s\n", _("Layer"), name);
g_string_append (markup, em);
g_free (em);
- g_free (name);
} else if (diagram) {
int layers = data_layer_count (DIA_DIAGRAM_DATA (diagram));
g_string_append_printf (markup, g_dngettext (GETTEXT_PACKAGE, "%d Layer", "%d Layers",
@@ -314,7 +313,7 @@ _dtv_select_items (GtkAction *action,
if (gtk_tree_model_get_iter (model, &iter, r->data)) {
Diagram *diagram;
- Layer *layer;
+ DiaLayer *layer;
DiaObject *object;
gtk_tree_model_get (model, &iter, DIAGRAM_COLUMN, &diagram, -1);
diff --git a/app/display.c b/app/display.c
index e08e2c20..5754116e 100644
--- a/app/display.c
+++ b/app/display.c
@@ -468,7 +468,7 @@ ddisplay_obj_render (DiaObject *obj,
}
if (ddisp->show_cx_pts &&
- obj->parent_layer != NULL && obj->parent_layer->connectable) {
+ obj->parent_layer != NULL && dia_layer_is_connectable (obj->parent_layer)) {
object_draw_connectionpoints (obj, ddisp);
}
}
diff --git a/app/dynamic_refresh.c b/app/dynamic_refresh.c
index 35ca9b8d..d44ba614 100644
--- a/app/dynamic_refresh.c
+++ b/app/dynamic_refresh.c
@@ -39,7 +39,7 @@ static void foreach_dynobj(DiaObject* obj, gpointer data) {
while (list != NULL) {
Diagram* dia;
DiagramData* obj_ddata;
- Layer* layer;
+ DiaLayer *layer;
dia = (Diagram*)list->data;
list = g_list_next(list);
diff --git a/app/highlight.c b/app/highlight.c
index 2eea7f64..a46cc46f 100644
--- a/app/highlight.c
+++ b/app/highlight.c
@@ -78,9 +78,9 @@ highlight_reset_objects(GList *objects, Diagram *dia)
* the active layer.
*/
void
-highlight_reset_all(Diagram *dia) {
+highlight_reset_all (Diagram *dia) {
int i;
for (i = 0; i < dia->data->layers->len; i++) {
- highlight_reset_objects(((Layer*)g_ptr_array_index(dia->data->layers, i))->objects, dia);
+ highlight_reset_objects (dia_layer_get_object_list (DIA_LAYER (g_ptr_array_index (dia->data->layers,
i))), dia);
}
}
diff --git a/app/layer_dialog.c b/app/layer_dialog.c
index fdbc7d8b..5155e0b2 100644
--- a/app/layer_dialog.c
+++ b/app/layer_dialog.c
@@ -56,7 +56,7 @@ struct _DiaLayerWidget
GtkListItem list_item;
Diagram *dia;
- Layer *layer;
+ DiaLayer *layer;
GtkWidget *visible;
GtkWidget *connectable;
@@ -118,7 +118,7 @@ struct LayerChange {
Change change;
enum LayerChangeType type;
- Layer *layer;
+ DiaLayer *layer;
int index;
int applied;
};
@@ -127,7 +127,7 @@ struct LayerVisibilityChange {
Change change;
GList *original_visibility;
- Layer *layer;
+ DiaLayer *layer;
gboolean is_exclusive;
int applied;
};
@@ -141,15 +141,15 @@ struct LayerVisibilityChange {
static gboolean internal_call = FALSE;
static Change *
-undo_layer(Diagram *dia, Layer *layer, enum LayerChangeType, int index);
+undo_layer(Diagram *dia, DiaLayer *layer, enum LayerChangeType, int index);
static struct LayerVisibilityChange *
-undo_layer_visibility(Diagram *dia, Layer *layer, gboolean exclusive);
+undo_layer_visibility(Diagram *dia, DiaLayer *layer, gboolean exclusive);
static void
layer_visibility_change_apply(struct LayerVisibilityChange *change,
Diagram *dia);
-static GtkWidget* dia_layer_widget_new(Diagram *dia, Layer *layer);
-static void dia_layer_set_layer(DiaLayerWidget *widget, Diagram *dia, Layer *layer);
+static GtkWidget* dia_layer_widget_new(Diagram *dia, DiaLayer *layer);
+static void dia_layer_set_layer(DiaLayerWidget *widget, Diagram *dia, DiaLayer *layer);
static void dia_layer_update_from_layer(DiaLayerWidget *widget);
static void layer_dialog_new_callback(GtkWidget *widget, gpointer gdata);
@@ -157,7 +157,7 @@ static void layer_dialog_rename_callback(GtkWidget *widget, gpointer gdata);
static void layer_dialog_raise_callback(GtkWidget *widget, gpointer gdata);
static void layer_dialog_lower_callback(GtkWidget *widget, gpointer gdata);
static void layer_dialog_delete_callback(GtkWidget *widget, gpointer gdata);
-static void layer_dialog_edit_layer(DiaLayerWidget *layer_widget, Diagram *dia, Layer *layer);
+static void layer_dialog_edit_layer(DiaLayerWidget *layer_widget, Diagram *dia, DiaLayer *layer);
static ButtonData buttons[] = {
{ GTK_STOCK_ADD, layer_dialog_new_callback, N_("New Layer") },
@@ -497,7 +497,7 @@ dia_layer_deselect_callback(GtkWidget *widget, gpointer data)
static void
layer_dialog_new_callback(GtkWidget *widget, gpointer gdata)
{
- Layer *layer;
+ DiaLayer *layer;
Diagram *dia;
GtkWidget *selected;
GList *list = NULL;
@@ -532,6 +532,8 @@ layer_dialog_new_callback(GtkWidget *widget, gpointer gdata)
undo_layer (dia, layer, TYPE_ADD_LAYER, dia->data->layers->len - pos);
undo_set_transactionpoint (dia->undo);
+
+ g_free (new_layer_name);
}
}
@@ -540,7 +542,7 @@ layer_dialog_rename_callback(GtkWidget *widget, gpointer gdata)
{
GtkWidget *selected;
Diagram *dia;
- Layer *layer;
+ DiaLayer *layer;
dia = layer_dialog->diagram;
selected = GTK_LIST(layer_dialog->layer_list)->selection->data;
layer = dia->data->active_layer;
@@ -552,7 +554,7 @@ layer_dialog_delete_callback(GtkWidget *widget, gpointer gdata)
{
Diagram *dia;
GtkWidget *selected;
- Layer *layer;
+ DiaLayer *layer;
int pos;
dia = layer_dialog->diagram;
@@ -584,7 +586,7 @@ layer_dialog_delete_callback(GtkWidget *widget, gpointer gdata)
static void
layer_dialog_raise_callback(GtkWidget *widget, gpointer gdata)
{
- Layer *layer;
+ DiaLayer *layer;
Diagram *dia;
GtkWidget *selected;
GList *list = NULL;
@@ -629,7 +631,7 @@ layer_dialog_raise_callback(GtkWidget *widget, gpointer gdata)
static void
layer_dialog_lower_callback(GtkWidget *widget, gpointer gdata)
{
- Layer *layer;
+ DiaLayer *layer;
Diagram *dia;
GtkWidget *selected;
GList *list = NULL;
@@ -790,8 +792,8 @@ layer_dialog_set_diagram(Diagram *dia)
{
DiagramData *data;
GtkWidget *layer_widget;
- Layer *layer;
- Layer *active_layer = NULL;
+ DiaLayer *layer;
+ DiaLayer *active_layer = NULL;
int sel_pos;
int i,j;
@@ -818,12 +820,13 @@ layer_dialog_set_diagram(Diagram *dia)
sel_pos = 0;
for (i=data->layers->len-1,j=0;i>=0;i--,j++) {
- layer = (Layer *) g_ptr_array_index(data->layers, i);
+ layer = (DiaLayer *) g_ptr_array_index(data->layers, i);
layer_widget = dia_layer_widget_new(dia, layer);
gtk_widget_show(layer_widget);
gtk_container_add(GTK_CONTAINER(layer_dialog->layer_list), layer_widget);
- if (layer==active_layer)
- sel_pos = j;
+ if (layer == active_layer) {
+ sel_pos = j;
+ }
}
gtk_list_select_item(GTK_LIST(layer_dialog->layer_list), sel_pos);
}
@@ -870,34 +873,34 @@ dia_layer_widget_set_connectable(DiaLayerWidget *widget, gboolean on)
}
static void
-dia_layer_widget_exclusive_connectable(DiaLayerWidget *layer_widget)
+dia_layer_widget_exclusive_connectable (DiaLayerWidget *layer_widget)
{
GList *list;
DiaLayerWidget *lw;
- Layer *layer;
+ DiaLayer *layer;
int connectable = FALSE;
int i;
/* First determine if _any_ other layer widgets are set to connectable */
- for (i=0;i<layer_widget->dia->data->layers->len;i++) {
- layer = g_ptr_array_index(layer_widget->dia->data->layers, i);
+ for (i = 0; i < layer_widget->dia->data->layers->len; i++) {
+ layer = g_ptr_array_index (layer_widget->dia->data->layers, i);
if (layer_widget->layer != layer) {
- connectable |= layer->connectable;
+ connectable |= dia_layer_is_connectable (layer);
}
}
/* Now, toggle the connectability for all layers except the specified one */
- list = GTK_LIST(layer_dialog->layer_list)->children;
+ list = GTK_LIST (layer_dialog->layer_list)->children;
while (list) {
- lw = DIA_LAYER_WIDGET(list->data);
- if (lw != layer_widget)
- dia_layer_widget_set_connectable(lw, !connectable);
- else {
- dia_layer_widget_set_connectable(lw, TRUE);
+ lw = DIA_LAYER_WIDGET (list->data);
+ if (lw != layer_widget) {
+ dia_layer_widget_set_connectable (lw, !connectable);
+ } else {
+ dia_layer_widget_set_connectable (lw, TRUE);
}
- gtk_widget_queue_draw(GTK_WIDGET(lw));
+ gtk_widget_queue_draw (GTK_WIDGET (lw));
- list = g_list_next(list);
+ list = g_list_next (list);
}
}
@@ -918,31 +921,36 @@ dia_layer_widget_button_event(GtkWidget *widget,
}
static void
-dia_layer_widget_connectable_toggled(GtkToggleButton *widget,
- gpointer userdata)
+dia_layer_widget_connectable_toggled (GtkToggleButton *widget,
+ gpointer userdata)
{
- DiaLayerWidget *lw = DIA_LAYER_WIDGET(userdata);
+ DiaLayerWidget *lw = DIA_LAYER_WIDGET (userdata);
+
if (!lw->layer)
return;
+
if (shifted) {
shifted = FALSE;
internal_call = TRUE;
- dia_layer_widget_exclusive_connectable(lw);
+ dia_layer_widget_exclusive_connectable (lw);
internal_call = FALSE;
} else {
- lw->layer->connectable = gtk_toggle_button_get_active(widget);
+ dia_layer_set_connectable (lw->layer,
+ gtk_toggle_button_get_active (widget));
}
if (lw->layer == lw->dia->data->active_layer) {
- lw->connect_off = !gtk_toggle_button_get_active(widget);
+ lw->connect_off = !gtk_toggle_button_get_active (widget);
if (lw->connect_off) lw->connect_on = FALSE;
} else {
- lw->connect_on = gtk_toggle_button_get_active(widget);
+ lw->connect_on = gtk_toggle_button_get_active (widget);
if (lw->connect_on) lw->connect_off = FALSE;
}
- gtk_widget_queue_draw(GTK_WIDGET(lw));
+
+ gtk_widget_queue_draw (GTK_WIDGET (lw));
+
if (!internal_call) {
- diagram_add_update_all(lw->dia);
- diagram_flush(lw->dia);
+ diagram_add_update_all (lw->dia);
+ diagram_flush (lw->dia);
}
}
@@ -1052,27 +1060,27 @@ dia_layer_widget_get_type(void)
}
static GtkWidget *
-dia_layer_widget_new(Diagram *dia, Layer *layer)
+dia_layer_widget_new (Diagram *dia, DiaLayer *layer)
{
GtkWidget *widget;
- widget = GTK_WIDGET ( gtk_type_new (dia_layer_widget_get_type ()));
- dia_layer_set_layer(DIA_LAYER_WIDGET(widget), dia, layer);
+ widget = GTK_WIDGET (gtk_type_new (dia_layer_widget_get_type ()));
+ dia_layer_set_layer (DIA_LAYER_WIDGET (widget), dia, layer);
/* These may get toggled when the button is set without the widget being
* selected first.
* The connect_on state gets also used to restore with just a deselect
* of the active layer.
*/
- DIA_LAYER_WIDGET(widget)->connect_on = layer->connectable;
- DIA_LAYER_WIDGET(widget)->connect_off = FALSE;
+ DIA_LAYER_WIDGET (widget)->connect_on = dia_layer_is_connectable (layer);
+ DIA_LAYER_WIDGET (widget)->connect_off = FALSE;
return widget;
}
/** Layer has either been selected or created */
static void
-dia_layer_set_layer(DiaLayerWidget *widget, Diagram *dia, Layer *layer)
+dia_layer_set_layer(DiaLayerWidget *widget, Diagram *dia, DiaLayer *layer)
{
widget->dia = dia;
widget->layer = layer;
@@ -1080,18 +1088,20 @@ dia_layer_set_layer(DiaLayerWidget *widget, Diagram *dia, Layer *layer)
dia_layer_update_from_layer(widget);
}
+
static void
dia_layer_update_from_layer (DiaLayerWidget *widget)
{
internal_call = TRUE;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget->visible),
- widget->layer->visible);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->visible),
+ dia_layer_is_visible (widget->layer));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget->connectable),
- widget->layer->connectable);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->connectable),
+ dia_layer_is_connectable (widget->layer));
internal_call = FALSE;
- gtk_label_set_text (GTK_LABEL (widget->label), widget->layer->name);
+ gtk_label_set_text (GTK_LABEL (widget->label),
+ dia_layer_get_name (widget->layer));
}
@@ -1103,14 +1113,15 @@ static void
edit_layer_ok_callback (GtkWidget *w, gpointer client_data)
{
EditLayerDialog *dialog = (EditLayerDialog *) client_data;
- Layer *layer;
+ DiaLayer *layer;
g_return_if_fail (dialog->layer_widget != NULL);
layer = dialog->layer_widget->layer;
- g_free (layer->name);
- layer->name = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)));
+ g_object_set (layer,
+ "name", gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)),
+ NULL);
/* reflect name change on listeners */
dia_diagram_change (dialog->layer_widget->dia, DIAGRAM_CHANGE_LAYER, layer);
@@ -1129,10 +1140,10 @@ edit_layer_add_ok_callback (GtkWidget *w, gpointer client_data)
{
EditLayerDialog *dialog = (EditLayerDialog *) client_data;
Diagram *dia = ddisplay_active_diagram ();
- Layer *layer;
+ DiaLayer *layer;
int pos = data_layer_get_index (dia->data, dia->data->active_layer) + 1;
- layer = dia_layer_new (g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry))), dia->data);
+ layer = dia_layer_new (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)), dia->data);
data_add_layer_at (dia->data, layer, pos);
data_set_active_layer (dia->data, layer);
@@ -1156,10 +1167,11 @@ edit_layer_rename_ok_callback (GtkWidget *w, gpointer client_data)
{
EditLayerDialog *dialog = (EditLayerDialog *) client_data;
Diagram *dia = ddisplay_active_diagram();
- Layer *layer = dia->data->active_layer;
+ DiaLayer *layer = dia->data->active_layer;
- g_free (layer->name);
- layer->name = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)));
+ g_object_set (layer,
+ "name", gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)),
+ NULL);
diagram_add_update_all(dia);
diagram_flush(dia);
@@ -1200,7 +1212,7 @@ edit_layer_delete_callback (GtkWidget *w,
}
static void
-layer_dialog_edit_layer (DiaLayerWidget *layer_widget, Diagram *dia, Layer *layer)
+layer_dialog_edit_layer (DiaLayerWidget *layer_widget, Diagram *dia, DiaLayer *layer)
{
EditLayerDialog *dialog;
GtkWidget *vbox;
@@ -1242,9 +1254,9 @@ layer_dialog_edit_layer (DiaLayerWidget *layer_widget, Diagram *dia, Layer *laye
gtk_entry_set_activates_default(GTK_ENTRY (dialog->name_entry), TRUE);
gtk_box_pack_start (GTK_BOX (hbox), dialog->name_entry, TRUE, TRUE, 0);
if (layer_widget)
- gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), layer_widget->layer->name);
+ gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), dia_layer_get_name (layer_widget->layer));
else if (layer)
- gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), layer->name);
+ gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), dia_layer_get_name (layer));
else if (dia) {
gchar *name = g_strdup_printf (_("New layer %d"), dia->data->layers->len);
gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), name);
@@ -1366,7 +1378,7 @@ layer_change_free(struct LayerChange *change)
}
static Change *
-undo_layer(Diagram *dia, Layer *layer, enum LayerChangeType type, int index)
+undo_layer(Diagram *dia, DiaLayer *layer, enum LayerChangeType type, int index)
{
struct LayerChange *change;
@@ -1390,7 +1402,7 @@ layer_visibility_change_apply(struct LayerVisibilityChange *change,
Diagram *dia)
{
GPtrArray *layers;
- Layer *layer = change->layer;
+ DiaLayer *layer = change->layer;
int visible = FALSE;
int i;
@@ -1398,29 +1410,29 @@ layer_visibility_change_apply(struct LayerVisibilityChange *change,
/* First determine if _any_ other layer widgets are set to visible.
* If there is, exclusive switching turns all off. */
for (i=0;i<dia->data->layers->len;i++) {
- Layer *temp_layer = g_ptr_array_index(dia->data->layers, i);
+ DiaLayer *temp_layer = g_ptr_array_index(dia->data->layers, i);
if (temp_layer != layer) {
- visible |= temp_layer->visible;
+ visible |= dia_layer_is_visible (temp_layer);
}
}
/* Now, toggle the visibility for all layers except the specified one */
layers = dia->data->layers;
for (i = 0; i < layers->len; i++) {
- Layer *temp_layer = (Layer *) g_ptr_array_index(layers, i);
+ DiaLayer *temp_layer = (DiaLayer *) g_ptr_array_index(layers, i);
if (temp_layer == layer) {
- temp_layer->visible = TRUE;
+ dia_layer_set_visible (temp_layer, TRUE);
} else {
- temp_layer->visible = !visible;
+ dia_layer_set_visible (temp_layer, !visible);
}
}
} else {
- layer->visible = !layer->visible;
+ dia_layer_set_visible (layer, !dia_layer_is_visible (layer));
}
- diagram_add_update_all(dia);
+ diagram_add_update_all (dia);
if (layer_dialog->diagram == dia) {
- layer_dialog_set_diagram(dia);
+ layer_dialog_set_diagram (dia);
}
}
@@ -1435,8 +1447,8 @@ layer_visibility_change_revert(struct LayerVisibilityChange *change,
int i;
for (i = 0; vis != NULL && i < layers->len; vis = g_list_next(vis), i++) {
- Layer *layer = (Layer*) g_ptr_array_index(layers, i);
- layer->visible = GPOINTER_TO_INT (vis->data);
+ DiaLayer *layer = DIA_LAYER (g_ptr_array_index (layers, i));
+ dia_layer_set_visible (layer, GPOINTER_TO_INT (vis->data));
}
if (vis != NULL || i < layers->len) {
@@ -1458,7 +1470,7 @@ layer_visibility_change_free(struct LayerVisibilityChange *change)
}
static struct LayerVisibilityChange *
-undo_layer_visibility(Diagram *dia, Layer *layer, gboolean exclusive)
+undo_layer_visibility(Diagram *dia, DiaLayer *layer, gboolean exclusive)
{
struct LayerVisibilityChange *change;
GList *visibilities = NULL;
@@ -1472,8 +1484,8 @@ undo_layer_visibility(Diagram *dia, Layer *layer, gboolean exclusive)
change->change.free = (UndoFreeFunc) layer_visibility_change_free;
for (i = 0; i < layers->len; i++) {
- Layer *temp_layer = (Layer *) g_ptr_array_index(layers, i);
- visibilities = g_list_append(visibilities, GINT_TO_POINTER (temp_layer->visible));
+ DiaLayer *temp_layer = DIA_LAYER (g_ptr_array_index (layers, i));
+ visibilities = g_list_append (visibilities, GINT_TO_POINTER (dia_layer_is_visible (temp_layer)));
}
change->original_visibility = visibilities;
@@ -1488,7 +1500,7 @@ undo_layer_visibility(Diagram *dia, Layer *layer, gboolean exclusive)
* \brief edit a layers name, possibly also creating the layer
*/
void
-diagram_edit_layer(Diagram *dia, Layer *layer)
+diagram_edit_layer(Diagram *dia, DiaLayer *layer)
{
g_return_if_fail(dia != NULL);
diff --git a/app/layer_dialog.h b/app/layer_dialog.h
index 4faba5b7..30ed682e 100644
--- a/app/layer_dialog.h
+++ b/app/layer_dialog.h
@@ -32,7 +32,7 @@ GtkWidget * create_layer_view_widget (void);
typedef struct _DiaLayerWidget DiaLayerWidget;
-void diagram_edit_layer(Diagram *dia, Layer *layer);
+void diagram_edit_layer (Diagram *dia, DiaLayer *layer);
#endif /* LAYER_DIALOG_H */
diff --git a/app/load_save.c b/app/load_save.c
index f2817581..f7c4c4f5 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -380,11 +380,11 @@ diagram_data_load(const gchar *filename, DiagramData *data, DiaContext *ctx, voi
xmlNodePtr paperinfo, gridinfo, guideinfo;
xmlNodePtr layer_node;
AttributeNode attr;
- Layer *layer;
+ DiaLayer *layer;
xmlNsPtr namespace;
gchar firstchar;
Diagram *diagram = DIA_IS_DIAGRAM (data) ? DIA_DIAGRAM (data) : NULL;
- Layer *active_layer = NULL;
+ DiaLayer *active_layer = NULL;
GHashTable* unknown_objects_hash = g_hash_table_new(g_str_hash, g_str_equal);
int num_layers_added = 0;
@@ -650,11 +650,14 @@ diagram_data_load(const gchar *filename, DiagramData *data, DiaContext *ctx, voi
name = (char *)xmlGetProp(layer_node, (const xmlChar *)"name");
if (!name) break; /* name is mandatory */
- layer = dia_layer_new (g_strdup (name), data);
+ layer = dia_layer_new (name, data);
if (name) xmlFree (name);
- layer->visible = _get_bool_prop (layer_node, "visible", FALSE);
- layer->connectable = _get_bool_prop (layer_node, "connectable", FALSE);
+ g_object_set (layer,
+ "visible", _get_bool_prop (layer_node, "visible", FALSE),
+ "connectable", _get_bool_prop (layer_node, "connectable", FALSE),
+ NULL);
+
/* Read in all objects: */
list = read_objects (layer_node, objects_hash, ctx, NULL, unknown_objects_hash);
dia_layer_add_objects (layer, list);
@@ -674,22 +677,25 @@ diagram_data_load(const gchar *filename, DiagramData *data, DiaContext *ctx, voi
int i = data_layer_count (data) - num_layers_added;
layer_node = find_node_named (root->xmlChildrenNode, "layer");
for (; i < data_layer_count (data); ++i) {
- layer = (Layer *) g_ptr_array_index(data->layers, i);
+ layer = (DiaLayer *) g_ptr_array_index(data->layers, i);
+
while (layer_node && xmlStrcmp (layer_node->name, (xmlChar *)"layer") != 0)
- layer_node = layer_node->next;
+ layer_node = layer_node->next;
+
if (!layer_node) {
- dia_context_add_message (ctx, _("Error reading connections"));
- break;
+ dia_context_add_message (ctx, _("Error reading connections"));
+ break;
}
- read_connections(layer->objects, layer_node, objects_hash);
+
+ read_connections (dia_layer_get_object_list (layer), layer_node, objects_hash);
layer_node = layer_node->next;
}
}
if (!active_layer)
- data->active_layer = (Layer *) g_ptr_array_index(data->layers, 0);
+ data->active_layer = DIA_LAYER (g_ptr_array_index (data->layers, 0));
else
- data_set_active_layer(data, active_layer);
+ data_set_active_layer (data, active_layer);
xmlFreeDoc(doc);
@@ -872,7 +878,7 @@ diagram_data_write_doc(DiagramData *data, const char *filename, DiaContext *ctx)
gboolean res;
int obj_nr;
guint i;
- Layer *layer;
+ DiaLayer *layer;
AttributeNode attr;
xmlNs *name_space;
Diagram *diagram = DIA_IS_DIAGRAM (data) ? DIA_DIAGRAM (data) : NULL;
@@ -976,15 +982,17 @@ diagram_data_write_doc(DiagramData *data, const char *filename, DiaContext *ctx)
layer_node = xmlNewChild (doc->xmlRootNode,
name_space,
(const xmlChar *) "layer", NULL);
- layer = (Layer *) g_ptr_array_index (data->layers, i);
- xmlSetProp (layer_node, (const xmlChar *) "name", (xmlChar *) layer->name);
+ layer = (DiaLayer *) g_ptr_array_index (data->layers, i);
+ xmlSetProp (layer_node,
+ (const xmlChar *) "name",
+ (xmlChar *) dia_layer_get_name (layer));
xmlSetProp (layer_node,
(const xmlChar *) "visible",
- (const xmlChar *) (layer->visible ? "true" : "false"));
+ (const xmlChar *) (dia_layer_is_visible (layer) ? "true" : "false"));
xmlSetProp (layer_node,
(const xmlChar *) "connectable",
- (const xmlChar *) (layer->connectable ? "true" : "false"));
+ (const xmlChar *) (dia_layer_is_connectable (layer) ? "true" : "false"));
if (layer == data->active_layer) {
xmlSetProp (layer_node,
@@ -992,7 +1000,7 @@ diagram_data_write_doc(DiagramData *data, const char *filename, DiaContext *ctx)
(const xmlChar *) "true");
}
- write_objects (layer->objects,
+ write_objects (dia_layer_get_object_list (layer),
layer_node,
objects_hash,
&obj_nr,
@@ -1005,16 +1013,24 @@ diagram_data_write_doc(DiagramData *data, const char *filename, DiaContext *ctx)
*/
layer_node = doc->xmlRootNode->children;
for (i = 0; i < data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index(data->layers, i);
- while (layer_node && xmlStrcmp (layer_node->name, (xmlChar *)"layer") != 0)
+ layer = (DiaLayer *) g_ptr_array_index (data->layers, i);
+ while (layer_node && xmlStrcmp (layer_node->name, (xmlChar *) "layer") != 0) {
layer_node = layer_node->next;
+ }
if (!layer_node) {
- dia_context_add_message (ctx, _("Error saving connections to layer '%s'"), layer->name);
+ dia_context_add_message (ctx,
+ _("Error saving connections to layer '%s'"),
+ dia_layer_get_name (layer));
break;
}
- res = write_connections(layer->objects, layer_node, objects_hash);
- if (!res)
- dia_context_add_message (ctx, _("Connection saving is incomplete for layer '%s'"), layer->name);
+ res = write_connections (dia_layer_get_object_list (layer),
+ layer_node,
+ objects_hash);
+ if (!res) {
+ dia_context_add_message (ctx,
+ _("Connection saving is incomplete for layer '%s'"),
+ dia_layer_get_name (layer));
+ }
layer_node = layer_node->next;
}
diff --git a/app/select.c b/app/select.c
index fd79e14a..4294a855 100644
--- a/app/select.c
+++ b/app/select.c
@@ -41,21 +41,21 @@ select_all_callback(GtkAction *action)
if (!ddisp || textedit_mode(ddisp)) return;
dia = ddisp->diagram;
- objects = dia->data->active_layer->objects;
+ objects = dia_layer_get_object_list (dia->data->active_layer);
while (objects != NULL) {
- DiaObject *obj = (DiaObject *)objects->data;
+ DiaObject *obj = DIA_OBJECT (objects->data);
- if (!diagram_is_selected(dia, obj)) {
- diagram_select(dia, obj);
+ if (!diagram_is_selected (dia, obj)) {
+ diagram_select (dia, obj);
}
- objects = g_list_next(objects);
+ objects = g_list_next (objects);
}
- ddisplay_do_update_menu_sensitivity(ddisp);
- object_add_updates_list(dia->data->selected, dia);
- diagram_flush(dia);
+ ddisplay_do_update_menu_sensitivity (ddisp);
+ object_add_updates_list (dia->data->selected, dia);
+ diagram_flush (dia);
}
void
@@ -75,30 +75,31 @@ select_none_callback(GtkAction *action)
}
void
-select_invert_callback(GtkAction *action)
+select_invert_callback (GtkAction *action)
{
Diagram *dia;
GList *tmp;
- DDisplay * ddisp = ddisplay_active();
+ DDisplay * ddisp = ddisplay_active ();
- if (!ddisp || textedit_mode(ddisp)) return;
+ if (!ddisp || textedit_mode (ddisp)) return;
dia = ddisp->diagram;
- tmp = dia->data->active_layer->objects;
+ tmp = dia_layer_get_object_list (dia->data->active_layer);
- for (; tmp != NULL; tmp = g_list_next(tmp)) {
- DiaObject *obj = (DiaObject *)tmp->data;
+ for (; tmp != NULL; tmp = g_list_next (tmp)) {
+ DiaObject *obj = DIA_OBJECT (tmp->data);
- if (!diagram_is_selected(dia, obj)) {
- diagram_select(dia, obj);
+ if (!diagram_is_selected (dia, obj)) {
+ diagram_select (dia, obj);
} else {
- diagram_unselect_object(dia, obj);
+ diagram_unselect_object (dia, obj);
}
}
- ddisplay_do_update_menu_sensitivity(ddisp);
- object_add_updates_list(dia->data->selected, dia);
- diagram_flush(dia);
+ ddisplay_do_update_menu_sensitivity (ddisp);
+ object_add_updates_list (dia->data->selected, dia);
+ diagram_flush (dia);
+
}
@@ -221,39 +222,39 @@ select_transitive_callback(GtkAction *action)
}
void
-select_same_type_callback(GtkAction *action)
+select_same_type_callback (GtkAction *action)
{
/* For now, do a brute force version: Check vs. all earlier selected.
Later, we should really sort the selecteds first to avoid n^2 */
- DDisplay *ddisp = ddisplay_active();
+ DDisplay *ddisp = ddisplay_active ();
Diagram *dia;
GList *objects, *tmp, *tmp2;
- if (!ddisp || textedit_mode(ddisp)) return;
+ if (!ddisp || textedit_mode (ddisp)) return;
dia = ddisp->diagram;
- tmp = dia->data->active_layer->objects;
+ tmp = dia_layer_get_object_list (dia->data->active_layer);
objects = dia->data->selected;
- for (; tmp != NULL; tmp = g_list_next(tmp)) {
+ for (; tmp != NULL; tmp = g_list_next (tmp)) {
DiaObject *obj = (DiaObject *)tmp->data;
- if (!diagram_is_selected(dia, obj)) {
- for (tmp2 = objects; tmp2 != NULL; tmp2 = g_list_next(tmp2)) {
- DiaObject *obj2 = (DiaObject *)tmp2->data;
+ if (!diagram_is_selected (dia, obj)) {
+ for (tmp2 = objects; tmp2 != NULL; tmp2 = g_list_next (tmp2)) {
+ DiaObject *obj2 = DIA_OBJECT (tmp2->data);
if (obj->type == obj2->type) {
- diagram_select(dia, obj);
+ diagram_select (dia, obj);
break;
}
}
}
}
- ddisplay_do_update_menu_sensitivity(ddisp);
- object_add_updates_list(dia->data->selected, dia);
- diagram_flush(dia);
+ ddisplay_do_update_menu_sensitivity (ddisp);
+ object_add_updates_list (dia->data->selected, dia);
+ diagram_flush (dia);
}
void
diff --git a/app/undo.c b/app/undo.c
index 59d48111..0767c8e8 100644
--- a/app/undo.c
+++ b/app/undo.c
@@ -623,7 +623,7 @@ undo_unconnect(Diagram *dia, DiaObject *obj, Handle *handle)
struct DeleteObjectsChange {
Change change;
- Layer *layer;
+ DiaLayer *layer;
GList *obj_list; /* Owning reference when applied */
GList *original_objects;
int applied;
@@ -710,7 +710,7 @@ undo_delete_objects(Diagram *dia, GList *obj_list)
change->layer = dia->data->active_layer;
change->obj_list = obj_list;
- change->original_objects = g_list_copy(dia->data->active_layer->objects);
+ change->original_objects = g_list_copy (dia_layer_get_object_list (dia->data->active_layer));
change->applied = 0;
DEBUG_PRINTF(("UNDO: Push new delete objects at %d\n", dia->undo->depth));
@@ -723,18 +723,18 @@ undo_delete_objects(Diagram *dia, GList *obj_list)
struct InsertObjectsChange {
Change change;
- Layer *layer;
+ DiaLayer *layer;
GList *obj_list; /* Owning reference when not applied */
int applied;
};
static void
-insert_objects_apply(struct InsertObjectsChange *change, Diagram *dia)
+insert_objects_apply (struct InsertObjectsChange *change, Diagram *dia)
{
- DEBUG_PRINTF(("insert_objects_apply()\n"));
+ DEBUG_PRINTF (("insert_objects_apply()\n"));
change->applied = 1;
dia_layer_add_objects (change->layer, g_list_copy (change->obj_list));
- object_add_updates_list(change->obj_list, dia);
+ object_add_updates_list (change->obj_list, dia);
}
static void
@@ -795,7 +795,7 @@ undo_insert_objects(Diagram *dia, GList *obj_list, int applied)
struct ReorderObjectsChange {
Change change;
- Layer *layer;
+ DiaLayer *layer;
GList *changed_list; /* Owning reference when applied */
GList *original_objects;
GList *reordered_objects;
@@ -842,7 +842,7 @@ undo_reorder_objects(Diagram *dia, GList *changed_list, GList *orig_list)
change->layer = dia->data->active_layer;
change->changed_list = changed_list;
change->original_objects = orig_list;
- change->reordered_objects = g_list_copy(dia->data->active_layer->objects);
+ change->reordered_objects = g_list_copy (dia_layer_get_object_list (DIA_DIAGRAM_DATA (dia)->active_layer));
DEBUG_PRINTF(("UNDO: Push new reorder objects at %d\n", dia->undo->depth));
undo_push_change(dia->undo, (Change *) change);
@@ -953,7 +953,7 @@ undo_object_change(Diagram *dia, DiaObject *obj,
struct GroupObjectsChange {
Change change;
- Layer *layer;
+ DiaLayer *layer;
DiaObject *group; /* owning reference if not applied */
GList *obj_list; /* The list of objects in this group. Owned by the
group */
@@ -1048,7 +1048,7 @@ undo_group_objects(Diagram *dia, GList *obj_list, DiaObject *group,
struct UngroupObjectsChange {
Change change;
- Layer *layer;
+ DiaLayer *layer;
DiaObject *group; /* owning reference if applied */
GList *obj_list; /* This list is owned by the ungroup. */
int group_index;
@@ -1219,7 +1219,7 @@ typedef struct _MoveObjectToLayerChange {
/** All objects in the original layer */
GList *orig_list;
/** The active layer when started */
- Layer *orig_layer;
+ DiaLayer *orig_layer;
gboolean moving_up;
} MoveObjectToLayerChange;
@@ -1231,7 +1231,7 @@ static void
move_object_layer_relative (Diagram *dia, GList *objects, gint dist)
{
/* from the active layer to above or below */
- Layer *active, *target;
+ DiaLayer *active, *target;
guint pos;
g_return_if_fail (dia->data->active_layer);
@@ -1297,12 +1297,12 @@ undo_move_object_other_layer(Diagram *dia, GList *selected_list,
change->free = (UndoFreeFunc) move_object_to_layer_free;
movetolayerchange->orig_layer = dia->data->active_layer;
- movetolayerchange->orig_list = g_list_copy(dia->data->active_layer->objects);
- movetolayerchange->objects = g_list_copy(selected_list);
+ movetolayerchange->orig_list = g_list_copy (dia_layer_get_object_list (DIA_DIAGRAM_DATA
(dia)->active_layer));
+ movetolayerchange->objects = g_list_copy (selected_list);
movetolayerchange->moving_up = moving_up;
- DEBUG_PRINTF(("UNDO: Push new obj_layer_change at %d\n", dia->undo->depth));
- undo_push_change(dia->undo, change);
+ DEBUG_PRINTF (("UNDO: Push new obj_layer_change at %d\n", dia->undo->depth));
+ undo_push_change (dia->undo, change);
return change;
}
@@ -1318,12 +1318,12 @@ _import_change_apply (ImportChange *change,
Diagram *dia)
{
GList *list;
- Layer *layer = dia->data->active_layer;
+ DiaLayer *layer = dia->data->active_layer;
/* add all objects and layers added from the diagram */
for (list = change->layers; list != NULL; list = list->next) {
- layer = (Layer *)list->data;
- data_add_layer (DIA_DIAGRAM_DATA(change->dia), layer);
+ layer = DIA_LAYER (list->data);
+ data_add_layer (DIA_DIAGRAM_DATA (change->dia), layer);
}
for (list = change->objects; list != NULL; list = list->next) {
DiaObject *obj = (DiaObject *)list->data;
@@ -1347,13 +1347,13 @@ _import_change_revert (ImportChange *change,
diagram_unselect_objects (change->dia, change->objects);
/* remove all objects and layers added from the diagram */
for (list = change->objects; list != NULL; list = list->next) {
- DiaObject *obj = (DiaObject *)list->data;
- Layer *layer = dia_object_get_parent_layer (obj);
+ DiaObject *obj = DIA_OBJECT (list->data);
+ DiaLayer *layer = dia_object_get_parent_layer (obj);
dia_layer_remove_object (layer, obj);
}
for (list = change->layers; list != NULL; list = list->next) {
- Layer *layer = (Layer *)list->data;
- data_remove_layer (DIA_DIAGRAM_DATA(change->dia), layer);
+ DiaLayer *layer = DIA_LAYER (list->data);
+ data_remove_layer (DIA_DIAGRAM_DATA (change->dia), layer);
}
diagram_update_extents (change->dia);
}
@@ -1370,9 +1370,9 @@ _import_change_free (ImportChange *change)
/* listen on the diagram for object add */
static void
_import_object_add (DiagramData *dia,
- Layer *layer,
- DiaObject *obj,
- ImportChange *change)
+ DiaLayer *layer,
+ DiaObject *obj,
+ ImportChange *change)
{
g_return_if_fail (change->dia == DIA_DIAGRAM(dia));
diff --git a/lib/arrows.c b/lib/arrows.c
index dac4a204..4aa324d2 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -44,7 +44,7 @@
#include "intl.h"
/**
- * SECTION:dia-arrows
+ * SECTION:arrows
* @title: Arrow
* @short_description: Arrow drawing
*
diff --git a/lib/arrows.h b/lib/arrows.h
index 4ff6541e..ffcbecb4 100644
--- a/lib/arrows.h
+++ b/lib/arrows.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ARROWS_H
-#define ARROWS_H
+
+#pragma once
#include "diatypes.h"
#include "geometry.h"
@@ -30,7 +30,7 @@
/**
* ArrowType:
- * @ARROW_NONE = 0: No arrow
+ * @ARROW_NONE: No arrow
* @ARROW_LINES: {open arrow}
* @ARROW_HOLLOW_TRIANGLE: {blanked arrow}
* @ARROW_FILLED_TRIANGLE: {filled arrow}
@@ -58,10 +58,10 @@
* @ARROW_HALF_DIAMOND: ---<
* @ARROW_OPEN_ROUNDED: ---c
* @ARROW_FILLED_DOT_N_TRIANGLE: ---|>o
- * @ARROW_ONE_OR_MANY: ER-model: 1 or many
- * @ARROW_NONE_OR_MANY: ER-model: 0 or many
- * @ARROW_ONE_OR_NONE: ER-model: 1 or 0
- * @ARROW_ONE_EXACTLY: ER-model: exactly one
+ * @ARROW_ONE_OR_MANY: ER-model, 1 or many
+ * @ARROW_NONE_OR_MANY: ER-model, 0 or many
+ * @ARROW_ONE_OR_NONE: ER-model, 1 or 0
+ * @ARROW_ONE_EXACTLY: ER-model, exactly one
* @ARROW_BACKSLASH: -\----
* @ARROW_THREE_DOTS:
* @MAX_ARROW_TYPE: This isn't an arrow, just marks the end
@@ -96,14 +96,14 @@ typedef enum {
ARROW_FILLED_CONCAVE,
ARROW_BLANKED_CONCAVE,
ARROW_ROUNDED,
- ARROW_HALF_DIAMOND, /* ---< */
- ARROW_OPEN_ROUNDED, /* ---c */
- ARROW_FILLED_DOT_N_TRIANGLE, /* ---|>o */
+ ARROW_HALF_DIAMOND, /* ---< */
+ ARROW_OPEN_ROUNDED, /* ---c */
+ ARROW_FILLED_DOT_N_TRIANGLE, /* ---|>o */
ARROW_ONE_OR_MANY, /* ER-model: 1 or many*/
ARROW_NONE_OR_MANY, /* ER-model: 0 or many*/
ARROW_ONE_OR_NONE, /* ER-model: 1 or 0 */
ARROW_ONE_EXACTLY, /* ER-model: exactly one*/
- ARROW_BACKSLASH, /* -\---- */
+ ARROW_BACKSLASH, /* -\---- */
ARROW_THREE_DOTS,
MAX_ARROW_TYPE /* No arrow heads may be defined beyond here. */
@@ -131,8 +131,8 @@ typedef enum {
/**
* Arrow:
* @type: kind of arrow
- * @length:
- * @width:
+ * @length: length of the arrow
+ * @width: width of the arrow
*
* Definition of line ends
*/
@@ -180,5 +180,3 @@ gint arrow_index_from_type (ArrowType atype);
ArrowType arrow_type_from_index (gint index);
const gchar *arrow_get_name_from_type (ArrowType type);
GList *get_arrow_names (void);
-
-#endif /* ARROWS_H */
diff --git a/lib/attributes.h b/lib/attributes.h
index 490b06d9..d918a8e8 100644
--- a/lib/attributes.h
+++ b/lib/attributes.h
@@ -15,14 +15,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef ATTRIBUTES_H
-#define ATTRIBUTES_H
+
+#pragma once
#include "dia-enums.h"
#include "geometry.h"
#include "color.h"
#include "arrows.h"
-#include "font.h"
+#include "diatypes.h"
G_BEGIN_DECLS
@@ -49,5 +49,3 @@ void attributes_get_default_font(DiaFont **font, real *font_height);
void attributes_set_default_font(DiaFont *font, real font_height);
G_END_DECLS
-
-#endif /* ATTRIBUTES_H */
diff --git a/lib/dia-layer.h b/lib/dia-layer.h
index 89dccf65..9da5667d 100644
--- a/lib/dia-layer.h
+++ b/lib/dia-layer.h
@@ -22,86 +22,83 @@
#include <glib.h>
+#include "diatypes.h"
+
#pragma once
G_BEGIN_DECLS
-/*!
- * \brief A diagram consists of layers holding objects
- *
- * \ingroup DiagramStructure
- * \todo : make this a GObject as well
- */
-struct _Layer {
- char *name; /*!< The name of the layer */
- Rectangle extents; /*!< The extents of the layer */
-
- GList *objects; /*!< List of objects in the layer,
- sorted by decreasing z-value,
- objects can ONLY be connected to objects
- in the same layer! */
+#define DIA_TYPE_LAYER dia_layer_get_type()
+G_DECLARE_DERIVABLE_TYPE (DiaLayer, dia_layer, DIA, LAYER, GObject)
- gboolean visible; /*!< The visibility of the layer */
- gboolean connectable; /*!< Whether the layer can currently be connected to.
- The selected layer is by default connectable */
-
- DiagramData *parent_diagram; /*!< Back-pointer to the diagram. This
- must only be set by functions internal
- to the diagram, and accessed via
- layer_get_parent_diagram() */
+struct _DiaLayerClass
+{
+ GObjectClass parent_class;
};
-Layer *dia_layer_new (char *name,
+DiaLayer *dia_layer_new (const char *name,
DiagramData *parent);
-void dia_layer_destroy (Layer *layer);
-void dia_layer_render (Layer *layer,
+DiaLayer *dia_layer_new_from_layer (DiaLayer *old);
+void dia_layer_destroy (DiaLayer *layer);
+void dia_layer_render (DiaLayer *layer,
DiaRenderer *renderer,
Rectangle *update,
ObjectRenderer obj_renderer /* Can be NULL */,
gpointer data,
int active_layer);
-int dia_layer_object_get_index (Layer *layer,
+int dia_layer_object_get_index (DiaLayer *layer,
DiaObject *obj);
-DiaObject *dia_layer_object_get_nth (Layer *layer,
+DiaObject *dia_layer_object_get_nth (DiaLayer *layer,
guint index);
-int dia_layer_object_count (Layer *layer);
-gchar *dia_layer_get_name (Layer *layer);
-void dia_layer_add_object (Layer *layer,
+int dia_layer_object_count (DiaLayer *layer);
+const char *dia_layer_get_name (DiaLayer *layer);
+void dia_layer_add_object (DiaLayer *layer,
DiaObject *obj);
-void dia_layer_add_object_at (Layer *layer,
+void dia_layer_add_object_at (DiaLayer *layer,
DiaObject *obj,
int pos);
-void dia_layer_add_objects (Layer *layer,
+void dia_layer_add_objects (DiaLayer *layer,
GList *obj_list);
-void dia_layer_add_objects_first (Layer *layer,
+void dia_layer_add_objects_first (DiaLayer *layer,
GList *obj_list);
-void dia_layer_remove_object (Layer *layer,
+void dia_layer_remove_object (DiaLayer *layer,
DiaObject *obj);
-void dia_layer_remove_objects (Layer *layer,
+void dia_layer_remove_objects (DiaLayer *layer,
GList *obj_list);
-GList *dia_layer_find_objects_intersecting_rectangle (Layer *layer,
+GList *dia_layer_find_objects_intersecting_rectangle (DiaLayer *layer,
Rectangle *rect);
-GList *dia_layer_find_objects_in_rectangle (Layer *layer,
+GList *dia_layer_find_objects_in_rectangle (DiaLayer *layer,
Rectangle *rect);
-GList *dia_layer_find_objects_containing_rectangle (Layer *layer,
+GList *dia_layer_find_objects_containing_rectangle (DiaLayer *layer,
Rectangle *rect);
-DiaObject *dia_layer_find_closest_object (Layer *layer,
+DiaObject *dia_layer_find_closest_object (DiaLayer *layer,
Point *pos,
real maxdist);
-DiaObject *dia_layer_find_closest_object_except (Layer *layer,
+DiaObject *dia_layer_find_closest_object_except (DiaLayer *layer,
Point *pos,
real maxdist,
GList *avoid);
-real dia_layer_find_closest_connectionpoint (Layer *layer,
+real dia_layer_find_closest_connectionpoint (DiaLayer *layer,
ConnectionPoint **closest,
Point *pos,
DiaObject *notthis);
-int dia_layer_update_extents (Layer *layer); /* returns true if
changed. */
-void dia_layer_replace_object_with_list (Layer *layer,
- DiaObject *obj,
+int dia_layer_update_extents (DiaLayer *layer); /* returns true if
changed. */
+void dia_layer_replace_object_with_list (DiaLayer *layer,
+ DiaObject *remove_obj,
+ GList *insert_list);
+void dia_layer_set_object_list (DiaLayer *layer,
GList *list);
-void dia_layer_set_object_list (Layer *layer,
- GList *list);
-DiagramData *dia_layer_get_parent_diagram (Layer *layer);
+GList *dia_layer_get_object_list (DiaLayer *layer);
+DiagramData *dia_layer_get_parent_diagram (DiaLayer *layer);
+void dia_layer_set_parent_diagram (DiaLayer *layer,
+ DiagramData *diagram);
+gboolean dia_layer_is_connectable (DiaLayer *self);
+void dia_layer_set_connectable (DiaLayer *self,
+ gboolean connectable);
+gboolean dia_layer_is_visible (DiaLayer *self);
+void dia_layer_set_visible (DiaLayer *self,
+ gboolean visible);
+void dia_layer_get_extents (DiaLayer *self,
+ Rectangle *rect);
G_END_DECLS
diff --git a/lib/diagramdata.c b/lib/diagramdata.c
index 4973e6b3..d8425e23 100644
--- a/lib/diagramdata.c
+++ b/lib/diagramdata.c
@@ -87,12 +87,16 @@ diagram_data_get_type(void)
/* signal default handlers */
static void
-_diagram_data_object_add (DiagramData* dia,Layer* layer,DiaObject* obj)
+_diagram_data_object_add (DiagramData *dia,
+ DiaLayer *layer,
+ DiaObject *obj)
{
}
static void
-_diagram_data_object_remove (DiagramData* dia,Layer* layer,DiaObject* obj)
+_diagram_data_object_remove (DiagramData *dia,
+ DiaLayer *layer,
+ DiaObject *obj)
{
}
@@ -109,7 +113,7 @@ diagram_data_init(DiagramData *data)
{
Color* color = persistence_register_color ("new_diagram_bgcolour", &color_white);
gboolean compress = persistence_register_boolean ("compress_save", TRUE);
- Layer *first_layer;
+ DiaLayer *first_layer;
data->extents.left = 0.0;
data->extents.right = 10.0;
@@ -120,7 +124,7 @@ diagram_data_init(DiagramData *data)
get_paper_info (&data->paper, -1, NULL);
- first_layer = dia_layer_new (g_strdup (_("Background")), data);
+ first_layer = dia_layer_new (_("Background"), data);
data->layers = g_ptr_array_new ();
g_ptr_array_add (data->layers, first_layer);
@@ -192,15 +196,11 @@ diagram_data_clone (DiagramData *data)
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 = dia_layer_new (dia_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;
+ DiaLayer *src_layer = g_ptr_array_index (data->layers, i);
+ DiaLayer *dest_layer = dia_layer_new_from_layer (src_layer);
+
g_ptr_array_add (clone->layers, dest_layer);
+
if (src_layer == data->active_layer)
clone->active_layer = dest_layer;
@@ -218,7 +218,7 @@ DiagramData *
diagram_data_clone_selected (DiagramData *data)
{
DiagramData *clone;
- Layer *dest_layer;
+ DiaLayer *dest_layer;
GList *sorted;
clone = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL);
@@ -230,15 +230,17 @@ diagram_data_clone_selected (DiagramData *data)
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 = dia_layer_get_name (data->active_layer);
+ dest_layer = g_ptr_array_index (clone->layers, 0);
+
+ g_object_set (dest_layer,
+ "name", dia_layer_get_name (data->active_layer),
+ "connectable", dia_layer_is_connectable (data->active_layer),
+ "visible", dia_layer_is_visible (data->active_layer),
+ NULL);
sorted = data_get_sorted_selected (data);
- dest_layer->objects = object_copy_list (sorted);
+ dia_layer_set_object_list (dest_layer, 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);
@@ -302,11 +304,11 @@ diagram_data_class_init(DiagramDataClass *klass)
* \memberof _DiagramData
*/
void
-data_raise_layer(DiagramData *data, Layer *layer)
+data_raise_layer (DiagramData *data, DiaLayer *layer)
{
guint i;
guint layer_nr = 0;
- Layer *tmp;
+ DiaLayer *tmp;
for (i=0;i<data->layers->len;i++) {
if (g_ptr_array_index(data->layers, i)==layer)
@@ -328,11 +330,11 @@ data_raise_layer(DiagramData *data, Layer *layer)
* \memberof _DiagramData
*/
void
-data_lower_layer(DiagramData *data, Layer *layer)
+data_lower_layer(DiagramData *data, DiaLayer *layer)
{
guint i;
int layer_nr = -1;
- Layer *tmp;
+ DiaLayer *tmp;
for (i=0;i<data->layers->len;i++) {
if (g_ptr_array_index(data->layers, i)==layer)
@@ -349,34 +351,35 @@ data_lower_layer(DiagramData *data, Layer *layer)
}
}
-/*!
- * \brief Add a layer object to a diagram.
- * @param data The diagram to add the layer to.
- * @param layer The layer to add.
- * \memberof _DiagramData
+/**
+ * data_add_layer:
+ * @data: The diagram to add the layer to.
+ * @layer: The layer to add.
+ *
+ * Add a layer object to a diagram.
*/
void
-data_add_layer (DiagramData *data, Layer *layer)
+data_add_layer (DiagramData *data, DiaLayer *layer)
{
g_ptr_array_add (data->layers, layer);
- layer->parent_diagram = data;
+ dia_layer_set_parent_diagram (layer, data);
data_emit (data, layer, NULL, "object_add");
dia_layer_update_extents (layer);
data_update_extents (data);
}
-/*!
- * \brief Add a layer at a defined postion in the stack
+/**
+ * data_add_layer_at:
+ * @data: the diagram
+ * @layer: layer to add
+ * @pos: the position in the layer stack
*
- * If the given pos is out of range the layer is added at the top of the stack.
+ * Add a layer at a defined postion in the stack
*
- * @param data the diagram
- * @param layer layer to add
- * @param pos the position in the layer stack
- * \memberof _DiagramData
+ * If the given pos is out of range the layer is added at the top of the stack.
*/
void
-data_add_layer_at(DiagramData *data, Layer *layer, int pos)
+data_add_layer_at (DiagramData *data, DiaLayer *layer, int pos)
{
int len;
int i;
@@ -391,10 +394,10 @@ data_add_layer_at(DiagramData *data, Layer *layer, int pos)
g_ptr_array_index(data->layers, pos) = layer;
}
- layer->parent_diagram = data;
+ dia_layer_set_parent_diagram (layer, data);
data_emit (data, layer, NULL, "object_add");
- dia_layer_update_extents(layer);
- data_update_extents(data);
+ dia_layer_update_extents (layer);
+ data_update_extents (data);
}
/*!
@@ -407,7 +410,7 @@ data_add_layer_at(DiagramData *data, Layer *layer, int pos)
* \memberof _DiagramData
*/
int
-data_layer_get_index (const DiagramData *data, const Layer *layer)
+data_layer_get_index (const DiagramData *data, const DiaLayer *layer)
{
int len;
int i;
@@ -419,6 +422,7 @@ data_layer_get_index (const DiagramData *data, const Layer *layer)
}
return -1;
}
+
/*!
* \brief Get the layer at position index
*
@@ -428,53 +432,55 @@ data_layer_get_index (const DiagramData *data, const Layer *layer)
*
* \memberof _DiagramData
*/
-Layer *
+DiaLayer *
data_layer_get_nth (const DiagramData *data, guint index)
{
if (data->layers->len > index)
return g_ptr_array_index(data->layers, index);
return NULL;
}
+
int
data_layer_count(const DiagramData *data)
{
return data->layers->len;
}
-/*!
- * \brief Set which layer is the active layer in a diagram.
- * @param data The diagram in which to set the active layer.
- * @param layer The layer that should be active.
+/**
+ * data_set_active_layer:
+ * @data: The diagram in which to set the active layer.
+ * @layer: The layer that should be active.
*
- * \memberof _DiagramData
+ * Set which layer is the active layer in a diagram.
*/
void
-data_set_active_layer(DiagramData *data, Layer *layer)
+data_set_active_layer (DiagramData *data, DiaLayer *layer)
{
data->active_layer = layer;
}
-/*!
- * \brief Remove a layer from a diagram.
- * @param data The diagram to remove the layer from.
- * @param layer The layer to remove.
- * \memberof _DiagramData
+/**
+ * data_remove_layer:
+ * @data: The diagram to remove the layer from.
+ * @layer: The layer to remove.
+ *
+ * Remove a layer from a diagram.
*/
void
-data_remove_layer(DiagramData *data, Layer *layer)
+data_remove_layer (DiagramData *data, DiaLayer *layer)
{
if (data->layers->len<=1)
return;
if (data->active_layer == layer) {
- data_remove_all_selected(data);
+ data_remove_all_selected (data);
}
data_emit (data, layer, NULL, "object_remove");
- layer->parent_diagram = NULL;
- g_ptr_array_remove(data->layers, layer);
+ dia_layer_set_parent_diagram (layer, NULL);
+ g_ptr_array_remove (data->layers, layer);
if (data->active_layer == layer) {
- data->active_layer = g_ptr_array_index(data->layers, 0);
+ data->active_layer = g_ptr_array_index (data->layers, 0);
}
}
@@ -585,12 +591,15 @@ data_remove_all_selected(DiagramData *data)
* \protected \memberof _DiagramData
*/
static gboolean
-data_has_visible_layers(DiagramData *data)
+data_has_visible_layers (DiagramData *data)
{
guint i;
for (i = 0; i < data->layers->len; i++) {
- Layer *layer = g_ptr_array_index(data->layers, i);
- if (layer->visible) return TRUE;
+ DiaLayer *layer = g_ptr_array_index (data->layers, i);
+
+ if (dia_layer_is_visible (layer)) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -601,24 +610,31 @@ data_has_visible_layers(DiagramData *data)
* \protected \memberof _DiagramData
*/
static void
-data_get_layers_extents_union(DiagramData *data)
+data_get_layers_extents_union (DiagramData *data)
{
guint i;
gboolean first = TRUE;
Rectangle new_extents;
- for ( i = 0 ; i<data->layers->len; i++) {
- Layer *layer = g_ptr_array_index(data->layers, i);
- if (!layer->visible) continue;
+ for ( i = 0; i < data->layers->len; i++) {
+ DiaLayer *layer = g_ptr_array_index (data->layers, i);
+
+ if (!dia_layer_is_visible (layer)) {
+ continue;
+ }
dia_layer_update_extents (layer);
if (first) {
- new_extents = layer->extents;
- first = rectangle_equals(&new_extents,&invalid_extents);
+ dia_layer_get_extents (layer, &new_extents);
+ first = rectangle_equals (&new_extents, &invalid_extents);
} else {
- if (!rectangle_equals(&layer->extents,&invalid_extents)) {
- rectangle_union(&new_extents, &layer->extents);
+ Rectangle extents;
+
+ dia_layer_get_extents (layer, &extents);
+
+ if (!rectangle_equals (&extents, &invalid_extents)) {
+ rectangle_union (&new_extents, &extents);
}
}
}
@@ -660,10 +676,11 @@ data_compute_extents (DiagramData *data)
if (!data_has_visible_layers (data)) {
if (data->layers->len > 0) {
- Layer *layer = g_ptr_array_index (data->layers, 0);
+ DiaLayer *layer = g_ptr_array_index (data->layers, 0);
+
dia_layer_update_extents (layer);
- data->extents = layer->extents;
+ dia_layer_get_extents (layer, &data->extents);
} else {
data->extents = invalid_extents;
}
@@ -706,7 +723,7 @@ data_update_extents(DiagramData *data)
* \memberof _DiagramData
*/
GList *
-data_get_sorted_selected(DiagramData *data)
+data_get_sorted_selected (DiagramData *data)
{
GList *list;
GList *sorted_list;
@@ -718,14 +735,14 @@ data_get_sorted_selected(DiagramData *data)
return NULL;
sorted_list = NULL;
- list = g_list_last(data->active_layer->objects);
+ list = g_list_last (dia_layer_get_object_list (data->active_layer));
while (list != NULL) {
- found = g_list_find(data->selected, list->data);
+ found = g_list_find (data->selected, list->data);
if (found) {
- obj = (DiaObject *)found->data;
- sorted_list = g_list_prepend(sorted_list, obj);
+ obj = (DiaObject *) found->data;
+ sorted_list = g_list_prepend (sorted_list, obj);
}
- list = g_list_previous(list);
+ list = g_list_previous (list);
}
return sorted_list;
@@ -742,9 +759,9 @@ data_get_sorted_selected(DiagramData *data)
* \memberof _DiagramData
*/
GList *
-data_get_sorted_selected_remove(DiagramData *data)
+data_get_sorted_selected_remove (DiagramData *data)
{
- GList *list,*tmp;
+ GList *list;
GList *sorted_list;
GList *found;
DiaObject *obj;
@@ -754,19 +771,18 @@ data_get_sorted_selected_remove(DiagramData *data)
return NULL;
sorted_list = NULL;
- list = g_list_last(data->active_layer->objects);
+ list = g_list_last (dia_layer_get_object_list (data->active_layer));
while (list != NULL) {
- found = g_list_find(data->selected, list->data);
+ found = g_list_find (data->selected, list->data);
if (found) {
- obj = (DiaObject *)found->data;
- sorted_list = g_list_prepend(sorted_list, obj);
+ obj = (DiaObject *) found->data;
+ sorted_list = g_list_prepend (sorted_list, obj);
+
+ list = g_list_previous (list);
- tmp = list;
- list = g_list_previous(list);
- data->active_layer->objects =
- g_list_remove_link(data->active_layer->objects, tmp);
+ dia_layer_remove_object (data->active_layer, obj);
} else {
- list = g_list_previous(list);
+ list = g_list_previous (list);
}
}
@@ -783,7 +799,9 @@ data_get_sorted_selected_remove(DiagramData *data)
* \memberof _DiagramData
*/
void
-data_emit(DiagramData *data, Layer *layer, DiaObject* obj,
+data_emit (DiagramData *data,
+ DiaLayer *layer,
+ DiaObject *obj,
const char *signal_name)
{
/* check what signal it is */
@@ -812,7 +830,7 @@ data_render (DiagramData *data,
ObjectRenderer obj_renderer,
gpointer gdata)
{
- Layer *layer;
+ DiaLayer *layer;
guint i, active_layer;
if (!DIA_IS_INTERACTIVE_RENDERER (renderer)) {
@@ -820,9 +838,9 @@ data_render (DiagramData *data,
}
for (i = 0; i < data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index (data->layers, i);
+ layer = (DiaLayer *) g_ptr_array_index (data->layers, i);
active_layer = (layer == data->active_layer);
- if (layer->visible) {
+ if (dia_layer_is_visible (layer)) {
if (obj_renderer) {
dia_layer_render (layer, renderer, update, obj_renderer, gdata, active_layer);
} else {
@@ -870,11 +888,12 @@ data_render_paginated (DiagramData *data, DiaRenderer *renderer, gpointer user_d
/* ensure we are not producing pages for epsilon */
if ((extents->bottom - y) < 1e-6)
break;
+
for (x = initx, xpos = 0; x < extents->right; x += width, xpos++) {
Rectangle page_bounds;
if ((extents->right - x) < 1e-6)
- break;
+ break;
page_bounds.left = x;
page_bounds.right = x + width;
@@ -896,10 +915,10 @@ data_render_paginated (DiagramData *data, DiaRenderer *renderer, gpointer user_d
void
data_foreach_object (DiagramData *data, GFunc func, gpointer user_data)
{
- Layer *layer;
+ DiaLayer *layer;
guint i;
for (i=0; i<data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index(data->layers, i);
- g_list_foreach (layer->objects, func, user_data);
+ layer = (DiaLayer *) g_ptr_array_index (data->layers, i);
+ g_list_foreach (dia_layer_get_object_list (layer), func, user_data);
}
}
diff --git a/lib/diagramdata.h b/lib/diagramdata.h
index 7978bd5d..c9f0e479 100644
--- a/lib/diagramdata.h
+++ b/lib/diagramdata.h
@@ -56,8 +56,8 @@ GType diagram_data_get_type (void) G_GNUC_CONST;
/*!
* \brief Base class for diagrams. This gets passed to plug-ins to work on diagrams.
*
- * Dia's diagram object is the container of _Layer, the managment object of _DiaObject selections
- * and text foci (_Focus) as well a highlithing state resulting from selections.
+ * Dia's diagram object is the container of #DiaLayer, the managment object of #DiaObject selections
+ * and text foci (#Focus) as well a highlithing state resulting from selections.
*
* \ingroup DiagramStructure
*/
@@ -73,7 +73,7 @@ struct _DiagramData {
The user can override this in Save As... */
GPtrArray *layers; /*!< Layers ordered by decreasing z-order */
- Layer *active_layer; /*!< The active layer, Defensive programmers check for NULL */
+ DiaLayer *active_layer; /*!< The active layer, Defensive programmers check for NULL */
guint selected_count_private; /*!< kept for binary compatibility and sanity, don't use ! */
GList *selected; /*!< List of objects that are selected,
@@ -97,8 +97,8 @@ typedef struct _DiagramDataClass {
GObjectClass parent_class;
/* Signals */
- void (* object_add) (DiagramData*, Layer*, DiaObject*);
- void (* object_remove) (DiagramData*, Layer*, DiaObject*);
+ void (* object_add) (DiagramData*, DiaLayer*, DiaObject*);
+ void (* object_remove) (DiagramData*, DiaLayer*, DiaObject*);
void (* selection_changed) (DiagramData*, int);
} DiagramDataClass;
@@ -110,16 +110,16 @@ typedef enum {
DIA_HIGHLIGHT_TEXT_EDIT
} DiaHighlightType;
-void data_raise_layer(DiagramData *data, Layer *layer);
-void data_lower_layer(DiagramData *data, Layer *layer);
+void data_raise_layer(DiagramData *data, DiaLayer *layer);
+void data_lower_layer(DiagramData *data, DiaLayer *layer);
-void data_add_layer(DiagramData *data, Layer *layer);
-void data_add_layer_at(DiagramData *data, Layer *layer, int pos);
-void data_set_active_layer(DiagramData *data, Layer *layer);
-void data_remove_layer(DiagramData *data, Layer *layer);
-int data_layer_get_index (const DiagramData *data, const Layer *layer);
+void data_add_layer(DiagramData *data, DiaLayer *layer);
+void data_add_layer_at(DiagramData *data, DiaLayer *layer, int pos);
+void data_set_active_layer(DiagramData *data, DiaLayer *layer);
+void data_remove_layer(DiagramData *data, DiaLayer *layer);
+int data_layer_get_index (const DiagramData *data, const DiaLayer *layer);
int data_layer_count(const DiagramData *data);
-Layer *data_layer_get_nth (const DiagramData *data, guint index);
+DiaLayer *data_layer_get_nth (const DiagramData *data, guint index);
void data_highlight_add(DiagramData *data, DiaObject *obj, DiaHighlightType type);
void data_highlight_remove(DiagramData *data, DiaObject *obj);
@@ -131,7 +131,7 @@ void data_remove_all_selected(DiagramData *data);
gboolean data_update_extents(DiagramData *data); /* returns true if changed. */
GList *data_get_sorted_selected(DiagramData *data);
GList *data_get_sorted_selected_remove(DiagramData *data);
-void data_emit(DiagramData *data,Layer *layer,DiaObject* obj,const char *signal_name);
+void data_emit(DiagramData *data,DiaLayer *layer,DiaObject* obj,const char *signal_name);
void data_foreach_object (DiagramData *data, GFunc func, gpointer user_data);
diff --git a/lib/diarenderer.c b/lib/diarenderer.c
index 15681f6d..144e7d9b 100644
--- a/lib/diarenderer.c
+++ b/lib/diarenderer.c
@@ -251,11 +251,11 @@ dia_renderer_get_property (GObject *object,
*/
static void
draw_layer (DiaRenderer *renderer,
- Layer *layer,
- gboolean active,
- Rectangle *update)
+ DiaLayer *layer,
+ gboolean active,
+ Rectangle *update)
{
- GList *list = layer->objects;
+ GList *list = dia_layer_get_object_list (layer);
void (*func) (DiaRenderer*, DiaObject *, DiaMatrix *);
g_return_if_fail (layer != NULL);
@@ -2116,7 +2116,7 @@ dia_renderer_bezier_stroke (DiaRenderer *self,
void
dia_renderer_draw_layer (DiaRenderer *self,
- Layer *layer,
+ DiaLayer *layer,
gboolean active,
Rectangle *update)
{
diff --git a/lib/diarenderer.h b/lib/diarenderer.h
index d9be8235..ca383015 100644
--- a/lib/diarenderer.h
+++ b/lib/diarenderer.h
@@ -24,7 +24,6 @@
#include "dia-enums.h"
#include "geometry.h"
-#include "font.h" /* not strictly needed by this header, but needed in almost any plug-in/ */
/* HACK: Work around circular deps */
typedef struct _DiaRenderer DiaRenderer;
@@ -114,7 +113,7 @@ struct _DiaRendererClass
GObjectClass parent_class;
void (*draw_layer) (DiaRenderer *renderer,
- Layer *layer,
+ DiaLayer *layer,
gboolean active,
Rectangle *update);
void (*draw_object) (DiaRenderer *renderer,
@@ -282,7 +281,7 @@ struct _DiaRendererClass
};
void dia_renderer_draw_layer (DiaRenderer *self,
- Layer *layer,
+ DiaLayer *layer,
gboolean active,
Rectangle *update);
void dia_renderer_draw_object (DiaRenderer *self,
diff --git a/lib/diatypes.h b/lib/diatypes.h
index 4ba02de4..187c79c2 100644
--- a/lib/diatypes.h
+++ b/lib/diatypes.h
@@ -18,20 +18,23 @@
/** @file diatypes.h -- All externally visible structures should be defined here */
-#ifndef TYPES_H
-#define TYPES_H
-
/* THIS HEADER MUST NOT INCLUDE ANY OTHER HEADER! */
-/*#include "units.h" */
+
+#pragma once
+
+#include <glib-object.h>
/* from geometry.h - but used more generic */
typedef double real;
/* In diagramdata.h: */
typedef struct _DiagramData DiagramData;
-typedef struct _Layer Layer;
typedef struct _NewDiagramData NewDiagramData;
+
+typedef struct _DiaLayer DiaLayer;
+
+
/* In arrows.h: */
typedef struct _Arrow Arrow;
@@ -192,5 +195,3 @@ typedef enum {
PATH_INTERSECTION,
PATH_EXCLUSION
} PathCombineMode;
-
-#endif
diff --git a/lib/focus.c b/lib/focus.c
index ad9fc2f6..4b4bec43 100644
--- a/lib/focus.c
+++ b/lib/focus.c
@@ -87,7 +87,7 @@ set_text_foci(DiagramData *dia, GList *foci)
void
request_focus(Focus *focus)
{
- DiagramData *dia = focus->obj->parent_layer->parent_diagram;
+ DiagramData *dia = dia_layer_get_parent_diagram (focus->obj->parent_layer);
GList *text_foci = get_text_foci(dia);
/* Only add to focus list if not already there, and don't snatch focus. */
if (!g_list_find(text_foci, focus)) {
@@ -99,7 +99,7 @@ request_focus(Focus *focus)
void
give_focus(Focus *focus)
{
- DiagramData *dia = focus->obj->parent_layer->parent_diagram;
+ DiagramData *dia = dia_layer_get_parent_diagram (focus->obj->parent_layer);
if (get_active_focus(dia) != NULL) {
get_active_focus(dia)->has_focus = FALSE;
@@ -113,7 +113,7 @@ give_focus(Focus *focus)
Focus *
focus_get_first_on_object(DiaObject *obj)
{
- GList *tmplist = get_text_foci(obj->parent_layer->parent_diagram);
+ GList *tmplist = get_text_foci (dia_layer_get_parent_diagram (obj->parent_layer));
for (; tmplist != NULL; tmplist = g_list_next(tmplist) ) {
Focus *focus = (Focus*)tmplist->data;
@@ -184,7 +184,7 @@ reset_foci_on_diagram(DiagramData *dia)
gboolean
remove_focus_object(DiaObject *obj)
{
- DiagramData *dia = obj->parent_layer->parent_diagram;
+ DiagramData *dia = dia_layer_get_parent_diagram (obj->parent_layer);
GList *tmplist = get_text_foci(dia);
gboolean active = FALSE;
Focus *next_focus = NULL;
diff --git a/lib/focus.h b/lib/focus.h
index 4dc12585..7154bdae 100644
--- a/lib/focus.h
+++ b/lib/focus.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FOCUS_H
-#define FOCUS_H
+
+#pragma once
#include "diatypes.h"
@@ -41,9 +41,3 @@ void remove_focus_on_diagram(DiagramData *dia);
gboolean remove_focus_object(DiaObject *obj);
void reset_foci_on_diagram(DiagramData *dia);
DiaObject* focus_get_object(Focus *focus);
-
-#endif /* FOCUS_H */
-
-
-
-
diff --git a/lib/font.h b/lib/font.h
index b1a9690f..ee9c8c7a 100644
--- a/lib/font.h
+++ b/lib/font.h
@@ -15,18 +15,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FONT_H
-#define FONT_H
-#include "diatypes.h"
+#pragma once
+
#include <glib.h>
#include <glib-object.h>
#include <pango/pango.h>
+
+#include "diatypes.h"
#include "dia-enums.h"
#include "geometry.h"
/*!
- \file font.h -- services based on font definitions
+ \file font.h -- services based on font definitions
*/
/*!
\defgroup ObjectFonts Dia's font definiton
@@ -46,7 +47,7 @@ G_BEGIN_DECLS
/*
* In a goodly selection of fonts, 500 is very common, yet Pango doesn't name it.
* I am calling 500 'medium' and 600 'demibold'.
- * We should really have a more flexible system where 300 or 400 is normal,
+ * We should really have a more flexible system where 300 or 400 is normal,
* the next one up bold, or something. But this will do for now.
* We should probably store the actual weight...
*/
@@ -57,7 +58,7 @@ G_BEGIN_DECLS
* many.
*/
-/* storing different style info like
+/* storing different style info like
* (DIA_FONT_SANS | DIA_FONT_ITALIC | DIA_FONT_BOLD)
*/
typedef guint DiaFontStyle;
@@ -138,17 +139,17 @@ DiaFont* dia_font_new_from_style(DiaFontStyle style, real height);
/*!
* \brief Font creation for object implementation
- * Get a font from a legacy font name
+ * Get a font from a legacy font name
* \ingroup ObjectFonts
- */
+ */
DiaFont* dia_font_new_from_legacy_name(const char *name);
/*!
* \brief Font creation for object implementation
* Get a simple font name from a font.
- * Name will be valid for the duration of the DiaFont* lifetime.
+ * Name will be valid for the duration of the DiaFont* lifetime.
* \ingroup ObjectFonts
- */
+ */
const char* dia_font_get_legacy_name(const DiaFont* font);
/* Same attributes */
@@ -165,37 +166,37 @@ const char* dia_font_get_family(const DiaFont* font);
/* Acessor for the PangoFontDescription */
const PangoFontDescription *dia_font_get_description (const DiaFont* font);
-/*!
+/*!
* \brief Retrieves the height of the font
* \memberof DiaFont
*/
real dia_font_get_height(const DiaFont* font);
-/*!
+/*!
* \brief Change the height inside a font record.
* \memberof DiaFont
*/
void dia_font_set_height(DiaFont* font, real height);
-/*!
+/*!
* \brief Delivers the size of the font
* \memberof DiaFont
*/
real dia_font_get_size(const DiaFont* font);
-/*!
+/*!
* \brief Changes the slant of an existing font
* \memberof DiaFont
*/
void dia_font_set_slant(DiaFont* font, DiaFontSlant slant);
-/*!
+/*!
* \brief Changes the weight of an existing font
* \memberof DiaFont
*/
void dia_font_set_weight(DiaFont* font, DiaFontWeight weight);
-/*!
+/*!
* \brief Changes the family of an existing font to one of the three standard families
* \memberof DiaFont
*/
void dia_font_set_family(DiaFont* font, DiaFontFamily family);
-/*!
+/*!
* \brief Changes the family of an existing font to any family
* The name is system configuration dependent, but font files are portable nowadays.
* \memberof DiaFont
@@ -234,12 +235,10 @@ PangoLayout* dia_font_build_layout(const char* string, DiaFont* font,
real height);
real* dia_font_get_sizes(const char* string, DiaFont *font, real height,
- real* width, real* ascent, real* descent,
+ real* width, real* ascent, real* descent,
int *n_offsets, PangoLayoutLine **layout_offsets);
/* -------- Font and string functions - scaled versions.
Use these version in Renderers, exclusively. */
G_END_DECLS
-
-#endif /* FONT_H */
diff --git a/lib/layer.c b/lib/layer.c
index 070bbd26..32ff5514 100644
--- a/lib/layer.c
+++ b/lib/layer.c
@@ -27,6 +27,201 @@
static const Rectangle invalid_extents = { -1.0,-1.0,-1.0,-1.0 };
+typedef struct _DiaLayerPrivate DiaLayerPrivate;
+struct _DiaLayerPrivate {
+ char *name; /* The name of the layer */
+ Rectangle extents; /* The extents of the layer */
+
+ GList *objects; /* List of objects in the layer,
+ sorted by decreasing z-value,
+ objects can ONLY be connected to objects
+ in the same layer! */
+
+ gboolean visible; /* The visibility of the layer */
+ gboolean connectable; /* Whether the layer can currently be connected
+ to. The selected layer is by default
+ connectable */
+
+ DiagramData *parent_diagram; /* Back-pointer to the diagram. This
+ must only be set by functions internal
+ to the diagram, and accessed via
+ layer_get_parent_diagram() */
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (DiaLayer, dia_layer, G_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_CONNECTABLE,
+ PROP_VISIBLE,
+ PROP_PARENT_DIAGRAM,
+ LAST_PROP
+};
+
+static GParamSpec *pspecs[LAST_PROP] = { NULL, };
+
+
+/**
+ * SECTION:dia-layer
+ * @title: DiaLayer
+ * @short_description: Group of #DiaObject s in a #DiagramData
+ *
+ * Since: 0.98
+ */
+
+
+static void
+dia_layer_finalize (GObject *object)
+{
+ DiaLayer *self = DIA_LAYER (object);
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (self);
+
+ g_clear_pointer (&priv->name, g_free);
+ destroy_object_list (priv->objects);
+
+ g_clear_object (&priv->parent_diagram);
+
+ G_OBJECT_CLASS (dia_layer_parent_class)->finalize (object);
+}
+
+
+static void
+dia_layer_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ DiaLayer *self = DIA_LAYER (object);
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (self);
+
+ switch (property_id) {
+ case PROP_NAME:
+ g_clear_pointer (&priv->name, g_free);
+ priv->name = g_value_dup_string (value);
+ break;
+ case PROP_CONNECTABLE:
+ dia_layer_set_connectable (self, g_value_get_boolean (value));
+ break;
+ case PROP_VISIBLE:
+ dia_layer_set_visible (self, g_value_get_boolean (value));
+ break;
+ case PROP_PARENT_DIAGRAM:
+ dia_layer_set_parent_diagram (self, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void
+dia_layer_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ DiaLayer *self = DIA_LAYER (object);
+
+ switch (property_id) {
+ case PROP_NAME:
+ g_value_set_string (value, dia_layer_get_name (self));
+ break;
+ case PROP_CONNECTABLE:
+ g_value_set_boolean (value, dia_layer_is_connectable (self));
+ break;
+ case PROP_VISIBLE:
+ g_value_set_boolean (value, dia_layer_is_visible (self));
+ break;
+ case PROP_PARENT_DIAGRAM:
+ g_value_set_object (value, dia_layer_get_parent_diagram (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void
+dia_layer_class_init (DiaLayerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = dia_layer_finalize;
+ object_class->set_property = dia_layer_set_property;
+ object_class->get_property = dia_layer_get_property;
+
+ /**
+ * DiaLayer:name:
+ *
+ * Since: 0.98
+ */
+ pspecs[PROP_NAME] =
+ g_param_spec_string ("name",
+ "Name",
+ "Layer name",
+ NULL,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
+
+ /**
+ * DiaLayer:connectable:
+ *
+ * Since: 0.98
+ */
+ pspecs[PROP_CONNECTABLE] =
+ g_param_spec_boolean ("connectable",
+ "Connectable",
+ "Layer is connectable",
+ TRUE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
+ /**
+ * DiaLayer:visible:
+ *
+ * Since: 0.98
+ */
+ pspecs[PROP_VISIBLE] =
+ g_param_spec_boolean ("visible",
+ "Visible",
+ "Layer is visible",
+ TRUE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
+ /**
+ * DiaLayer:parent-diagram:
+ *
+ * Since: 0.98
+ */
+ pspecs[PROP_PARENT_DIAGRAM] =
+ g_param_spec_object ("parent-diagram",
+ "Parent Diagram",
+ "The diagram containing the layer",
+ DIA_TYPE_DIAGRAM_DATA,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
+ g_object_class_install_properties (object_class, LAST_PROP, pspecs);
+}
+
+
+static void
+dia_layer_init (DiaLayer *self)
+{
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (self);
+
+ priv->visible = TRUE;
+ priv->connectable = FALSE;
+
+ priv->objects = NULL;
+
+ priv->extents.left = 0.0;
+ priv->extents.right = 10.0;
+ priv->extents.top = 0.0;
+ priv->extents.bottom = 10.0;
+}
+
+
/*! The default object renderer.
* @param obj An object to render.
* @param renderer The renderer to render on.
@@ -44,7 +239,9 @@ normal_render (DiaObject *obj,
}
-/*!
+/**
+ * render_bounding_boxes:
+ *
* bounding box debug helper : environment variable DIA_RENDER_BOUNDING_BOXES
* set to !0 to see the calculated bounding boxes
*/
@@ -61,7 +258,7 @@ render_bounding_boxes (void)
return rbb;
}
-/*!
+/**
* layer_render:
* @layer: The layer to render.
* @renderer: The renderer to draw things with.
@@ -74,9 +271,11 @@ render_bounding_boxes (void)
* Render all components of a single layer.
*
* This function also handles rendering of bounding boxes for debugging purposes.
+ *
+ * Since: 0.98
*/
void
-dia_layer_render (Layer *layer,
+dia_layer_render (DiaLayer *layer,
DiaRenderer *renderer,
Rectangle *update,
ObjectRenderer obj_renderer,
@@ -85,12 +284,13 @@ dia_layer_render (Layer *layer,
{
GList *list;
DiaObject *obj;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
if (obj_renderer == NULL)
obj_renderer = normal_render;
/* Draw all objects: */
- list = layer->objects;
+ list = priv->objects;
while (list != NULL) {
obj = (DiaObject *) list->data;
@@ -117,47 +317,74 @@ dia_layer_render (Layer *layer,
}
}
-/*!
- * \brief Create a new layer in this diagram.
- * @param name Name of the new layer.
- * @param parent The DiagramData that the layer will belong to,.
- * @return A new Layer object.
- * \memberof _Layer
+/**
+ * dia_layer_new:
+ * @name: Name of the new layer.
+ * @parent: The #DiagramData that the layer will belong to,.
+ *
+ * Create a new layer in this diagram.
+ *
+ * Returns: A new #DiaLayer object
+ *
+ * Since: 0.98
+ */
+DiaLayer *
+dia_layer_new (const char *name, DiagramData *parent)
+{
+ DiaLayer *layer;
+
+ layer = g_object_new (DIA_TYPE_LAYER,
+ "name", name,
+ "parent-diagram", parent,
+ NULL);
+
+ return layer;
+}
+
+/**
+ * dia_layer_new_from_layer:
+ * @old: The #DiaLayer to clone
+ *
+ * Returns: A new #DiaLayer object
+ *
+ * Since: 0.98
*/
-Layer *
-dia_layer_new (gchar *name, DiagramData *parent)
+DiaLayer *
+dia_layer_new_from_layer (DiaLayer *old)
{
- Layer *layer;
+ DiaLayer *layer;
+ DiaLayerPrivate *priv;
+ DiaLayerPrivate *old_priv;
- layer = g_new (Layer, 1);
+ g_return_val_if_fail (DIA_IS_LAYER (old), NULL);
- layer->name = name;
+ old_priv = dia_layer_get_instance_private (old);
- layer->parent_diagram = parent;
- layer->visible = TRUE;
- layer->connectable = FALSE;
+ layer = g_object_new (DIA_TYPE_LAYER,
+ "name", dia_layer_get_name (old),
+ "visible", old_priv->visible,
+ "connectable", old_priv->connectable,
+ "parent-diagram", old_priv->parent_diagram,
+ NULL);
- layer->objects = NULL;
+ priv = dia_layer_get_instance_private (layer);
- layer->extents.left = 0.0;
- layer->extents.right = 10.0;
- layer->extents.top = 0.0;
- layer->extents.bottom = 10.0;
+ priv->extents = old_priv->extents;
+ priv->objects = object_copy_list (priv->objects);
return layer;
}
-/*!
- * \brief Destroy a layer object.
- * @param layer The layer object to deallocate entirely.
- * \memberof _Layer
+/**
+ * dia_layer_destroy;
+ * @layer: The layer object to deallocate entirely.
+ *
+ * Destroy a layer object.
*/
void
-dia_layer_destroy (Layer *layer)
+dia_layer_destroy (DiaLayer *layer)
{
- g_free (layer->name);
- destroy_object_list (layer->objects);
- g_free (layer);
+ g_object_unref (layer);
}
/*!
@@ -169,101 +396,142 @@ dia_layer_destroy (Layer *layer)
static void
set_parent_layer (gpointer element, gpointer user_data)
{
- ((DiaObject*)element)->parent_layer = (Layer*)user_data;
+ ((DiaObject*) element)->parent_layer = (DiaLayer *) user_data;
/* FIXME: even group members need a parent_layer and what about parent objects ???
* Now I know again why I always try to avoid back-pointers )-; --hb.
* If the group objects didn't actually leave the diagram, this wouldn't
* be a problem. --LC */
}
-/*!
- * \brief Get the index of an object in a layer.
- * @param layer The layer the object is (should be) in.
- * @param obj The object to look for.
- * @return The index of the object in the layers list of objects. This is also
+/**
+ * dia_layer_object_get_index:
+ * @layer: The layer the object is (should be) in.
+ * @obj: The object to look for.
+ *
+ * Get the index of an object in a layer.
+ *
+ * Returns: The index of the object in the layers list of objects. This is also
* the vertical position of the object.
- * \memberof _Layer
+ *
+ * Since: 0.98
*/
int
-dia_layer_object_get_index (Layer *layer, DiaObject *obj)
+dia_layer_object_get_index (DiaLayer *layer, DiaObject *obj)
{
- return (int) g_list_index (layer->objects, (gpointer) obj);
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
+ return (int) g_list_index (priv->objects, (gpointer) obj);
}
-/*!
- * \brief Get the object a index or NULL
- * @param layer The layer to query for the nth object
- * @param index The zero-based indexed of the object
- * \memberof _Layer
+/**
+ * dia_layer_object_get_nth:
+ * @layer: The layer to query for the nth object
+ * @index: The zero-based indexed of the object
+ *
+ * Get the object a index or %NULL
+ *
+ * Since: 0.98
*/
DiaObject *
-dia_layer_object_get_nth (Layer *layer, guint index)
+dia_layer_object_get_nth (DiaLayer *layer, guint index)
{
- if (g_list_length (layer->objects) > index) {
- g_assert (g_list_nth (layer->objects, index));
- return (DiaObject *) g_list_nth (layer->objects, index)->data;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
+ if (g_list_length (priv->objects) > index) {
+ g_assert (g_list_nth (priv->objects, index));
+ return (DiaObject *) g_list_nth (priv->objects, index)->data;
}
return NULL;
}
+/**
+ * dia_layer_object_count:
+ * @layer: the #DiaLayer
+ *
+ * Since: 0.98
+ */
int
-dia_layer_object_count (Layer *layer)
+dia_layer_object_count (DiaLayer *layer)
{
- return g_list_length (layer->objects);
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
+ return g_list_length (priv->objects);
}
-gchar *
-dia_layer_get_name (Layer *layer)
+/**
+ * dia_layer_get_name:
+ * @layer: the #DiaLayer
+ *
+ * Since: 0.98
+ */
+const char *
+dia_layer_get_name (DiaLayer *layer)
{
- return g_strdup (layer->name);
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
+ return priv->name;
}
-/*!
- * \brief Add an object to the top of a layer.
- * @param layer The layer to add the object to.
- * @param obj The object to add. This must not already be part of another layer.
- * \memberof _Layer
+/**
+ * dia_layer_add_object:
+ * @layer: The layer to add the object to.
+ * @obj: The object to add. This must not already be part of another layer.
+ *
+ * Add an object to the top of a layer.
+ *
+ * Since: 0.98
*/
void
-dia_layer_add_object(Layer *layer, DiaObject *obj)
+dia_layer_add_object (DiaLayer *layer, DiaObject *obj)
{
- layer->objects = g_list_append(layer->objects, (gpointer) obj);
- set_parent_layer(obj, layer);
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
+ priv->objects = g_list_append (priv->objects, (gpointer) obj);
+ set_parent_layer (obj, layer);
/* send a signal that we have added a object to the diagram */
- data_emit (dia_layer_get_parent_diagram(layer), layer, obj, "object_add");
+ data_emit (dia_layer_get_parent_diagram (layer), layer, obj, "object_add");
}
-/*!
- * \brief Add an object to a layer at a specific position.
- * @param layer The layer to add the object to.
- * @param obj The object to add. This must not be part of another layer.
- * @param pos The top-to-bottom position this object should be inserted at.
- * \memberof _Layer
+/**
+ * dia_layer_add_object_at:
+ * @layer: The layer to add the object to.
+ * @obj: The object to add. This must not be part of another layer.
+ * @pos: The top-to-bottom position this object should be inserted at.
+ *
+ * Add an object to a layer at a specific position.
+ *
+ * Since: 0.98
*/
void
-dia_layer_add_object_at (Layer *layer, DiaObject *obj, int pos)
+dia_layer_add_object_at (DiaLayer *layer, DiaObject *obj, int pos)
{
- layer->objects = g_list_insert (layer->objects, (gpointer) obj, pos);
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
+ priv->objects = g_list_insert (priv->objects, (gpointer) obj, pos);
set_parent_layer (obj, layer);
/* send a signal that we have added a object to the diagram */
data_emit (dia_layer_get_parent_diagram (layer), layer, obj, "object_add");
}
-/*!
- * \brief Add a list of objects to the end of a layer.
- * @param layer The layer to add objects to.
- * @param obj_list The list of objects to add. These must not already
+/**
+ * dia_layer_add_objects:
+ * @layer: The layer to add objects to.
+ * @obj_list: The list of objects to add. These must not already
* be part of another layer.
- * \memberof _Layer
+ *
+ * Add a list of objects to the end of a layer.
+ *
+ * Since: 0.98
*/
void
-dia_layer_add_objects (Layer *layer, GList *obj_list)
+dia_layer_add_objects (DiaLayer *layer, GList *obj_list)
{
GList *list = obj_list;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
- layer->objects = g_list_concat (layer->objects, obj_list);
+ priv->objects = g_list_concat (priv->objects, obj_list);
g_list_foreach (obj_list, set_parent_layer, layer);
while (list != NULL) {
@@ -275,18 +543,22 @@ dia_layer_add_objects (Layer *layer, GList *obj_list)
}
}
-/*!
- * \brief Add a list of objects to the top of a layer.
- * @param layer The layer to add objects to.
- * @param obj_list The list of objects to add. These must not already
+/**
+ * dia_layer_add_objects_first:
+ * @layer: The layer to add objects to.
+ * @obj_list: The list of objects to add. These must not already
* be part of another layer.
- * \memberof _Layer
+ *
+ * Add a list of objects to the top of a layer.
+ *
+ * Since: 0.98
*/
void
-dia_layer_add_objects_first (Layer *layer, GList *obj_list) {
+dia_layer_add_objects_first (DiaLayer *layer, GList *obj_list) {
GList *list = obj_list;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
- layer->objects = g_list_concat (obj_list, layer->objects);
+ priv->objects = g_list_concat (obj_list, priv->objects);
g_list_foreach (obj_list, set_parent_layer, layer);
/* Send one signal per object added */
@@ -299,31 +571,39 @@ dia_layer_add_objects_first (Layer *layer, GList *obj_list) {
}
}
-/*!
- * \brief Remove an object from a layer.
- * @param layer The layer to remove the object from.
- * @param obj The object to remove.
- * \memberof _Layer
+/**
+ * dia_layer_remove_object:
+ * @layer: The layer to remove the object from.
+ * @obj: The object to remove.
+ *
+ * Remove an object from a layer.
+ *
+ * Since: 0.98
*/
void
-dia_layer_remove_object (Layer *layer, DiaObject *obj)
+dia_layer_remove_object (DiaLayer *layer, DiaObject *obj)
{
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
/* send a signal that we'll remove a object from the diagram */
data_emit (dia_layer_get_parent_diagram (layer), layer, obj, "object_remove");
- layer->objects = g_list_remove (layer->objects, obj);
+ priv->objects = g_list_remove (priv->objects, obj);
dynobj_list_remove_object (obj);
set_parent_layer (obj, NULL);
}
-/*!
+/**
+ * dia_layer_remove_objects:
+ * @layer: The layer to remove the objects from.
+ * @obj_list: The objects to remove.
+ *
* Remove a list of objects from a layer.
- * @param layer The layer to remove the objects from.
- * @param obj_list The objects to remove.
- * \memberof _Layer
+ *
+ * Since: 0.98
*/
void
-dia_layer_remove_objects (Layer *layer, GList *obj_list)
+dia_layer_remove_objects (DiaLayer *layer, GList *obj_list)
{
DiaObject *obj;
while (obj_list != NULL) {
@@ -335,136 +615,157 @@ dia_layer_remove_objects (Layer *layer, GList *obj_list)
}
}
-/*!
- * \brief Find the objects that intersect a given rectangle.
- * @param layer The layer to search in.
- * @param rect The rectangle to intersect with.
- * @return List of objects whose bounding box intersect the rectangle. The
+/**
+ * dia_layer_find_objects_intersecting_rectangle:
+ * @layer: The layer to search in.
+ * @rect: The rectangle to intersect with.
+ *
+ * Find the objects that intersect a given rectangle.
+ *
+ * Returns: List of objects whose bounding box intersect the rectangle. The
* list should be freed by the caller.
- * \memberof _Layer
+ *
+ * Since: 0.98
*/
GList *
-dia_layer_find_objects_intersecting_rectangle (Layer *layer, Rectangle *rect)
+dia_layer_find_objects_intersecting_rectangle (DiaLayer *layer,
+ Rectangle *rect)
{
GList *list;
GList *selected_list;
DiaObject *obj;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
selected_list = NULL;
- list = layer->objects;
+ list = priv->objects;
while (list != NULL) {
obj = (DiaObject *)list->data;
- if (rectangle_intersects(rect, &obj->bounding_box)) {
- if (dia_object_is_selectable(obj)) {
- selected_list = g_list_prepend(selected_list, obj);
+ if (rectangle_intersects (rect, &obj->bounding_box)) {
+ if (dia_object_is_selectable (obj)) {
+ selected_list = g_list_prepend (selected_list, obj);
}
/* Objects in closed groups do not get selected, but their parents do.
* Since the parents bbox is outside the objects, they will be found
* anyway and the inner object can just be skipped. */
}
- list = g_list_next(list);
+ list = g_list_next (list);
}
return selected_list;
}
-/*!
- * \brief Find objects entirely contained in a rectangle.
- * @param layer The layer to search for objects in.
- * @param rect The rectangle that the objects should be in.
- * @return A list containing the objects that are entirely contained in the
+/**
+ * dia_layer_find_objects_in_rectangle:
+ * @layer: The layer to search for objects in.
+ * @rect: The rectangle that the objects should be in.
+ *
+ * Find objects entirely contained in a rectangle.
+ *
+ * Returns: A list containing the objects that are entirely contained in the
* rectangle. The list should be freed by the caller.
- * \memberof _Layer
+ *
+ * Since: 0.98
*/
GList *
-dia_layer_find_objects_in_rectangle (Layer *layer, Rectangle *rect)
+dia_layer_find_objects_in_rectangle (DiaLayer *layer, Rectangle *rect)
{
GList *list;
GList *selected_list;
DiaObject *obj;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
selected_list = NULL;
- list = layer->objects;
+ list = priv->objects;
while (list != NULL) {
obj = (DiaObject *)list->data;
- if (rectangle_in_rectangle(rect, &obj->bounding_box)) {
- if (dia_object_is_selectable(obj)) {
- selected_list = g_list_prepend(selected_list, obj);
+ if (rectangle_in_rectangle (rect, &obj->bounding_box)) {
+ if (dia_object_is_selectable (obj)) {
+ selected_list = g_list_prepend (selected_list, obj);
}
}
- list = g_list_next(list);
+ list = g_list_next (list);
}
return selected_list;
}
-/*!
- * \brief Find objects entirely containing a rectangle.
- * @param layer The layer to search for objects in.
- * @param rect The rectangle that the objects should surround.
- * @return A list containing the objects that entirely contain the
+/**
+ * dia_layer_find_objects_containing_rectangle:
+ * @layer: The layer to search for objects in.
+ * @rect: The rectangle that the objects should surround.
+ *
+ * Find objects entirely containing a rectangle.
+ *
+ * Returns: A list containing the objects that entirely contain the
* rectangle. The list should be freed by the caller.
- * \memberof _Layer
+ *
+ * Since: 0.98
*/
GList *
-dia_layer_find_objects_containing_rectangle (Layer *layer, Rectangle *rect)
+dia_layer_find_objects_containing_rectangle (DiaLayer *layer, Rectangle *rect)
{
GList *list;
GList *selected_list;
DiaObject *obj;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
g_return_val_if_fail (layer != NULL, NULL);
selected_list = NULL;
- list = layer->objects;
+ list = priv->objects;
while (list != NULL) {
- obj = (DiaObject *)list->data;
+ obj = (DiaObject *) list->data;
- if (rectangle_in_rectangle(&obj->bounding_box, rect)) {
- if (dia_object_is_selectable(obj)) {
- selected_list = g_list_prepend(selected_list, obj);
+ if (rectangle_in_rectangle (&obj->bounding_box, rect)) {
+ if (dia_object_is_selectable (obj)) {
+ selected_list = g_list_prepend (selected_list, obj);
}
}
- list = g_list_next(list);
+ list = g_list_next (list);
}
return selected_list;
}
-/*!
- * \brief Find the object closest to the given point in the layer
+/**
+ * dia_layer_find_closest_object_except:
+ * @layer: The layer to search in.
+ * @pos: The point to compare to.
+ * @maxdist: The maximum distance the object can be from the point.
+ * @avoid: A list of objects that cannot be returned by this search.
+ *
+ * Find the object closest to the given point in the layer no further away
+ * than maxdist, and not included in avoid.
*
- * no further away than maxdist, and not included in avoid.
* Stops it if finds an object that includes the point.
- * @param layer The layer to search in.
- * @param pos The point to compare to.
- * @param maxdist The maximum distance the object can be from the point.
- * @param avoid A list of objects that cannot be returned by this search.
- * @return The closest object, or NULL if no allowed objects are closer than
+ *
+ * Returns: The closest object, or %NULL if no allowed objects are closer than
* maxdist.
- * \memberof _Layer
+ *
+ * Since: 0.98
*/
DiaObject *
-dia_layer_find_closest_object_except (Layer *layer,
- Point *pos,
- real maxdist,
- GList *avoid)
+dia_layer_find_closest_object_except (DiaLayer *layer,
+ Point *pos,
+ real maxdist,
+ GList *avoid)
{
GList *l;
DiaObject *closest;
DiaObject *obj;
real dist;
GList *avoid_tmp;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
closest = NULL;
- for (l = layer->objects; l!=NULL; l = g_list_next(l)) {
+ for (l = priv->objects; l!=NULL; l = g_list_next(l)) {
obj = (DiaObject *) l->data;
/* Check bounding box here too. Might give speedup. */
@@ -472,9 +773,9 @@ dia_layer_find_closest_object_except (Layer *layer,
if (maxdist-dist > 0.00000001) {
for (avoid_tmp = avoid; avoid_tmp != NULL; avoid_tmp = avoid_tmp->next) {
- if (avoid_tmp->data == obj) {
- goto NEXTOBJECT;
- }
+ if (avoid_tmp->data == obj) {
+ goto NEXTOBJECT;
+ }
}
closest = obj;
}
@@ -485,33 +786,41 @@ dia_layer_find_closest_object_except (Layer *layer,
return closest;
}
-/*!
- * \brief Find the object closest to the given point in the layer,
+/**
+ * dia_layer_find_closest_object:
+ * @layer: The layer to search in.
+ * @pos: The point to compare to.
+ * @maxdist: The maximum distance the object can be from the point.
+ *
+ * Find the object closest to the given point in the layer, no further away
+ * than maxdist. Stops it if finds an object that includes the point.
+ *
+ * Returns: The closest object, or %NULL if none are closer than maxdist.
*
- * no further away than maxdist. Stops it if finds an object that includes the point.
- * @param layer The layer to search in.
- * @param pos The point to compare to.
- * @param maxdist The maximum distance the object can be from the point.
- * @return The closest object, or NULL if none are closer than maxdist.
+ * Since: 0.98
*/
DiaObject *
-dia_layer_find_closest_object(Layer *layer, Point *pos, real maxdist)
+dia_layer_find_closest_object (DiaLayer *layer, Point *pos, real maxdist)
{
- return dia_layer_find_closest_object_except(layer, pos, maxdist, NULL);
+ return dia_layer_find_closest_object_except (layer, pos, maxdist, NULL);
}
-/*!
- * \brief Find the connectionpoint closest to pos in a layer.
- * @param layer the layer to search in
- * @param closest connection point found or NULL
- * @param pos refernce position in diagram coordinates
- * @param notthis object not to search on
- * @return the distance of the connection point and pos
- * \memberof _Layer
+/**
+ * dia_layer_find_closest_connectionpoint:
+ * @layer: the layer to search in
+ * @closest: connection point found or NULL
+ * @pos: refernce position in diagram coordinates
+ * @notthis: object not to search on
+ *
+ * Find the #ConnectionPoint closest to pos in a layer.
+ *
+ * Returns: the distance of the connection point and pos
+ *
+ * Since: 0.98
*/
real
-dia_layer_find_closest_connectionpoint (Layer *layer,
+dia_layer_find_closest_connectionpoint (DiaLayer *layer,
ConnectionPoint **closest,
Point *pos,
DiaObject *notthis)
@@ -521,43 +830,49 @@ dia_layer_find_closest_connectionpoint (Layer *layer,
ConnectionPoint *cp;
real mindist, dist;
int i;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
mindist = 1000000.0; /* Realy big value... */
*closest = NULL;
- for (l = layer->objects; l!=NULL; l = g_list_next(l) ) {
+ for (l = priv->objects; l!=NULL; l = g_list_next (l) ) {
obj = (DiaObject *) l->data;
if (obj == notthis)
continue;
- for (i=0;i<obj->num_connections;i++) {
+
+ for (i = 0; i < obj->num_connections; i++) {
cp = obj->connections[i];
/* Note: Uses manhattan metric for speed... */
dist = distance_point_point_manhattan (pos, &cp->pos);
- if (dist<mindist) {
+ if (dist < mindist) {
mindist = dist;
*closest = cp;
}
}
-
- }
+ }
return mindist;
}
-/*!
- * \brief Recalculation of the bounding box containing all objects in the layer
- * \memberof _Layer
+/**
+ * dia_layer_update_extents:
+ * @layer: the #DiaLayer
+ *
+ * Recalculation of the bounding box containing all objects in the layer
+ *
+ * Since: 0.98
*/
int
-dia_layer_update_extents (Layer *layer)
+dia_layer_update_extents (DiaLayer *layer)
{
GList *l;
DiaObject *obj;
Rectangle new_extents;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
- l = layer->objects;
+ l = priv->objects;
if (l!=NULL) {
obj = (DiaObject *) l->data;
new_extents = obj->bounding_box;
@@ -576,28 +891,35 @@ dia_layer_update_extents (Layer *layer)
new_extents = invalid_extents;
}
- if (rectangle_equals (&new_extents, &layer->extents)) return FALSE;
+ if (rectangle_equals (&new_extents, &priv->extents)) return FALSE;
- layer->extents = new_extents;
+ priv->extents = new_extents;
return TRUE;
}
-/*!
- * \brief Swaps a list of objects with a single object
+/**
+ * dia_layer_replace_object_with_list:
+ * @layer: the #DiaLayer
+ * @remove_obj: the #DiaObject that will be removed from layer
+ * @insert_list: list of #DiaObject to insert where remove_obj was
+ *
+ * Swaps a list of objects with a single object
*
* This function exchanges the given object with the list of objects.
- * Ownership of remove_obj and insert_list objects is swapped, too.
*
- * \memberof _Layer
+ * Ownership of @remove_obj and @insert_list objects is swapped, too.
+ *
+ * Since: 0.98
*/
void
-dia_layer_replace_object_with_list (Layer *layer,
+dia_layer_replace_object_with_list (DiaLayer *layer,
DiaObject *remove_obj,
GList *insert_list)
{
GList *list, *il;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
- list = g_list_find (layer->objects, remove_obj);
+ list = g_list_find (priv->objects, remove_obj);
g_assert (list!=NULL);
dynobj_list_remove_object (remove_obj);
@@ -606,7 +928,7 @@ dia_layer_replace_object_with_list (Layer *layer,
g_list_foreach (insert_list, set_parent_layer, layer);
if (list->prev == NULL) {
- layer->objects = insert_list;
+ priv->objects = insert_list;
} else {
list->prev->next = insert_list;
insert_list->prev = list->prev;
@@ -635,26 +957,35 @@ layer_remove_dynobj (gpointer obj, gpointer userdata)
dynobj_list_remove_object ((DiaObject*)obj);
}
+/**
+ * dia_layer_set_object_list:
+ * @layer: the #DiaLayer
+ * @list: new list of #DiaObject s
+ *
+ * Since: 0.98
+ */
void
-dia_layer_set_object_list (Layer *layer, GList *list)
+dia_layer_set_object_list (DiaLayer *layer, GList *list)
{
GList *ol;
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
/* signal removal on all objects */
- ol = layer->objects;
+ ol = priv->objects;
while (ol) {
if (!g_list_find (list, ol->data)) /* only if it really vanishes */
- data_emit (dia_layer_get_parent_diagram(layer), layer, ol->data, "object_remove");
+ data_emit (dia_layer_get_parent_diagram (layer), layer, ol->data, "object_remove");
ol = g_list_next (ol);
}
/* restore old list */
- ol = layer->objects;
- g_list_foreach (layer->objects, set_parent_layer, NULL);
- g_list_foreach (layer->objects, layer_remove_dynobj, NULL);
+ ol = priv->objects;
+ g_list_foreach (priv->objects, set_parent_layer, NULL);
+ g_list_foreach (priv->objects, layer_remove_dynobj, NULL);
- layer->objects = list;
- g_list_foreach (layer->objects, set_parent_layer, layer);
+ priv->objects = list;
+ g_list_foreach (priv->objects, set_parent_layer, layer);
/* signal addition on all objects */
- list = layer->objects;
+ list = priv->objects;
while (list) {
if (!g_list_find (ol, list->data)) /* only if it is new */
data_emit (dia_layer_get_parent_diagram (layer), layer, list->data, "object_add");
@@ -663,8 +994,162 @@ dia_layer_set_object_list (Layer *layer, GList *list)
g_list_free (ol);
}
+/**
+ * dia_layer_set_object_list:
+ * @layer: the #DiaLayer
+ *
+ * Since: 0.98
+ */
+GList *
+dia_layer_get_object_list (DiaLayer *layer)
+{
+ DiaLayerPrivate *priv = dia_layer_get_instance_private (layer);
+
+ return priv->objects;
+}
+
+/**
+ * dia_layer_get_parent_diagram:
+ * @layer: the #DiaLayer
+ *
+ * Since: 0.98
+ */
DiagramData *
-dia_layer_get_parent_diagram (Layer *layer)
+dia_layer_get_parent_diagram (DiaLayer *layer)
+{
+ DiaLayerPrivate *priv;
+
+ g_return_val_if_fail (DIA_IS_LAYER (layer), NULL);
+
+ priv = dia_layer_get_instance_private (layer);
+
+ return priv->parent_diagram;
+}
+
+/**
+ * dia_layer_set_parent_diagram:
+ * @layer: the #DiaLayer
+ * @diagram: the #DiagramData
+ *
+ * Since: 0.98
+ */
+void
+dia_layer_set_parent_diagram (DiaLayer *layer,
+ DiagramData *diagram)
+{
+ DiaLayerPrivate *priv;
+
+ g_return_if_fail (DIA_IS_LAYER (layer));
+
+ priv = dia_layer_get_instance_private (layer);
+
+ g_clear_object (&priv->parent_diagram);
+ priv->parent_diagram = g_object_ref (diagram);
+
+ g_object_notify_by_pspec (G_OBJECT (layer), pspecs[PROP_PARENT_DIAGRAM]);
+}
+
+/**
+ * dia_layer_is_connectable:
+ * @self: the #DiaLayer
+ *
+ * Since: 0.98
+ */
+gboolean
+dia_layer_is_connectable (DiaLayer *self)
+{
+ DiaLayerPrivate *priv;
+
+ g_return_val_if_fail (DIA_IS_LAYER (self), FALSE);
+
+ priv = dia_layer_get_instance_private (self);
+
+ return priv->connectable;
+}
+
+
+/**
+ * dia_layer_set_connectable:
+ * @self: the #DiaLayer
+ * @connectable: the new connectable status
+ *
+ * Since: 0.98
+ */
+void
+dia_layer_set_connectable (DiaLayer *self,
+ gboolean connectable)
+{
+ DiaLayerPrivate *priv;
+
+ g_return_if_fail (DIA_IS_LAYER (self));
+
+ priv = dia_layer_get_instance_private (self);
+
+ priv->connectable = connectable;
+
+ g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_CONNECTABLE]);
+}
+
+
+/**
+ * dia_layer_is_visible:
+ * @self: the #DiaLayer
+ *
+ * Since: 0.98
+ */
+gboolean
+dia_layer_is_visible (DiaLayer *self)
+{
+ DiaLayerPrivate *priv;
+
+ g_return_val_if_fail (DIA_IS_LAYER (self), FALSE);
+
+ priv = dia_layer_get_instance_private (self);
+
+ return priv->visible;
+}
+
+
+/**
+ * dia_layer_set_visible:
+ * @self: the #DiaLayer
+ * @visible: new visibility
+ *
+ * Since: 0.98
+ */
+void
+dia_layer_set_visible (DiaLayer *self,
+ gboolean visible)
+{
+ DiaLayerPrivate *priv;
+
+ g_return_if_fail (DIA_IS_LAYER (self));
+
+ priv = dia_layer_get_instance_private (self);
+
+ priv->visible = visible;
+
+ g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_VISIBLE]);
+}
+
+
+/**
+ * dia_layer_get_extents:
+ * @self: the #DiaLayer
+ * @rect: (out): the extents
+ *
+ * Since: 0.98
+ */
+void
+dia_layer_get_extents (DiaLayer *self,
+ Rectangle *rect)
{
- return layer->parent_diagram;
+ DiaLayerPrivate *priv;
+
+ g_return_if_fail (DIA_IS_LAYER (self));
+ g_return_if_fail (rect != NULL);
+
+ priv = dia_layer_get_instance_private (self);
+
+ *rect = priv->extents;
}
diff --git a/lib/object.c b/lib/object.c
index 45c7d85d..823fb936 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -32,96 +32,114 @@
#include "debug.h"
-/** Initialize an already allocated object with the given number of handles
- * and connections. This does not create the actual Handle and Connection
- * objects, which are expected to be added later.
- * @param obj A newly allocated object with no handles or connections
- * previously allocated.
- * @param num_handles the number of handles to allocate room for.
- * @param num_connections the number of connections to allocate room for.
+/**
+ * object_init:
+ * @obj: A newly allocated object with no handles or connections
+ * previously allocated.
+ * @num_handles: the number of handles to allocate room for.
+ * @num_connections: the number of connections to allocate room for.
+ *
+ * Initialize an already allocated object with the given number of handles
+ * and connections. This does not create the actual #Handle and #Connection
+ * objects, which are expected to be added later.
*/
void
-object_init(DiaObject *obj,
- int num_handles,
- int num_connections)
+object_init (DiaObject *obj,
+ int num_handles,
+ int num_connections)
{
obj->num_handles = num_handles;
- if (num_handles>0)
- obj->handles = g_malloc0(sizeof(Handle *) * num_handles);
+ if (num_handles > 0)
+ obj->handles = g_malloc0 (sizeof (Handle *) * num_handles);
else
obj->handles = NULL;
obj->num_connections = num_connections;
- if (num_connections>0)
- obj->connections = g_malloc0(sizeof(ConnectionPoint *) * num_connections);
+ if (num_connections > 0)
+ obj->connections = g_malloc0 (sizeof (ConnectionPoint *) * num_connections);
else
obj->connections = NULL;
}
-/** Destroy an objects allocations and disconnect it from everything else.
- * After calling this function, the object is no longer valid for use
- * in a diagram. Note that this does not deallocate the object itself.
- * @param obj The object being destroyed.
+/**
+ * object_destroy:
+ * @obj: The object being destroyed.
+ *
+ * Destroy an objects allocations and disconnect it from everything else.
+ * After calling this function, the object is no longer valid for use
+ * in a diagram. Note that this does not deallocate the object itself.
*/
void
-object_destroy(DiaObject *obj)
+object_destroy (DiaObject *obj)
{
- object_unconnect_all(obj);
+ object_unconnect_all (obj);
if (obj->handles)
- g_free(obj->handles);
+ g_free (obj->handles);
obj->handles = NULL;
if (obj->connections)
- g_free(obj->connections);
+ g_free (obj->connections);
obj->connections = NULL;
if (obj->meta)
g_hash_table_destroy (obj->meta);
obj->meta = NULL;
}
-/** Copy the object-level information of this object.
- * This includes type, position, bounding box, number of handles and
- * connections, operations, parentability, parent and children.
- * After this copying you have to fix up:
- handles
- connections
- children/parents
+/**
+ * object_copy:
+ * @from: The object being copied from
+ * @to: The object being copied to. This object does not need to
+ * have been object_init'ed, but if it is, its handles and
+ * connections arrays will be freed.
+ *
+ * Copy the object-level information of this object.
+ *
+ * This includes type, position, bounding box, number of handles and
+ * connections, operations, parentability, parent and children.
+ *
+ * After this copying you have to fix up:
+ *
+ * - #Handle s
+ * - #Connection s
+ * - children / parents
+ *
* In particular the children lists will contain the same objects, which
* is not a valid situation.
- * @param from The object being copied from
- * @param to The object being copied to. This object does not need to
- * have been object_init'ed, but if it is, its handles and
- * connections arrays will be freed.
- * @bug Any existing children list will not be freed and will leak.
+ *
+ * bug Any existing children list will not be freed and will leak.
*/
void
-object_copy(DiaObject *from, DiaObject *to)
+object_copy (DiaObject *from, DiaObject *to)
{
to->type = from->type;
to->position = from->position;
to->bounding_box = from->bounding_box;
to->num_handles = from->num_handles;
- if (to->handles != NULL) g_free(to->handles);
- if (to->num_handles>0)
- to->handles = g_malloc(sizeof(Handle *)*to->num_handles);
+ if (to->handles != NULL) g_free (to->handles);
+ if (to->num_handles > 0)
+ to->handles = g_malloc (sizeof (Handle *)*to->num_handles);
else
to->handles = NULL;
to->num_connections = from->num_connections;
- if (to->connections != NULL) g_free(to->connections);
- if (to->num_connections>0)
- to->connections = g_malloc0(sizeof(ConnectionPoint *) * to->num_connections);
+ if (to->connections != NULL) g_free (to->connections);
+ if (to->num_connections > 0)
+ to->connections = g_malloc0 (sizeof (ConnectionPoint *) * to->num_connections);
else
to->connections = NULL;
to->ops = from->ops;
to->parent = from->parent;
- to->children = g_list_copy(from->children);
+ to->children = g_list_copy (from->children);
}
-/** A hash function of a pointer value. Not the most well-spreadout
+/**
+ * pointer_hash:
+ * @some_pointer: pointer to hash
+ *
+ * A hash function of a pointer value. Not the most well-spreadout
* function, as it has the same low bits as the pointer.
*/
static guint
@@ -131,18 +149,23 @@ pointer_hash(gpointer some_pointer)
}
-/** Copy a list of objects, keeping connections and parent-children
- * relation ships between the objects. It is assumed that the
- * ops->copy function correctly creates the connections and handles
- * objects.
- * @param list_orig The original list. This list will not be changed,
- * nor will its objects.
- * @return A list with the list_orig copies copied.
- * @bug Any children of an object in the list that are not themselves
+/**
+ * object_copy_list:
+ * @list_orig: The original list. This list will not be changed,
+ * nor will its objects.
+ *
+ * Copy a list of objects, keeping connections and parent-children
+ * relation ships between the objects. It is assumed that the
+ * ops->copy function correctly creates the connections and handles
+ * objects.
+ *
+ * Returns: A list with the list_orig copies copied.
+ *
+ * bug Any children of an object in the list that are not themselves
* in the list will cause a NULL entry in the children list.
*/
GList *
-object_copy_list(GList *list_orig)
+object_copy_list (GList *list_orig)
{
GList *list_copy;
GList *list;
@@ -235,19 +258,24 @@ object_copy_list(GList *list_orig)
return list_copy;
}
-/** Move a number of objects the same distance. Any children of objects in
+/**
+ * object_list_move_delta_r:
+ * @objects: The list of objects to move. This list must not contain
+ * any object that is a child (at any depth) of another object.
+ * see parent_list_affected_hierarchy()
+ * @delta: How far to move the objects.
+ * @affected: Whether to check parent boundaries???
+ *
+ * Move a number of objects the same distance. Any children of objects in
* the list are moved as well. This is intended to be called from within
- * object_list_move_delta.
- * @param objects The list of objects to move. This list must not contain
- * any object that is a child (at any depth) of another object.
- * @see parent_list_affected_hierarchy
- * @param delta How far to move the objects.
- * @param affected Whether to check parent boundaries???
- * @return Undo information for the move, or NULL if no objects moved.
- * @bug The return Change object only contains info for a single object.
+ * object_list_move_delta().
+ *
+ * Returns: Undo information for the move, or %NULL if no objects moved.
+ *
+ * bug The return Change object only contains info for a single object.
*/
ObjectChange*
-object_list_move_delta_r(GList *objects, Point *delta, gboolean affected)
+object_list_move_delta_r (GList *objects, Point *delta, gboolean affected)
{
GList *list;
DiaObject *obj;
@@ -286,12 +314,15 @@ object_list_move_delta_r(GList *objects, Point *delta, gboolean affected)
return objchange;
}
-/** Move a set of objects a given amount.
- * @param objects The list ob objects to move.
- * @param delta The amount to move them.
+/**
+ * object_list_move_delta:
+ * @objects: The list ob objects to move.
+ * @delta: The amount to move them.
+ *
+ * Move a set of objects a given amount.
*/
ObjectChange*
-object_list_move_delta(GList *objects, Point *delta)
+object_list_move_delta (GList *objects, Point *delta)
{
GList *list;
DiaObject *obj;
@@ -337,6 +368,7 @@ _find_connectable (DiaObject *obj, int *num)
}
return NULL;
}
+
/*!
* Bezierlines don't have just two connectable handles, but every
* major handle is connectable. To let us find the correct handles
@@ -374,6 +406,11 @@ static PropDescription _style_prop_descs[] = {
PROP_DESC_END
};
+/**
+ * object_copy_style:
+ * @dest: the object to copy onto
+ * @src: the object to copy from
+ */
void
object_copy_style (DiaObject *dest, const DiaObject *src)
{
@@ -383,16 +420,16 @@ object_copy_style (DiaObject *dest, const DiaObject *src)
g_return_if_fail (dest && dest->ops->set_props != NULL);
props = prop_list_from_descs (_style_prop_descs, pdtpp_true);
- src->ops->get_props((DiaObject *)src, props);
- dest->ops->set_props(dest, props);
- prop_list_free(props);
+ dia_object_get_properties ((DiaObject *) src, props);
+ dia_object_set_properties (dest, props);
+ prop_list_free (props);
}
static void
_object_exchange (ObjectChange *change, DiaObject *obj)
{
ObjectChangeExchange *c = (ObjectChangeExchange *)change;
- Layer *layer = dia_object_get_parent_layer (obj);
+ DiaLayer *layer = dia_object_get_parent_layer (obj);
DiagramData *dia = layer ? dia_layer_get_parent_diagram (layer) : NULL;
DiaObject *subst = (obj == c->orig) ? c->subst : c->orig;
DiaObject *parent_object = obj->parent;
@@ -453,6 +490,7 @@ _object_exchange (ObjectChange *change, DiaObject *obj)
data_select(dia, subst);
}
}
+
/* It is adviced to not use the passed in object at all */
static void
_object_exchange_apply (ObjectChange *change, DiaObject *obj)
@@ -463,6 +501,7 @@ _object_exchange_apply (ObjectChange *change, DiaObject *obj)
_object_exchange (change, c->orig);
c->applied = 1;
}
+
/* It is adviced to not use the passed in object at all */
static void
_object_exchange_revert (ObjectChange *change, DiaObject *obj)
@@ -473,6 +512,7 @@ _object_exchange_revert (ObjectChange *change, DiaObject *obj)
_object_exchange (change, c->subst);
c->applied = 0;
}
+
static void
_object_exchange_free (ObjectChange *change)
{
@@ -484,17 +524,20 @@ _object_exchange_free (ObjectChange *change)
g_free(obj);
}
}
-/*!
- * \brief Replace an object with another one
+
+/**
+ * object_substitute:
+ * @obj: the original object which will be replace
+ * @subst: the sunstitute object
+ *
+ * Replace an object with another one
*
* The type of an object can not change dynamically. To substitute one
* object with another this function helps. It does it's best to transfer
* all the existing object relations, e.g. connections, parent_layer
* and parenting information.
*
- * @param obj the original object which will be replace
- * @param subst the sunstitute object
- * @return _ObjectChange containing undo/redo information
+ * Returns: #ObjectChange containing undo/redo information
*/
ObjectChange *
object_substitute (DiaObject *obj, DiaObject *subst)
@@ -512,12 +555,15 @@ object_substitute (DiaObject *obj, DiaObject *subst)
return (ObjectChange*)change;
}
-/** Destroy a list of objects by calling ops->destroy on each in turn.
- * @param list_to_be_destroyed A of objects list to destroy. The list itself
- * will also be freed.
+/**
+ * destroy_object_list:
+ * @list_to_be_destroyed: A of objects list to destroy. The list itself
+ * will also be freed.
+ *
+ * Destroy a list of objects by calling ops->destroy on each in turn.
*/
void
-destroy_object_list(GList *list_to_be_destroyed)
+destroy_object_list (GList *list_to_be_destroyed)
{
GList *list;
DiaObject *obj;
@@ -828,7 +874,7 @@ object_load(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx)
* @return The layer that contains the object, or NULL if the object is
* not in any layer.
*/
-Layer *
+DiaLayer *
dia_object_get_parent_layer(DiaObject *obj) {
return obj->parent_layer;
}
@@ -844,8 +890,8 @@ dia_object_get_parent_layer(DiaObject *obj) {
gboolean
dia_object_is_selected (const DiaObject *obj)
{
- Layer *layer = obj->parent_layer;
- DiagramData *diagram = layer ? layer->parent_diagram : NULL;
+ DiaLayer *layer = obj->parent_layer;
+ DiagramData *diagram = layer ? dia_layer_get_parent_diagram (layer) : NULL;
GList * selected;
/* although this is a little bogus, it is better than crashing
@@ -904,7 +950,7 @@ dia_object_is_selectable(DiaObject *obj)
if (obj->parent_layer == NULL) {
return FALSE;
}
- return obj->parent_layer == obj->parent_layer->parent_diagram->active_layer;
+ return obj->parent_layer == dia_layer_get_parent_diagram (obj->parent_layer)->active_layer;
}
diff --git a/lib/object.h b/lib/object.h
index 6b2454ce..803ab362 100644
--- a/lib/object.h
+++ b/lib/object.h
@@ -351,7 +351,7 @@ struct _DiaObject {
_DIA_OBJECT_FIELD (ObjectOps *, ops); /* pointer to the vtable */
- Layer *parent_layer; /*!< Back-pointer to the owning layer.
+ DiaLayer *parent_layer; /*!< Back-pointer to the owning layer.
This may only be set by functions internal to
the layer, and accessed via
dia_object_get_parent_layer() */
@@ -482,7 +482,7 @@ DiaObject *dia_object_default_create (const DiaObjectType *type,
Handle **handle1,
Handle **handle2);
gboolean dia_object_defaults_save (const gchar *filename, DiaContext *ctx);
-Layer *dia_object_get_parent_layer(DiaObject *obj);
+DiaLayer *dia_object_get_parent_layer(DiaObject *obj);
gboolean dia_object_is_selected (const DiaObject *obj);
const Rectangle *dia_object_get_bounding_box(const DiaObject *obj);
const Rectangle *dia_object_get_enclosing_box(const DiaObject *obj);
diff --git a/plug-ins/cgm/cgm.c b/plug-ins/cgm/cgm.c
index 304990b2..06be7a96 100644
--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -39,6 +39,7 @@
#include "plug-ins.h"
#include "diarenderer.h"
#include "dia_image.h"
+#include "font.h"
#include <gdk/gdk.h>
diff --git a/plug-ins/drs/dia-render-script-import.c b/plug-ins/drs/dia-render-script-import.c
index 567ef112..d2235cc5 100644
--- a/plug-ins/drs/dia-render-script-import.c
+++ b/plug-ins/drs/dia-render-script-import.c
@@ -470,10 +470,10 @@ import_drs (const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user
GList *item, *items;
xmlDocPtr doc = xmlParseFile(filename);
xmlNodePtr root = NULL, node;
- Layer *active_layer = NULL;
+ DiaLayer *active_layer = NULL;
for (node = doc->children; node; node = node->next)
- if (xmlStrcmp (node->name, (const xmlChar *)"drs") == 0)
+ if (xmlStrcmp (node->name, (const xmlChar *) "drs") == 0)
root = node;
if (!root || !(root = find_child_named (root, "diagram"))) {
@@ -482,24 +482,24 @@ import_drs (const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user
}
for (node = root->children; node != NULL; node = node->next) {
- if (xmlStrcmp (node->name, (const xmlChar *)"layer") == 0) {
+ if (xmlStrcmp (node->name, (const xmlChar *) "layer") == 0) {
xmlChar *str;
- xmlChar *name = xmlGetProp (node, (const xmlChar *)"name");
- Layer *layer = dia_layer_new (g_strdup (name ? (gchar *)name : _("Layer")), dia);
+ xmlChar *name = xmlGetProp (node, (const xmlChar *) "name");
+ DiaLayer *layer = dia_layer_new (name ? (gchar *) name : _("Layer"), dia);
if (name)
xmlFree (name);
- str = xmlGetProp (node, (const xmlChar *)"active");
- if (xmlStrcmp (str, (const xmlChar *)"true")) {
+ str = xmlGetProp (node, (const xmlChar *) "active");
+ if (xmlStrcmp (str, (const xmlChar *) "true")) {
active_layer = layer;
xmlFree (str);
}
items = read_items (node->children, ctx);
for (item = items; item != NULL; item = g_list_next (item)) {
- DiaObject *obj = (DiaObject *)item->data;
- dia_layer_add_object(layer, obj);
+ DiaObject *obj = DIA_OBJECT (item->data);
+ dia_layer_add_object (layer, obj);
}
g_list_free (items);
data_add_layer (dia, layer);
diff --git a/plug-ins/drs/dia-render-script.c b/plug-ins/drs/dia-render-script.c
index bb0db34c..942b143f 100644
--- a/plug-ins/drs/dia-render-script.c
+++ b/plug-ins/drs/dia-render-script.c
@@ -67,7 +67,7 @@
#include "dia-render-script-renderer.h"
static void
-drs_render_layer (DiaRenderer *self, Layer *layer, gboolean active)
+drs_render_layer (DiaRenderer *self, DiaLayer *layer, gboolean active)
{
DrsRenderer *renderer = DRS_RENDERER (self);
xmlNodePtr node;
@@ -76,13 +76,18 @@ drs_render_layer (DiaRenderer *self, Layer *layer, gboolean active)
g_queue_push_tail (renderer->parents, renderer->root);
renderer->root = node = xmlNewChild(renderer->root, NULL, (const xmlChar *)"layer", NULL);
- xmlSetProp(node, (const xmlChar *)"name", (xmlChar *)layer->name);
- xmlSetProp(node, (const xmlChar *)"visible", (xmlChar *)(layer->visible ? "true" : "false"));
- if (active)
- xmlSetProp(node, (const xmlChar *)"active", (xmlChar *)"true");
+ xmlSetProp (node,
+ (const xmlChar *) "name",
+ (xmlChar *) dia_layer_get_name (layer));
+ xmlSetProp (node,
+ (const xmlChar *) "visible",
+ (xmlChar *) (dia_layer_is_visible (layer) ? "true" : "false"));
+ if (active) {
+ xmlSetProp (node, (const xmlChar *) "active", (xmlChar *) "true");
+ }
/* Draw all objects: */
- list = layer->objects;
+ list = dia_layer_get_object_list (layer);
while (list!=NULL) {
obj = (DiaObject *) list->data;
dia_renderer_draw_object (self, obj, NULL);
@@ -100,7 +105,7 @@ drs_data_render (DiagramData *data, DiaRenderer *renderer)
dia_renderer_begin_render (renderer, NULL);
for (i=0; i < data->layers->len; i++) {
- Layer *layer = (Layer *) g_ptr_array_index (data->layers, i);
+ DiaLayer *layer = DIA_LAYER (g_ptr_array_index (data->layers, i));
drs_render_layer (renderer, layer, layer == data->active_layer);
}
dia_renderer_end_render (renderer);
diff --git a/plug-ins/dxf/dxf-export.c b/plug-ins/dxf/dxf-export.c
index c4fa22ee..f09f63aa 100644
--- a/plug-ins/dxf/dxf-export.c
+++ b/plug-ins/dxf/dxf-export.c
@@ -36,6 +36,7 @@
#include "diarenderer.h"
#include "filter.h"
#include "dia-layer.h"
+#include "font.h"
/* used to be 10 and inconsistent with import and even here */
#define MAGIC_THICKNESS_FACTOR (1.0)
@@ -122,7 +123,7 @@ struct _DxfRenderer
TextAttrdxf tcurrent, tinfile;
- char *layername;
+ const char *layername;
};
static void dxf_renderer_class_init (DxfRendererClass *klass);
@@ -568,7 +569,7 @@ export_dxf(DiagramData *data, DiaContext *ctx,
DxfRenderer *renderer;
FILE *file;
int i;
- Layer *layer;
+ DiaLayer *layer;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gchar buf2[G_ASCII_DTOSTR_BUF_SIZE];
@@ -600,12 +601,12 @@ export_dxf(DiagramData *data, DiaContext *ctx,
fprintf(file," 2\nLAYER\n 70\n255\n");
for (i=0; i<data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index(data->layers, i);
- fprintf(file," 0\nLAYER\n 2\n%s\n",layer->name);
- if(layer->visible)
- fprintf(file," 62\n%d\n",i+1);
+ layer = DIA_LAYER (g_ptr_array_index (data->layers, i));
+ fprintf (file," 0\nLAYER\n 2\n%s\n", dia_layer_get_name (layer));
+ if (dia_layer_is_visible (layer))
+ fprintf (file," 62\n%d\n",i+1);
else
- fprintf(file," 62\n%d\n",(-1)*(i+1));
+ fprintf (file," 62\n%d\n",(-1)*(i+1));
}
fprintf(file, " 0\nENDTAB\n 0\nENDSEC\n");
@@ -617,8 +618,8 @@ export_dxf(DiagramData *data, DiaContext *ctx,
dia_renderer_begin_render (DIA_RENDERER (renderer), NULL);
for (i=0; i<data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index (data->layers, i);
- renderer->layername = layer->name;
+ layer = DIA_LAYER (g_ptr_array_index (data->layers, i));
+ renderer->layername = dia_layer_get_name (layer);
dia_layer_render (layer, DIA_RENDERER (renderer), NULL, NULL, data, 0);
}
diff --git a/plug-ins/dxf/dxf-import.c b/plug-ins/dxf/dxf-import.c
index cc1c0d7c..741a91bf 100644
--- a/plug-ins/dxf/dxf-import.c
+++ b/plug-ins/dxf/dxf-import.c
@@ -87,20 +87,21 @@ static void read_section_classes_dxf(FILE *filedxf, DxfData *data, DiagramData *
static void read_section_tables_dxf(FILE *filedxf, DxfData *data, DiagramData *dia);
static void read_section_entities_dxf(FILE *filedxf, DxfData *data, DiagramData *dia);
static void read_section_blocks_dxf(FILE *filedxf, DxfData *data, DiagramData *dia);
-static Layer *layer_find_by_name(char *layername, DiagramData *dia);
+static DiaLayer *layer_find_by_name(char *layername, DiagramData *dia);
static LineStyle get_dia_linestyle_dxf(char *dxflinestyle);
GHashTable *_color_by_layer_ht = NULL;
static void
-_dxf_color_set_by_layer (const Layer *layer, int color_index)
+_dxf_color_set_by_layer (const DiaLayer *layer, int color_index)
{
if (!_color_by_layer_ht) /* lazy creation */
_color_by_layer_ht = g_hash_table_new (g_direct_hash, g_direct_equal);
g_hash_table_insert (_color_by_layer_ht, (void *)layer, GINT_TO_POINTER (color_index));
}
+
static int
-_dxf_color_get_by_layer (const Layer *layer)
+_dxf_color_get_by_layer (const DiaLayer *layer)
{
int color_index;
@@ -111,6 +112,7 @@ _dxf_color_get_by_layer (const Layer *layer)
return color_index;
return 0;
}
+
static void
_color_init_from_rgb (Color *color, RGB_t rgb)
{
@@ -122,24 +124,24 @@ _color_init_from_rgb (Color *color, RGB_t rgb)
/* returns the layer with the given name */
/* TODO: merge this with other layer code? */
-static Layer *
+static DiaLayer *
layer_find_by_name(char *layername, DiagramData *dia)
{
- Layer *matching_layer, *layer;
- guint i;
+ DiaLayer *matching_layer, *layer;
+ guint i;
- matching_layer = NULL;
+ matching_layer = NULL;
- for (i=0; i<dia->layers->len; i++) {
- layer = (Layer *)g_ptr_array_index(dia->layers, i);
- if(strcmp(layer->name, layername) == 0) {
- matching_layer = layer;
- break;
- }
+ for (i=0; i<dia->layers->len; i++) {
+ layer = DIA_LAYER (g_ptr_array_index (dia->layers, i));
+ if (strcmp (dia_layer_get_name (layer), layername) == 0) {
+ matching_layer = layer;
+ break;
}
+ }
if (matching_layer == NULL) {
- matching_layer = dia_layer_new (g_strdup (layername), dia);
+ matching_layer = dia_layer_new (layername, dia);
data_add_layer (dia, matching_layer);
}
@@ -165,12 +167,12 @@ get_dia_linestyle_dxf(char *dxflinestyle)
/* reads a line entity from the dxf file and creates a line object in dia*/
static DiaObject *
-read_entity_line_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
+read_entity_line_dxf (FILE *filedxf, DxfData *data, DiagramData *dia)
{
/* line data */
Point start, end;
- DiaObjectType *otype = object_get_type("Standard - Line");
+ DiaObjectType *otype = object_get_type ("Standard - Line");
Handle *h1, *h2;
DiaObject *line_obj;
@@ -180,45 +182,46 @@ read_entity_line_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
real line_width = DEFAULT_LINE_WIDTH;
LineStyle style = LINESTYLE_SOLID;
- Layer *layer = dia->active_layer;
+ DiaLayer *layer = dia->active_layer;
end.x=0;
end.y=0;
- props = g_ptr_array_new();
+ props = g_ptr_array_new ();
do {
- if(read_dxf_codes(filedxf, data) == FALSE){
- return( NULL );
- }
- switch(data->code){
- case 6: style = get_dia_linestyle_dxf(data->value);
- break;
- case 8:
- layer = layer_find_by_name(data->value, dia);
- color = pal_get_rgb (_dxf_color_get_by_layer (layer));
- break;
+ if (read_dxf_codes (filedxf, data) == FALSE){
+ return NULL;
+ }
+ switch(data->code){
+ case 6:
+ style = get_dia_linestyle_dxf (data->value);
+ break;
+ case 8:
+ layer = layer_find_by_name (data->value, dia);
+ color = pal_get_rgb (_dxf_color_get_by_layer (layer));
+ break;
case 10:
- start.x = g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- break;
+ start.x = g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ break;
case 11:
- end.x = g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- break;
+ end.x = g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ break;
case 20:
- start.y = (-1)*g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- break;
+ start.y = (-1)*g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ break;
case 21:
- end.y = (-1)*g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- break;
+ end.y = (-1)*g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ break;
case 39:
- line_width = g_ascii_strtod(data->value, NULL) * WIDTH_SCALE;
- /*printf( "line width %f\n", line_width ); */
- break;
- case 62 :
- color = pal_get_rgb (atoi(data->value));
- break;
- }
- } while(data->code != 0);
+ line_width = g_ascii_strtod (data->value, NULL) * WIDTH_SCALE;
+ /*printf( "line width %f\n", line_width ); */
+ break;
+ case 62 :
+ color = pal_get_rgb (atoi (data->value));
+ break;
+ }
+ } while (data->code != 0);
_color_init_from_rgb (&line_colour, color);
line_obj = otype->ops->create(&start, otype->default_user_data,
@@ -263,67 +266,67 @@ read_entity_solid_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
real line_width = 0.001;
LineStyle style = LINESTYLE_SOLID;
- Layer *layer = dia->active_layer;
+ DiaLayer *layer = dia->active_layer;
RGB_t color = { 127, 127, 127 };
/* printf( "Solid " ); */
memset(p, 0, sizeof(p));
- do {
- if(read_dxf_codes(filedxf, data) == FALSE){
- return( NULL );
- }
- switch(data->code){
- case 6:
- style = get_dia_linestyle_dxf(data->value);
- break;
- case 8:
- layer = layer_find_by_name(data->value, dia);
- color = pal_get_rgb (_dxf_color_get_by_layer (layer));
- /*printf( "layer: %s ", data->value );*/
- break;
- case 10:
- p[0].x = g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P0.x: %f ", p[0].x );*/
- break;
- case 11:
- p[1].x = g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P1.x: %f ", p[1].x );*/
- break;
- case 12: /* bot only swapped, but special for only 3 points given */
- p[2].x = p[3].x = g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P2.x: %f ", p[2].x );*/
- break;
- case 13: /* SOLID order swapped compared to Dia's */
- p[2].x = g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P3.x: %f ", p[3].x );*/
- break;
- case 20:
- p[0].y = (-1)*g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P0.y: %f ", p[0].y );*/
- break;
- case 21:
- p[1].y = (-1)*g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P1.y: %f ", p[1].y );*/
- break;
- case 22:
- p[2].y = p[3].y = (-1)*g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P2.y: %f ", p[2].y );*/
- break;
- case 23:
- p[2].y = (-1)*g_ascii_strtod(data->value, NULL) * coord_scale * measure_scale;
- /*printf( "P3.y: %f\n", p[3].y );*/
- break;
- case 39:
- line_width = g_ascii_strtod(data->value, NULL) * WIDTH_SCALE;
- /*printf( "width %f\n", line_width );*/
- break;
- case 62:
- color = pal_get_rgb (atoi(data->value));
- break;
- }
- } while(data->code != 0);
+ do {
+ if (read_dxf_codes (filedxf, data) == FALSE) {
+ return NULL;
+ }
+ switch(data->code){
+ case 6:
+ style = get_dia_linestyle_dxf (data->value);
+ break;
+ case 8:
+ layer = layer_find_by_name (data->value, dia);
+ color = pal_get_rgb (_dxf_color_get_by_layer (layer));
+ /*printf( "layer: %s ", data->value );*/
+ break;
+ case 10:
+ p[0].x = g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P0.x: %f ", p[0].x );*/
+ break;
+ case 11:
+ p[1].x = g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P1.x: %f ", p[1].x );*/
+ break;
+ case 12: /* bot only swapped, but special for only 3 points given */
+ p[2].x = p[3].x = g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P2.x: %f ", p[2].x );*/
+ break;
+ case 13: /* SOLID order swapped compared to Dia's */
+ p[2].x = g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P3.x: %f ", p[3].x );*/
+ break;
+ case 20:
+ p[0].y = (-1)*g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P0.y: %f ", p[0].y );*/
+ break;
+ case 21:
+ p[1].y = (-1)*g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P1.y: %f ", p[1].y );*/
+ break;
+ case 22:
+ p[2].y = p[3].y = (-1)*g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P2.y: %f ", p[2].y );*/
+ break;
+ case 23:
+ p[2].y = (-1)*g_ascii_strtod (data->value, NULL) * coord_scale * measure_scale;
+ /*printf( "P3.y: %f\n", p[3].y );*/
+ break;
+ case 39:
+ line_width = g_ascii_strtod (data->value, NULL) * WIDTH_SCALE;
+ /*printf( "width %f\n", line_width );*/
+ break;
+ case 62:
+ color = pal_get_rgb (atoi (data->value));
+ break;
+ }
+ } while(data->code != 0);
pcd = g_new( MultipointCreateData, 1);
@@ -397,7 +400,7 @@ read_entity_polyline_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
real line_width = DEFAULT_LINE_WIDTH;
real radius, start_angle = 0;
LineStyle style = LINESTYLE_SOLID;
- Layer *layer = dia->active_layer;
+ DiaLayer *layer = dia->active_layer;
RGB_t color = { 0, };
unsigned char closed = 0;
int points = 0;
@@ -600,7 +603,7 @@ read_entity_circle_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
GPtrArray *props;
real line_width = DEFAULT_LINE_WIDTH;
- Layer *layer = dia->active_layer;
+ DiaLayer *layer = dia->active_layer;
do {
if(read_dxf_codes(filedxf, data) == FALSE){
@@ -676,7 +679,7 @@ read_entity_arc_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
GPtrArray *props;
real line_width = DEFAULT_LINE_WIDTH;
- Layer *layer = dia->active_layer;
+ DiaLayer *layer = dia->active_layer;
do {
if(read_dxf_codes(filedxf, data) == FALSE){
@@ -766,7 +769,7 @@ read_entity_ellipse_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
GPtrArray *props;
real line_width = DEFAULT_LINE_WIDTH;
- Layer *layer = dia->active_layer;
+ DiaLayer *layer = dia->active_layer;
do {
if(read_dxf_codes(filedxf, data) == FALSE){
@@ -850,7 +853,7 @@ read_entity_text_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
TextProperty *tprop;
GPtrArray *props;
- Layer *layer = dia->active_layer;
+ DiaLayer *layer = dia->active_layer;
do {
if (read_dxf_codes(filedxf, data) == FALSE) {
@@ -980,27 +983,28 @@ read_entity_text_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
/* reads the layer table from the dxf file and creates the layers */
static void
-read_table_layer_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
+read_table_layer_dxf (FILE *filedxf, DxfData *data, DiagramData *dia)
{
- Layer *layer = NULL;
- int color_index;
-
- do {
- if (read_dxf_codes(filedxf, data) == FALSE)
- return;
- switch (data->code) {
- case 2 : /* layer name */
- layer = layer_find_by_name( data->value, dia );
- break;
- case 62 : /* Color number, if negative layer is off */
- color_index = atoi(data->value);
- if (layer && color_index < 0)
- layer->visible = FALSE;
- else
- _dxf_color_set_by_layer (layer, color_index);
- break;
- }
- } while ((data->code != 0) || (strcmp(data->value, "ENDTAB") != 0));
+ DiaLayer *layer = NULL;
+ int color_index;
+
+ do {
+ if (read_dxf_codes (filedxf, data) == FALSE)
+ return;
+
+ switch (data->code) {
+ case 2 : /* layer name */
+ layer = layer_find_by_name( data->value, dia );
+ break;
+ case 62 : /* Color number, if negative layer is off */
+ color_index = atoi(data->value);
+ if (layer && color_index < 0)
+ dia_layer_set_visible (layer, FALSE);
+ else
+ _dxf_color_set_by_layer (layer, color_index);
+ break;
+ }
+ } while ((data->code != 0) || (strcmp (data->value, "ENDTAB") != 0));
}
/* reads a scale entity from the dxf file */
@@ -1199,7 +1203,7 @@ read_section_blocks_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
int group_items = 0, group = 0;
GList *group_list = NULL;
DiaObject *obj = NULL;
- Layer *group_layer = NULL;
+ DiaLayer *group_layer = NULL;
if (read_dxf_codes(filedxf, data) == FALSE){
return;
diff --git a/plug-ins/hpgl/hpgl.c b/plug-ins/hpgl/hpgl.c
index 1732ad7c..cfdbd591 100644
--- a/plug-ins/hpgl/hpgl.c
+++ b/plug-ins/hpgl/hpgl.c
@@ -42,6 +42,7 @@
#include "diarenderer.h"
#include "filter.h"
#include "plug-ins.h"
+#include "font.h"
/* #DEFINE DEBUG_HPGL */
diff --git a/plug-ins/pstricks/render_pstricks.c b/plug-ins/pstricks/render_pstricks.c
index 4197110a..ec6ac838 100644
--- a/plug-ins/pstricks/render_pstricks.c
+++ b/plug-ins/pstricks/render_pstricks.c
@@ -58,6 +58,7 @@ NOT WORKING (exporting macros):
#include "diagramdata.h"
#include "dia_image.h"
#include "filter.h"
+#include "font.h"
#define POINTS_in_INCH 28.346
#define DTOSTR_BUF_SIZE G_ASCII_DTOSTR_BUF_SIZE
diff --git a/plug-ins/python/pydia-diagramdata.c b/plug-ins/python/pydia-diagramdata.c
index 98e186af..2ce388e2 100644
--- a/plug-ins/python/pydia-diagramdata.c
+++ b/plug-ins/python/pydia-diagramdata.c
@@ -113,20 +113,22 @@ PyDiaDiagramData_GetSortedSelected(PyDiaDiagramData *self, PyObject *args)
}
static PyObject *
-PyDiaDiagramData_AddLayer(PyDiaDiagramData *self, PyObject *args)
+PyDiaDiagramData_AddLayer (PyDiaDiagramData *self, PyObject *args)
{
- gchar *name;
- int pos = -1;
- Layer *layer;
-
- if (!PyArg_ParseTuple(args, "s|i:DiagramData.add_layer", &name, &pos))
- return NULL;
- layer = new_layer(g_strdup(name),self->data);
- if (pos != -1)
- data_add_layer_at(self->data, layer, pos);
- else
- data_add_layer(self->data, layer);
- return PyDiaLayer_New(layer);
+ gchar *name;
+ int pos = -1;
+ DiaLayer *layer;
+
+ if (!PyArg_ParseTuple(args, "s|i:DiagramData.add_layer", &name, &pos))
+ return NULL;
+
+ layer = dia_layer_new (name, self->data);
+ if (pos != -1) {
+ data_add_layer_at(self->data, layer, pos);
+ } else {
+ data_add_layer (self->data, layer);
+ }
+ return PyDiaLayer_New (layer);
}
static PyObject *
@@ -171,16 +173,17 @@ PyDiaDiagramData_SetActiveLayer(PyDiaDiagramData *self, PyObject *args)
static PyObject *
PyDiaDiagramData_DeleteLayer(PyDiaDiagramData *self, PyObject *args)
{
- PyDiaLayer *layer;
+ PyDiaLayer *layer;
- if (!PyArg_ParseTuple(args, "O!:DiagramData.delete_layer",
- &PyDiaLayer_Type, &layer))
- return NULL;
- data_remove_layer(self->data, layer->layer);
- layer_destroy(layer->layer);
- layer->layer = NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ if (!PyArg_ParseTuple(args, "O!:DiagramData.delete_layer",
+ &PyDiaLayer_Type, &layer))
+ return NULL;
+
+ data_remove_layer (self->data, layer->layer);
+ dia_layer_destroy (layer->layer);
+ layer->layer = NULL;
+ Py_INCREF (Py_None);
+ return Py_None;
}
/*!
@@ -193,7 +196,7 @@ PyDiaDiagramData_DeleteLayer(PyDiaDiagramData *self, PyObject *args)
* @param user_data The python function to be called by the callback.
*/
static void
-PyDiaDiagramData_CallbackObject(DiagramData *dia,Layer *layer,DiaObject *obj,void *user_data)
+PyDiaDiagramData_CallbackObject(DiagramData *dia, DiaLayer *layer, DiaObject *obj, void *user_data)
{
PyObject *pydata,*pylayer,*pyobj,*res,*arg;
PyObject *func = user_data;
diff --git a/plug-ins/python/pydia-layer.c b/plug-ins/python/pydia-layer.c
index bb555181..b0c1f75b 100644
--- a/plug-ins/python/pydia-layer.c
+++ b/plug-ins/python/pydia-layer.c
@@ -28,15 +28,15 @@
#include <structmember.h> /* PyMemberDef */
PyObject *
-PyDiaLayer_New(Layer *layer)
+PyDiaLayer_New(DiaLayer *layer)
{
- PyDiaLayer *self;
+ PyDiaLayer *self;
- self = PyObject_NEW(PyDiaLayer, &PyDiaLayer_Type);
+ self = PyObject_NEW (PyDiaLayer, &PyDiaLayer_Type);
- if (!self) return NULL;
- self->layer = layer;
- return (PyObject *)self;
+ if (!self) return NULL;
+ self->layer = layer;
+ return (PyObject *)self;
}
static void
@@ -62,7 +62,7 @@ PyDiaLayer_Hash(PyDiaLayer *self)
static PyObject *
PyDiaLayer_Str(PyDiaLayer *self)
{
- return PyString_FromString(self->layer->name);
+ return PyString_FromString (dia_layer_get_name (self->layer));
}
/* methods here */
@@ -287,26 +287,30 @@ PyDiaLayer_GetAttr(PyDiaLayer *self, gchar *attr)
{
if (!strcmp (attr, "__members__"))
return Py_BuildValue ("[ssss]", "extents", "name", "objects", "visible");
- else if (!strcmp (attr, "name"))
- return PyString_FromString (self->layer->name);
- else if (!strcmp (attr, "extents"))
+ else if (!strcmp (attr, "name")) {
+ return PyString_FromString (dia_layer_get_name (self->layer));
+ } else if (!strcmp (attr, "extents")) {
+ Rectangle extents;
+
+ dia_layer_get_extents (self->layer, &extents);
+
return Py_BuildValue ("(dddd)",
- self->layer->extents.top,
- self->layer->extents.left,
- self->layer->extents.bottom,
- self->layer->extents.right);
- else if (!strcmp (attr, "objects")) {
+ extents.top,
+ extents.left,
+ extents.bottom,
+ extents.right);
+ } else if (!strcmp (attr, "objects")) {
PyObject *ret;
GList *tmp;
gint i;
- ret = PyTuple_New (g_list_length (self->layer->objects));
- for (i = 0, tmp = self->layer->objects; tmp; i++, tmp = tmp->next) {
+ ret = PyTuple_New (g_list_length (dia_layer_get_object_list (self->layer)));
+ for (i = 0, tmp = dia_layer_get_object_list (self->layer); tmp; i++, tmp = tmp->next) {
PyTuple_SetItem (ret, i, PyDiaObject_New ((DiaObject *)tmp->data));
}
return ret;
} else if (!strcmp (attr, "visible")) {
- return PyInt_FromLong (self->layer->visible);
+ return PyInt_FromLong (dia_layer_is_visible (self->layer));
}
return Py_FindMethod (PyDiaLayer_Methods, (PyObject *) self, attr);
diff --git a/plug-ins/python/pydia-layer.h b/plug-ins/python/pydia-layer.h
index c20cd790..a08c4462 100644
--- a/plug-ins/python/pydia-layer.h
+++ b/plug-ins/python/pydia-layer.h
@@ -25,13 +25,13 @@
#include "diagramdata.h"
typedef struct {
- PyObject_HEAD
- Layer *layer;
+ PyObject_HEAD
+ DiaLayer *layer;
} PyDiaLayer;
extern PyTypeObject PyDiaLayer_Type;
-PyObject *PyDiaLayer_New(Layer *layer);
+PyObject *PyDiaLayer_New (DiaLayer *layer);
#endif
diff --git a/plug-ins/python/pydia-render.c b/plug-ins/python/pydia-render.c
index f9419a75..3c499452 100644
--- a/plug-ins/python/pydia-render.c
+++ b/plug-ins/python/pydia-render.c
@@ -398,9 +398,9 @@ is_capable_to (DiaRenderer *renderer, RenderCapability cap)
*/
static void
draw_layer (DiaRenderer *renderer,
- Layer *layer,
- gboolean active,
- Rectangle *update)
+ DiaLayer *layer,
+ gboolean active,
+ Rectangle *update)
{
PyObject *func, *res, *arg, *self = PYDIA_RENDERER (renderer);
diff --git a/plug-ins/svg/render_svg.c b/plug-ins/svg/render_svg.c
index d1f171d0..b5396ffd 100644
--- a/plug-ins/svg/render_svg.c
+++ b/plug-ins/svg/render_svg.c
@@ -101,9 +101,9 @@ GType svg_renderer_get_type (void) G_GNUC_CONST;
static DiaSvgRenderer *new_svg_renderer(DiagramData *data, const char *filename);
static void draw_layer (DiaRenderer *self,
- Layer *layer,
- gboolean active,
- Rectangle *update);
+ DiaLayer *layer,
+ gboolean active,
+ Rectangle *update);
static void draw_object (DiaRenderer *renderer,
DiaObject *object,
DiaMatrix *matrix);
@@ -297,9 +297,9 @@ new_svg_renderer(DiagramData *data, const char *filename)
*/
static void
draw_layer (DiaRenderer *self,
- Layer *layer,
- gboolean active,
- Rectangle *update)
+ DiaLayer *layer,
+ gboolean active,
+ Rectangle *update)
{
DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
SvgRenderer *svg_renderer = SVG_RENDERER (self);
@@ -310,8 +310,11 @@ draw_layer (DiaRenderer *self,
/* modifying the root pointer so everything below us gets into the new node */
renderer->root = layer_group = xmlNewNode (renderer->svg_name_space, (const xmlChar *)"g");
- if (layer->name)
- xmlSetProp(renderer->root, (const xmlChar *)"id", (xmlChar *) layer->name);
+ if (dia_layer_get_name (layer)) {
+ xmlSetProp (renderer->root,
+ (const xmlChar *) "id",
+ (xmlChar *) dia_layer_get_name (layer));
+ }
DIA_RENDERER_CLASS (parent_class)->draw_layer (self, layer, active, update);
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index db394136..b2872203 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -1905,13 +1905,13 @@ import_shape_info (xmlNodePtr start_node, DiagramData *dia, DiaContext *ctx)
const DiaObjectType *ot_cp = object_get_type ("Shape Design - Connection Point");
const DiaObjectType *ot_mp = object_get_type ("Shape Design - Main Connection Point");
xmlNodePtr node;
- Layer *layer;
+ DiaLayer *layer;
if (!ot_cp || !ot_mp) {
dia_context_add_message (ctx, _("'Shape Design' shapes missing."));
return FALSE;
}
- layer = dia_layer_new (g_strdup ("Shape Design"), dia);
+ layer = dia_layer_new ("Shape Design", dia);
data_add_layer (dia, layer);
for (node = start_node; node != NULL; node = node->next) {
@@ -2105,7 +2105,9 @@ import_svg (xmlDocPtr doc, DiagramData *dia,
if (groups_to_layers) {
gchar *name = dia_object_get_meta (obj, "id");
/* new_layer() is taking ownership of the name */
- Layer *layer = dia_layer_new (name, dia);
+ DiaLayer *layer = dia_layer_new (name, dia);
+
+ g_free (name);
/* keep the group for potential transformation */
dia_layer_add_object (layer, obj);
diff --git a/plug-ins/vdx/vdx-export.c b/plug-ins/vdx/vdx-export.c
index 984abaf4..d126128d 100644
--- a/plug-ins/vdx/vdx-export.c
+++ b/plug-ins/vdx/vdx-export.c
@@ -1756,7 +1756,7 @@ export_vdx(DiagramData *data, DiaContext *ctx,
FILE *file;
VDXRenderer *renderer;
int i;
- Layer *layer;
+ DiaLayer *layer;
char* old_locale;
file = g_fopen(filename, "w");
@@ -1783,8 +1783,8 @@ export_vdx(DiagramData *data, DiaContext *ctx,
/* First run through without drawing to setup tables */
for (i = 0; i < data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index (data->layers, i);
- if (layer->visible) {
+ layer = DIA_LAYER (g_ptr_array_index (data->layers, i));
+ if (dia_layer_is_visible (layer)) {
dia_layer_render (layer, DIA_RENDERER (renderer), NULL, NULL, data, 0);
}
renderer->depth++;
@@ -1801,8 +1801,8 @@ export_vdx(DiagramData *data, DiaContext *ctx,
/* Now render */
for (i = 0; i < data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index (data->layers, i);
- if (layer->visible) {
+ layer = DIA_LAYER (g_ptr_array_index (data->layers, i));
+ if (dia_layer_is_visible (layer)) {
dia_layer_render (layer, DIA_RENDERER (renderer), NULL, NULL, data, 0);
}
renderer->depth++;
diff --git a/plug-ins/vdx/vdx-import.c b/plug-ins/vdx/vdx-import.c
index 697bee4b..73841882 100644
--- a/plug-ins/vdx/vdx-import.c
+++ b/plug-ins/vdx/vdx-import.c
@@ -2678,7 +2678,7 @@ vdx_parse_shape(xmlNodePtr Shape, struct vdx_PageSheet *PageSheet,
GSList *object;
struct vdx_LayerMem *LayerMem = NULL;
unsigned int dia_layer_num = 0;
- Layer *diaLayer = NULL;
+ DiaLayer *diaLayer = NULL;
char *name = NULL;
if (theDoc->PageLayers)
@@ -2734,27 +2734,26 @@ vdx_parse_shape(xmlNodePtr Shape, struct vdx_PageSheet *PageSheet,
layer_num);
if (theDoc->debug_comments)
g_debug("Layer %d -> %d", layer_num, dia_layer_num);
- }
- else
- {
- if (theDoc->debug_comments)
- g_debug("Layer %d", dia_layer_num);
- }
- diaLayer = (Layer *)g_ptr_array_index(dia->layers, dia_layer_num);
-
- /* Draw the shape (or group) and get list of created objects */
- objects = vdx_plot_shape(&theShape, objects, 0, theDoc, ctx);
-
- /* Add the objects straight into the diagram */
- /* This isn't strictly correct as a child object can be on a
- different layer from its parent. */
- for (object = objects; object; object = object->next) {
- if (!object->data) continue;
- dia_layer_add_object (diaLayer, (DiaObject *)object->data);
- }
-
- free_children(&theShape);
- g_slist_free(objects);
+ } else {
+ if (theDoc->debug_comments)
+ g_debug("Layer %d", dia_layer_num);
+ }
+ diaLayer = DIA_LAYER (g_ptr_array_index (dia->layers, dia_layer_num));
+
+ /* Draw the shape (or group) and get list of created objects */
+ objects = vdx_plot_shape (&theShape, objects, 0, theDoc, ctx);
+
+ /* Add the objects straight into the diagram */
+ /* This isn't strictly correct as a child object can be on a
+ different layer from its parent. */
+ for (object = objects; object; object = object->next) {
+ if (!object->data) continue;
+
+ dia_layer_add_object (diaLayer, DIA_OBJECT (object->data));
+ }
+
+ free_children (&theShape);
+ g_slist_free (objects);
}
/** Parse the pages of the VDX
@@ -2773,7 +2772,7 @@ vdx_setup_layers(struct vdx_PageSheet* PageSheet, VDXDocument* theDoc,
GSList *layername = NULL;
struct vdx_any* Any;
struct vdx_Layer *theLayer;
- Layer *diaLayer = 0;
+ DiaLayer *diaLayer = 0;
unsigned int found_layer, page_layer;
gboolean found;
@@ -2824,8 +2823,8 @@ vdx_setup_layers(struct vdx_PageSheet* PageSheet, VDXDocument* theDoc,
if (!found)
{
g_array_append_val(theDoc->LayerNames, layername->data);
- diaLayer = dia_layer_new (g_strdup ((char*)layername->data), dia);
- data_add_layer(dia, diaLayer);
+ diaLayer = dia_layer_new (((char*) layername->data), dia);
+ data_add_layer (dia, diaLayer);
}
page_layer++;
g_array_prepend_val(theDoc->PageLayers, page_layer);
diff --git a/plug-ins/wpg/wpg-import.c b/plug-ins/wpg/wpg-import.c
index 199a245c..e52f7659 100644
--- a/plug-ins/wpg/wpg-import.c
+++ b/plug-ins/wpg/wpg-import.c
@@ -30,6 +30,7 @@
#include "intl.h"
#include "message.h" /* just dia_log_message() */
#include "dia-layer.h"
+#include "font.h"
typedef struct _WpgImportRenderer WpgImportRenderer;
diff --git a/plug-ins/wpg/wpg.c b/plug-ins/wpg/wpg.c
index 326e489a..ff54fde0 100644
--- a/plug-ins/wpg/wpg.c
+++ b/plug-ins/wpg/wpg.c
@@ -41,6 +41,7 @@
#include "diarenderer.h"
#include "filter.h"
#include "plug-ins.h"
+#include "font.h"
/* Noise reduction for
* return value of 'fwrite', declared with attribute warn_unused_result
diff --git a/plug-ins/xfig/xfig-export.c b/plug-ins/xfig/xfig-export.c
index c6851da0..f93ac572 100644
--- a/plug-ins/xfig/xfig-export.c
+++ b/plug-ins/xfig/xfig-export.c
@@ -1153,14 +1153,16 @@ export_fig(DiagramData *data, DiaContext *ctx,
FILE *file;
XfigRenderer *renderer;
int i;
- Layer *layer;
+ DiaLayer *layer;
gchar d_buf[DTOSTR_BUF_SIZE];
file = g_fopen(filename, "w");
if (file == NULL) {
- dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
- dia_context_get_filename(ctx));
+ dia_context_add_message_with_errno (ctx,
+ errno,
+ _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
return FALSE;
}
@@ -1183,8 +1185,8 @@ export_fig(DiagramData *data, DiaContext *ctx,
dia_renderer_begin_render (DIA_RENDERER (renderer), NULL);
for (i = 0; i < data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index (data->layers, i);
- if (layer->visible) {
+ layer = DIA_LAYER (g_ptr_array_index (data->layers, i));
+ if (dia_layer_is_visible (layer)) {
dia_layer_render (layer, DIA_RENDERER (renderer), NULL, NULL, data, 0);
renderer->depth++;
}
@@ -1197,8 +1199,8 @@ export_fig(DiagramData *data, DiaContext *ctx,
dia_renderer_begin_render (DIA_RENDERER (renderer), NULL);
for (i=0; i<data->layers->len; i++) {
- layer = (Layer *) g_ptr_array_index (data->layers, i);
- if (layer->visible) {
+ layer = DIA_LAYER (g_ptr_array_index (data->layers, i));
+ if (dia_layer_is_visible (layer)) {
dia_layer_render (layer, DIA_RENDERER (renderer), NULL, NULL, data, 0);
renderer->depth++;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]