[glom/import_csv_refactored: 41/41] Merged from master



commit 46e76d6f92be9a5dcc16c0f5c63e98cf3ecc3800
Merge: 60fa53e... eccde55...
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Sep 25 17:57:49 2009 +0200

    Merged from master

 ChangeLog                                          |  161 ++++
 Makefile.am                                        |    2 +-
 Makefile_glom.am                                   |   20 +-
 Makefile_tests.am                                  |    1 +
 NEWS                                               |   16 +
 configure.ac                                       |    9 +-
 glom/application.cc                                |  177 +++--
 glom/application.h                                 |   34 +-
 glom/bakery/app_withdoc_gtk.cc                     |   30 +-
 glom/base_db.cc                                    |    6 +-
 glom/box_reports.cc                                |    2 +
 glom/box_reports.h                                 |    2 +
 glom/box_withbuttons.h                             |    2 +-
 glom/frame_glom.cc                                 |   95 ++-
 glom/frame_glom.h                                  |   21 +-
 glom/glom.glade                                    |    2 +-
 glom/import_csv/dialog_import_csv.cc               |    3 +
 glom/libglom/connectionpool_backends/postgres.cc   |   16 +-
 glom/libglom/connectionpool_backends/postgres.h    |    6 +-
 .../connectionpool_backends/postgres_self.cc       |  246 +++++-
 .../connectionpool_backends/postgres_self.h        |    8 +
 glom/libglom/document/document.cc                  |    2 +-
 glom/libglom/{glom-1.0.pc.in => glom-1.12.pc.in}   |    0
 glom/libglom/spawn_with_feedback.cc                |  107 ++-
 glom/libglom/spawn_with_feedback.h                 |    8 +
 glom/main.cc                                       |    9 +-
 glom/mode_data/box_data.cc                         |    2 +-
 glom/mode_data/box_data_list.cc                    |    1 -
 glom/mode_data/box_data_list_related.cc            |    1 -
 glom/mode_data/notebook_data.cc                    |   71 ++-
 glom/mode_data/notebook_data.h                     |   21 +-
 glom/navigation/box_tables.cc                      |    2 +
 glom/navigation/box_tables.h                       |    8 +-
 glom/navigation/maemo/pickerbutton_table.cc        |  119 +++
 glom/navigation/maemo/pickerbutton_table.h         |   75 ++
 glom/utility_widgets/adddel/adddel.cc              |   10 -
 glom/utility_widgets/adddel/adddel.h               |    4 -
 .../utility_widgets/canvas/canvas_image_movable.cc |    4 +-
 glom/utility_widgets/datawidget.cc                 |   66 +--
 glom/utility_widgets/db_adddel/db_adddel.cc        |  514 +++++++----
 glom/utility_widgets/db_adddel/db_adddel.h         |   54 +-
 .../db_adddel/db_adddel_withbuttons.cc             |    6 +-
 glom/utility_widgets/entryglom.cc                  |   29 +-
 glom/utility_widgets/entryglom.h                   |   13 +-
 glom/utility_widgets/flowtable.cc                  |    2 +-
 glom/utility_widgets/imageglom.cc                  |    4 +-
 glom/utility_widgets/textviewglom.cc               |    8 +-
 glom/utility_widgets/textviewglom.h                |    9 +
 glom/utils_ui.cc                                   |   98 ++
 glom/utils_ui.h                                    |    6 +
 glom/{dialog_glom.cc => window_boxholder.cc}       |   23 +-
 glom/{dialog_glom.h => window_boxholder.h}         |   33 +-
 po/POTFILES.in                                     |    1 +
 po/de.po                                           |  929 ++++++++++----------
 po/es.po                                           |   84 +-
 tests/import/test_parsing.cc                       |    1 +
 tests/import/test_signals.cc                       |    1 +
 tests/import/utils.cc                              |    1 +
 tests/import/utils.h                               |    4 +-
 59 files changed, 2148 insertions(+), 1041 deletions(-)
---
diff --cc ChangeLog
index 82bd453,311969e..891f1c2
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,60 -1,81 +1,139 @@@
 +2009-09-25  Murray Cumming  <murrayc murrayc-desktop>
 +
 +	Import tests: Fixed.
 +
 +	* tests/import/utils.[h|cc]: run_parser_from_buffer(): Added a 
 +	version that takes a std::string, to make the common case more robust.
 +	* tests/import/test_parsing.cc:
 +	* tests/import/test_signals.cc: Fix the tests by not incorrectly 
 +	taking the length of the raw arrays, which caused the temp files to 
 +	contain garbage.
 +
 +2009-09-25  Murray Cumming  <murrayc murrayc-desktop>
 +
 +	Import tests: Handle encoding errors.
 +
 +	* tests/import/utils.cc: Handle signal_encoding_error too, because this
 +	is one way that the parser can stop.
 +	Increase the timeout because an infinite loop is unlikely (and not 
 +	currently happening).
 +
 +2009-09-25  Murray Cumming  <murrayc murrayc com>
 +
 +	tests/import/: Small cleanup.
 +
 +	* tests/import/test_parsing.cc:
 +	* tests/import/utils.[h|cc]: Use a sigc::slot instead of the ugly 
 +	(because not typedefed) function pointer type.
 +
 +2009-09-25  Murray Cumming  <murrayc murrayc com>
 +
 +	Removed some debug output.
 +
 +	* glom/libglom/data_structure/glomconversions.cc: parse_time():
 +	* tests/test_parsing_time.cc: Removed debug output.
 +
 +2009-09-25  Michael Hasselmann  <michaelh openismus com>
 +
 +	Import: Changed the signature of line_scanned handler
 +	
 +	* glom/import_csv/dialog_import_csv.[h|cc]: Changed the signare of
 +	on_parser_line_scanned, to use CsvParser::type_row_strings. It does not
 +	change anything, as the handler didn't even use the parameters.
 +
 +	Import: Fixed tests to fit new parser API
 +	
 +	* glom/import_csv/csv_parser.[h|cc]: Added a finished_parsing signal since the
 +	max_row count logic is flawed
 +	(https://bugzilla.gnome.org/show_bug.cgi?id=588233#c16). Also moved common
 +	parts of on_stream_read(.) (now on_buffer_read(.)) into
 +	copy_buffer_and_continue_reading(.), to avoid copy'n'paste bugs.
 +	
 +	* tests/import/utils.[h|cc]: Added mainloop functionality to trigger the idle
 +	parse sequence of the CsvParser for the testcases.
 +	
 +	* tests/import/test_[parsing,signals].cc: Fixed the tests to fit new parser
 +	API.
 +
+ 1.12.0:
+ 
+ 2009-09-25  Murray Cumming  <murrayc murrayc com>
+ 
+ 	Command spawning: Really check the return value.
+ 
+ 	* glom/libglom/spawn_with_feedback.cc:
+ 	execute_command_line_and_wait_until_second_command_returns_success():
+ 	Actually check the return value of the first command, so we can fail 
+ 	immediately (with stderr output) when, for instance, postgresql 
+ 	fails to read the configuration file due to changed options, such as 
+ 	no longer recognizing max_fsm_pages in PostgreSQL 8.4
+ 
+ 2009-09-25  Murray Cumming  <murrayc murrayc com>
+ 
+ 	Replace some NULLs with 0 because this is C++, not C.
+ 
+ 	* glom/libglom/connectionpool_backends/postgres.cc:
+ 	* glom/libglom/connectionpool_backends/postgres_self.cc:
+ 	* glom/libglom/spawn_with_feedback.cc: Replace NULLs with 0.
+ 
+ 2009-09-24  Murray Cumming  <murrayc murrayc com>
+ 
+ 	Self-Hosting: Use the new ident configuration for PostgreSQL 8.4.
+ 
+ 	* glom/libglom/spawn_with_feedback.[h|cc]: Added an 
+ 	execute_command_line_and_wait() overload that has an output parameter 
+ 	for the stdout from the command.
+ 	* glom/libglom/connectionpool_backends/postgres_self.[h|cc]:
+ 	Added a get_postgresql_utils_version_as_number() utiltity method, 
+ 	and use it in set_network_shared() to use a different syntax for 
+ 	Postgres 8.4, hopefully fixing bug #595608 (Fryderyk Dziarmagowski)
+ 
+ 2009-09-24  Murray Cumming  <murrayc murrayc com>
+ 
+ 	Self-Hosting: Retry the connection just-long-enough.
+ 
+ 	* glom/libglom/connectionpool_backends/postgres.[h|cc]: attempt_connect(): 
+ 	Add a throw() declaration because we know that this really never throws, 
+ 	though other similar methods do.
+ 	* glom/libglom/connectionpool_backends/postgres_self.cc: connect():
+ 	If not network-shared then retry every second when the connection fails, 
+ 	because the (default) password really must be correct. Seems to work, 
+ 	requiring 6 retries on my system. 
+ 	However, we must still wait a hard-coded time to be sure of failure 
+ 	if the password is not the default one, for instance when network sharing.
+ 	* glom/libglom/spawn_with_feedback.cc: 
+ 	execute_command_line_and_wait_until_second_command_returns_success():
+ 	Remove the hacked 8-second wait here. 
+ 
+ 2009-09-23  Murray Cumming  <murrayc murrayc com>
+ 
+ 	Renamed Dialog_Glom to Window_BoxHolder.
+ 
+ 	* glom/dialog_glom.[h|cc]: Renamed to window_boxholder.[h|cc] to make 
+ 	its purpose clearer.
+ 	* glom/frame_glom.[h|cc]:
+ 	* glom/mode_data/notebook_data.[h|cc]:
+ 	* Makefile_glom.am: Adapted.
+ 
+ 2009-09-22  Murray Cumming  <murrayc murrayc com>
+ 
+ 	Dialog_Glom: Make this a little less stupid, so we can ifdef for Maemo.
+ 
+ 	* glom/dialog_glom.[h|cc]: Derive from Window, not Dialog.
+ 	Constructor: Add the provided box instead of requiring us to add it 
+ 	explicitly (to the Dialog's vbox).
+ 	* glom/frame_glom.cc:
+ 	* glom/mode_data/notebook_data.cc: Adapt.
+ 
+ 2009-09-22  Murray Cumming  <murrayc murrayc com>
+ 
+ 	On Maemo, show the details in a separate window.
+ 	
+ 	* glom/mode_data/notebook_data.[h|cc]: On maemo, hide the tabs, and don't 
+ 	add the details box to the notebook. Instead add it to a window and show that 	
+ 	window instead of switching to a details tab when details are requested.
+ 
++
  2009-09-21  Murray Cumming  <murrayc murrayc com>
  
  	import tests: Fix the no-exceptions build.
@@@ -72,23 -131,17 +189,36 @@@
  
  2009-09-18  Murray Cumming  <murrayc murrayc com>
  
 +	CsvParser: Make this an actual parser, with a sane API.
 +
 +	* glom/dialog_import_csv.[h|cc]:
 +	* glom/dialog_import_csv_progress.[h|cc]: Move into glom/import_csv/
 +	* glom/import_csv/: Added file_encodings.[h|cc], moving the encodings 
 +	list into it. This is similar to mode_design/iso_codes.[h|cc].
 +	* glom/import_csv.[h|cc]: Rename to glom/import_csv/csv_parser.[h|cc] 
 +	to match the class name.
 +	Move actual parsing (and the vector of row/column data) into 
 +	CsvParser, leaving the dialogs to just respond to signals and get 
 +	data via get methods.
 +
 +	However, this breaks the import tests, because they add data to 
 +	the parser directly using m_raw. They must be changed to read actual 
 +	files, or maybe we could add some intermediate level of API that they 
 +	could test.
 +
++2009-09-18  Murray Cumming  <murrayc murrayc com>
++
+ 	Maemo: Use some Hildon widgets.
+ 	
+ 	* glom/utility_widgets/entryglom.[h|cc]:
+ 	* glom/utility_widgets/textviewglom.h: Use Hildon::TextView and Hildon::Entry.
+ 
+ 2009-09-18  Murray Cumming  <murrayc murrayc com>
+ 
+ 	* configure.ac: Add a full configure example for maemo in a comment, 
+ 		to help my memory.
+ 	* glom/dialog_import_csv.cc: Fix a typo to fix the build on maemo. 
+ 
  2009-09-18  Murray Cumming  <murrayc murrayc-desktop>
  
  	CsvParser: Made some API private.
diff --cc Makefile_glom.am
index 01c03f6,114036e..72dbcb5
--- a/Makefile_glom.am
+++ b/Makefile_glom.am
@@@ -34,8 -34,10 +34,6 @@@ glom_glom_SOURCES =							
  	glom/dialog_connection.h					\
  	glom/dialog_existing_or_new.cc					\
  	glom/dialog_existing_or_new.h					\
- 	glom/dialog_glom.cc						\
- 	glom/dialog_glom.h						\
 -	glom/dialog_import_csv.cc					\
 -	glom/dialog_import_csv.h					\
 -	glom/dialog_import_csv_progress.cc				\
 -	glom/dialog_import_csv_progress.h				\
  	glom/dialog_invalid_data.cc					\
  	glom/dialog_invalid_data.h					\
  	glom/dialog_progress_creating.cc				\
diff --cc Makefile_tests.am
index e8ca5a1,e0e25a6..4c35a85
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@@ -47,9 -47,10 +47,10 @@@ glom_test_pyembed_SOURCES = glom/test_p
  tests_test_parsing_time_SOURCES = tests/test_parsing_time.cc
  tests_test_signal_reemit_SOURCES = tests/test_signal_reemit.cc
  tests_test_load_python_library_SOURCES = tests/test_load_python_library.cc
+ tests_test_python_module_SOURCES = tests/test_python_module.cc
  tests_import_test_parsing_SOURCES =	\
 -	glom/import_csv.cc	\
 -	glom/import_csv.h	\
 +	glom/import_csv/csv_parser.cc	\
 +	glom/import_csv/csv_parser.h	\
  	tests/import/utils.cc\
  	tests/import/utils.h\
  	tests/import/test_parsing.cc
diff --cc glom/import_csv/dialog_import_csv.cc
index 04ce580,9415aff..a623539
--- a/glom/import_csv/dialog_import_csv.cc
+++ b/glom/import_csv/dialog_import_csv.cc
@@@ -86,19 -127,18 +86,21 @@@ Dialog_Import_CSV::Dialog_Import_CSV(Ba
    // Separator:
    m_encoding_model->append();
  
 -  for(guint i = 0; i < N_ENCODINGS; ++ i)
 +  const FileEncodings::type_list_encodings list_encodings =  FileEncodings::get_list_of_encodings();
 +  for(FileEncodings::type_list_encodings::const_iterator encodings_iter = list_encodings.begin(); encodings_iter  != list_encodings.end(); encodings_iter ++)
    {
 +    const FileEncodings::Encoding encoding = *encodings_iter;
 +    if(encoding.get_name().empty())
 +      continue;
 +
      iter = m_encoding_model->append();
 -    if(ENCODINGS[i].name != 0)
 -    {
 -      (*iter)[m_encoding_columns.m_col_name] = _(ENCODINGS[i].name);
 -      (*iter)[m_encoding_columns.m_col_charset] = ENCODINGS[i].charset;
 -    }
 +    Gtk::TreeModel::Row row = *iter;
 +    row[m_encoding_columns.m_col_name] = encoding.get_name();
 +    row[m_encoding_columns.m_col_charset] = encoding.get_charset();
    }
  
+   m_sample_rows->set_value(2); //A sensible default.
+ 
    Gtk::CellRendererText* renderer = Gtk::manage(new Gtk::CellRendererText);
    m_encoding_combo->set_model(m_encoding_model);
    m_encoding_combo->pack_start(*renderer);
@@@ -278,10 -340,151 +280,11 @@@ bool Dialog_Import_CSV::row_separator_f
    return (*iter)[m_encoding_columns.m_col_name] == "";
  }
  
 -void Dialog_Import_CSV::on_query_info(const Glib::RefPtr<Gio::AsyncResult>& result)
 -{
 -#ifdef GLIBMM_EXCEPTIONS_ENABLED
 -  try
 -  {
 -    Glib::RefPtr<Gio::FileInfo> info = m_file->query_info_finish(result);
 -    m_filename = info->get_display_name();
 -    set_title(m_filename + _(" - Import From CSV File"));
 -  }
 -  catch(const Glib::Exception& ex)
 -  {
 -    std::cerr << "Failed to fetch display name of uri " << m_file->get_uri() << ": " << ex.what() << std::endl;
 -  }
 -#else
 -  std::auto_ptr<Glib::Error> error;
 -  Glib::RefPtr<Gio::FileInfo> info = m_file->query_info_finish(result, error);
 -  if (!error.get())
 -  {
 -    m_filename = info->get_display_name();
 -    set_title(m_filename + _(" - Import From CSV File"));
 -  }
 -  else
 -    std::cerr << "Failed to fetch display name of uri " << m_file->get_uri() << ": " << error->what() << std::endl;
 -#endif    
 -}
 -
 -void Dialog_Import_CSV::on_file_read(const Glib::RefPtr<Gio::AsyncResult>& result)
 -{
 -#ifdef GLIBMM_EXCEPTIONS_ENABLED
 -  try
 -  {
 -    m_parser->m_stream = m_file->read_finish(result);
 -
 -    m_buffer.reset(new Buffer);
 -    m_parser->m_stream->read_async(m_buffer->buf, sizeof(m_buffer->buf), sigc::mem_fun(*this, &Dialog_Import_CSV::on_stream_read));
 -  }
 -  catch(const Glib::Exception& error)
 -  {
 -    show_error_dialog(_("Could Not Open file"), Glib::ustring::compose(_("The file at \"%1\" could not be opened: %2"), m_file->get_uri(), error.what()));
 -    clear();
 -    // TODO: Response?
 -  }
 -#else
 -    std::auto_ptr<Glib::Error> error;
 -    m_parser->m_stream = m_file->read_finish(result, error);
 -    if (!error.get())
 -    {
 -      m_buffer.reset(new Buffer);
 -      m_parser->m_stream->read_async(m_buffer->buf, sizeof(m_buffer->buf), sigc::mem_fun(*this, &Dialog_Import_CSV::on_stream_read));
 -    }
 -    else
 -    {
 -      show_error_dialog(_("Could Not Open file"), Glib::ustring::compose(_("The file at \"%1\" could not be opened: %2"), m_file->get_uri(), error->what()));
 -      clear();
 -    }
 -#endif    
 -}
  
 -void Dialog_Import_CSV::on_stream_read(const Glib::RefPtr<Gio::AsyncResult>& result)
 +void Dialog_Import_CSV::on_combo_encoding_changed()
  {
 -#ifdef GLIBMM_EXCEPTIONS_ENABLED
 -  try
 -  {
 -    const gssize size = m_parser->m_stream->read_finish(result);
 -    m_parser->m_raw.insert(m_parser->m_raw.end(), m_buffer->buf, m_buffer->buf + size);
 -
 -    // If the parser already exists, but it is currently not parsing because it waits
 -    // for new input, then continue parsing.
 -    // TODO: Introduce CsvParser::is_idle_handler_connected() instead?
 -    if(m_parser.get() && !m_parser->m_idle_connection.connected())
 -    {
 -      m_parser->m_idle_connection = Glib::signal_idle().connect(sigc::mem_fun(*m_parser.get(), &CsvParser::on_idle_parse));
 -    }
 -    // If the parser does not exist yet, then create a new parser, except when the
 -    // current encoding does not work for the file ,in which case the user must first
 -    // choose another encoding.
 -    else if(!m_parser.get() && get_parser_state() != CsvParser::STATE_ENCODING_ERROR)
 -    {
 -      begin_parse();
 -    }
 +  const int active = m_encoding_combo->get_active_row_number();
+ 
 -    if(size > 0)
 -    {
 -      // Read the next few bytes
 -      m_parser->m_stream->read_async(m_buffer->buf, sizeof(m_buffer->buf), sigc::mem_fun(*this, &Dialog_Import_CSV::on_stream_read));
 -    }
 -    else
 -    {
 -      // Finished reading
 -      m_buffer.reset(0);
 -      m_parser->m_stream.reset();
 -      m_file.reset();
 -    }
 -  }
 -  catch(const Glib::Exception& error)
 -  {
 -    show_error_dialog(_("Could Not Read File"), Glib::ustring::compose(_("The file at \"%1\" could not be read: %2"), m_file->get_uri(), error.what()));
 -    clear();
 -    // TODO: Response?
 -  }
 -#else
 -    std::auto_ptr<Glib::Error> error;
 -    const gssize size = m_parser->m_stream->read_finish(result, error);
 -    if (!error.get())
 -    {
 -      m_parser->m_raw.insert(m_parser->m_raw.end(), m_buffer->buf, m_buffer->buf + size);
 -
 -      // If the parser already exists, but it is currently not parsing because it waits
 -      // for new input, then continue parsing.
 -      if(m_parser.get() && !m_parser->m_idle_connection.connected())
 -      {
 -        m_parser->m_idle_connection = Glib::signal_idle().connect(sigc::mem_fun(*m_parser.get(), &CsvParser::on_idle_parse));
 -      }
 -      // If the parser does not exist yet, then create a new parser, except when the
 -      // current encoding does not work for the file ,in which case the user must first
 -      // choose another encoding.
 -      else if(!m_parser.get() && get_parser_state() != CsvParser::STATE_ENCODING_ERROR)
 -      {
 -        begin_parse();
 -      }
 -
 -      if(size > 0)
 -      {
 -        // Read the next few bytes
 -        m_parser->m_stream->read_async(m_buffer->buf, sizeof(m_buffer->buf), sigc::mem_fun(*this, &Dialog_Import_CSV::on_stream_read));
 -      }
 -      else
 -      {
 -        // Finished reading
 -        m_buffer.reset(0);
 -        m_parser->m_stream.reset();
 -        m_file.reset();
 -      }
 -    }
 -    if (error.get())
 -    {
 -      show_error_dialog(_("Could Not Read File"), Glib::ustring::compose(_("The file at \"%1\" could not be read: %2"), m_file->get_uri(), error->what()));
 -      clear();
 -    }
 -#endif
 -}
 -
 -void Dialog_Import_CSV::on_encoding_changed()
 -{
 -  int active = m_encoding_combo->get_active_row_number();
    switch(active)
    {
    case -1: // No active item
diff --cc tests/import/test_parsing.cc
index 1581d25,3c8299b..1ee0ddb
--- a/tests/import/test_parsing.cc
+++ b/tests/import/test_parsing.cc
@@@ -203,3 -199,3 +203,4 @@@ int main(int argc, char* argv[]
  
    return result ? EXIT_SUCCESS : EXIT_FAILURE;
  }
++
diff --cc tests/import/test_signals.cc
index 10f763e,b1df045..e0ebf3d
--- a/tests/import/test_signals.cc
+++ b/tests/import/test_signals.cc
@@@ -163,3 -164,3 +163,4 @@@ int main(int argc, char* argv[]
    return result ? EXIT_SUCCESS : EXIT_FAILURE;
  }
  
++
diff --cc tests/import/utils.cc
index 5bad66e,0a9f868..c02fb62
--- a/tests/import/utils.cc
+++ b/tests/import/utils.cc
@@@ -105,3 -19,3 +105,4 @@@ bool run_parser_from_buffer(const FuncC
  
  } //namespace ImportTests
  
++
diff --cc tests/import/utils.h
index c2e4063,4088b5c..3e9f759
--- a/tests/import/utils.h
+++ b/tests/import/utils.h
@@@ -12,17 -9,8 +12,19 @@@ namespace ImportTest
  
  bool check(const std::string& name, bool test, std::stringstream& report);
  
 -/// This takes a @a size argument so we can test parsing of null bytes.
 -void set_parser_contents(Glom::CsvParser& parser, const char* input, guint size);
 +typedef sigc::slot<void, Glom::CsvParser&> FuncConnectParserSignals;
 +
 +/**
 + * @result Whether the parser finished without being killed by a timeout.
 + */
 +bool run_parser_from_buffer(const FuncConnectParserSignals& connect_parser_signals, const char* input, guint input_size);
 +
 +/**
 + * @result Whether the parser finished without being killed by a timeout.
 + */
 +bool run_parser_from_buffer(const FuncConnectParserSignals& connect_parser_signals, const std::string& input);
  
  } //namespace ImportTests
--#endif
++
++#endif //TEST_IMPORT_UTILS_H
++



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