]> www.fi.muni.cz Git - evince.git/commitdiff
Patch by Juanjo Marín <juanj.marin@juntadeandalucia.es> to fix the bug
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>
Sat, 4 Apr 2009 21:34:19 +0000 (21:34 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sat, 4 Apr 2009 21:34:19 +0000 (21:34 +0000)
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

ChangeLog
shell/ev-print-operation.c
test/Makefile.am
test/test7.py [new file with mode: 0755]

index f8fc2b9f6c6504c7f3279e304d0bb752a638cb75..e5d24f2a45ce4f65b5a02e3c09a5985d300b5827 100644 (file)
--- 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
index 8498dceb7b1677cd0b6fc9e4235d15c876ebdc31..c45f90cc2ef918fdbc9dd6c3f3578a8ed1b034aa 100644 (file)
@@ -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;
index 82748770dc4a41a72ff1097011f1a409b48323e2..17855ea78e5ade5f66ba01e02bfb1a9dc6227779 100644 (file)
@@ -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 (executable)
index 0000000..f104a47
--- /dev/null
@@ -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')