Changeset 274 for trunk/src/main.cxx

Show
Ignore:
Timestamp:
05/04/07 07:24:59 (19 months ago)
Author:
jordi
Message:

Applied a patch by Igor Vagulin that defers the loading of a file specified from the command line until Gtk+ is idle, so the page view doesn't try to resize before the page is loaded. This closes bug #66.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/main.cxx

    r267 r274  
    2525 
    2626using namespace ePDFView; 
     27 
     28struct LoadFileInfo 
     29{ 
     30    gchar *fileName; 
     31    MainPter *mainPter; 
     32    PDFDocument *document; 
     33}; 
     34 
     35static int 
     36loadFileFromCommandLine (gpointer data) 
     37{ 
     38    LoadFileInfo *info = static_cast<LoadFileInfo *> (data); 
     39 
     40    info->mainPter->setOpenState (info->fileName, FALSE); 
     41    info->document->load (info->fileName, NULL); 
     42 
     43    g_free (info->fileName); 
     44    delete info; 
     45 
     46    return FALSE; 
     47} 
    2748 
    2849int 
     
    5778    // Let know to the presenter which is its view. 
    5879    mainPter->setView (mainView); 
    59     // Enter the main loop and wait for user interaction. */ 
    6080    // Now check if we have additional parameters. Any additional parameter 
    6181    // will be a file name to open. 
    6282    if ( argc > 1 ) 
    6383    { 
    64         mainPter->setOpenState (argv[1], FALSE); 
    65         document->load (argv[1], NULL); 
     84        LoadFileInfo *info = new LoadFileInfo; 
     85        info->mainPter = mainPter; 
     86        info->document = document; 
     87        info->fileName = g_strdup (argv[1]); 
     88        g_idle_add (loadFileFromCommandLine, info); 
    6689    } 
    6790