| | 126 | } |
| | 127 | |
| | 128 | /// |
| | 129 | /// @brief The "Go To First Page" action was activated. |
| | 130 | /// |
| | 131 | void |
| | 132 | MainPter::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 | |
| | 141 | void |
| | 142 | MainPter::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 | |
| | 151 | void |
| | 152 | MainPter::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 | |
| | 161 | void |
| | 162 | MainPter::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 | |
| | 180 | void |
| | 181 | MainPter::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 (); |
| 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 | |