glom r1915 - in trunk: . glom glom/libglom glom/libglom/connectionpool_backends glom/navigation
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1915 - in trunk: . glom glom/libglom glom/libglom/connectionpool_backends glom/navigation
- Date: Fri, 20 Feb 2009 13:42:30 +0000 (UTC)
Author: murrayc
Date: Fri Feb 20 13:42:29 2009
New Revision: 1915
URL: http://svn.gnome.org/viewvc/glom?rev=1915&view=rev
Log:
2009-02-20 Murray Cumming <murrayc murrayc com>
* glom/application.cc:
* glom/base_db.[h|cc]:
* glom/dialog_connection.cc:
* glom/frame_glom.cc:
* glom/libglom/connectionpool.[h|cc]:
* glom/libglom/connectionpool_backends/postgres_central.cc
* glom/navigation/box_tables.[h|cc]:
Added ifdefs to fix the build with --enable-client-only.
Modified:
trunk/ChangeLog
trunk/glom/application.cc
trunk/glom/base_db.cc
trunk/glom/base_db.h
trunk/glom/dialog_connection.cc
trunk/glom/frame_glom.cc
trunk/glom/libglom/connectionpool.cc
trunk/glom/libglom/connectionpool_backends/postgres_central.cc
trunk/glom/navigation/box_tables.cc
trunk/glom/navigation/box_tables.h
Modified: trunk/glom/application.cc
==============================================================================
--- trunk/glom/application.cc (original)
+++ trunk/glom/application.cc Fri Feb 20 13:42:29 2009
@@ -1224,10 +1224,8 @@
open_browsed_document(dialog->get_service_info(), dialog->get_service_name());
break;
#endif
-#ifndef GLOM_ENABLE_CLIENT_ONLY
default:
break;
-#endif // !GLOM_ENABLE_CLIENT_ONLY
}
//Check that a document was opened:
Modified: trunk/glom/base_db.cc
==============================================================================
--- trunk/glom/base_db.cc (original)
+++ trunk/glom/base_db.cc Fri Feb 20 13:42:29 2009
@@ -734,186 +734,6 @@
return result;
}
-
-}
-
-bool Base_DB::add_standard_tables() const
-{
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- try
-#endif // GLIBMM_EXCEPTIONS_ENABLED
- {
- Document_Glom::type_vecFields pref_fields;
- sharedptr<TableInfo> prefs_table_info = Document_Glom::create_table_system_preferences(pref_fields);
-
- //Name, address, etc:
- if(!get_table_exists_in_database(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME))
- {
- const bool test = create_table(prefs_table_info, pref_fields);
-
- if(test)
- {
- //Add the single record:
- const bool test = query_execute("INSERT INTO \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\" (\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ID "\") VALUES (1)");
- if(!test)
- std::cerr << "Base_DB::add_standard_tables(): INSERT failed." << std::endl;
-
- //Use the database title from the document, if there is one:
- const Glib::ustring system_name = get_document()->get_database_title();
- if(!system_name.empty())
- {
- const bool test = query_execute("UPDATE \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\" SET " "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_NAME "\" = '" + system_name + "' WHERE \"" GLOM_STANDARD_TABLE_PREFS_FIELD_ID "\" = 1");
- if(!test)
- std::cerr << "Base_DB::add_standard_tables(): UPDATE failed." << std::endl;
- }
- }
- else
- {
- g_warning("Base_DB::add_standard_tables(): create_table(prefs) failed.");
- return false;
- }
- }
- else
- {
- //Make sure that it has all the fields it should have,
- //because we sometimes add some in new Glom versions:
- create_table_add_missing_fields(prefs_table_info, pref_fields);
- }
-
- //Auto-increment next values:
- if(!get_table_exists_in_database(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME))
- {
- sharedptr<TableInfo> table_info(new TableInfo());
- table_info->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
- table_info->set_title("System: Auto Increments"); //TODO: Provide standard translations.
- table_info->m_hidden = true;
-
- Document_Glom::type_vecFields fields;
-
- sharedptr<Field> primary_key(new Field()); //It's not used, because there's only one record, but we must have one.
- primary_key->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_ID);
- primary_key->set_glom_type(Field::TYPE_NUMERIC);
- fields.push_back(primary_key);
-
- sharedptr<Field> field_table_name(new Field());
- field_table_name->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME);
- field_table_name->set_glom_type(Field::TYPE_TEXT);
- fields.push_back(field_table_name);
-
- sharedptr<Field> field_field_name(new Field());
- field_field_name->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME);
- field_field_name->set_glom_type(Field::TYPE_TEXT);
- fields.push_back(field_field_name);
-
- sharedptr<Field> field_next_value(new Field());
- field_next_value->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE);
- field_next_value->set_glom_type(Field::TYPE_TEXT);
- fields.push_back(field_next_value);
-
- const bool test = create_table(table_info, fields);
- if(!test)
- {
- g_warning("Base_DB::add_standard_tables(): create_table(autoincrements) failed.");
- return false;
- }
-
- return true;
- }
- else
- {
- return false;
- }
- }
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- catch(const Glib::Exception& ex)
- {
- std::cerr << "Base_DB::add_standard_tables(): caught exception: " << ex.what() << std::endl;
- return false;
- }
- catch(const std::exception& ex)
- {
- std::cerr << "Base_DB::add_standard_tables(): caught exception: " << ex.what() << std::endl;
- return false;
- }
-#endif // GLIBMM_EXCEPTIONS_ENABLED
-}
-
-bool Base_DB::add_standard_groups()
-{
- //Add the glom_developer group if it does not exist:
- const Glib::ustring devgroup = GLOM_STANDARD_GROUP_NAME_DEVELOPER;
-
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- sharedptr<SharedConnection> sharedconnection = connect_to_server();
-#else
- std::auto_ptr<ExceptionConnection> error;
- sharedptr<SharedConnection> sharedconnection = connect_to_server(0, error);
- if(error.get())
- {
- g_warning("Base_DB::add_standard_groups: Failed to connect: %s", error->what());
- // TODO: Rethrow?
- }
-#endif
-
- // If the connection doesn't support users we can skip this step
- if(sharedconnection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
- {
- const type_vecStrings vecGroups = Privs::get_database_groups();
- type_vecStrings::const_iterator iterFind = std::find(vecGroups.begin(), vecGroups.end(), devgroup);
- if(iterFind == vecGroups.end())
- {
- bool test = query_execute("CREATE GROUP \"" GLOM_STANDARD_GROUP_NAME_DEVELOPER "\"");
- if(!test)
- {
- std::cerr << "Glom Base_DB::add_standard_groups(): CREATE GROUP failed when adding the developer group." << std::endl;
- return false;
- }
-
- //Make sure the current user is in the developer group.
- //(If he is capable of creating these groups then he is obviously a developer, and has developer rights on the postgres server.)
- const Glib::ustring current_user = ConnectionPool::get_instance()->get_user();
- Glib::ustring strQuery = "ALTER GROUP \"" GLOM_STANDARD_GROUP_NAME_DEVELOPER "\" ADD USER \"" + current_user + "\"";
- test = query_execute(strQuery);
- if(!test)
- {
- std::cerr << "Glom Base_DB::add_standard_groups(): ALTER GROUP failed when adding the user to the developer group." << std::endl;
- return false;
- }
-
- std::cout << "DEBUG: Added user " << current_user << " to glom developer group on postgres server." << std::endl;
-
- Privileges priv_devs;
- priv_devs.m_view = true;
- priv_devs.m_edit = true;
- priv_devs.m_create = true;
- priv_devs.m_delete = true;
-
- Document_Glom::type_listTableInfo table_list = get_document()->get_tables(true /* including system prefs */);
-
- for(Document_Glom::type_listTableInfo::const_iterator iter = table_list.begin(); iter != table_list.end(); ++iter)
- {
- sharedptr<const TableInfo> table_info = *iter;
- if(table_info)
- {
- const Glib::ustring table_name = table_info->get_name();
- if(get_table_exists_in_database(table_name)) //Maybe the table has not been created yet.
- Privs::set_table_privileges(devgroup, table_name, priv_devs, true /* developer privileges */);
- }
- }
-
- //Make sure that it is in the database too:
- GroupInfo group_info;
- group_info.set_name(GLOM_STANDARD_GROUP_NAME_DEVELOPER);
- group_info.m_developer = true;
- get_document()->set_group(group_info);
- }
- }
- else
- {
- std::cout << "DEBUG: Connection does not support users" << std::endl;
- }
-
- return true;
}
Gnome::Gda::Value Base_DB::auto_increment_insert_first_if_necessary(const Glib::ustring& table_name, const Glib::ustring& field_name) const
@@ -1093,16 +913,199 @@
//Return the result, or try again:
if(succeeded)
return result;
+#ifndef GLOM_ENABLE_CLIENT_ONLY
else
{
add_standard_tables();
++attempts; //Try again now that we have tried to create the table.
}
+#endif //GLOM_ENABLE_CLIENT_ONLY
}
return result;
}
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+
+bool Base_DB::add_standard_tables() const
+{
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+ {
+ Document_Glom::type_vecFields pref_fields;
+ sharedptr<TableInfo> prefs_table_info = Document_Glom::create_table_system_preferences(pref_fields);
+
+ //Name, address, etc:
+ if(!get_table_exists_in_database(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME))
+ {
+ const bool test = create_table(prefs_table_info, pref_fields);
+
+ if(test)
+ {
+ //Add the single record:
+ const bool test = query_execute("INSERT INTO \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\" (\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ID "\") VALUES (1)");
+ if(!test)
+ std::cerr << "Base_DB::add_standard_tables(): INSERT failed." << std::endl;
+
+ //Use the database title from the document, if there is one:
+ const Glib::ustring system_name = get_document()->get_database_title();
+ if(!system_name.empty())
+ {
+ const bool test = query_execute("UPDATE \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\" SET " "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_NAME "\" = '" + system_name + "' WHERE \"" GLOM_STANDARD_TABLE_PREFS_FIELD_ID "\" = 1");
+ if(!test)
+ std::cerr << "Base_DB::add_standard_tables(): UPDATE failed." << std::endl;
+ }
+ }
+ else
+ {
+ g_warning("Base_DB::add_standard_tables(): create_table(prefs) failed.");
+ return false;
+ }
+ }
+ else
+ {
+ //Make sure that it has all the fields it should have,
+ //because we sometimes add some in new Glom versions:
+ create_table_add_missing_fields(prefs_table_info, pref_fields);
+ }
+
+ //Auto-increment next values:
+ if(!get_table_exists_in_database(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME))
+ {
+ sharedptr<TableInfo> table_info(new TableInfo());
+ table_info->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
+ table_info->set_title("System: Auto Increments"); //TODO: Provide standard translations.
+ table_info->m_hidden = true;
+
+ Document_Glom::type_vecFields fields;
+
+ sharedptr<Field> primary_key(new Field()); //It's not used, because there's only one record, but we must have one.
+ primary_key->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_ID);
+ primary_key->set_glom_type(Field::TYPE_NUMERIC);
+ fields.push_back(primary_key);
+
+ sharedptr<Field> field_table_name(new Field());
+ field_table_name->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME);
+ field_table_name->set_glom_type(Field::TYPE_TEXT);
+ fields.push_back(field_table_name);
+
+ sharedptr<Field> field_field_name(new Field());
+ field_field_name->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME);
+ field_field_name->set_glom_type(Field::TYPE_TEXT);
+ fields.push_back(field_field_name);
+
+ sharedptr<Field> field_next_value(new Field());
+ field_next_value->set_name(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE);
+ field_next_value->set_glom_type(Field::TYPE_TEXT);
+ fields.push_back(field_next_value);
+
+ const bool test = create_table(table_info, fields);
+ if(!test)
+ {
+ g_warning("Base_DB::add_standard_tables(): create_table(autoincrements) failed.");
+ return false;
+ }
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ catch(const Glib::Exception& ex)
+ {
+ std::cerr << "Base_DB::add_standard_tables(): caught exception: " << ex.what() << std::endl;
+ return false;
+ }
+ catch(const std::exception& ex)
+ {
+ std::cerr << "Base_DB::add_standard_tables(): caught exception: " << ex.what() << std::endl;
+ return false;
+ }
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+}
+
+bool Base_DB::add_standard_groups()
+{
+ //Add the glom_developer group if it does not exist:
+ const Glib::ustring devgroup = GLOM_STANDARD_GROUP_NAME_DEVELOPER;
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ sharedptr<SharedConnection> sharedconnection = connect_to_server();
+#else
+ std::auto_ptr<ExceptionConnection> error;
+ sharedptr<SharedConnection> sharedconnection = connect_to_server(0, error);
+ if(error.get())
+ {
+ g_warning("Base_DB::add_standard_groups: Failed to connect: %s", error->what());
+ // TODO: Rethrow?
+ }
+#endif
+
+ // If the connection doesn't support users we can skip this step
+ if(sharedconnection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
+ {
+ const type_vecStrings vecGroups = Privs::get_database_groups();
+ type_vecStrings::const_iterator iterFind = std::find(vecGroups.begin(), vecGroups.end(), devgroup);
+ if(iterFind == vecGroups.end())
+ {
+ bool test = query_execute("CREATE GROUP \"" GLOM_STANDARD_GROUP_NAME_DEVELOPER "\"");
+ if(!test)
+ {
+ std::cerr << "Glom Base_DB::add_standard_groups(): CREATE GROUP failed when adding the developer group." << std::endl;
+ return false;
+ }
+
+ //Make sure the current user is in the developer group.
+ //(If he is capable of creating these groups then he is obviously a developer, and has developer rights on the postgres server.)
+ const Glib::ustring current_user = ConnectionPool::get_instance()->get_user();
+ Glib::ustring strQuery = "ALTER GROUP \"" GLOM_STANDARD_GROUP_NAME_DEVELOPER "\" ADD USER \"" + current_user + "\"";
+ test = query_execute(strQuery);
+ if(!test)
+ {
+ std::cerr << "Glom Base_DB::add_standard_groups(): ALTER GROUP failed when adding the user to the developer group." << std::endl;
+ return false;
+ }
+
+ std::cout << "DEBUG: Added user " << current_user << " to glom developer group on postgres server." << std::endl;
+
+ Privileges priv_devs;
+ priv_devs.m_view = true;
+ priv_devs.m_edit = true;
+ priv_devs.m_create = true;
+ priv_devs.m_delete = true;
+
+ Document_Glom::type_listTableInfo table_list = get_document()->get_tables(true /* including system prefs */);
+
+ for(Document_Glom::type_listTableInfo::const_iterator iter = table_list.begin(); iter != table_list.end(); ++iter)
+ {
+ sharedptr<const TableInfo> table_info = *iter;
+ if(table_info)
+ {
+ const Glib::ustring table_name = table_info->get_name();
+ if(get_table_exists_in_database(table_name)) //Maybe the table has not been created yet.
+ Privs::set_table_privileges(devgroup, table_name, priv_devs, true /* developer privileges */);
+ }
+ }
+
+ //Make sure that it is in the database too:
+ GroupInfo group_info;
+ group_info.set_name(GLOM_STANDARD_GROUP_NAME_DEVELOPER);
+ group_info.m_developer = true;
+ get_document()->set_group(group_info);
+ }
+ }
+ else
+ {
+ std::cout << "DEBUG: Connection does not support users" << std::endl;
+ }
+
+ return true;
+}
+
void Base_DB::set_database_preferences(const SystemPrefs& prefs)
{
if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
@@ -1326,7 +1329,6 @@
return true;
}
-#ifndef GLOM_ENABLE_CLIENT_ONLY
bool Base_DB::add_column(const Glib::ustring& table_name, const sharedptr<const Field>& field, Gtk::Window* parent_window) const
{
ConnectionPool* connection_pool = ConnectionPool::get_instance();
Modified: trunk/glom/base_db.h
==============================================================================
--- trunk/glom/base_db.h (original)
+++ trunk/glom/base_db.h Fri Feb 20 13:42:29 2009
@@ -93,7 +93,7 @@
static int count_rows_returned_by(const Glib::ustring& sql_query);
-
+#ifndef GLOM_ENABLE_CLIENT_ONLY
bool add_standard_groups();
bool add_standard_tables() const;
@@ -103,7 +103,6 @@
/// Also saves the table information in the document:
bool create_table_with_default_fields(const Glib::ustring& table_name);
-#ifndef GLOM_ENABLE_CLIENT_ONLY
// TODO: Should these functions update the document, so callers don't need
// to do it?
bool add_column(const Glib::ustring& table_name, const sharedptr<const Field>& field, Gtk::Window* parent_window) const;
@@ -113,7 +112,7 @@
sharedptr<Field> change_column(const Glib::ustring& table_name, const sharedptr<const Field>& field_old, const sharedptr<const Field>& field, Gtk::Window* parent_window) const;
bool change_columns(const Glib::ustring& table_name, const type_vecConstFields& old_fields, type_vecFields& fields, Gtk::Window* parent_window) const;
-#endif
+#endif //GLOM_ENABLE_CLIENT_ONLY
bool insert_example_data(const Glib::ustring& table_name) const;
Modified: trunk/glom/dialog_connection.cc
==============================================================================
--- trunk/glom/dialog_connection.cc (original)
+++ trunk/glom/dialog_connection.cc Fri Feb 20 13:42:29 2009
@@ -129,6 +129,7 @@
unconst->set_connection_port(central->get_port() );
}
+#ifndef GLOM_ENABLE_CLIENT_ONLY
else if(document->get_hosting_mode() == Document_Glom::POSTGRES_SELF_HOSTED)
{
ConnectionPoolBackend* backend = connection_pool->get_backend();
@@ -137,6 +138,7 @@
unconst->set_connection_port(self->get_port() );
}
+#endif
}
/*
Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc (original)
+++ trunk/glom/frame_glom.cc Fri Feb 20 13:42:29 2009
@@ -1613,6 +1613,7 @@
ConnectionPool* connection_pool = ConnectionPool::get_instance();
switch(document->get_hosting_mode())
{
+#ifndef GLOM_ENABLE_CLIENT_ONLY
case Document_Glom::POSTGRES_SELF_HOSTED:
{
ConnectionPoolBackends::PostgresSelfHosted* backend = new ConnectionPoolBackends::PostgresSelfHosted;
@@ -1620,6 +1621,7 @@
connection_pool->set_backend(std::auto_ptr<ConnectionPoolBackend>(backend));
}
break;
+#endif //GLOM_ENABLE_CLIENT_ONLY
case Document_Glom::POSTGRES_CENTRAL_HOSTED:
{
ConnectionPoolBackends::PostgresCentralHosted* backend = new ConnectionPoolBackends::PostgresCentralHosted;
@@ -1630,6 +1632,7 @@
}
break;
+#ifndef GLOM_ENABLE_CLIENT_ONLY
case Document_Glom::SQLITE_HOSTED:
{
ConnectionPoolBackends::Sqlite* backend = new ConnectionPoolBackends::Sqlite;
@@ -1637,6 +1640,7 @@
connection_pool->set_backend(std::auto_ptr<ConnectionPoolBackend>(backend));
}
break;
+#endif //GLOM_ENABLE_CLIENT_ONLY
default:
g_assert_not_reached();
break;
Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc (original)
+++ trunk/glom/libglom/connectionpool.cc Fri Feb 20 13:42:29 2009
@@ -37,11 +37,11 @@
#include <signal.h> //To catch segfaults
-/* TODO: Should this be used in client-only mode? */
-
+#ifndef GLOM_ENABLE_CLIENT_ONLY
#ifndef G_OS_WIN32
static EpcProtocol publish_protocol = EPC_PROTOCOL_HTTPS;
#endif
+#endif
// Uncomment to see debug messages
//#define GLOM_CONNECTION_DEBUG
@@ -875,7 +875,7 @@
previous_sig_handler = SIG_DFL; /* Arbitrary default */
}
-#ifndef GLOM_ENABLE_CLIENT_ENLY
+#ifndef GLOM_ENABLE_CLIENT_ONLY
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ConnectionPool::add_column(const Glib::ustring& table_name, const sharedptr<const Field>& field)
#else
Modified: trunk/glom/libglom/connectionpool_backends/postgres_central.cc
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres_central.cc (original)
+++ trunk/glom/libglom/connectionpool_backends/postgres_central.cc Fri Feb 20 13:42:29 2009
@@ -156,10 +156,12 @@
return connection;
}
+#ifndef GLOM_ENABLE_CLIENT_ONLY
bool PostgresCentralHosted::create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password, std::auto_ptr<Glib::Error>& error)
{
return attempt_create_database(database_name, get_host(), port_as_string(m_port), username, password, error);
}
+#endif //GLOM_ENABLE_CLIENT_ONLY
}
Modified: trunk/glom/navigation/box_tables.cc
==============================================================================
--- trunk/glom/navigation/box_tables.cc (original)
+++ trunk/glom/navigation/box_tables.cc Fri Feb 20 13:42:29 2009
@@ -49,10 +49,12 @@
refGlade->get_widget("checkbutton_show_hidden", m_pCheckButtonShowHidden);
m_pCheckButtonShowHidden->signal_toggled().connect(sigc::mem_fun(*this, &Box_Tables::on_show_hidden_toggled));
+#ifndef GLOM_ENABLE_CLIENT_ONLY
m_AddDel.signal_user_added().connect(sigc::mem_fun(*this, &Box_Tables::on_adddel_Add));
m_AddDel.signal_user_requested_delete().connect(sigc::mem_fun(*this, &Box_Tables::on_adddel_Delete));
- m_AddDel.signal_user_requested_edit().connect(sigc::mem_fun(*this, &Box_Tables::on_adddel_Edit));
m_AddDel.signal_user_changed().connect(sigc::mem_fun(*this, &Box_Tables::on_adddel_changed));
+#endif //GLOM_ENABLE_CLIENT_ONLY
+ m_AddDel.signal_user_requested_edit().connect(sigc::mem_fun(*this, &Box_Tables::on_adddel_Edit));
show_all_children();
}
@@ -208,6 +210,7 @@
return result;
}
+#ifndef GLOM_ENABLE_CLIENT_ONLY
void Box_Tables::on_adddel_Add(const Gtk::TreeModel::iterator& row)
{
//TODO: Handle cell renderer changes to prevent illegal table names (e.g. starting with numbers.).
@@ -322,72 +325,6 @@
}
}
-void Box_Tables::on_adddel_Edit(const Gtk::TreeModel::iterator& row)
-{
- Glib::ustring table_name = m_AddDel.get_value_key(row);
-
- Document_Glom* document = get_document();
- if(document)
- {
- //Don't open a table that the document does not know about, because we need information from the document:
- //This should never happen, because we never show them in the list:
- if(false) //Let's see if we can adapt. (!document->get_table_is_known(table_name))
- {
- Gtk::MessageDialog dialog(Bakery::App_Gtk::util_bold_message(_("Unknown Table")), true);
- dialog.set_secondary_text(_("You cannot open this table, because there is no information about this table in the document."));
- dialog.set_transient_for(*App_Glom::get_application());
- dialog.run();
- }
- else
- {
- //Go ahead:
-
- save_to_document();
-
- //Emit the signal:
- signal_selected.emit(table_name);
- }
- }
-}
-
-void Box_Tables::save_to_document()
-{
- if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
- {
- //Save the hidden tables. TODO_usermode: Only if we are in developer mode.
- Document_Glom::type_listTableInfo listTables;
-
- Document_Glom* document = get_document();
-
- for(Gtk::TreeModel::iterator iter = m_AddDel.get_model()->children().begin(); iter != m_AddDel.get_model()->children().end(); ++iter)
- {
- const Glib::ustring table_name = m_AddDel.get_value(iter, m_colTableName); //The name has already been changed in the document.
- sharedptr<TableInfo> table_info = document->get_table(table_name); //Start with the existing table_info, to preserve extra information, such as translations.
- if(table_info)
- {
- table_info->set_name( m_AddDel.get_value(iter, m_colTableName) );
-
- if(!table_info->get_name().empty())
- {
- table_info->m_hidden = m_AddDel.get_value_as_bool(iter, m_colHidden);
- table_info->set_title( m_AddDel.get_value(iter, m_colTitle) ); //TODO_Translations: Store the TableInfo in the TreeView.
- //std::cout << "save_to_document(): title=" << table_info->get_title() << std::endl;
- table_info->m_default = m_AddDel.get_value_as_bool(iter, m_colDefault);
-
- listTables.push_back(table_info);
- }
- }
- }
-
- if(document)
- document->set_tables(listTables); //TODO: Don't save all new tables - just the ones already in the document.
- }
-}
-
-void Box_Tables::on_show_hidden_toggled()
-{
- fill_from_database();
-}
void Box_Tables::on_adddel_changed(const Gtk::TreeModel::iterator& row, guint column)
{
@@ -455,6 +392,74 @@
}
}
}
+#endif //GLOM_ENABLE_CLIENT_ONLY
+
+void Box_Tables::on_adddel_Edit(const Gtk::TreeModel::iterator& row)
+{
+ Glib::ustring table_name = m_AddDel.get_value_key(row);
+
+ Document_Glom* document = get_document();
+ if(document)
+ {
+ //Don't open a table that the document does not know about, because we need information from the document:
+ //This should never happen, because we never show them in the list:
+ if(false) //Let's see if we can adapt. (!document->get_table_is_known(table_name))
+ {
+ Gtk::MessageDialog dialog(Bakery::App_Gtk::util_bold_message(_("Unknown Table")), true);
+ dialog.set_secondary_text(_("You cannot open this table, because there is no information about this table in the document."));
+ dialog.set_transient_for(*App_Glom::get_application());
+ dialog.run();
+ }
+ else
+ {
+ //Go ahead:
+
+ save_to_document();
+
+ //Emit the signal:
+ signal_selected.emit(table_name);
+ }
+ }
+}
+
+void Box_Tables::save_to_document()
+{
+ if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
+ {
+ //Save the hidden tables. TODO_usermode: Only if we are in developer mode.
+ Document_Glom::type_listTableInfo listTables;
+
+ Document_Glom* document = get_document();
+
+ for(Gtk::TreeModel::iterator iter = m_AddDel.get_model()->children().begin(); iter != m_AddDel.get_model()->children().end(); ++iter)
+ {
+ const Glib::ustring table_name = m_AddDel.get_value(iter, m_colTableName); //The name has already been changed in the document.
+ sharedptr<TableInfo> table_info = document->get_table(table_name); //Start with the existing table_info, to preserve extra information, such as translations.
+ if(table_info)
+ {
+ table_info->set_name( m_AddDel.get_value(iter, m_colTableName) );
+
+ if(!table_info->get_name().empty())
+ {
+ table_info->m_hidden = m_AddDel.get_value_as_bool(iter, m_colHidden);
+ table_info->set_title( m_AddDel.get_value(iter, m_colTitle) ); //TODO_Translations: Store the TableInfo in the TreeView.
+ //std::cout << "save_to_document(): title=" << table_info->get_title() << std::endl;
+ table_info->m_default = m_AddDel.get_value_as_bool(iter, m_colDefault);
+
+ listTables.push_back(table_info);
+ }
+ }
+ }
+
+ if(document)
+ document->set_tables(listTables); //TODO: Don't save all new tables - just the ones already in the document.
+ }
+}
+
+void Box_Tables::on_show_hidden_toggled()
+{
+ fill_from_database();
+}
void Box_Tables::on_userlevel_changed(AppState::userlevels /* userlevel */)
{
Modified: trunk/glom/navigation/box_tables.h
==============================================================================
--- trunk/glom/navigation/box_tables.h (original)
+++ trunk/glom/navigation/box_tables.h Fri Feb 20 13:42:29 2009
@@ -49,10 +49,12 @@
virtual void save_to_document();
//Signal handlers:
+#ifndef GLOM_ENABLE_CLIENT_ONLY
void on_adddel_Add(const Gtk::TreeModel::iterator& row);
void on_adddel_Delete(const Gtk::TreeModel::iterator& rowStart, const Gtk::TreeModel::iterator& rowEnd);
- void on_adddel_Edit(const Gtk::TreeModel::iterator& row);
void on_adddel_changed(const Gtk::TreeModel::iterator& row, guint column);
+#endif //GLOM_ENABLE_CLIENT_ONLY
+ void on_adddel_Edit(const Gtk::TreeModel::iterator& row);
void on_show_hidden_toggled();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]