Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>2009-04-04 21:34:19 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2009-04-04 21:34:19 (GMT)
commit310d7d00b2e808f174750683335ec01f4af3291b (patch)
treea553cb4ba358525657d52bd964c3784b22079877
parent5a4c35515e95a0a1be9e003574b71e9d21fbfb36 (diff)
Patch by Juanjo Marín <juanj.marin@juntadeandalucia.es> to fix the bug
2009-04-05 Nickolay V. Shmyrev <nshmyrev@yandex.ru> * shell/ev-print-operation.c (clamp_ranges), (ev_print_operation_export_print_dialog_response_cb): * test/Makefile.am: * test/test7.py: Patch by Juanjo Marín <juanj.marin@juntadeandalucia.es> to fix the bug 517735. Fixes preview of the empty selection. svn path=/trunk/; revision=3570
-rw-r--r--ChangeLog10
-rw-r--r--shell/ev-print-operation.c43
-rw-r--r--test/Makefile.am3
-rwxr-xr-xtest/test7.py33
4 files changed, 80 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index f8fc2b9..e5d24f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-05 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * shell/ev-print-operation.c (clamp_ranges),
+ (ev_print_operation_export_print_dialog_response_cb):
+ * test/Makefile.am:
+ * test/test7.py:
+
+ Patch by Juanjo Marín <juanj.marin@juntadeandalucia.es> to fix
+ the bug 517735. Fixes preview of the empty selection.
+
2009-04-01 Christian Persch <chpe@gnome.org>
* data/evince.desktop.in.in: Direct bug-buddy bugs to the
diff --git a/shell/ev-print-operation.c b/shell/ev-print-operation.c
index 8498dce..c45f90c 100644
--- a/shell/ev-print-operation.c
+++ b/shell/ev-print-operation.c
@@ -576,12 +576,13 @@ find_range (EvPrintOperationExport *export)
}
}
-static void
+static gboolean
clamp_ranges (EvPrintOperationExport *export)
{
gint num_of_correct_ranges = 0;
gint n_pages_to_print = 0;
gint i;
+ gboolean null_flag = FALSE;
for (i = 0; i < export->n_ranges; i++) {
gint n_pages;
@@ -612,16 +613,27 @@ clamp_ranges (EvPrintOperationExport *export)
} else if (n_pages % 2 == 0) {
n_pages_to_print += n_pages / 2;
} else if (export->page_set == GTK_PAGE_SET_EVEN) {
- n_pages_to_print += export->ranges[i].start % 2 == 0 ?
+ if (n_pages==1 && export->ranges[i].start % 2 == 0)
+ null_flag = TRUE;
+ else
+ n_pages_to_print += export->ranges[i].start % 2 == 0 ?
n_pages / 2 : (n_pages / 2) + 1;
} else if (export->page_set == GTK_PAGE_SET_ODD) {
- n_pages_to_print += export->ranges[i].start % 2 == 0 ?
+ if (n_pages==1 && export->ranges[i].start % 2 != 0)
+ null_flag = TRUE;
+ else
+ n_pages_to_print += export->ranges[i].start % 2 == 0 ?
(n_pages / 2) + 1 : n_pages / 2;
}
}
- export->n_ranges = num_of_correct_ranges;
- export->n_pages_to_print = n_pages_to_print;
+ if (null_flag && !n_pages_to_print) {
+ return FALSE;
+ } else {
+ export->n_ranges = num_of_correct_ranges;
+ export->n_pages_to_print = n_pages_to_print;
+ return TRUE;
+ }
}
static void
@@ -988,8 +1000,6 @@ ev_print_operation_export_print_dialog_response_cb (GtkDialog *dial
return;
}
- ev_print_operation_update_status (op, -1, -1, 0.0);
-
export->print_preview = (response == GTK_RESPONSE_APPLY);
printer = gtk_print_unix_dialog_get_selected_printer (GTK_PRINT_UNIX_DIALOG (dialog));
@@ -1062,8 +1072,25 @@ ev_print_operation_export_print_dialog_response_cb (GtkDialog *dial
break;
}
- clamp_ranges (export);
+ if (!clamp_ranges (export)) {
+ GtkWidget *message_dialog;
+
+ message_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CLOSE,
+ "%s", _("Invalid page selection"));
+ gtk_window_set_title (GTK_WINDOW (message_dialog), _("Warning"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
+ "%s", _("Your print range selection does not include any page"));
+ g_signal_connect (message_dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
+ gtk_widget_show (message_dialog);
+ return;
+ } else ev_print_operation_update_status (op, -1, -1, 0.0);
+
width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
scale = gtk_print_settings_get_scale (print_settings) * 0.01;
diff --git a/test/Makefile.am b/test/Makefile.am
index 8274877..17855ea 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,7 +5,8 @@ dist_check_SCRIPTS = \
test3.py \
test4.py \
test5.py \
- test6.py
+ test6.py \
+ test7.py
TESTS = $(dist_check_SCRIPTS)
diff --git a/test/test7.py b/test/test7.py
new file mode 100755
index 0000000..f104a47
--- /dev/null
+++ b/test/test7.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+# Test printing
+
+import os
+os.environ['LANG']='C'
+srcdir = os.environ['srcdir']
+
+from dogtail.procedural import *
+
+run('evince', arguments=' '+srcdir+'/test-page-labels.pdf')
+
+#!/usr/bin/python
+from dogtail.procedural import *
+
+focus.application('evince')
+focus.frame('test-page-labels.pdf')
+click('File', roleName='menu')
+click('Print...', roleName='menu item')
+focus.dialog('Print')
+click('Pages:', roleName='radio button')
+keyCombo('Tab')
+type('1')
+click('Page Setup', roleName='page tab', raw=True)
+click('All sheets')
+click('Even sheets')
+click('Print Preview', roleName='push button')
+keyCombo('Return')
+click('Cancel')
+
+# Close evince
+click('File', roleName='menu')
+click('Close', roleName='menu item')