[glom] Simplify OptionEntry code.



commit 2cad5c2a20fd933cbcdf55a57eb318cbbfa52dc8
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Oct 11 12:27:35 2011 +0200

    Simplify OptionEntry code.
    
    * glom/glom_create_from_example.cc:
    * glom/main.cc: Reuse one OptionEntry instance.

 ChangeLog                        |    7 ++++
 glom/glom_create_from_example.cc |   60 +++++++++++++++++---------------------
 glom/main.cc                     |   49 +++++++++++++++----------------
 3 files changed, 58 insertions(+), 58 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 34f65e6..649669c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-11  Murray Cumming  <murrayc murrayc com>
+
+	Simplify OptionEntry code.
+
+	* glom/glom_create_from_example.cc:
+	* glom/main.cc: Reuse one OptionEntry instance.
+
 2011-10-10  Murray Cumming  <murrayc murrayc com>
 
 	Cope with Gnome::Gda::DataModelIter::get_value_at() throwing.
diff --git a/glom/glom_create_from_example.cc b/glom/glom_create_from_example.cc
index 0cf4319..e5948b5 100644
--- a/glom/glom_create_from_example.cc
+++ b/glom/glom_create_from_example.cc
@@ -66,42 +66,36 @@ GlomCreateOptionGroup::GlomCreateOptionGroup()
   entry.set_description(_("The example .glom file to open."));
   add_entry_filename(entry, m_arg_filename_input);
   
-  Glib::OptionEntry entry2;
-  entry2.set_long_name("output-path");
-  entry2.set_short_name('o');
-  entry2.set_description(_("The directory in which to save the created .glom file, or sub-directory if necessary, such as /home/someuser/ ."));
-  add_entry_filename(entry2, m_arg_filepath_dir_output);
+  entry.set_long_name("output-path");
+  entry.set_short_name('o');
+  entry.set_description(_("The directory in which to save the created .glom file, or sub-directory if necessary, such as /home/someuser/ ."));
+  add_entry_filename(entry, m_arg_filepath_dir_output);
   
-  Glib::OptionEntry entry3;
-  entry3.set_long_name("output-name");
-  entry3.set_short_name('n');
-  entry3.set_description(_("The name for the created .glom file, such as something.glom ."));
-  add_entry_filename(entry3, m_arg_filepath_name_output);
-
-  Glib::OptionEntry entry_version;
-  entry_version.set_long_name("version");
-  entry_version.set_short_name('V');
-  entry_version.set_description(_("The version of this application."));
-  add_entry(entry_version, m_arg_version);
-  
-  
-  Glib::OptionEntry entry4;
-  entry4.set_long_name("server-hostname");
-  entry4.set_short_name('h');
-  entry4.set_description(_("The hostname of the PostgreSQL server, such as localhost. If this is not specified then a self-hosted database will be created."));
-  add_entry(entry4, m_arg_server_hostname);
+  entry.set_long_name("output-name");
+  entry.set_short_name('n');
+  entry.set_description(_("The name for the created .glom file, such as something.glom ."));
+  add_entry_filename(entry, m_arg_filepath_name_output);
+
+  entry.set_long_name("version");
+  entry.set_short_name('V');
+  entry.set_description(_("The version of this application."));
+  add_entry(entry, m_arg_version);
+
+
+  entry.set_long_name("server-hostname");
+  entry.set_short_name('h');
+  entry.set_description(_("The hostname of the PostgreSQL server, such as localhost. If this is not specified then a self-hosted database will be created."));
+  add_entry(entry, m_arg_server_hostname);
   
-  Glib::OptionEntry entry5;
-  entry5.set_long_name("server-port");
-  entry5.set_short_name('p');
-  entry5.set_description(_("The port of the PostgreSQL server, such as 5434."));
-  add_entry(entry5, m_arg_server_port);
+  entry.set_long_name("server-port");
+  entry.set_short_name('p');
+  entry.set_description(_("The port of the PostgreSQL server, such as 5434."));
+  add_entry(entry, m_arg_server_port);
   
-  Glib::OptionEntry entry6;
-  entry6.set_long_name("server-username");
-  entry6.set_short_name('u');
-  entry6.set_description(_("The username for the PostgreSQL server."));
-  add_entry(entry6, m_arg_server_username);
+  entry.set_long_name("server-username");
+  entry.set_short_name('u');
+  entry.set_description(_("The username for the PostgreSQL server."));
+  add_entry(entry, m_arg_server_username);
 }
 
 static void on_initialize_progress()
diff --git a/glom/main.cc b/glom/main.cc
index 4f8a727..bee9ffe 100644
--- a/glom/main.cc
+++ b/glom/main.cc
@@ -204,31 +204,30 @@ OptionGroup::OptionGroup()
   entry.set_description(_("The Filename"));
   add_entry_filename(entry, m_arg_filename);
 
-  Glib::OptionEntry entry_version;
-  entry_version.set_long_name("version");
-  entry_version.set_short_name('V');
-  entry_version.set_description(_("The version of this application."));
-  add_entry(entry_version, m_arg_version);
-
-  Glib::OptionEntry entry_restore;
-  entry_restore.set_long_name("restore");
-  entry_restore.set_description(_("Whether the filename is a .tar.gz backup to be restored."));
-  add_entry(entry_restore, m_arg_restore);
-
-  Glib::OptionEntry entry_stop_auto_server_shutdown;
-  entry_stop_auto_server_shutdown.set_long_name("stop-auto-server-shutdown");
-  entry_stop_auto_server_shutdown.set_description(_("Do not automatically stop the database server if Glom quits. This is helpful for debugging with gdb."));
-  add_entry(entry_stop_auto_server_shutdown, m_arg_stop_auto_server_shutdown);
-
-  Glib::OptionEntry entry_debug_sql;
-  entry_debug_sql.set_long_name("debug_sql");
-  entry_debug_sql.set_description(_("Show the generated SQL queries on stdout, for debugging."));
-  add_entry(entry_debug_sql, m_arg_debug_sql);
-
-  Glib::OptionEntry entry_debug_date_check;
-  entry_debug_date_check.set_long_name("debug-date-check");
-  entry_debug_date_check.set_description(_("Show how Glom outputs a date in this locale, then stop."));
-  add_entry(entry_debug_date_check, m_arg_debug_date_check);
+  entry.set_long_name("version");
+  entry.set_short_name('V');
+  entry.set_description(_("The version of this application."));
+  add_entry(entry, m_arg_version);
+
+  entry.set_long_name("restore");
+  entry.set_short_name(0);
+  entry.set_description(_("Whether the filename is a .tar.gz backup to be restored."));
+  add_entry(entry, m_arg_restore);
+
+  entry.set_long_name("stop-auto-server-shutdown");
+  entry.set_short_name(0);
+  entry.set_description(_("Do not automatically stop the database server if Glom quits. This is helpful for debugging with gdb."));
+  add_entry(entry, m_arg_stop_auto_server_shutdown);
+
+  entry.set_long_name("debug_sql");
+  entry.set_short_name(0);
+  entry.set_description(_("Show the generated SQL queries on stdout, for debugging."));
+  add_entry(entry, m_arg_debug_sql);
+
+  entry.set_long_name("debug-date-check");
+  entry.set_short_name(0);
+  entry.set_description(_("Show how Glom outputs a date in this locale, then stop."));
+  add_entry(entry, m_arg_debug_date_check);
 }
 
 #ifdef GLOM_ENABLE_POSTGRESQL



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