glom r1503 - in trunk: . glom glom/mode_data glom/utility_widgets/db_adddel
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1503 - in trunk: . glom glom/mode_data glom/utility_widgets/db_adddel
- Date: Tue, 1 Apr 2008 11:35:17 +0100 (BST)
Author: murrayc
Date: Tue Apr 1 11:35:17 2008
New Revision: 1503
URL: http://svn.gnome.org/viewvc/glom?rev=1503&view=rev
Log:
2008-04-01 Murray Cumming <murrayc murrayc com>
* glom/notebook_glom.h
* glom/notebook_glom.cc: constructor, on_show(): Delay the connection of
the switch_page handler because GtkNotebook sometimes emits the signal
during show().
Save the sigc::connection so we can block it later.
* glom/mode_data/notebook_data.cc init_db_details(),
on_switch_page_handler(): Block the handling of this signal during
the first initialization, to avoid an unnecessary duplicate SQL query.
* glom/utility_widgets/db_adddel/db_adddel.h
* glom/utility_widgets/db_adddel/db_adddel.cc
on_self_style_changed): Correct the ifndef to an ifdef so this is
really only used on Maemo, preventing a third duplicate SQL query.
Modified:
trunk/ChangeLog
trunk/glom/mode_data/dialog_layout_export.cc
trunk/glom/mode_data/notebook_data.cc
trunk/glom/notebook_glom.cc
trunk/glom/notebook_glom.h
trunk/glom/utility_widgets/db_adddel/db_adddel.cc
trunk/glom/utility_widgets/db_adddel/db_adddel.h
Modified: trunk/glom/mode_data/dialog_layout_export.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_export.cc (original)
+++ trunk/glom/mode_data/dialog_layout_export.cc Tue Apr 1 11:35:17 2008
@@ -313,7 +313,7 @@
Gtk::TreeModel::Row row = *iter;
//Indicate that it's a field in another table.
- sharedptr<LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item]; //TODO_performance: Reduce copying.
+ sharedptr<LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item];
//Names can never be edited.
g_object_set(renderer_text->gobj(), "markup", item->get_layout_display_name().c_str(), "editable", FALSE, (gpointer)NULL);
Modified: trunk/glom/mode_data/notebook_data.cc
==============================================================================
--- trunk/glom/mode_data/notebook_data.cc (original)
+++ trunk/glom/mode_data/notebook_data.cc Tue Apr 1 11:35:17 2008
@@ -72,7 +72,7 @@
const bool details_record_specified = !Conversions::value_is_empty(primary_key_value_for_details);
- bool result = false;
+ bool result = true;
//where_clause is only used as a result of a find.
//Performance optimisation:
@@ -86,100 +86,95 @@
// Ignore error, sharedconnection is not used directly within this function
#endif
- const FoundSet old_found_set = m_Box_List.get_found_set();
+ //const FoundSet old_found_set = m_Box_List.get_found_set();
//std::cout << " old_where_clause=" << old_where_clause << std::endl;
//std::cout << " where_clause=" << where_clause << std::endl;
//const bool new_find_set = !(found_set == old_found_set);
- result = m_Box_List.init_db_details(found_set); //TODO: Select the last selected record.
- //m_Box_List.load_from_document();
- //Show the previously-shown record, if there is one, if this is not a new found-set (via a new where_clause)
- //so that returning to this table will return the user to the same record:
- Document_Glom* document = get_document();
- if(document)
- {
- Gnome::Gda::Value primary_key_for_details;
-
- if(!details_record_specified)
- {
- //std::cout << "debug: no new_found_set" << std::endl;
- primary_key_for_details = document->get_layout_record_viewed(m_table_name, m_Box_Details.get_layout_name());
- }
- else if(details_record_specified)
- {
- primary_key_for_details = primary_key_value_for_details;
- }
- else
+ //if(get_current_view() == DATA_VIEW_List)
+ //{
+ result = m_Box_List.init_db_details(found_set); //TODO: Select the last selected record.
+ //m_Box_List.load_from_document();
+ //}
+ //else //DATA_VIEW_Details
+ //{
+ //Show the previously-shown record, if there is one, if this is not a new found-set (via a new where_clause)
+ //so that returning to this table will return the user to the same record:
+ Document_Glom* document = get_document();
+ if(document)
{
- //std::cout << "debug: new_found_set" << std::endl;
- }
+ Gnome::Gda::Value primary_key_for_details;
+ if(!details_record_specified)
+ {
+ //std::cout << "debug: no new_found_set" << std::endl;
+ primary_key_for_details = document->get_layout_record_viewed(m_table_name, m_Box_Details.get_layout_name());
+ }
+ else if(details_record_specified)
+ {
+ primary_key_for_details = primary_key_value_for_details;
+ }
+ else
+ {
+ //std::cout << "debug: new_found_set" << std::endl;
+ }
- //If the specified (or remembered) primary key value is not in the found set,
- //then ignore it:
- if(!found_set.m_where_clause.empty() && !get_primary_key_is_in_foundset(found_set, primary_key_for_details))
- {
- primary_key_for_details = Gnome::Gda::Value(); //TODO: We set it to empty just so we can test if for empty.
- }
- if(Conversions::value_is_empty(primary_key_for_details))
- {
- //Make sure that the details view is not empty, if there are any records to show:
- primary_key_for_details = m_Box_List.get_primary_key_value_selected();
- //std::cout << "debug: m_Box_List.get_primary_key_value_selected()=" << primary_key_for_details.to_string() << std::endl;
+ //If the specified (or remembered) primary key value is not in the found set,
+ //then ignore it:
+ if(!found_set.m_where_clause.empty() && !get_primary_key_is_in_foundset(found_set, primary_key_for_details))
+ {
+ primary_key_for_details = Gnome::Gda::Value(); //TODO: We set it to empty just so we can test if for empty.
+ }
+
if(Conversions::value_is_empty(primary_key_for_details))
{
- //std::cout << "debug: calling list.get_primary_key_value_first()" << std::endl;
- primary_key_for_details = m_Box_List.get_primary_key_value_first();
- //std::cout << " debug: result=" << primary_key_for_details.to_string() << std::endl;
+ //Make sure that the details view is not empty, if there are any records to show:
+ primary_key_for_details = m_Box_List.get_primary_key_value_selected();
+ //std::cout << "debug: m_Box_List.get_primary_key_value_selected()=" << primary_key_for_details.to_string() << std::endl;
+ if(Conversions::value_is_empty(primary_key_for_details))
+ {
+ //std::cout << "debug: calling list.get_primary_key_value_first()" << std::endl;
+ primary_key_for_details = m_Box_List.get_primary_key_value_first();
+ //std::cout << " debug: result=" << primary_key_for_details.to_string() << std::endl;
+ }
}
- }
-
- m_Box_Details.init_db_details(found_set, primary_key_for_details);
- }
+ m_Box_Details.init_db_details(found_set, primary_key_for_details);
+ }
+ //}
}
+ //Block this handler temporarily because we don't need another refresh from the database:
+ if(m_connection_switch_page)
+ m_connection_switch_page.block();
+
//Select the last-viewed layout, or the details layout, if a specific details record was specified:
- if(details_record_specified)
+ const dataview current_view = get_current_view();
+ if(details_record_specified && (current_view != DATA_VIEW_Details))
{
- set_current_page(m_iPage_Details);
+ set_current_view(DATA_VIEW_Details);
}
else
{
//Select the last-viewed layout:
- bool found = false;
Document_Glom* document = get_document();
+
if(document)
{
const Glib::ustring current_layout = get_document()->get_layout_current(m_table_name);
- if(!current_layout.empty())
- {
- const int count = get_n_pages();
- int page = 0;
- while(!found && (page < count))
- {
- Box_Data* box = dynamic_cast<Box_Data*>(get_nth_page(page));
- if(box && (box->get_layout_name() == current_layout))
- found = true;
- else
- ++page;
- }
-
- if(found)
- {
- set_current_page(page);
- }
- }
- }
-
- if(!found)
- {
- //Select List as default:
- set_current_page(m_iPage_List);
+ if( (current_layout.empty() || (current_layout == "list"))
+ && (current_view != DATA_VIEW_List) )
+ set_current_view(DATA_VIEW_List);
+ else if( (current_layout == "details") && (current_view != DATA_VIEW_Details) )
+ set_current_view(DATA_VIEW_Details);
}
}
+ //Re-enable this handler, so we can respond to notebook page changes:
+ if(m_connection_switch_page)
+ m_connection_switch_page.unblock();
+
return result;
}
@@ -309,10 +304,17 @@
//TODO_Performance: This causes double refreshes (with database retrieval) when doing finds. We probably want to distinguish between user page-switches and programmatic page-switches.
if(box == &m_Box_List)
{
+ std::cout << "debug: switching to list" << std::endl;
Gnome::Gda::Value primary_key_selected = m_Box_List.get_primary_key_value_selected();
m_Box_List.refresh_data_from_database();
m_Box_List.set_primary_key_value_selected(primary_key_selected);
}
+ else if(box == &m_Box_Details)
+ {
+ std::cout << "debug: switching to details" << std::endl;
+ Gnome::Gda::Value primary_key_selected = m_Box_List.get_primary_key_value_selected();
+ m_Box_Details.refresh_data_from_database_with_primary_key(primary_key_selected);
+ }
}
}
Modified: trunk/glom/notebook_glom.cc
==============================================================================
--- trunk/glom/notebook_glom.cc (original)
+++ trunk/glom/notebook_glom.cc Tue Apr 1 11:35:17 2008
@@ -29,7 +29,9 @@
m_uiPreviousPage = 0;
//Connect signals:
- signal_switch_page().connect(sigc::mem_fun(*this, &Notebook_Glom::on_switch_page_handler));
+ //We do this on on_show() instead, because otherwise GtkNotebook emits the signal (and we catch it) during show:
+ //signal_switch_page().connect(sigc::mem_fun(*this, &Notebook_Glom::on_switch_page_handler));
+
//signal_leave_page().connect(sigc::mem_fun(*this, &Notebook_Glom::on_leave_page));
m_destructor_in_progress = false;
@@ -39,6 +41,15 @@
{
}
+void Notebook_Glom::on_show()
+{
+ Gtk::Notebook::on_show();
+
+ //We do this only in on_show() because otherwise GtkNotebook emits the signal (and we catch it) during show:
+ if(!m_connection_switch_page)
+ m_connection_switch_page = signal_switch_page().connect(sigc::mem_fun(*this, &Notebook_Glom::on_switch_page_handler));
+}
+
/*
Notebook_Glom::type_signal_leave_page Notebook_Glom::signal_leave_page()
{
@@ -48,10 +59,6 @@
void Notebook_Glom::on_switch_page_handler(GtkNotebookPage* pPage, guint uiPageNumber)
{
- //Call base class:
- //Don't call base class because this is no default signal handler (anymore?)
- //Gtk::Notebook::on_switch_page(pPage, uiPageNumber);
-
//Remove the help hint for the previous page:
Gtk::Window* pApp = get_app_window();
Modified: trunk/glom/notebook_glom.h
==============================================================================
--- trunk/glom/notebook_glom.h (original)
+++ trunk/glom/notebook_glom.h Tue Apr 1 11:35:17 2008
@@ -42,13 +42,15 @@
//Signals:
//Page number
//typedef sigc::signal<void, guint> type_signal_leave_page;
- // type_signal_leave_page signal_leave_page();
+ // type_signal_leave_page signal_leave_page();
- virtual void do_menu_developer_layout();
- virtual void do_menu_file_print();
+ virtual void do_menu_developer_layout();
+ virtual void do_menu_file_print();
protected:
+ virtual void on_show();
+
Gtk::Window* get_app_window();
//Signal handlers:
@@ -59,6 +61,7 @@
guint m_uiPreviousPage;
bool m_destructor_in_progress; //A hack to prevent calling wrap() on dead C instances.
+ sigc::connection m_connection_switch_page; //This allows us to delay connecting, and to block the handler temporarily.
};
} //namespace Glom
Modified: trunk/glom/utility_widgets/db_adddel/db_adddel.cc
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/db_adddel.cc (original)
+++ trunk/glom/utility_widgets/db_adddel/db_adddel.cc Tue Apr 1 11:35:17 2008
@@ -122,7 +122,7 @@
show_all_children();
-#ifndef GLOM_ENABLE_CLIENT_ONLY //Actually this has only been necessary for Maemo.
+#ifdef GLOM_ENABLE_CLIENT_ONLY //Actually this has only been necessary for Maemo.
// Adjust sizing when style changed
// TODO_Maemo: This calls construct_specified_columns(), which runs the SQL query again.
// Try to change the row and column sizes without doing that.
@@ -2061,6 +2061,7 @@
on_MenuPopup_activate_Edit();
}
+#ifdef GLOM_ENABLE_CLIENT_ONLY
void DbAddDel::on_self_style_changed(const Glib::RefPtr<Gtk::Style>& style)
{
// Reset fixed cell height because the font might have changed due to the new style:
@@ -2070,6 +2071,7 @@
// (TODO: But don't get the data again because that would be inefficient).
construct_specified_columns();
}
+#endif
void DbAddDel::set_open_button_title(const Glib::ustring& title)
{
Modified: trunk/glom/utility_widgets/db_adddel/db_adddel.h
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/db_adddel.h (original)
+++ trunk/glom/utility_widgets/db_adddel/db_adddel.h Tue Apr 1 11:35:17 2008
@@ -288,11 +288,13 @@
virtual void on_cell_button_clicked(const Gtk::TreeModel::Path& path);
void on_cell_layout_button_clicked(const Gtk::TreeModel::Path& path, int model_column_index);
- // Don't call it on_style_changed, otherwise we would override a virtual
+#ifdef GLOM_ENABLE_CLIENT_ONLY
+ // Don't name it on_style_changed, otherwise we would override a virtual
// function from Gtk::Widget. We could indeed do that, but we do it with
// a normal signal handler, because we have to do it this way anyway in
// case default signal handlers have been disabled in glibmm.
void on_self_style_changed(const Glib::RefPtr<Gtk::Style>& style);
+#endif //GLOM_ENABLE_CLIENT_ONLY
bool get_prevent_user_signals() const;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]