Code

Display the total number of pages next to the page number spinbutton
authormiklosh <miklosh@users.sourceforge.net>
Thu, 23 Aug 2007 09:50:28 +0000 (09:50 +0000)
committermiklosh <miklosh@users.sourceforge.net>
Thu, 23 Aug 2007 09:50:28 +0000 (09:50 +0000)
src/extension/internal/pdfinput/pdf-input.cpp
src/extension/internal/pdfinput/pdf-input.h

index 0b30b3b247a680f6f9244688c1ac0cc5a540776f..c0982187af5c2f8b4a85440654e6e0e95bbd9923 100644 (file)
@@ -63,10 +63,17 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc)
     Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
             new class Gtk::Adjustment(1, 1, _pdf_doc->getNumPages(), 1, 10, 0));
     _pageNumberSpin = Gtk::manage(new class Gtk::SpinButton(*_pageNumberSpin_adj, 1, 1));
+    _labelTotalPages = Gtk::manage(new class Gtk::Label());
     hbox2 = Gtk::manage(new class Gtk::HBox(false, 0));
     // Disable the page selector when there's only one page
-    if ( _pdf_doc->getCatalog()->getNumPages() == 1 ) {
+    int num_pages = _pdf_doc->getCatalog()->getNumPages();
+    if ( num_pages == 1 ) {
         _pageNumberSpin->set_sensitive(false);
+    } else {
+        // Display total number of pages
+        gchar *label_text = g_strdup_printf("/ %i", num_pages);
+        _labelTotalPages->set_label(label_text);
+        g_free(label_text);
     }
 
     // Crop settings
@@ -125,8 +132,15 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc)
     _pageNumberSpin->set_numeric(true);
     _pageNumberSpin->set_digits(0);
     _pageNumberSpin->set_wrap(false);
+    _labelTotalPages->set_alignment(0.5,0.5);
+    _labelTotalPages->set_padding(0,0);
+    _labelTotalPages->set_justify(Gtk::JUSTIFY_LEFT);
+    _labelTotalPages->set_line_wrap(false);
+    _labelTotalPages->set_use_markup(false);
+    _labelTotalPages->set_selectable(false);
     hbox2->pack_start(*_labelSelect, Gtk::PACK_SHRINK, 0);
     hbox2->pack_start(*_pageNumberSpin, Gtk::PACK_SHRINK, 4);
+    hbox2->pack_start(*_labelTotalPages, Gtk::PACK_SHRINK, 0);
     _cropCheck->set_flags(Gtk::CAN_FOCUS);
     _cropCheck->set_relief(Gtk::RELIEF_NORMAL);
     _cropCheck->set_mode(true);
@@ -217,6 +231,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc)
     okbutton->show();
     _labelSelect->show();
     _pageNumberSpin->show();
+    _labelTotalPages->show();
     hbox2->show();
     _cropCheck->show();
     _cropTypeCombo->show();
index 06b93fabb98991476aace6e1299026b0be4ecb17..56c7c2019838b7f43d143857dd430e092a62d37a 100644 (file)
@@ -67,6 +67,7 @@ private:
     class Gtk::Button * okbutton;
     class Gtk::Label * _labelSelect;
     class Gtk::SpinButton * _pageNumberSpin;
+    class Gtk::Label * _labelTotalPages;
     class Gtk::HBox * hbox2;
     class Gtk::CheckButton * _cropCheck;
     class Gtk::ComboBoxText * _cropTypeCombo;