[gnumeric] Conf: Don't cache page setup. (Let gconf handle all caching.)



commit 015ac98305e58d5a529e5bdb08cef76c5558d4b1
Author: Morten Welinder <terra gnome org>
Date:   Sun Jun 28 21:48:22 2009 -0400

    Conf: Don't cache page setup.  (Let gconf handle all caching.)

 src/gnumeric-gconf.c |   98 +++++++++++++++++++++----------------------------
 src/print-info.c     |    2 +-
 src/print.c          |    2 +-
 3 files changed, 44 insertions(+), 58 deletions(-)
---
diff --git a/src/gnumeric-gconf.c b/src/gnumeric-gconf.c
index 0d44daa..da1b0ee 100644
--- a/src/gnumeric-gconf.c
+++ b/src/gnumeric-gconf.c
@@ -48,7 +48,6 @@
 #endif
 
 static GOConfNode *root = NULL;
-static GtkPageSetup *page_setup = NULL;
 
 /*
  * Hashes to simply ownership rules.  We use this so none of the getters
@@ -79,8 +78,6 @@ gnm_conf_init (void)
 void
 gnm_conf_shutdown (void)
 {
-	gnm_conf_set_page_setup (NULL);
-
 	g_hash_table_destroy (string_pool);
 	string_pool = NULL;
 
@@ -100,33 +97,31 @@ gnm_conf_get_root (void)
 GtkPageSetup *
 gnm_conf_get_page_setup (void)
 {
-	if (!page_setup) {
-		page_setup = gtk_page_setup_new ();
-
-		page_setup_set_paper (page_setup,
-				      gnm_conf_get_printsetup_paper ());
-
-		gtk_page_setup_set_orientation
-			(page_setup,
-			 gnm_conf_get_printsetup_paper_orientation ());
-
-		gtk_page_setup_set_top_margin
-			(page_setup,
-			 gnm_conf_get_printsetup_margin_gtk_top (),
-			 GTK_UNIT_POINTS);
-		gtk_page_setup_set_bottom_margin
-			(page_setup,
-			 gnm_conf_get_printsetup_margin_gtk_bottom (),
-			 GTK_UNIT_POINTS);
-		gtk_page_setup_set_left_margin
-			(page_setup,
-			 gnm_conf_get_printsetup_margin_gtk_left (),
-			 GTK_UNIT_POINTS);
-		gtk_page_setup_set_right_margin
-			(page_setup,
-			 gnm_conf_get_printsetup_margin_gtk_right (),
-			 GTK_UNIT_POINTS);
-	}
+	GtkPageSetup *page_setup = gtk_page_setup_new ();
+
+	page_setup_set_paper (page_setup,
+			      gnm_conf_get_printsetup_paper ());
+
+	gtk_page_setup_set_orientation
+		(page_setup,
+		 gnm_conf_get_printsetup_paper_orientation ());
+
+	gtk_page_setup_set_top_margin
+		(page_setup,
+		 gnm_conf_get_printsetup_margin_gtk_top (),
+		 GTK_UNIT_POINTS);
+	gtk_page_setup_set_bottom_margin
+		(page_setup,
+		 gnm_conf_get_printsetup_margin_gtk_bottom (),
+		 GTK_UNIT_POINTS);
+	gtk_page_setup_set_left_margin
+		(page_setup,
+		 gnm_conf_get_printsetup_margin_gtk_left (),
+		 GTK_UNIT_POINTS);
+	gtk_page_setup_set_right_margin
+		(page_setup,
+		 gnm_conf_get_printsetup_margin_gtk_right (),
+		 GTK_UNIT_POINTS);
 
 	return page_setup;
 }
@@ -134,32 +129,23 @@ gnm_conf_get_page_setup (void)
 void
 gnm_conf_set_page_setup (GtkPageSetup *setup)
 {
-	if (page_setup) {
-		g_object_unref (page_setup);
-		page_setup = NULL;
-	}
+	char *paper;
 
-	if (setup) {
-		char *paper;
+	paper = page_setup_get_paper (setup);
+	gnm_conf_set_printsetup_paper (paper);
+	g_free (paper);
 
-		page_setup = gtk_page_setup_copy (setup);
+	gnm_conf_set_printsetup_paper_orientation
+		(gtk_page_setup_get_orientation (setup));
 
-		paper = page_setup_get_paper (setup);
-		gnm_conf_set_printsetup_paper (paper);
-		g_free (paper);
-
-		gnm_conf_set_printsetup_paper_orientation
-			(gtk_page_setup_get_orientation (setup));
-
-		gnm_conf_set_printsetup_margin_gtk_top
-			(gtk_page_setup_get_top_margin (setup, GTK_UNIT_POINTS));
-		gnm_conf_set_printsetup_margin_gtk_bottom
-			(gtk_page_setup_get_bottom_margin (setup, GTK_UNIT_POINTS));
-		gnm_conf_set_printsetup_margin_gtk_left
-			(gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS));
-		gnm_conf_set_printsetup_margin_gtk_right
-			(gtk_page_setup_get_right_margin (setup, GTK_UNIT_POINTS));
-	}
+	gnm_conf_set_printsetup_margin_gtk_top
+		(gtk_page_setup_get_top_margin (setup, GTK_UNIT_POINTS));
+	gnm_conf_set_printsetup_margin_gtk_bottom
+		(gtk_page_setup_get_bottom_margin (setup, GTK_UNIT_POINTS));
+	gnm_conf_set_printsetup_margin_gtk_left
+		(gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS));
+	gnm_conf_set_printsetup_margin_gtk_right
+		(gtk_page_setup_get_right_margin (setup, GTK_UNIT_POINTS));
 }
 
 GnmStyle *
diff --git a/src/print-info.c b/src/print-info.c
index 7e2b955..2e5a248 100644
--- a/src/print-info.c
+++ b/src/print-info.c
@@ -232,7 +232,7 @@ print_info_load_defaults (PrintInformation *res)
 	if (res->page_setup != NULL)
 		return res;
 
-	res->page_setup = gtk_page_setup_copy (gnm_conf_get_page_setup ());
+	res->page_setup = gnm_conf_get_page_setup ();
 
 	res->scaling.type = gnm_conf_get_printsetup_scale_percentage ()
 		? PRINT_SCALE_PERCENTAGE
diff --git a/src/print.c b/src/print.c
index 5a78b3e..5ecfa32 100644
--- a/src/print.c
+++ b/src/print.c
@@ -318,7 +318,7 @@ ensure_decoration_layout (GtkPrintContext   *context)
 	PangoLayout *layout;
 
 	layout = gtk_print_context_create_pango_layout (context);
-	style = gnm_style_dup (gnm_conf_get_printer_decoration_font ());
+	style = gnm_conf_get_printer_decoration_font ();
 	font = gnm_style_get_font
 		(style,
 		 pango_layout_get_context (layout),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]