Changeset 29 for trunk/src/MainPter.cxx

Show
Ignore:
Timestamp:
04/11/06 13:58:09 (3 years ago)
Author:
jordi
Message:

The page navigation toolbar works as expected, setting the sensitiveness of its controls correctly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/MainPter.cxx

    r27 r29  
    6363    if ( m_Document->isLoaded () ) 
    6464    { 
     65        m_Document->goToFirstPage (); 
    6566        if ( 0 == g_ascii_strcasecmp ("", m_Document->getTitle ()) ) 
    6667        { 
     
    7172            view.setTitle (m_Document->getTitle ()); 
    7273        } 
    73         view.sensitiveGoToFirstPage (FALSE); 
    74         view.sensitiveGoToLastPage (TRUE); 
    75         view.sensitiveGoToNextPage (TRUE); 
    7674        view.sensitiveGoToPage (TRUE); 
    77         view.sensitiveGoToPreviousPage (FALSE); 
    7875        view.sensitiveZoomIn (TRUE); 
    7976        view.sensitiveZoomOut (TRUE); 
    8077        view.sensitiveZoomFit (TRUE); 
    8178        view.sensitiveZoomWidth (TRUE); 
     79        view.setTotalPages (m_Document->getNumPages ()); 
    8280        showPage (); 
    8381    } 
     
    126124    // state. 
    127125    setInitialState (); 
     126} 
     127 
     128/// 
     129/// @brief The "Go To First Page" action was activated. 
     130/// 
     131void 
     132MainPter::goToFirstPageActivated (void) 
     133{ 
     134    g_assert (NULL != m_Document &&  
     135              "Tried to go to the first page of a NULL document."); 
     136     
     137    m_Document->goToFirstPage (); 
     138    showPage (); 
     139} 
     140 
     141void 
     142MainPter::goToLastPageActivated (void) 
     143{ 
     144    g_assert (NULL != m_Document &&  
     145              "Tried to go to the last page of a NULL document."); 
     146     
     147    m_Document->goToLastPage (); 
     148    showPage (); 
     149} 
     150 
     151void 
     152MainPter::goToNextPageActivated (void) 
     153{ 
     154    g_assert (NULL != m_Document &&  
     155              "Tried to go to the next page of a NULL document."); 
     156     
     157    m_Document->goToNextPage (); 
     158    showPage (); 
     159} 
     160 
     161void 
     162MainPter::goToPageActivated (void) 
     163{ 
     164    g_assert (NULL != m_Document &&  
     165              "Tried to go to the a page of a NULL document."); 
     166     
     167    // First try to get the page number from the view. 
     168    const gchar *goToPageText = getView ().getGoToPageText (); 
     169    if ( NULL != goToPageText ) 
     170    { 
     171        // Try to read as much as possible. 
     172        int pageNum = atoi (goToPageText); 
     173        // If the page number is too high, the Document class will 
     174        // go to the last page. The same if it's too low. 
     175        m_Document->goToPage (pageNum); 
     176        showPage (); 
     177    } 
     178} 
     179 
     180void 
     181MainPter::goToPreviousPageActivated (void) 
     182{ 
     183    g_assert (NULL != m_Document &&  
     184              "Tried to go to the previous page of a NULL document."); 
     185     
     186    m_Document->goToPreviousPage (); 
     187    showPage (); 
    128188} 
    129189 
     
    218278    g_assert (m_Document->isLoaded () &&  
    219279              "Tried to show a page from a not loaded document."); 
    220              
     280 
     281    IMainView &view = getView (); 
     282    // Set the text for the current page. 
     283    gint currentPage = m_Document->getCurrentPageNum (); 
     284    gchar *goToPageText = g_strdup_printf ("%d", currentPage); 
     285    view.setGoToPageText (goToPageText); 
     286    g_free (goToPageText); 
     287     
     288    // Set the page navigation sensitivity. 
     289    view.sensitiveGoToFirstPage (1 < currentPage ); 
     290    view.sensitiveGoToPreviousPage (1 < currentPage ); 
     291    view.sensitiveGoToLastPage (m_Document->getNumPages() > currentPage); 
     292    view.sensitiveGoToNextPage (m_Document->getNumPages() > currentPage); 
     293     
    221294    DocumentPage *page = m_Document->renderPage (); 
    222295    if ( NULL != page )