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

The MainPter? now resizes the page shown if the zoom to width or zoom to fit, that now are toggle actions, are activated. The view also tells to the presenter when the scroll window has resized, so it can calculate the new page.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gtk/MainView.cxx

    r97 r99  
    4646static void main_window_open_file_cb (GtkWidget *, gpointer); 
    4747static void main_window_outline_cb (GtkTreeSelection *, gpointer); 
     48static void main_window_page_view_resized_cb (GtkWidget *, GtkAllocation *,  
     49                                              gpointer); 
    4850static void main_window_quit_cb (GtkWidget *, gpointer); 
    4951static void main_window_show_sidebar_cb (GtkToggleAction *, gpointer); 
    5052static void main_window_show_statusbar_cb (GtkToggleAction *, gpointer); 
    5153static void main_window_show_toolbar_cb (GtkToggleAction *, gpointer); 
    52 static void main_window_zoom_fit_cb (GtkWidget *, gpointer); 
     54static void main_window_zoom_fit_cb (GtkToggleAction *, gpointer); 
    5355static void main_window_zoom_in_cb (GtkWidget *, gpointer); 
    5456static void main_window_zoom_out_cb (GtkWidget *, gpointer); 
    55 static void main_window_zoom_width_cb (GtkWidget *, gpointer); 
     57static void main_window_zoom_width_cb (GtkToggleAction *, gpointer); 
    5658 
    5759// The actions for menus and toolbars. 
     
    8385      G_CALLBACK (main_window_zoom_out_cb) }, 
    8486     
    85     { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("Zoom to _Fit"), NULL, 
    86       N_("Make the current document fill the window"),  
    87       G_CALLBACK (main_window_zoom_fit_cb) }, 
    88  
    89     { "ZoomWidth", EPDFVIEW_STOCK_ZOOM_WIDTH, N_("Zoom to _Width"), NULL, 
    90       N_("Make the current document fill the window width"),  
    91       G_CALLBACK (main_window_zoom_width_cb) }, 
    92  
    9387    { "RotateRight", EPDFVIEW_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), NULL,  
    9488      N_("Rotate the document 90 degrees clockwise"),  
     
    130124    { "ShowSideBar", NULL, N_("Show O_utline"), NULL, 
    131125      N_("Show or hide the document's outline"), 
    132       G_CALLBACK (main_window_show_sidebar_cb), FALSE } 
     126      G_CALLBACK (main_window_show_sidebar_cb), FALSE }, 
     127 
     128    { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("Zoom to _Fit"), NULL, 
     129      N_("Make the current document fill the window"),  
     130      G_CALLBACK (main_window_zoom_fit_cb), FALSE }, 
     131 
     132    { "ZoomWidth", EPDFVIEW_STOCK_ZOOM_WIDTH, N_("Zoom to _Width"), NULL, 
     133      N_("Make the current document fill the window width"),  
     134      G_CALLBACK (main_window_zoom_width_cb), FALSE } 
     135 
    133136}; 
    134137 
     
    190193} 
    191194 
     195void 
     196MainView::activeZoomFit (gboolean active) 
     197{ 
     198    GtkAction *zoomFit =  
     199        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/ViewMenu/ZoomFit"); 
     200    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (zoomFit), active); 
     201} 
     202 
     203void 
     204MainView::activeZoomWidth (gboolean active) 
     205{ 
     206    GtkAction *zoomWidth =  
     207        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/ViewMenu/ZoomWidth"); 
     208    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (zoomWidth), active); 
     209} 
    192210 
    193211gchar * 
     
    513531                                    GTK_POLICY_AUTOMATIC, 
    514532                                    GTK_POLICY_AUTOMATIC); 
     533    // When resizing. 
     534    g_signal_connect (G_OBJECT (m_PageViewScroll), "size-allocate", 
     535                      G_CALLBACK (main_window_page_view_resized_cb), m_Pter); 
     536    // The actual image, 
    515537    m_PageView = gtk_image_new  (); 
    516538    gtk_misc_set_padding (GTK_MISC (m_PageView),  
     
    586608    gtk_action_group_add_toggle_actions (actionGroup, g_ToggleEntries, 
    587609                                         G_N_ELEMENTS (g_ToggleEntries), 
    588                                          this); 
     610                                         m_Pter); 
    589611    m_UIManager = gtk_ui_manager_new (); 
    590612    gtk_ui_manager_insert_action_group (m_UIManager, actionGroup, 0); 
     
    919941    } 
    920942} 
     943 
     944/// 
     945/// @brief The page view has been resized. 
     946static void 
     947main_window_page_view_resized_cb (GtkWidget *widget, GtkAllocation *allocation, 
     948                                  gpointer data) 
     949{ 
     950    g_assert ( NULL != data && "The data parameter is NULL."); 
     951 
     952    gint scrollSize = SCROLLBARS_SIZE + PAGE_VIEW_PADDING * 2; 
     953    gint width = allocation->width - scrollSize; 
     954    gint height = allocation->height - scrollSize; 
     955    MainPter *pter = (MainPter *)data; 
     956    pter->pageViewResized (width, height); 
     957} 
     958 
    921959/// 
    922960/// @brief Called when the window is closed or Quit is activated. 
     
    936974    g_assert ( NULL != data && "The data parameter is NULL."); 
    937975 
    938     MainView *view = (MainView *)data; 
    939     view->showSidebar (gtk_toggle_action_get_active (action)); 
     976//    MainView *view = (MainView *)data; 
     977//    view->showSidebar (gtk_toggle_action_get_active (action)); 
    940978} 
    941979 
     
    948986    g_assert ( NULL != data && "The data parameter is NULL."); 
    949987 
    950     MainView *view = (MainView *)data; 
    951     view->showStatusbar (gtk_toggle_action_get_active (action)); 
     988//    MainView *view = (MainView *)data; 
     989//    view->showStatusbar (gtk_toggle_action_get_active (action)); 
    952990} 
    953991 
     
    960998    g_assert ( NULL != data && "The data parameter is NULL."); 
    961999 
    962     MainView *view = (MainView *)data; 
    963     view->showToolbar (gtk_toggle_action_get_active (action)); 
     1000//    MainView *view = (MainView *)data; 
     1001//    view->showToolbar (gtk_toggle_action_get_active (action)); 
    9641002} 
    9651003 
     
    9681006/// 
    9691007void 
    970 main_window_zoom_fit_cb (GtkWidget *widget, gpointer data) 
    971 { 
    972     g_assert ( NULL != data && "The data parameter is NULL."); 
    973  
    974     MainPter *pter = (MainPter *)data; 
    975     pter->zoomFitActivated (); 
     1008main_window_zoom_fit_cb (GtkToggleAction *action, gpointer data) 
     1009{ 
     1010    g_assert ( NULL != data && "The data parameter is NULL."); 
     1011 
     1012    MainPter *pter = (MainPter *)data; 
     1013    pter->zoomFitActivated (gtk_toggle_action_get_active (action)); 
    9761014} 
    9771015 
     
    10041042/// 
    10051043void 
    1006 main_window_zoom_width_cb (GtkWidget *widget, gpointer data) 
    1007 { 
    1008     g_assert ( NULL != data && "The data parameter is NULL."); 
    1009  
    1010     MainPter *pter = (MainPter *)data; 
    1011     pter->zoomWidthActivated (); 
    1012 } 
     1044main_window_zoom_width_cb (GtkToggleAction *action, gpointer data) 
     1045{ 
     1046    g_assert ( NULL != data && "The data parameter is NULL."); 
     1047 
     1048    MainPter *pter = (MainPter *)data; 
     1049    pter->zoomWidthActivated (gtk_toggle_action_get_active (action)); 
     1050}