Changeset 97
- Timestamp:
- 04/20/06 10:08:49 (2 years ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
src/IMainView.h (modified) (1 diff)
-
src/MainPter.cxx (modified) (1 diff)
-
src/gtk/MainView.cxx (modified) (2 diffs)
-
src/gtk/MainView.h (modified) (1 diff)
-
tests/DumbMainView.cxx (modified) (4 diffs)
-
tests/DumbMainView.h (modified) (3 diffs)
-
tests/MainPterTest.cxx (modified) (3 diffs)
-
tests/MainPterTest.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/IMainView.h
r67 r97 49 49 /// the toolkit's specific open dialog. 50 50 /// 51 /// @param folder The last folder used to open a file. This is 52 /// used to show this folder when the open dialog 53 /// appears. 54 /// 51 55 /// @return A copy of the file name that the user will try to open 52 56 /// or NULL if the user cancelled the operation. 53 57 /// This string will be freed by the presenter. 54 58 /// 55 virtual gchar *openFileDialog ( void) = 0;59 virtual gchar *openFileDialog (const gchar *lastFolder) = 0; 56 60 57 61 /// -
trunk/src/MainPter.cxx
r67 r97 253 253 { 254 254 IMainView &view = getView (); 255 gchar *fileName = view.openFileDialog (); 255 Config &config = Config::getConfig (); 256 257 gchar *lastFolder = config.getOpenFileFolder (); 258 gchar *fileName = view.openFileDialog (lastFolder); 259 g_free (lastFolder); 260 256 261 openDocument (fileName, NULL, TRUE); 257 g_free (fileName); 262 if ( NULL != fileName ) 263 { 264 gchar *dirName = g_path_get_dirname (fileName); 265 g_free (fileName); 266 267 config.setOpenFileFolder (dirName); 268 g_free (dirName); 269 } 270 258 271 } 259 272 -
trunk/src/gtk/MainView.cxx
r95 r97 192 192 193 193 gchar * 194 MainView::openFileDialog ( )194 MainView::openFileDialog (const gchar *lastFolder) 195 195 { 196 196 GtkWidget *openDialog = gtk_file_chooser_dialog_new (_("Open PDF File"), … … 200 200 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 201 201 NULL); 202 203 if ( NULL != lastFolder ) 204 { 205 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (openDialog), 206 lastFolder); 207 } 208 202 209 if ( GTK_RESPONSE_ACCEPT == gtk_dialog_run (GTK_DIALOG (openDialog)) ) 203 210 { -
trunk/src/gtk/MainView.h
r70 r97 32 32 ~MainView (); 33 33 34 gchar *openFileDialog ( );35 gchar *promptPasswordDialog ( );34 gchar *openFileDialog (const gchar *lastFolder); 35 gchar *promptPasswordDialog (void); 36 36 void sensitiveGoToFirstPage (gboolean sensitive); 37 37 void sensitiveGoToLastPage (gboolean sensitive); -
trunk/tests/DumbMainView.cxx
r73 r97 32 32 m_GoToPageText = g_strdup (""); 33 33 m_OpenFileName = g_strdup (""); 34 m_LastOpenFileFolder = NULL; 34 35 m_Outline = NULL; 35 36 m_Password = NULL; … … 57 58 { 58 59 g_free (m_GoToPageText); 60 g_free (m_LastOpenFileFolder); 59 61 g_free (m_OpenFileName); 60 62 g_free (m_Password); … … 63 65 64 66 gchar * 65 DumbMainView::openFileDialog (void) 66 { 67 DumbMainView::openFileDialog (const gchar *lastFolder) 68 { 69 g_free (m_LastOpenFileFolder); 70 m_LastOpenFileFolder = g_strdup (lastFolder); 67 71 return g_strdup (m_OpenFileName); 68 72 } … … 226 230 return m_CurrentPage; 227 231 } 232 233 const gchar * 234 DumbMainView::getLastOpenFileFolder () 235 { 236 return m_LastOpenFileFolder; 237 } 238 228 239 229 240 DocumentOutline * -
trunk/tests/DumbMainView.h
r66 r97 28 28 ~DumbMainView (); 29 29 30 gchar *openFileDialog ( void);30 gchar *openFileDialog (const gchar *lastFolder); 31 31 gchar *promptPasswordDialog (void); 32 32 void sensitiveGoToFirstPage (gboolean sensitive); … … 56 56 gint countTimesShownPasswordPrompt (void); 57 57 gint getCurrentPage (void); 58 const gchar *getLastOpenFileFolder (void); 58 59 DocumentOutline *getOutline (void); 59 60 const gchar *getTitle (void); … … 82 83 DocumentPage *m_DocumentPage; 83 84 gchar *m_GoToPageText; 85 gchar *m_LastOpenFileFolder; 84 86 gchar *m_OpenFileName; 85 87 DocumentOutline *m_Outline; -
trunk/tests/MainPterTest.cxx
r80 r97 36 36 m_View = new DumbMainView (m_MainPter); 37 37 m_MainPter->setView (m_View); 38 Config::loadFile (FALSE); 38 39 } 39 40 … … 47 48 // classes are deleted by it. 48 49 delete m_MainPter; 50 // Drop the current configuration. 51 Config::destroy (); 49 52 } 50 53 … … 292 295 } 293 296 297 /// 298 /// @brief Test the last folder used to open a file. 299 /// 300 /// When the presenter wants to open a file, it should pass to the 301 /// view the last folder that was used to open a file, so the 302 /// view can show it up when opening the dialog. 303 /// 304 void 305 MainPterTest::lastFolder () 306 { 307 m_View->setOpenFileName ("/tmp/test.pdf"); 308 m_MainPter->openFileActivated (); 309 CPPUNIT_ASSERT (NULL == m_View->getLastOpenFileFolder ()); 310 311 312 m_View->setOpenFileName ("/usr/test.pdf"); 313 m_MainPter->openFileActivated (); 314 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("/tmp", 315 m_View->getLastOpenFileFolder ())); 316 317 m_MainPter->openFileActivated (); 318 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("/usr", 319 m_View->getLastOpenFileFolder ())); 320 } 294 321 295 322 /// -
trunk/tests/MainPterTest.h
r66 r97 33 33 CPPUNIT_TEST (badPassword); 34 34 CPPUNIT_TEST (goodPassword); 35 CPPUNIT_TEST (lastFolder); 35 36 CPPUNIT_TEST (pageNavigation); 36 37 CPPUNIT_TEST (pageNavigationEntry); … … 54 55 void badPassword (void); 55 56 void goodPassword (void); 57 void lastFolder (void); 56 58 void pageNavigation (void); 57 59 void pageNavigationEntry (void);
