[dia] Bug 155929 - Snap-to settings not saved
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Bug 155929 - Snap-to settings not saved
- Date: Fri, 8 Oct 2010 18:55:00 +0000 (UTC)
commit c264da6b805c5f618127fd1c9f4b9ddb0b26549b
Author: Hans Breuer <hans breuer org>
Date: Fri Oct 8 20:41:32 2010 +0200
Bug 155929 - Snap-to settings not saved
Some display settings are now saved: antialiased, snap-to-grid,
snap-to-object, show-grid and show-connection-points.
Implementation is a bit hacky, there are just some magic numbers
stored with the diagram object and used during new_display.c().
app/display.c | 16 +++++++++++++++
app/load_save.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/app/display.c b/app/display.c
index 363ebb3..c39d42d 100644
--- a/app/display.c
+++ b/app/display.c
@@ -276,6 +276,7 @@ new_display(Diagram *dia)
{
DDisplay *ddisp;
Rectangle visible;
+ int preset;
ddisp = g_new0(DDisplay,1);
@@ -284,14 +285,29 @@ new_display(Diagram *dia)
g_object_ref(dia);
ddisp->grid.visible = prefs.grid.visible;
+ preset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(dia), "show-grid"));
+ if (preset != 0)
+ ddisp->grid.visible = (preset > 0 ? TRUE : FALSE);
ddisp->grid.snap = prefs.grid.snap;
+ preset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(dia), "snap-to-grid"));
+ if (preset != 0)
+ ddisp->grid.snap = (preset > 0 ? TRUE : FALSE);
ddisp->show_cx_pts = prefs.show_cx_pts;
+ preset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(dia), "show-connection-points"));
+ if (preset != 0)
+ ddisp->show_cx_pts = (preset > 0 ? TRUE : FALSE);
ddisp->autoscroll = TRUE;
ddisp->mainpoint_magnetism = prefs.snap_object;
+ preset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(dia), "snap-to-object"));
+ if (preset != 0)
+ ddisp->mainpoint_magnetism = (preset > 0 ? TRUE : FALSE);
ddisp->aa_renderer = prefs.view_antialised;
+ preset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(dia), "antialiased"));
+ if (preset != 0)
+ ddisp->aa_renderer = (preset > 0 ? TRUE : FALSE);
ddisp->update_areas = NULL;
ddisp->display_areas = NULL;
diff --git a/app/load_save.c b/app/load_save.c
index dd52e45..9c37d8e 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -610,7 +610,42 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
}
}
}
+ /* parse some display settings */
+ if (diagram) {
+ attr = composite_find_attribute(diagramdata, "display");
+ if (attr != NULL) {
+ DataNode dispinfo;
+
+ dispinfo = attribute_first_data(attr);
+ /* using the diagramdata object as temporary storage is a bit hacky,
+ * and also the magic numbers (keeping 0 as dont care) */
+
+ attr = composite_find_attribute(dispinfo, "antialiased");
+ if (attr != NULL)
+ g_object_set_data(G_OBJECT(diagram),
+ "antialiased", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+
+ attr = composite_find_attribute(dispinfo, "snap-to-grid");
+ if (attr != NULL)
+ g_object_set_data(G_OBJECT(diagram),
+ "snap-to-grid", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+ attr = composite_find_attribute(dispinfo, "snap-to-object");
+ if (attr != NULL)
+ g_object_set_data(G_OBJECT(diagram),
+ "snap-to-object", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+
+ attr = composite_find_attribute(dispinfo, "show-grid");
+ if (attr != NULL)
+ g_object_set_data(G_OBJECT(diagram),
+ "show-grid", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+
+ attr = composite_find_attribute(dispinfo, "show-connection-points");
+ if (attr != NULL)
+ g_object_set_data(G_OBJECT(diagram),
+ "show-connection-points", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+ }
+ }
/* Read in all layers: */
layer_node =
find_node_named (doc->xmlRootNode->xmlChildrenNode, "layer");
@@ -919,7 +954,26 @@ diagram_data_write_doc(DiagramData *data, const char *filename)
data_add_real(attr, diagram->guides.hguides[i]);
attr = composite_add_attribute(guideinfo, "vguides");
for (i = 0; i < diagram->guides.nvguides; i++)
- data_add_real(attr, diagram->guides.vguides[i]);
+ data_add_real(attr, diagram->guides.vguides[i]);
+
+ if (g_slist_length(diagram->displays) == 1) {
+ xmlNodePtr dispinfo;
+ /* store some display attributes */
+ DDisplay *ddisp = diagram->displays->data;
+
+ attr = new_attribute((ObjectNode)tree, "display");
+ dispinfo = data_add_composite(attr, "display");
+ data_add_boolean(composite_add_attribute(dispinfo, "antialiased"),
+ ddisp->aa_renderer);
+ data_add_boolean(composite_add_attribute(dispinfo, "snap-to-grid"),
+ ddisp->grid.snap);
+ data_add_boolean(composite_add_attribute(dispinfo, "snap-to-object"),
+ ddisp->mainpoint_magnetism);
+ data_add_boolean(composite_add_attribute(dispinfo, "show-grid"),
+ ddisp->grid.visible);
+ data_add_boolean(composite_add_attribute(dispinfo, "show-connection-points"),
+ ddisp->show_cx_pts);
+ }
}
objects_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]