Changeset 201
- Timestamp:
- 06/05/06 11:16:50 (2 years ago)
- Files:
-
- trunk/src/IDocument.cxx (modified) (1 diff)
- trunk/src/IMainView.h (modified) (3 diffs)
- trunk/src/MainPter.cxx (modified) (10 diffs)
- trunk/src/MainPter.h (modified) (2 diffs)
- trunk/src/gtk/MainView.cxx (modified) (11 diffs)
- trunk/src/gtk/MainView.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/IDocument.cxx
r200 r201 1245 1245 IDocument::setZoom (gdouble zoom) 1246 1246 { 1247 if ( ABS (zoom - m_Scale) > 0.00001 ) 1247 if ( ABS (zoom - m_Scale) > 0.00001 ) 1248 1248 { 1249 1249 G_LOCK (JobRender); 1250 m_Scale = zoom;1250 m_Scale = CLAMP (zoom, ZOOM_OUT_MAX, ZOOM_IN_MAX); 1251 1251 refreshCache (); 1252 1252 G_UNLOCK (JobRender); trunk/src/IMainView.h
r200 r201 267 267 268 268 /// 269 /// @brief Changes the sensitivity of the "Zoom" entry. 270 /// 271 /// The view must change the sensitivity (it's called enabled or 272 /// disabled on some toolkits) of the "Zoom" entry 273 /// on the toolbar. 274 /// 275 /// @param sensitive Set to TRUE if need to make sensitive (enable) 276 /// the entry or FALSE to insensitive (disable) it. 277 /// 278 virtual void sensitiveZoom (gboolean sensitive) = 0; 279 280 /// 269 281 /// @brief Changes the sensitivity of the "Zoom In" action. 270 282 /// … … 338 350 /// 339 351 virtual void setStatusBarText (const gchar *text) = 0; 352 353 /// 354 /// @brief Sets the current zoom text. 355 /// 356 /// The current zoom text is displayed on the tool bar and 357 /// the user can change it in order to specify a concrete 358 /// zoom level. 359 /// 360 /// @param text The text to show in the current zoom entry. 361 /// 362 virtual void setZoomText (const gchar *text) = 0; 340 363 341 364 /// … … 472 495 /// 473 496 virtual IPreferencesView *getPreferencesView (void) = 0; 497 498 /// 499 /// @brief Gets the text from the zoom entry. 500 /// 501 /// Gets the text inside the "Current Zoom" entry on the 502 /// tool bar. 503 /// 504 /// @return The text inside the "Current Zoom" entry. 505 /// 506 virtual const gchar *getZoomText (void) = 0; 474 507 475 508 /// trunk/src/MainPter.cxx
r200 r201 118 118 view.setTitle (m_Document->getTitle ()); 119 119 } 120 setZoomText (m_Document->getZoom ()); 120 121 view.sensitiveFind (TRUE); 121 122 view.sensitiveGoToPage (TRUE); … … 124 125 view.sensitiveRotateLeft (TRUE); 125 126 view.sensitiveSave (TRUE); 127 view.sensitiveZoom (TRUE); 126 128 view.sensitiveZoomIn (TRUE); 127 129 view.sensitiveZoomOut (TRUE); … … 142 144 { 143 145 view.setTitle (_("PDF Viewer")); 146 setZoomText (1.0); 144 147 view.sensitiveFind (FALSE); 145 148 view.sensitiveGoToFirstPage (FALSE); … … 152 155 view.sensitiveRotateLeft (FALSE); 153 156 view.sensitiveSave (FALSE); 157 view.sensitiveZoom (FALSE); 154 158 view.sensitiveZoomIn (FALSE); 155 159 view.sensitiveZoomOut (FALSE); … … 191 195 { 192 196 // Insensitive the open, reload, page navigation, zoom and rotate. 197 setZoomText (1.0); 193 198 IMainView &view = getView (); 194 199 view.sensitiveFind (FALSE); … … 202 207 view.sensitiveRotateLeft (FALSE); 203 208 view.sensitiveSave (FALSE); 209 view.sensitiveZoom (FALSE); 204 210 view.sensitiveZoomIn (FALSE); 205 211 view.sensitiveZoomOut (FALSE); … … 223 229 // Set the number of times we can try the password. 224 230 m_PasswordTries = 3; 231 } 232 233 /// 234 /// @brief Tells the view which text to show in the zoom entry. 235 /// 236 /// @param zoom The current document's zoom value. 237 /// 238 void 239 MainPter::setZoomText (gdouble zoom) 240 { 241 gchar *zoomText = g_strdup_printf ("%.3g%%", zoom * 100.0); 242 getView ().setZoomText (zoomText); 243 g_free (zoomText); 225 244 } 226 245 … … 541 560 542 561 /// 562 /// @brief The user entered a zoom value. 563 /// 564 void 565 MainPter::zoomActivated () 566 { 567 IMainView &view = getView (); 568 const gchar *zoomText = view.getZoomText (); 569 if ( NULL != zoomText ) 570 { 571 Config &config = Config::getConfig (); 572 config.setZoomToFit (FALSE); 573 config.setZoomToWidth (FALSE); 574 575 view.activeZoomFit (FALSE); 576 view.activeZoomWidth (FALSE); 577 578 gdouble zoom = atof (zoomText); 579 m_Document->setZoom (zoom / 100.0); 580 } 581 } 582 583 /// 543 584 /// @brief Performs the "Zoom Fit Best". 544 585 /// … … 591 632 view.activeZoomFit (FALSE); 592 633 view.activeZoomWidth (FALSE); 593 634 594 635 m_Document->zoomIn (); 595 636 } … … 784 825 { 785 826 IMainView &view = getView (); 827 // Show the new zoom. 828 setZoomText (zoom); 786 829 // Set the zoom sensitivity. 787 830 view.sensitiveZoomIn (m_Document->canZoomIn ()); trunk/src/MainPter.h
r200 r201 64 64 void showStatusbarActivated (gboolean show); 65 65 void showToolbarActivated (gboolean show); 66 void zoomActivated (void); 66 67 void zoomFitActivated (gboolean active); 67 68 void zoomInActivated (void); … … 97 98 98 99 void checkZoomSettings (void); 100 void setZoomText (gdouble zoom); 99 101 void zoomFit (void); 100 102 void zoomWidth (void); trunk/src/gtk/MainView.cxx
r200 r201 32 32 // Constants. 33 33 static gint CURRENT_PAGE_POS = 5; 34 static gint CURRENT_PAGE_WIDTH = 14; 35 static gint CURRENT_ZOOM_POS = 8; 36 static gint CURRENT_ZOOM_WIDTH = 7; 34 37 35 38 // Enumerations. … … 63 66 static void main_window_show_statusbar_cb (GtkToggleAction *, gpointer); 64 67 static void main_window_show_toolbar_cb (GtkToggleAction *, gpointer); 68 static void main_window_zoom_cb (GtkWidget *, gpointer); 65 69 static void main_window_zoom_fit_cb (GtkToggleAction *, gpointer); 66 70 static void main_window_zoom_in_cb (GtkWidget *, gpointer); … … 201 205 CURRENT_PAGE_POS); 202 206 gtk_widget_show_all (GTK_WIDGET (m_CurrentPageToolItem)); 203 gtk_toolbar_insert (GTK_TOOLBAR (toolBar), gtk_separator_tool_item_new (), 204 CURRENT_PAGE_POS + 1); 207 GtkToolItem *separator = gtk_separator_tool_item_new (); 208 gtk_toolbar_insert (GTK_TOOLBAR (toolBar), separator, CURRENT_PAGE_POS + 1); 209 gtk_widget_show_all (GTK_WIDGET (separator)); 210 // Add the current zoom item. 211 createCurrentZoom (); 212 gtk_toolbar_insert (GTK_TOOLBAR (toolBar), m_CurrentZoomToolItem, 213 CURRENT_ZOOM_POS); 214 gtk_widget_show_all (GTK_WIDGET (m_CurrentZoomToolItem)); 205 215 // Create the page view 206 216 GtkWidget *pageViewPaned = createPageView (); … … 484 494 485 495 void 496 MainView::sensitiveZoom (gboolean sensitive) 497 { 498 gtk_widget_set_sensitive (m_CurrentZoom, sensitive); 499 } 500 501 void 486 502 MainView::sensitiveZoomIn (gboolean sensitive) 487 503 { … … 604 620 } 605 621 622 const gchar * 623 MainView::getZoomText (void) 624 { 625 return gtk_entry_get_text (GTK_ENTRY (m_CurrentZoom)); 626 } 627 606 628 void 607 629 MainView::setStatusBarText (const gchar *text) … … 614 636 gtk_statusbar_push (GTK_STATUSBAR (m_StatusBar), contextId, text); 615 637 } 638 } 639 640 void 641 MainView::setZoomText (const gchar *text) 642 { 643 gtk_entry_set_text (GTK_ENTRY (m_CurrentZoom), text); 616 644 } 617 645 … … 692 720 /// @brief Creates the "Current Page" widget that will be displayed on toolbar. 693 721 /// 694 /// @return The tool item to add to the toolbar.695 ///696 722 void 697 723 MainView::createCurrentPage () … … 705 731 gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), _("0 of 0")); 706 732 gtk_entry_set_alignment (GTK_ENTRY (m_CurrentPage), 1.0f); 733 gtk_entry_set_width_chars (GTK_ENTRY (m_CurrentPage), CURRENT_PAGE_WIDTH); 707 734 g_signal_connect (G_OBJECT (m_CurrentPage), "activate", 708 735 G_CALLBACK (main_window_go_to_page_cb), m_Pter); … … 711 738 m_CurrentPageToolItem = gtk_tool_item_new (); 712 739 gtk_container_add (GTK_CONTAINER (m_CurrentPageToolItem), hbox); 740 } 741 742 743 /// 744 /// @brief Creates the "Current Zoom" widget that will be displayed on toolbar. 745 /// 746 void 747 MainView::createCurrentZoom () 748 { 749 m_CurrentZoom = gtk_entry_new (); 750 gtk_entry_set_alignment (GTK_ENTRY (m_CurrentZoom), 1.0f); 751 gtk_entry_set_width_chars (GTK_ENTRY (m_CurrentZoom), CURRENT_ZOOM_WIDTH); 752 g_signal_connect (G_OBJECT (m_CurrentZoom), "activate", 753 G_CALLBACK (main_window_zoom_cb), m_Pter); 754 755 m_CurrentZoomToolItem = gtk_tool_item_new (); 756 gtk_container_add (GTK_CONTAINER (m_CurrentZoomToolItem), m_CurrentZoom); 713 757 } 714 758 … … 800 844 801 845 GError *error = NULL; 802 if ( !gtk_ui_manager_add_ui_from_file (m_UIManager, 803 DATADIR"/ui/epdfview-ui.xml", 846 if ( !gtk_ui_manager_add_ui_from_file (m_UIManager, 847 DATADIR"/ui/epdfview-ui.xml", 804 848 &error) ) 805 849 { … … 1169 1213 1170 1214 /// 1215 /// @brief The user tries to set a zoom. 1216 /// 1217 void 1218 main_window_zoom_cb (GtkWidget *widget, gpointer data) 1219 { 1220 g_assert ( NULL != data && "The data parameter is NULL."); 1221 1222 MainPter *pter = (MainPter *)data; 1223 pter->zoomActivated (); 1224 } 1225 1226 /// 1171 1227 /// @brief The user tries to fit the document into the window. 1172 1228 /// trunk/src/gtk/MainView.h
r200 r201 50 50 void sensitiveRotateRight (gboolean sensitive); 51 51 void sensitiveSave (gboolean sensitive); 52 void sensitiveZoom (gboolean sensitive); 52 53 void sensitiveZoomIn (gboolean sensitive); 53 54 void sensitiveZoomOut (gboolean sensitive); … … 61 62 void setGoToPageText (const gchar *text); 62 63 void setStatusBarText (const gchar *text); 64 void setZoomText (const gchar *text); 63 65 const gchar *getGoToPageText (void); 64 66 IFindView *getFindView (void); 65 67 IPageView *getPageView (void); 66 68 IPreferencesView *getPreferencesView (void); 69 const gchar *getZoomText (void); 67 70 void setTitle (const gchar *title); 68 71 void setOutline (DocumentOutline *outline); … … 73 76 GtkWidget *m_CurrentPage; 74 77 GtkToolItem *m_CurrentPageToolItem; 78 GtkWidget *m_CurrentZoom; 79 GtkToolItem *m_CurrentZoomToolItem; 75 80 FindView *m_FindView; 76 GtkWidget *m_MainWindow; 81 GtkWidget *m_MainWindow; 77 82 GtkWidget *m_MainBox; 78 83 GtkTreeStore *m_Outline; … … 85 90 86 91 void createCurrentPage (void); 92 void createCurrentZoom (void); 87 93 GtkWidget *createPageView (void); 88 94 void createUIManager (void);
