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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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.