Changeset 35

Show
Ignore:
Timestamp:
04/12/06 05:27:57 (3 years ago)
Author:
jordi
Message:

Now the shell shows the first page, but to do so the Main presenter had to make sure the document page is not destroyed until the call to shell's showPage() is done, as the shells mantains a copy of it.

Location:
trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/MainPter.cxx

    r33 r35  
    2626{ 
    2727    m_Document = new PDFDocument (); 
     28    m_DocumentPage = NULL; 
    2829    m_View = NULL; 
    2930} 
     
    4142 
    4243    m_Document = document; 
     44    m_DocumentPage = NULL; 
    4345    m_View = NULL; 
    4446} 
     
    5052{ 
    5153    delete m_Document; 
     54    delete m_DocumentPage; 
    5255    delete m_View; 
    5356} 
     
    268271                    getView ().showErrorMessage (_("Error Loading File"), 
    269272                            _("The password you have supplier is not a" 
    270                               "valid password for this file.")); 
     273                              " valid password for this file.")); 
    271274                    g_free (password); 
    272275                } 
     
    394397    view.sensitiveZoomOut (m_Document->canZoomOut ()); 
    395398     
    396     DocumentPage *page = m_Document->renderPage (); 
    397     if ( NULL != page ) 
     399    DocumentPage *oldPage = m_DocumentPage; 
     400    m_DocumentPage = m_Document->renderPage (); 
     401    if ( NULL != m_DocumentPage ) 
    398402    { 
    399         getView ().showPage (page); 
    400         delete page; 
     403        getView ().showPage (m_DocumentPage); 
    401404    } 
    402 } 
     405    delete oldPage; 
     406} 
  • trunk/src/MainPter.h

    r33 r35  
    2323    // Forward declarations. 
    2424    class IDocument; 
     25    class DocumentPage; 
    2526     
    2627    class MainPter 
     
    5253 
    5354            IDocument *m_Document; 
     55            DocumentPage *m_DocumentPage; 
    5456            IMainView *m_View; 
    5557    }; 
  • trunk/src/gtk/MainView.cxx

    r34 r35  
    2020#include <IMainView.h> 
    2121#include <MainPter.h> 
     22#include <DocumentPage.h> 
    2223#include "MainView.h" 
    2324 
     
    5253    GtkWidget *toolBar = gtk_ui_manager_get_widget (m_UIManager, "/ToolBar"); 
    5354    gtk_box_pack_start (GTK_BOX (m_MainBox), toolBar, FALSE, FALSE, 0); 
     55    // Create the page view 
     56    GtkWidget *pageView = createPageView (); 
     57    gtk_box_pack_start (GTK_BOX (m_MainBox), pageView, TRUE, TRUE, 0); 
    5458} 
    5559 
     
    8286MainView::promptPasswordDialog () 
    8387{ 
     88    return g_strdup(""); 
    8489} 
    8590 
     
    154159MainView::showPage (DocumentPage *page) 
    155160{ 
     161    gtk_image_set_from_pixbuf (GTK_IMAGE (m_PageView), NULL); 
     162    GdkPixbuf *pixbuf = getPixbufFromPage (page);  
     163    gtk_image_set_from_pixbuf (GTK_IMAGE (m_PageView), pixbuf); 
     164    gdk_pixbuf_unref (pixbuf); 
    156165} 
    157166 
     
    169178MainView::getGoToPageText (void) 
    170179{ 
     180    return "1"; 
    171181} 
    172182 
     
    185195// GTK+ Functions. 
    186196//////////////////////////////////////////////////////////////// 
     197 
     198GtkWidget * 
     199MainView::createPageView () 
     200{ 
     201    GtkWidget *scrolledWindow = gtk_scrolled_window_new (NULL, NULL); 
     202    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindow), 
     203                                    GTK_POLICY_AUTOMATIC, 
     204                                    GTK_POLICY_AUTOMATIC); 
     205    m_PageView = gtk_image_new  (); 
     206    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledWindow), 
     207                                           m_PageView); 
     208    return scrolledWindow; 
     209} 
    187210 
    188211void 
     
    268291} 
    269292 
     293GdkPixbuf * 
     294MainView::getPixbufFromPage (DocumentPage *page) 
     295{ 
     296    GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data (page->getData (), 
     297            GDK_COLORSPACE_RGB, FALSE, 8, page->getWidth (), page->getHeight (), 
     298            page->getRowStride (), NULL, NULL); 
     299 
     300    return pixbuf; 
     301} 
     302 
    270303//////////////////////////////////////////////////////////////// 
    271304// GTK+ Callbacks. 
  • trunk/src/gtk/MainView.h

    r33 r35  
    5555            GtkWidget *m_MainWindow;  
    5656            GtkWidget *m_MainBox; 
     57            GtkWidget *m_PageView; 
    5758            GtkUIManager *m_UIManager; 
    5859 
     60            GtkWidget *createPageView (void); 
    5961            void createUIManager (void); 
     62            GdkPixbuf *getPixbufFromPage (DocumentPage *page); 
    6063    }; 
    6164}