gnumeric r16766 - in trunk: . src



Author: guelzow
Date: Sun Aug 31 05:15:51 2008
New Revision: 16766
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16766&view=rev

Log:
2008-08-25  Andreas Guelzow  <aguelzow pyrshep ca>

	Implementation of #525368
	* src/print.c (PrintingInstance): add button_print_hidden_sheets
	(compute_pages): Include PRINT_ALL_SHEETS_INCLUDING_HIDDEN and exclude
	  hidden sheets from  PRINT_ALL_SHEETS. Rewrite  PRINT_SHEET_RANGE
	(workbook_visible_sheet_count): new
	(gnm_create_widget_cb): add checkbox
	(gnm_custom_widget_apply_cb): handle new checkbox
	* src/print.h (PrintRange): add PRINT_ALL_SHEETS_INCLUDING_HIDDEN



Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/src/print.c
   trunk/src/print.h

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Sun Aug 31 05:15:51 2008
@@ -1,3 +1,10 @@
+Gnumeric 1.9.3
+
+Andreas:
+	* Do not print hidden sheets. [#525368]
+
+
+--------------------------------------------------------------------------
 Gnumeric 1.9.2
 
 Andreas:

Modified: trunk/src/print.c
==============================================================================
--- trunk/src/print.c	(original)
+++ trunk/src/print.c	Sun Aug 31 05:15:51 2008
@@ -67,7 +67,7 @@
 	Sheet *sheet;
 	GtkWidget *button_all_sheets, *button_selected_sheet,
 		*button_spec_sheets;
-	GtkWidget *button_selection, *button_ignore_printarea;
+	GtkWidget *button_selection, *button_ignore_printarea, *button_print_hidden_sheets;
 	GtkWidget *spin_from, *spin_to;
 	PrintRange pr;
 	guint to, from;
@@ -1000,6 +1000,7 @@
 	Workbook *wb = pi->wb;
 	guint i;
 	guint n;
+	guint ct;
 
 	switch (pr) {
 	case PRINT_ACTIVE_SHEET:
@@ -1011,15 +1012,15 @@
 			Sheet *sheet = workbook_sheet_by_index (wb, i);
 			if (sheet->print_info->do_not_print)
 				continue;
+			if (!sheet_is_visible(sheet))
+				continue;			
 			compute_sheet_pages_add_sheet (pi, sheet,
 						       FALSE, FALSE);
 		}
 		break;
-	case PRINT_SHEET_RANGE:
+	case PRINT_ALL_SHEETS_INCLUDING_HIDDEN:
 		n = workbook_sheet_count (wb);
-		if (to > n)
-			to = n;
-		for (i = from - 1; i < to; i++){
+		for (i = 0; i < n; i++) {
 			Sheet *sheet = workbook_sheet_by_index (wb, i);
 			if (sheet->print_info->do_not_print)
 				continue;
@@ -1027,6 +1028,24 @@
 						       FALSE, FALSE);
 		}
 		break;
+	case PRINT_SHEET_RANGE:
+		if (from > to)
+			break;
+		n = workbook_sheet_count (wb);
+		ct = 0;
+		for (i = 0; i < n; i++){
+			Sheet *sheet = workbook_sheet_by_index (wb, i);
+			if (sheet_is_visible(sheet))
+				ct++;
+			else
+				continue;
+			if (sheet->print_info->do_not_print)
+				continue;
+			if ((ct >= from) && (ct <= to))
+				compute_sheet_pages_add_sheet (pi, sheet,
+							       FALSE, FALSE);
+		}
+		break;
 	case PRINT_SHEET_SELECTION:
 		compute_sheet_pages_add_sheet (pi, pi->sheet, TRUE, FALSE);
 		break;
@@ -1229,6 +1248,21 @@
 	gtk_widget_set_sensitive (check, gtk_toggle_button_get_active (togglebutton));
 }
 
+static guint
+workbook_visible_sheet_count (Workbook *wb)
+{
+	guint i;
+	guint n = workbook_sheet_count (wb);
+	guint count = 0;
+	
+	for (i = 0; i < n; i++) {
+		Sheet *sheet = workbook_sheet_by_index (wb, i);
+		if (sheet_is_visible(sheet))
+			count++;		
+	}	
+	return count;	
+}
+
 static GObject*
 gnm_create_widget_cb (GtkPrintOperation *operation, gpointer user_data)
 {
@@ -1236,16 +1270,17 @@
 	GtkWidget *frame, *table;
 	GtkWidget *button_all_sheets, *button_selected_sheet, *button_spec_sheets;
 	GtkWidget *button_selection, *button_ignore_printarea;
+	GtkWidget *button_print_hidden_sheets;
 	GtkWidget *label_from, *label_to;
 	GtkWidget *spin_from, *spin_to;
 	GtkPrintSettings * settings;
-	guint n_sheets = workbook_sheet_count (pi->wb);
+	guint n_sheets = workbook_visible_sheet_count (pi->wb);
 
 	frame = gtk_frame_new (NULL);
 	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
 	gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
 
-	table = gtk_table_new (7, 6, FALSE);
+	table = gtk_table_new (7, 7, FALSE);
 	gtk_table_set_col_spacing (GTK_TABLE (table), 1,20);
 	gtk_container_add (GTK_CONTAINER (frame), table);
 
@@ -1255,40 +1290,45 @@
 	gtk_table_attach (GTK_TABLE (table), button_all_sheets, 1, 3, 1, 2,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
+	button_print_hidden_sheets  = gtk_check_button_new_with_mnemonic
+		(_("Also print _hidden sheets"));
+	gtk_table_attach (GTK_TABLE (table), button_print_hidden_sheets, 2, 7, 2, 3,
+			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
+
 	button_selected_sheet = gtk_radio_button_new_with_mnemonic_from_widget
 		(GTK_RADIO_BUTTON (button_all_sheets), _("A_ctive workbook sheet"));
-	gtk_table_attach (GTK_TABLE (table), button_selected_sheet, 1, 3, 2, 3,
+	gtk_table_attach (GTK_TABLE (table), button_selected_sheet, 1, 3, 3, 4,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
 	button_spec_sheets = gtk_radio_button_new_with_mnemonic_from_widget
 		(GTK_RADIO_BUTTON (button_all_sheets), _("_Workbook sheets:"));
-	gtk_table_attach (GTK_TABLE (table), button_spec_sheets, 1, 3, 5, 6,
+	gtk_table_attach (GTK_TABLE (table), button_spec_sheets, 1, 3, 6, 7,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
 	button_selection = gtk_check_button_new_with_mnemonic
 		(_("Current _selection only"));
-	gtk_table_attach (GTK_TABLE (table), button_selection, 2, 7, 3, 4,
+	gtk_table_attach (GTK_TABLE (table), button_selection, 2, 7, 4, 5,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
 	button_ignore_printarea  = gtk_check_button_new_with_mnemonic
 		(_("_Ignore defined print area"));
-	gtk_table_attach (GTK_TABLE (table), button_ignore_printarea, 2, 7, 4, 5,
+	gtk_table_attach (GTK_TABLE (table), button_ignore_printarea, 2, 7, 5, 6,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
 	label_from = gtk_label_new (_("from:"));
-	gtk_table_attach (GTK_TABLE (table), label_from, 3, 4, 5, 6,
+	gtk_table_attach (GTK_TABLE (table), label_from, 3, 4, 6, 7,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
 	spin_from = gtk_spin_button_new_with_range (1, n_sheets, 1);
-	gtk_table_attach (GTK_TABLE (table), spin_from, 4, 5, 5, 6,
+	gtk_table_attach (GTK_TABLE (table), spin_from, 4, 5, 6, 7,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
 	label_to = gtk_label_new (_("to:"));
-	gtk_table_attach (GTK_TABLE (table), label_to, 5, 6, 5, 6,
+	gtk_table_attach (GTK_TABLE (table), label_to, 5, 6, 6, 7,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 
 	spin_to = gtk_spin_button_new_with_range (1, n_sheets, 1);
-	gtk_table_attach (GTK_TABLE (table), spin_to, 6, 7, 5, 6,
+	gtk_table_attach (GTK_TABLE (table), spin_to, 6, 7, 6, 7,
 			  GTK_EXPAND | GTK_FILL,GTK_SHRINK | GTK_FILL,0,0);
 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_to), n_sheets);
 
@@ -1297,6 +1337,9 @@
 	g_signal_connect_after (G_OBJECT (button_selected_sheet), "toggled",
 		G_CALLBACK (widget_button_cb), button_ignore_printarea);
 
+	g_signal_connect_after (G_OBJECT (button_all_sheets), "toggled",
+		G_CALLBACK (widget_button_cb), button_print_hidden_sheets);
+
 	g_signal_connect_after (G_OBJECT (button_spec_sheets), "toggled",
 		G_CALLBACK (widget_button_cb), label_from);
 	g_signal_connect_after (G_OBJECT (button_spec_sheets), "toggled",
@@ -1330,6 +1373,9 @@
 		case PRINT_SHEET_RANGE:
 			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_spec_sheets), TRUE);
 			break;
+		case PRINT_ALL_SHEETS_INCLUDING_HIDDEN:
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_print_hidden_sheets), TRUE);
+			/* no break */
 		case PRINT_ALL_SHEETS:
 			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_all_sheets), TRUE);
 			break;
@@ -1358,6 +1404,7 @@
 	pi->button_spec_sheets = button_spec_sheets;
 	pi->button_selection = button_selection;
 	pi->button_ignore_printarea = button_ignore_printarea;
+	pi->button_print_hidden_sheets = button_print_hidden_sheets;
 	pi->spin_from = spin_from;
 	pi->spin_to = spin_to;
 
@@ -1391,7 +1438,10 @@
 	pi->to = to;
 
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pi->button_all_sheets))) {
-		pr = PRINT_ALL_SHEETS;
+		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pi->button_print_hidden_sheets)))
+			pr = PRINT_ALL_SHEETS_INCLUDING_HIDDEN;
+		else
+			pr = PRINT_ALL_SHEETS;
 	} else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pi->button_spec_sheets))) {
 		pr = PRINT_SHEET_RANGE;
 	} else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pi->button_selected_sheet))) {

Modified: trunk/src/print.h
==============================================================================
--- trunk/src/print.h	(original)
+++ trunk/src/print.h	Sun Aug 31 05:15:51 2008
@@ -14,6 +14,7 @@
 typedef enum {
 	PRINT_ACTIVE_SHEET,
 	PRINT_ALL_SHEETS,
+	PRINT_ALL_SHEETS_INCLUDING_HIDDEN,
 	PRINT_SHEET_RANGE,
 	PRINT_SHEET_SELECTION,
 	PRINT_IGNORE_PRINTAREA,



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