[glom] Initial dialog: Really try to load examples from each path.



commit 45fdc57aa670c01bc956cbb047bc058a6d841575
Author: David King <davidk openismus com>
Date:   Thu Sep 9 13:03:21 2010 +0200

    Initial dialog: Really try to load examples from each path.
    
    	* glom/dialog_existing_or_new.[h|cc]: list_examples_at_path():
      Use synchronous IO rather than asynchronous, to solve bug #626417.
      This means that we really check the result of trying the first directory,
      so we can try the other location too.

 ChangeLog                      |    9 ++
 glom/dialog_existing_or_new.cc |  270 +++++++++++++++++-----------------------
 glom/dialog_existing_or_new.h  |   13 +--
 3 files changed, 127 insertions(+), 165 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ae9a9bc..eb8b38d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-09  David King  <davidk openismus com>
+
+	Initial dialog: Really try to load examples from each path.
+
+	* glom/dialog_existing_or_new.[h|cc]: list_examples_at_path():
+  Use synchronous IO rather than asynchronous, to solve bug #626417.
+  This means that we really check the result of trying the first directory,
+  so we can try the other location too.
+
 2010-09-09  Murray Cumming  <murrayc murrayc com>>
 
 	Choices drop-down: Remove hack to fix the list view choices.
diff --git a/glom/dialog_existing_or_new.cc b/glom/dialog_existing_or_new.cc
index bf33f01..52b3dcc 100644
--- a/glom/dialog_existing_or_new.cc
+++ b/glom/dialog_existing_or_new.cc
@@ -113,7 +113,7 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
   builder->get_widget("existing_or_new_label", label);
   label->set_text(_("Open a Document"));
 #endif //GLOM_ENABLE_CLIENT_ONLY
-  
+
   builder->get_widget("existing_or_new_existing_treeview", m_existing_view);
   g_assert(m_existing_view);
 
@@ -127,7 +127,7 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
   m_existing_model->set_sort_column(m_existing_columns.m_col_time, Gtk::SORT_DESCENDING);
   m_existing_view->set_model(m_existing_model);
 
- 
+
 
   m_iter_existing_other = m_existing_model->append();
   (*m_iter_existing_other)[m_existing_columns.m_col_title] = _("Select File");
@@ -139,8 +139,8 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
 
   m_iter_existing_recent = m_existing_model->append();
   (*m_iter_existing_recent)[m_existing_columns.m_col_title] = _("Recently Opened");
-  
- 
+
+
 
   m_existing_column_title.set_expand(true);
   m_existing_column_title.pack_start(m_existing_icon_renderer, false);
@@ -151,29 +151,6 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
 
   m_existing_view->set_headers_visible(false);
   m_existing_view->signal_row_activated().connect(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_existing_row_activated));
- 
- // Load example files:
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-
-#ifdef G_OS_WIN32
-  gchar* dir = g_win32_get_package_installation_directory_of_module(0);
-  std::string path = Glib::build_filename(dir, "share" G_DIR_SEPARATOR_S "doc"
-                                                       G_DIR_SEPARATOR_S "glom"
-                                                       G_DIR_SEPARATOR_S "examples");
-  g_free(dir);
-
-  if(!Glib::file_test(path, Glib::FILE_TEST_EXISTS))
-    path = GLOM_DOCDIR_EXAMPLES;
-#else
-  const char *const path = GLOM_DOCDIR_EXAMPLES;
-#endif //G_OS_WIN32
-
-  //Show the installed example files,
-  //falling back to the ones from the local source tree if none are installed:
-  if(!list_examples_at_path(path))
-    list_examples_at_path(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED);
-
-#endif //!GLOM_ENABLE_CLIENT_ONLY
 
 
   // Browse local network
@@ -208,9 +185,9 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
   m_iter_existing_network_dummy = create_dummy_item_existing(m_iter_existing_network, _(NETWORK_DUMMY_TEXT));
 #endif
 
- 
+
   // Expand recently used files and the networked files,
-  // because the contents help to explain what this is: 
+  // because the contents help to explain what this is:
   m_existing_view->expand_row(m_existing_model->get_path(m_iter_existing_recent), false);
 #ifndef G_OS_WIN32
   m_existing_view->expand_row(m_existing_model->get_path(m_iter_existing_network), false);
@@ -222,35 +199,35 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   m_notebook->signal_switch_page().connect(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_switch_page));
 #endif /* !GLOM_ENABLE_CLIENT_ONLY */
-    
+
   Glib::RefPtr<Gtk::TreeView::Selection> existing_view_selection = m_existing_view->get_selection();
   existing_view_selection->signal_changed().connect(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_existing_selection_changed));
-  existing_view_selection->set_select_function( sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_existing_select_func) ); 
+  existing_view_selection->set_select_function( sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_existing_select_func) );
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   builder->get_widget("existing_or_new_new_treeview", m_new_view);
   g_assert(m_new_view);
   m_new_model = Gtk::TreeStore::create(m_new_columns);
   m_new_view->set_model(m_new_model);
-  
+
   m_iter_new_empty = m_new_model->append();
   (*m_iter_new_empty)[m_new_columns.m_col_title] = _("New Empty Document");
 
   m_iter_new_template = m_new_model->append();
   (*m_iter_new_template)[m_new_columns.m_col_title] = _("New From Template");
-  
+
   m_new_column_title.set_expand(true);
   m_new_column_title.pack_start(m_new_icon_renderer, false);
   m_new_column_title.pack_start(m_new_title_renderer, true);
   m_new_column_title.set_cell_data_func(m_new_icon_renderer, sigc::mem_fun(*this, &Dialog_ExistingOrNew::new_icon_data_func));
   m_new_column_title.set_cell_data_func(m_new_title_renderer, sigc::mem_fun(*this, &Dialog_ExistingOrNew::new_title_data_func));
   m_new_view->append_column(m_new_column_title);
-  
+
   m_new_view->set_headers_visible(false);
   m_new_view->signal_row_activated().connect(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_new_row_activated));
 
   m_iter_new_template_dummy = create_dummy_item_new(m_iter_new_template, _(TEMPLATE_DUMMY_TEXT));
- 
+
   Glib::RefPtr<Gtk::TreeView::Selection> new_view_selection = m_new_view->get_selection();
   new_view_selection->signal_changed().connect(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_new_selection_changed));
   new_view_selection->set_select_function( sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_new_select_func) );
@@ -258,10 +235,34 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
   m_notebook->remove_page(NEW_PAGE);
   m_notebook->set_show_tabs(false);
 #endif /* !GLOM_ENABLE_CLIENT_ONLY */
-    
-  //Make sure the first item is visible, 
-  //which is not always the case on Maemo. 
-  m_existing_view->scroll_to_row( 
+
+
+ // Load example files:
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+
+#ifdef G_OS_WIN32
+  gchar* dir = g_win32_get_package_installation_directory_of_module(0);
+  std::string path = Glib::build_filename(dir, "share" G_DIR_SEPARATOR_S "doc"
+                                                       G_DIR_SEPARATOR_S "glom"
+                                                       G_DIR_SEPARATOR_S "examples");
+  g_free(dir);
+
+  if(!Glib::file_test(path, Glib::FILE_TEST_EXISTS))
+    path = GLOM_DOCDIR_EXAMPLES;
+#else
+  const char *const path = GLOM_DOCDIR_EXAMPLES;
+#endif //G_OS_WIN32
+
+  //Show the installed example files,
+  //falling back to the ones from the local source tree if none are installed:
+  if(!list_examples_at_path(path))
+    list_examples_at_path(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED);
+
+#endif //!GLOM_ENABLE_CLIENT_ONLY
+
+  //Make sure the first item is visible,
+  //which is not always the case on Maemo.
+  m_existing_view->scroll_to_row(
     Gtk::TreeModel::Path(m_iter_existing_other) );
 
   update_ui_sensitivity();
@@ -272,20 +273,32 @@ bool Dialog_ExistingOrNew::list_examples_at_path(const std::string& path)
 {
   //std::cout << "debug: " << G_STRFUNC << ": path=" << path << std::endl;
 
-  m_examples_dir = Gio::File::create_for_path(path);
+  Glib::RefPtr<Gio::File> examples_dir = Gio::File::create_for_path(path);
+  Glib::RefPtr<Gio::FileInfo> info;
 
   try
   {
-    m_examples_dir->enumerate_children_async(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_enumerate_children),
-                                             G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE","G_FILE_ATTRIBUTE_STANDARD_NAME);
+    Glib::RefPtr<Gio::FileEnumerator> examples = examples_dir->enumerate_children(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE","G_FILE_ATTRIBUTE_STANDARD_NAME);
+    bool example_found = false;
+    while(info = examples->next_file())
+    {
+      const Glib::ustring title = get_title_from_example(info, examples_dir);
+      if(!title.empty())
+      {
+        append_example(title, Gio::File::create_for_path(Glib::build_filename(examples_dir->get_path(), info->get_name())));
+      	example_found = true;
+      }
+    }
+
     // TODO: Monitor example directory for new/removed files?
-    return true;
+    return example_found;
   }
   catch(const Glib::Exception& ex)
   {
-    std::cerr << "Could not enumerate examples at path=:" << path << ex.what() << std::endl;
-    return false;
+    std::cerr << "Could not enumerate examples at path=" << path << ", Error=" << ex.what() << std::endl;
   }
+
+  return false;
 }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
@@ -367,7 +380,7 @@ Dialog_ExistingOrNew::Action Dialog_ExistingOrNew::get_action_impl(Gtk::TreeMode
       return NONE;
     #endif //GLOM_ENABLE_CLIENT_ONLY
   }
-  
+
   return NONE;
 }
 
@@ -387,7 +400,7 @@ Glib::ustring Dialog_ExistingOrNew::get_uri() const
   {
     return (*iter)[m_new_columns.m_col_template_uri];
   }
-  else 
+  else
   #endif //GLOM_ENABLE_CLIENT_ONLY
   if(action == OPEN_URI)
   {
@@ -403,7 +416,7 @@ Glib::ustring Dialog_ExistingOrNew::get_uri() const
   }
   else
   {
-    throw std::logic_error("Dialog_ExistingOrNew::get_uri: action is neither NEW_FROM_TEMPLATE nor OPEN_URI"); 
+    throw std::logic_error("Dialog_ExistingOrNew::get_uri: action is neither NEW_FROM_TEMPLATE nor OPEN_URI");
   }
 
   return Glib::ustring();
@@ -416,7 +429,7 @@ EpcServiceInfo* Dialog_ExistingOrNew::get_service_info() const
   Action action = get_action_impl(iter);
 
   if(action == OPEN_REMOTE)
-    return (*iter)[m_existing_columns.m_col_service_info];  
+    return (*iter)[m_existing_columns.m_col_service_info];
   else
     throw std::logic_error("Dialog_ExistingOrNew::get_service_info: action is not OPEN_REMOTE");
 
@@ -429,7 +442,7 @@ Glib::ustring Dialog_ExistingOrNew::get_service_name() const
   Action action = get_action_impl(iter);
 
   if(action == OPEN_REMOTE)
-    return (*iter)[m_existing_columns.m_col_service_name];  
+    return (*iter)[m_existing_columns.m_col_service_name];
   else
     throw std::logic_error("Dialog_ExistingOrNew::get_service_name: action is not OPEN_REMOTE");
 
@@ -455,8 +468,8 @@ std::auto_ptr<Gtk::TreeModel::iterator> Dialog_ExistingOrNew::create_dummy_item_
 
 void Dialog_ExistingOrNew::existing_icon_data_func(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter)
 {
-  Gtk::CellRendererPixbuf* pixbuf_renderer = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);  
-  if(!pixbuf_renderer) 
+  Gtk::CellRendererPixbuf* pixbuf_renderer = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
+  if(!pixbuf_renderer)
   throw std::logic_error("Renderer not a pixbuf renderer in existing_icon_data_func");
 
   pixbuf_renderer->property_stock_size() = Gtk::ICON_SIZE_BUTTON;
@@ -501,7 +514,7 @@ void Dialog_ExistingOrNew::existing_icon_data_func(Gtk::CellRenderer* renderer,
 #endif
     else
     {
-      throw std::logic_error("Unexpected iterator in existing_icon_data_func");   
+      throw std::logic_error("Unexpected iterator in existing_icon_data_func");
     }
   }
 }
@@ -516,7 +529,7 @@ void Dialog_ExistingOrNew::existing_title_data_func(Gtk::CellRenderer* renderer,
 
   // Default: Use default color:
   text_renderer->property_foreground_set() = false;
-  
+
   // Use grey if parent item has no children:
 #ifndef G_OS_WIN32
   if( (iter == m_iter_existing_network && m_iter_existing_network_dummy.get()) ||
@@ -539,7 +552,7 @@ void Dialog_ExistingOrNew::new_icon_data_func(Gtk::CellRenderer* renderer, const
   pixbuf_renderer->property_stock_size() = Gtk::ICON_SIZE_BUTTON;
   pixbuf_renderer->property_stock_id() = "";
   pixbuf_renderer->property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>();
-      
+
   if(iter == m_iter_new_empty)
     pixbuf_renderer->property_stock_id() = Gtk::Stock::NEW.id;
   else if(iter == m_iter_new_template)
@@ -554,7 +567,7 @@ void Dialog_ExistingOrNew::new_icon_data_func(Gtk::CellRenderer* renderer, const
     }
     else
     {
-      throw std::logic_error("Unexpected iterator in new_icon_data_func");   
+      throw std::logic_error("Unexpected iterator in new_icon_data_func");
     }
   }
 }
@@ -562,8 +575,8 @@ void Dialog_ExistingOrNew::new_icon_data_func(Gtk::CellRenderer* renderer, const
 void Dialog_ExistingOrNew::new_title_data_func(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter)
 {
   Gtk::CellRendererText* text_renderer = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(!text_renderer) 
-    throw std::logic_error("Renderer not a text renderer in new_title_data_func");  
+  if(!text_renderer)
+    throw std::logic_error("Renderer not a text renderer in new_title_data_func");
 
   text_renderer->property_text() = (*iter)[m_new_columns.m_col_title];
 
@@ -620,7 +633,7 @@ void Dialog_ExistingOrNew::update_ui_sensitivity()
 #endif
     }
   }
-  #ifndef GLOM_ENABLE_CLIENT_ONLY
+#ifndef GLOM_ENABLE_CLIENT_ONLY
   else
   {
     const int count = m_new_view->get_selection()->count_selected_rows();
@@ -636,134 +649,81 @@ void Dialog_ExistingOrNew::update_ui_sensitivity()
                      (!m_iter_new_template_dummy.get() || sel != *m_iter_new_template_dummy));
     }
   }
-  #endif //GLOM_ENABLE_CLIENT_ONLY
+#endif //GLOM_ENABLE_CLIENT_ONLY
 
   m_select_button->set_sensitive(sensitivity);
 }
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
-void Dialog_ExistingOrNew::on_enumerate_children(const Glib::RefPtr<Gio::AsyncResult>& res)
+Glib::ustring Dialog_ExistingOrNew::get_title_from_example(const Glib::RefPtr<Gio::FileInfo>& info, const Glib::RefPtr<Gio::File>& examples_dir)
 {
-  if(!m_examples_dir)
-    return;
-
   try
   {
-    m_examples_enumerator = m_examples_dir->enumerate_children_finish(res);
-    m_examples_enumerator->next_files_async(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_next_files));
-  }
-  catch(const Glib::Exception& ex)
-  {
-    std::cerr << "Could not enumerate files in examples directory: " << ex.what() << std::endl;
-    
-    m_examples_enumerator.reset();
-    m_examples_dir.reset();
-  }
-}
+    // Load file.
+    const Glib::ustring content_type = info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
+    const Glib::ustring mime_type = Gio::content_type_get_mime_type(content_type);
 
-void Dialog_ExistingOrNew::on_next_files(const Glib::RefPtr<Gio::AsyncResult>& res)
-{
-  try
-  {
-    const Glib::ListHandle<Glib::RefPtr<Gio::FileInfo> >& list = m_examples_enumerator->next_files_finish(res);
-    if(list.empty())
+    if(mime_type == "application/x-glom")
     {
-      // Done
-      m_examples_dir.reset();
-      m_examples_enumerator.reset();
-    }
-    else
-    {
-      // Load file
-      Glib::RefPtr<Gio::FileInfo> info = *list.begin();
-      Glib::ustring content_type = info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
-      Glib::ustring mime_type = Gio::content_type_get_mime_type(content_type);
-
-      if(mime_type == "application/x-glom")
-      {
-        m_current_example = Gio::File::create_for_path(Glib::build_filename(m_examples_dir->get_path(), info->get_name()));
-        m_current_example->read_async(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_read));
-      }
-      else
-      {
-        // File is not a glom file, continue with next
-        m_examples_enumerator->next_files_async(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_next_files));
-      }
+      const Glib::RefPtr<Gio::File> current_example =
+        Gio::File::create_for_path(Glib::build_filename(examples_dir->get_path(), info->get_name()));
+      Glib::RefPtr<Gio::FileInputStream> stream = current_example->read();
+      m_current_buffer.reset(new buffer);
+      const int bytes_read = stream->read(m_current_buffer->buf, buffer::SIZE);
+      const std::string data(m_current_buffer->buf, bytes_read);
+      // TODO: Check that data is valid UTF-8, the last character might be truncated
+
+      Parser parser;
+      return (Glib::ustring(parser.get_example_title(data)));
     }
   }
-  catch(const Glib::Exception& ex)
+  catch(const Glib::Exception& exception)
   {
-    std::cerr << "Could not enumerate examples: " << ex.what() << std::endl;
+    std::cerr << "Could not enumerate files in examples directory: " << exception.what() << std::endl;
 
-    m_examples_dir.reset();
-    m_examples_enumerator.reset();
+    m_current_buffer.reset();
   }
+
+  // File is not a glom file, continue with next.
+  return Glib::ustring();
 }
 
-void Dialog_ExistingOrNew::on_read(const Glib::RefPtr<Gio::AsyncResult>& res)
+void Dialog_ExistingOrNew::append_example(const Glib::ustring& title, const Glib::RefPtr<Gio::File>& file)
 {
-  try
+  if(!m_new_model)
   {
-    m_current_stream = m_current_example->read_finish(res);
-    m_current_buffer.reset(new buffer);
-    m_current_stream->read_async(m_current_buffer->buf, buffer::SIZE, sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_stream_read));
+    std::cerr << G_STRFUNC << ": m_new_model is null" << std::endl;
+    return;
   }
-  catch(const Glib::Exception& exception)
-  {
-    // Could not read this file, read next
-    m_examples_enumerator->next_files_async(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_next_files));
 
-    m_current_example.reset();
-    m_current_stream.reset();
-    m_current_buffer.reset();
+  if(!m_iter_new_template)
+  {
+    std::cerr << G_STRFUNC << ": m_iter_new_template is null" << std::endl;
+    return;
   }
-}
 
-void Dialog_ExistingOrNew::on_stream_read(const Glib::RefPtr<Gio::AsyncResult>& res)
-{
   try
   {
-    gssize size_read = m_current_stream->read_finish(res);
-    std::string data(m_current_buffer->buf, size_read);
-    // TODO: Check that data is valid UTF-8, the last character might be truncated
+    const bool is_first_item = m_iter_new_template_dummy.get();
 
-    Parser parser;
-    Glib::ustring title = parser.get_example_title(data);
+    // Add to list.
+    Gtk::TreeModel::iterator iter = m_new_model->append(m_iter_new_template->children());
+    (*iter)[m_new_columns.m_col_title] = title;
+    (*iter)[m_new_columns.m_col_template_uri] = file->get_uri();
 
-    if(title.empty())
-    {
-      // TODO: Read more data from this file?
-    }
-    else
+    if(is_first_item)
     {
-      const bool is_first_item = m_iter_new_template_dummy.get();
-
-      // Add to list
-      Gtk::TreeModel::iterator iter = m_new_model->append(m_iter_new_template->children());
-      (*iter)[m_new_columns.m_col_title] = title;
-      (*iter)[m_new_columns.m_col_template_uri] = m_current_example->get_uri();
-
-      if(is_first_item)
-      {
-        // Remove dummy
-        m_new_model->erase(*m_iter_new_template_dummy);
-        m_iter_new_template_dummy.reset();
-        // Expand if this is the first item
-        m_new_view->expand_row(m_new_model->get_path(m_iter_new_template), false);
-      }
+      // Remove dummy.
+      m_new_model->erase(*m_iter_new_template_dummy);
+      m_iter_new_template_dummy.reset();
+      // Expand if this is the first item.
+      m_new_view->expand_row(m_new_model->get_path(m_iter_new_template), false);
     }
   }
   catch(const Glib::Exception& ex)
   {
-    std::cerr << "Could not read " << m_current_example->get_path() << ": " << ex.what() << std::endl;
+    std::cerr << "Could not read example: " << file->get_path() << ": " << ex.what() << std::endl;
   }
-
-  // Done with this, read next file
-  m_current_example.reset();
-  m_current_stream.reset();
-  m_current_buffer.reset();
-
-  m_examples_enumerator->next_files_async(sigc::mem_fun(*this, &Dialog_ExistingOrNew::on_next_files));
 }
 #endif /* !GLOM_ENABLE_CLIENT_ONLY */
 
@@ -790,7 +750,7 @@ void Dialog_ExistingOrNew::on_service_found(const Glib::ustring& name, EpcServic
 
   epc_service_info_ref(info);
   g_free(title);
-  
+
   // Remove dummy item
   if(m_iter_existing_network_dummy.get())
   {
diff --git a/glom/dialog_existing_or_new.h b/glom/dialog_existing_or_new.h
index 37c9e52..afd0b38 100644
--- a/glom/dialog_existing_or_new.h
+++ b/glom/dialog_existing_or_new.h
@@ -95,10 +95,8 @@ private:
 
   
   bool list_examples_at_path(const std::string& path);
-  void on_enumerate_children(const Glib::RefPtr<Gio::AsyncResult>& res);
-  void on_next_files(const Glib::RefPtr<Gio::AsyncResult>& res);
-  void on_read(const Glib::RefPtr<Gio::AsyncResult>& res);
-  void on_stream_read(const Glib::RefPtr<Gio::AsyncResult>& res);
+  Glib::ustring get_title_from_example(const Glib::RefPtr<Gio::FileInfo>& info, const Glib::RefPtr<Gio::File>& examples_dir);
+  void append_example(const Glib::ustring& title, const Glib::RefPtr<Gio::File>& file);
 #endif /* !GLOM_ENABLE_CLIENT_ONLY */
     
 #ifndef G_OS_WIN32
@@ -197,11 +195,6 @@ private:
 
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
-  Glib::RefPtr<Gio::File> m_examples_dir;
-  Glib::RefPtr<Gio::FileEnumerator> m_examples_enumerator;
-  Glib::RefPtr<Gio::File> m_current_example;
-  Glib::RefPtr<Gio::InputStream> m_current_stream;
-    
   struct buffer { static const guint SIZE = 1024; char buf[SIZE]; };
   std::auto_ptr<buffer> m_current_buffer;
 #endif /* !GLOM_ENABLE_CLIENT_ONLY */
@@ -216,5 +209,5 @@ private:
 
 } //namespace Glom
 
-#endif //GLOM_DIALOG_DATABASE_PREFERENCES_H
+#endif //GLOM_DIALOG_EXISTING_OR_NEW_H
 



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