Changeset 71
- Timestamp:
- 04/16/06 06:52:48 (2 years ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
data/epdfview.desktop (modified) (1 diff)
-
src/MainPter.h (modified) (2 diffs)
-
src/main.cxx (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/epdfview.desktop
r48 r71 5 5 Comment[es]=Visor de documentos PDF ligero 6 6 Encoding=UTF-8 7 Exec=epdfview 7 Exec=epdfview %f 8 8 GenericName=PDF Viewer 9 9 GenericName[ca]=Visor PDF -
trunk/src/MainPter.h
r66 r71 50 50 void goToPageActivated (void); 51 51 void goToPreviousPageActivated (void); 52 void openDocument (const gchar *fileName, const gchar *oldPassword, 53 gboolean canShowPage); 52 54 void openFileActivated (void); 53 55 void outlineActivated (DocumentOutline *outline); … … 61 63 62 64 protected: 63 void openDocument (const gchar *fileName, const gchar *oldPassword,64 gboolean canShowPage);65 65 void showPage (void); 66 66 -
trunk/src/main.cxx
r49 r71 25 25 #include "MainPter.h" 26 26 27 27 28 using namespace ePDFView; 29 30 /// 31 /// @brief The data passed to open_command_line_file() function. 32 /// 33 typedef struct 34 { 35 /// The presenter to make open the file. 36 MainPter *presenter; 37 /// The filename to open. 38 gchar *fileName; 39 } OpenFileData; 40 41 // Forward declarations. 42 static gboolean open_command_line_file (gpointer data); 28 43 29 44 int 30 45 main (int argc, char **argv) 31 46 { 32 // Enable NLS support.47 // Enable NLS. 33 48 setlocale (LC_ALL, ""); 34 49 bindtextdomain (PACKAGE, LOCALEDIR); 35 50 bind_textdomain_codeset (PACKAGE, "UTF-8"); 36 51 textdomain (PACKAGE); 52 // Create the comman line options context. 53 GOptionContext *optionContext = 54 g_option_context_new (_("[FILE] - view PDF documents")); 55 g_option_context_add_group (optionContext, gtk_get_option_group (TRUE)); 56 GError *error = NULL; 57 if ( !g_option_context_parse (optionContext, &argc, &argv, &error) ) 58 { 59 g_critical ("Error parsing command line options: %s\n", error->message); 60 g_error_free (error); 61 exit (EXIT_FAILURE); 62 } 37 63 // Initialise the GTK library. 38 64 gtk_init (&argc, &argv); … … 40 66 // Create the main presenter. 41 67 MainPter *mainPter = new MainPter (); 68 // Now check if we have additional parameters. Any additional parameter 69 // will be a filename to open. 70 if ( argc > 1 ) 71 { 72 OpenFileData *openFile = new OpenFileData; 73 if ( NULL != openFile ) 74 { 75 openFile->presenter = mainPter; 76 openFile->fileName = g_strdup (argv[1]); 77 78 // This will call the function when no other GTK event is on 79 // the queue, and will let the presenter open the file when 80 // then main view is shown. 81 g_idle_add (open_command_line_file, openFile); 82 } 83 } 42 84 // Create the main view. 43 85 MainView *mainView = new MainView (mainPter); … … 53 95 return EXIT_SUCCESS; 54 96 } 97 98 gboolean 99 open_command_line_file (gpointer data) 100 { 101 g_assert (NULL != data && "The data parameter is NULL."); 102 103 OpenFileData *openFile = (OpenFileData *)data; 104 g_assert (NULL != openFile->presenter && "The presenter is NULL."); 105 g_assert (NULL != openFile->fileName && "The file name is NULL."); 106 openFile->presenter->openDocument (openFile->fileName, NULL, TRUE); 107 delete openFile; 108 109 // Returning FALSE means that the function won't be called again. 110 return FALSE; 111 }
