bakery r132 - in trunk: . bakery/App bakery/Document



Author: murrayc
Date: Mon Jan 19 16:54:34 2009
New Revision: 132
URL: http://svn.gnome.org/viewvc/bakery?rev=132&view=rev

Log:
2009-01-19  Murray Cumming  <murrayc murrayc com>

* bakery/App/App_WithDoc_Gtk.[h|cc]: document_history_add():
Remove the new method overload that took RecentManager::Data because 
there is no need to remember files that do not exist. Instead, just 
check that the file exists before giving the URI to RecentManager.
Added a comment about why this can happen with Glom.

Modified:
   trunk/ChangeLog
   trunk/bakery/App/App_WithDoc.cc
   trunk/bakery/App/App_WithDoc_Gtk.cc
   trunk/bakery/App/App_WithDoc_Gtk.h
   trunk/bakery/Document/Document.cc

Modified: trunk/bakery/App/App_WithDoc.cc
==============================================================================
--- trunk/bakery/App/App_WithDoc.cc	(original)
+++ trunk/bakery/App/App_WithDoc.cc	Mon Jan 19 16:54:34 2009
@@ -275,7 +275,7 @@
     if(bUseThisFileUri)
     {
       m_pDocument->set_file_uri(file_uri, true); //true = enforce file extension
-      bool bTest  = m_pDocument->save();
+      const bool bTest = m_pDocument->save();
 
       if(!bTest)
       {

Modified: trunk/bakery/App/App_WithDoc_Gtk.cc
==============================================================================
--- trunk/bakery/App/App_WithDoc_Gtk.cc	(original)
+++ trunk/bakery/App/App_WithDoc_Gtk.cc	Mon Jan 19 16:54:34 2009
@@ -265,39 +265,27 @@
 
 void App_WithDoc_Gtk::document_history_add(const Glib::ustring& file_uri)
 {
-#ifdef GTKMM_GEQ_2_10
-  if(!file_uri.empty())
-  {
-    //TODO: Wrap gnome_vfs_escape_path_string() in gnome-vfsmm.
-    //Glib::ustring filename_e = Gnome::Vfs::escape_path_string(file_uri);
-    Glib::ustring uri = file_uri; // "file://" + filename_e;
+  if(file_uri.empty())
+    return;
 
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
-    Gtk::RecentManager::get_default()->add_item(uri);
-#else
-    std::auto_ptr<Glib::Error> error;
-    Gtk::RecentManager::get_default()->add_item(uri, error);
-    // Ignore error
-#endif
-  }
-#endif // GTKMM_GEQ_2_10
-}
+  //This can sometimes be called for a file that does not yet exist on disk.
+  //Avoid warning in RecentManager if that is the case.
+  //For instance, Glom does this when the user chooses a new filename, 
+  //but before Glom has enough information to save a useful file.
+  if(file_exists(file_uri))
+    return;
 
-void App_WithDoc_Gtk::document_history_add(const Glib::ustring& file_uri,
-                                           Gtk::RecentManager::Data& data)
-{
 #ifdef GTKMM_GEQ_2_10
-  if(!file_uri.empty())
   {
     //TODO: Wrap gnome_vfs_escape_path_string() in gnome-vfsmm.
     //Glib::ustring filename_e = Gnome::Vfs::escape_path_string(file_uri);
     Glib::ustring uri = file_uri; // "file://" + filename_e;
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-    Gtk::RecentManager::get_default()->add_item(uri, data);
+    Gtk::RecentManager::get_default()->add_item(uri);
 #else
     std::auto_ptr<Glib::Error> error;
-    Gtk::RecentManager::get_default()->add_item(uri, data, error);
+    Gtk::RecentManager::get_default()->add_item(uri, error);
     // Ignore error
 #endif
   }

Modified: trunk/bakery/App/App_WithDoc_Gtk.h
==============================================================================
--- trunk/bakery/App/App_WithDoc_Gtk.h	(original)
+++ trunk/bakery/App/App_WithDoc_Gtk.h	Mon Jan 19 16:54:34 2009
@@ -69,8 +69,6 @@
   virtual void init_toolbars(); //overridden to add open/save
 
   virtual void document_history_add(const Glib::ustring& file_uri); //overridden.
-  virtual void document_history_add(const Glib::ustring& file_uri,
-                                    Gtk::RecentManager::Data& data);
   virtual void document_history_remove(const Glib::ustring& file_uri); //overridden.
 
   virtual void update_window_title();

Modified: trunk/bakery/Document/Document.cc
==============================================================================
--- trunk/bakery/Document/Document.cc	(original)
+++ trunk/bakery/Document/Document.cc	Mon Jan 19 16:54:34 2009
@@ -170,7 +170,7 @@
   if(m_pView)
     m_pView->save_to_document();
 
-  bool bTest = save_before(); //This could be overridden.
+  const bool bTest = save_before(); //This could be overridden.
   if(bTest)
     return write_to_disk();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]