Changeset 227

Show
Ignore:
Timestamp:
06/12/06 16:40:59 (2 years ago)
Author:
jordi
Message:

The MainView? now has a separate widget for the current page number and the total page number, as requested in bug #37 closed in this revision.

Location:
trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/IMainView.h

    r213 r227  
    356356 
    357357            /// 
     358            /// @brief Sets the text for the number of pages. 
     359            /// 
     360            /// The view displays the number of pages separately 
     361            /// of the current page. This function should set the 
     362            /// text to display in this separate control. 
     363            /// 
     364            /// @param text The text to set as the number of pages. 
     365            /// 
     366            virtual void setNumberOfPagesText (const gchar *text) = 0; 
     367 
     368            /// 
    358369            /// @brief Sets the text of the status bar. 
    359370            /// 
     
    436447            /// 
    437448            virtual void showToolbar (gboolean show) = 0; 
    438  
    439             /// 
    440             /// @brief Gives the number of pages that the document has. 
    441             /// 
    442             /// The view should keep a the number of total pages and show it 
    443             /// to the user. 
    444             /// 
    445             /// @param pages The total number of pages the document has. 
    446             /// 
    447             virtual void setTotalPages (gint pages) = 0; 
    448449 
    449450            /// 
  • trunk/src/MainPter.cxx

    r225 r227  
    137137        view.activeZoomFit (config.zoomToFit ()); 
    138138        view.activeZoomWidth (config.zoomToWidth ()); 
    139         view.setTotalPages (m_Document->getNumPages ()); 
    140139#if defined (HAVE_CUPS) 
    141140        view.sensitivePrint (TRUE); 
     
    376375        gint newPageNum = m_Document->getCurrentPageNum (); 
    377376        gint totalPages = m_Document->getNumPages (); 
    378         gchar *goToPageText = g_strdup_printf (_("%d of %d"),  
    379                                                newPageNum, totalPages); 
     377        gchar *goToPageText = g_strdup_printf ("%d", newPageNum); 
    380378        getView ().setGoToPageText (goToPageText); 
    381379        g_free (goToPageText); 
     380        gchar *totalPagesText = g_strdup_printf (_("of %d"), totalPages); 
     381        getView ().setNumberOfPagesText (totalPagesText); 
     382        g_free (totalPagesText); 
    382383    } 
    383384} 
     
    845846    // Set the text for the current page. 
    846847    gint totalPages = m_Document->getNumPages (); 
    847     gchar *goToPageText = g_strdup_printf (_("%d of %d"), pageNum, totalPages); 
     848    gchar *goToPageText = g_strdup_printf ("%d", pageNum); 
    848849    view.setGoToPageText (goToPageText); 
    849850    g_free (goToPageText); 
     851    gchar *totalPagesText = g_strdup_printf(_("of %d"), totalPages); 
     852    view.setNumberOfPagesText (totalPagesText); 
     853    g_free (totalPagesText); 
    850854 
    851855    // Set the page navigation sensitivity. 
  • trunk/src/gtk/MainView.cxx

    r225 r227  
    3535// Constants. 
    3636static gint CURRENT_PAGE_POS = 5; 
    37 static gint CURRENT_PAGE_WIDTH = 14; 
     37static gint CURRENT_PAGE_WIDTH = 5; 
    3838static gint CURRENT_ZOOM_POS = 8; 
    3939static gint CURRENT_ZOOM_WIDTH = 6; 
    4040 
    4141// Enumerations. 
    42 static enum 
     42enum indexColumns 
    4343{ 
    4444    outlineTitleColumn, 
     
    4646    outlineDataColumn, 
    4747    outlineNumColumns 
    48 } indexColumns; 
     48}; 
    4949 
    5050// Forward declarations. 
     
    625625} 
    626626 
    627 void  
    628 MainView::setTotalPages (gint pages) 
    629 { 
    630     m_TotalPages = pages; 
    631 } 
    632  
    633 void  
     627void 
     628MainView::setNumberOfPagesText (const gchar *text) 
     629{ 
     630    gtk_label_set_text (GTK_LABEL (m_NumberOfPages), text); 
     631} 
     632 
     633void 
    634634MainView::setGoToPageText (const gchar *text) 
    635635{ 
     
    756756    GtkWidget *hbox = gtk_hbox_new (FALSE, 3); 
    757757 
    758     GtkWidget *pageLabel= gtk_label_new (_("Page")); 
     758    GtkWidget *pageLabel = gtk_label_new (_("Page")); 
    759759    gtk_box_pack_start (GTK_BOX (hbox), pageLabel, FALSE, FALSE, 0); 
    760760 
    761761    m_CurrentPage = gtk_entry_new (); 
    762     gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), _("0 of 0")); 
     762    gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), "0"); 
    763763    gtk_entry_set_alignment (GTK_ENTRY (m_CurrentPage), 1.0f); 
    764764    gtk_entry_set_width_chars (GTK_ENTRY (m_CurrentPage), CURRENT_PAGE_WIDTH); 
     
    766766                      G_CALLBACK (main_window_go_to_page_cb), m_Pter); 
    767767    gtk_box_pack_start (GTK_BOX (hbox), m_CurrentPage, TRUE, TRUE, 0); 
     768    m_NumberOfPages = gtk_label_new (_("of 0")); 
     769    gtk_misc_set_alignment (GTK_MISC (m_NumberOfPages), 0.0f, 0.5f); 
     770    gtk_box_pack_start (GTK_BOX (hbox), m_NumberOfPages, FALSE, FALSE, 0); 
    768771 
    769772    m_CurrentPageToolItem = gtk_tool_item_new (); 
  • trunk/src/gtk/MainView.h

    r213 r227  
    6262            void showIndex (gboolean show); 
    6363            void setCursor (ViewCursor cursorType); 
    64             void setTotalPages (gint pages); 
     64            void setNumberOfPagesText (const gchar *text); 
    6565            void setGoToPageText (const gchar *text); 
    6666            void setStatusBarText (const gchar *text); 
     
    8787            GtkWidget *m_MainWindow; 
    8888            GtkWidget *m_MainBox; 
     89            GtkWidget *m_NumberOfPages; 
    8990            GtkTreeStore *m_Outline; 
    9091            PageView *m_PageView; 
     
    9293            GtkWidget *m_StatusBar; 
    9394            GtkWidget *m_TreeIndex; 
    94             gint m_TotalPages; 
    9595            GtkUIManager *m_UIManager; 
    9696 
  • trunk/tests/DumbMainView.cxx

    r216 r227  
    3434    m_CurrentPage = 0; 
    3535    m_FindView = new DumbFindView (); 
     36    m_NumberOfPages = g_strdup ("of 0"); 
    3637    m_GoToPageText = g_strdup (""); 
    3738    m_OpenFileName = g_strdup (""); 
     
    6566    m_Title = g_strdup (""); 
    6667    m_TimesShownPassword = 0; 
    67     m_TotalPages = 0; 
    6868    m_ZoomText = g_strdup (""); 
    6969    m_ZoomToFit = FALSE; 
     
    7676    delete m_PageView; 
    7777    g_free (m_GoToPageText); 
     78    g_free (m_NumberOfPages); 
    7879    g_free (m_LastOpenFileFolder); 
    7980    g_free (m_LastSaveFileFolder); 
     
    200201} 
    201202 
    202 void  
     203void 
    203204DumbMainView::sensitiveRotateLeft (gboolean sensitive) 
    204205{ 
     
    266267 
    267268void 
    268 DumbMainView::setTotalPages (gint pages) 
    269 { 
    270     m_TotalPages = pages; 
     269DumbMainView::setNumberOfPagesText (const gchar *text) 
     270{ 
     271    g_free (m_NumberOfPages); 
     272    m_NumberOfPages = g_strdup (text); 
    271273} 
    272274 
     
    367369{ 
    368370    return m_Outline; 
    369 } 
    370  
    371 gint 
    372 DumbMainView::getTotalPages () 
    373 { 
    374     return m_TotalPages; 
    375371} 
    376372 
  • trunk/tests/DumbMainView.h

    r216 r227  
    6363            const gchar *getGoToPageText (void); 
    6464            void setCursor (ViewCursor cursorType); 
    65             void setTotalPages (gint pages); 
    66             void setGoToPageText (const char *text); 
     65            void setNumberOfPagesText (const gchar *text); 
     66            void setGoToPageText (const gchar *text); 
    6767            void setTitle (const gchar *title); 
    6868            void setOutline (DocumentOutline *outline); 
     
    8282            DocumentOutline *getOutline (void); 
    8383            const gchar *getTitle (void); 
    84             gint getTotalPages (void); 
    8584            gboolean isShown (void); 
    8685            gboolean isSensitiveFind (void); 
     
    113112            gint m_CurrentPage; 
    114113            DumbFindView *m_FindView; 
     114            gchar *m_NumberOfPages; 
    115115            gchar *m_GoToPageText; 
    116116            gchar *m_LastOpenFileFolder; 
     
    144144            gint m_TimesShownPassword; 
    145145            gchar *m_Title; 
    146             gint m_TotalPages; 
    147146            gchar *m_ZoomText; 
    148147            gboolean m_ZoomToFit; 
  • trunk/tests/MainPterTest.cxx

    r212 r227  
    454454    m_MainPter->openFileActivated (); 
    455455    m_MainPter->waitForFileLoaded (); 
    456     // Check that sets the correct number of pages and the current page. 
    457     CPPUNIT_ASSERT_EQUAL (4, m_View->getTotalPages ()); 
     456    // Check that sets the correct current page. 
    458457    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ()); 
    459458    // Going to the next page should make all actions sensitive. 
     
    523522    m_MainPter->openFileActivated (); 
    524523    m_MainPter->waitForFileLoaded (); 
    525     // Check that sets the correct number of pages and the current page. 
    526     CPPUNIT_ASSERT_EQUAL (4, m_View->getTotalPages ()); 
     524    // Check that sets the correct current page. 
    527525    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ()); 
    528526 
  • trunk/tests/PrintPterTest.cxx

    r218 r227  
    1717 
    1818#include <epdfview.h> 
     19#include "DumbDocument.h" 
    1920#include "DumbPrintView.h" 
    2021#include "PrintPterTest.h" 
     
    3233{ 
    3334    Config::loadFile (FALSE); 
    34     m_PrintPter = new PrintPter (); 
     35    m_Document = new DumbDocument (); 
     36    m_PrintPter = new PrintPter (m_Document); 
    3537    m_View = new DumbPrintView (); 
    3638    m_PrintPter->setView (m_View); 
     
    5254        m_View = NULL; 
    5355    } 
     56    delete m_Document; 
    5457} 
    5558 
  • trunk/tests/PrintPterTest.h

    r218 r227  
    4040 
    4141        protected: 
     42            DumbDocument *m_Document; 
    4243            PrintPter *m_PrintPter; 
    4344            DumbPrintView *m_View;