Changeset 200 for trunk/src/MainPter.cxx

Show
Ignore:
Timestamp:
06/05/06 08:41:08 (2 years ago)
Author:
jordi
Message:

Added the option to save a copy of the currently loaded document.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/MainPter.cxx

    r199 r200  
    123123        view.sensitiveRotateRight (TRUE); 
    124124        view.sensitiveRotateLeft (TRUE); 
     125        view.sensitiveSave (TRUE); 
    125126        view.sensitiveZoomIn (TRUE); 
    126127        view.sensitiveZoomOut (TRUE); 
     
    150151        view.sensitiveRotateRight (FALSE); 
    151152        view.sensitiveRotateLeft (FALSE); 
     153        view.sensitiveSave (FALSE); 
    152154        view.sensitiveZoomIn (FALSE); 
    153155        view.sensitiveZoomOut (FALSE); 
     
    199201    view.sensitiveRotateRight (FALSE); 
    200202    view.sensitiveRotateLeft (FALSE); 
     203    view.sensitiveSave (FALSE); 
    201204    view.sensitiveZoomIn (FALSE); 
    202205    view.sensitiveZoomOut (FALSE); 
     
    292295    g_assert (NULL != m_Document &&  
    293296              "Tried to go to the last page of a NULL document."); 
    294      
     297 
    295298    m_PagePter->setNextPageScroll (PAGE_SCROLL_START); 
    296299    m_Document->goToLastPage (); 
     
    380383    IMainView &view = getView (); 
    381384    gchar *fileName = view.openFileDialog (lastFolder); 
    382     g_free (lastFolder);     
     385    g_free (lastFolder); 
    383386    if ( NULL != fileName ) 
    384387    { 
     
    389392        setOpenState (fileName, FALSE); 
    390393        m_Document->load (fileName, NULL); 
     394        g_free (fileName); 
    391395    } 
    392396} 
     
    465469    checkZoomSettings (); 
    466470} 
     471 
     472/// 
     473/// @brief The Save File action was activated. 
     474/// 
     475/// This means that the user wants to save a copy of the document. 
     476/// The presenter asks the view to show the Save File dialog and return a  
     477/// file name. 
     478/// Then it will try to save the document and if there's any error it will  
     479/// request the view to show an error dialog. 
     480/// 
     481void 
     482MainPter::saveFileActivated () 
     483{ 
     484    Config &config = Config::getConfig (); 
     485    gchar *lastFolder = config.getSaveFileFolder (); 
     486    IMainView &view = getView (); 
     487    gchar *fileName = view.saveFileDialog (lastFolder); 
     488    g_free (lastFolder); 
     489    if ( NULL != fileName ) 
     490    { 
     491 
     492        // Show on the status bar that we are saving the copy. 
     493        gchar *statusText = g_strdup_printf (_("Saving document to %s..."), 
     494                                             fileName); 
     495        view.setStatusBarText (statusText); 
     496        g_free (statusText); 
     497        gchar *dirName = g_path_get_dirname (fileName); 
     498        config.setSaveFileFolder (dirName); 
     499        g_free (dirName); 
     500        // Save the document. 
     501        m_Document->save (fileName); 
     502        g_free (fileName); 
     503    } 
     504} 
     505 
    467506 
    468507/// 
     
    720759    view.setGoToPageText (goToPageText); 
    721760    g_free (goToPageText); 
    722      
     761 
    723762    // Set the page navigation sensitivity. 
    724763    gboolean documentLoaded = m_Document->isLoaded (); 
     
    761800} 
    762801 
     802void 
     803MainPter::notifySave () 
     804{ 
     805    // Remove the status text. 
     806    getView ().setStatusBarText (NULL); 
     807} 
     808 
     809void 
     810MainPter::notifySaveError (const GError *error) 
     811{ 
     812    getView ().showErrorMessage (_("Error Saving File"), error->message); 
     813} 
     814 
    763815#if defined (DEBUG) 
    764816///