[glom] Fix the build with the latest gtkmm, with --enable-warnings=fatal.



commit 4c040283b7f72b4f722b86899892235ed59ccfe4
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Mar 28 10:23:20 2012 +0200

    Fix the build with the latest gtkmm, with --enable-warnings=fatal.
    
    * glom/mode_data/box_data.[h|cc]: on_Button_Find(): Let the signal
    handler do the check and warning about no criteria.
    * glom/frame_glom.cc: on_notebook_find_criteria(): Check for quickfind
    criteria here too, so we can use this to do quick finds too, which lets
    use just use the existing Find button (the window's default activate widget),
    instead of trying to make the separate quickfind Find button be the default
    for the entry, but not for other widgets.
    on_button_quickfind(): Just call on_notebook_find_criteria(), letting it do
    all the work.
    Constructor: Call set_activates_default() on the quickfind entry so that the
    regular Find button will be activated when enter is pressed.

 ChangeLog                  |   16 +++++++++++
 glom/frame_glom.cc         |   62 ++++++++++++++++++++++++-------------------
 glom/mode_data/box_data.cc |   13 ++-------
 glom/mode_data/box_data.h  |    5 ++-
 4 files changed, 57 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e5b2410..0476398 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2012-03-28  Murray Cumming  <murrayc murrayc com>
 
+	Fix the build with the latest gtkmm, with --enable-warnings=fatal.
+
+	* glom/mode_data/box_data.[h|cc]: on_Button_Find(): Let the signal
+	handler do the check and warning about no criteria.
+	* glom/frame_glom.cc: on_notebook_find_criteria(): Check for quickfind
+	criteria here too, so we can use this to do quick finds too, which lets
+	use just use the existing Find button (the window's default activate widget),
+	instead of trying to make the separate quickfind Find button be the default
+	for the entry, but not for other widgets.
+	on_button_quickfind(): Just call on_notebook_find_criteria(), letting it do 
+	all the work.
+	Constructor: Call set_activates_default() on the quickfind entry so that the
+	regular Find button will be activated when enter is pressed.
+	
+2012-03-28  Murray Cumming  <murrayc murrayc com>
+
 	Slight code improvement.
 
 	* glom/mode_find/box_data_details_find.cc:
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 6703018..78c158f 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -114,8 +114,9 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
   m_pBox_QuickFind->pack_start(*label, Gtk::PACK_SHRINK);
 
   m_pEntry_QuickFind = Gtk::manage(new Gtk::Entry());
-  m_pEntry_QuickFind->signal_activate().connect(
-   sigc::mem_fun(*this, &Frame_Glom::on_button_quickfind) ); //Pressing Enter here is like pressing Find.
+
+  //Pressing Enter here is like pressing Find:
+  m_pEntry_QuickFind->set_activates_default();
 
   label->set_mnemonic_widget(*m_pEntry_QuickFind);
 
@@ -304,7 +305,6 @@ bool Frame_Glom::set_mode(enumModes mode)
 
       //Put the cursor in the quick find entry:
       m_pEntry_QuickFind->grab_focus();
-      //m_pButton_QuickFind->grab_default();
     }
   }
   else
@@ -1308,45 +1308,53 @@ void Frame_Glom::show_ok_dialog(const Glib::ustring& title, const Glib::ustring&
 
 void Frame_Glom::on_button_quickfind()
 {
-  const Glib::ustring criteria = m_pEntry_QuickFind->get_text();
-  if(criteria.empty())
-  {
-    Glib::ustring message(_("You have not entered any quick find criteria."));
-    Gtk::MessageDialog dialog(Utils::bold_message(_("No find criteria")), true, Gtk::MESSAGE_WARNING );
-    dialog.set_secondary_text(message);
-    dialog.set_transient_for(*get_app_window());
-    dialog.run();
-  }
-  else
-  {
-    const Gnome::Gda::SqlExpr where_clause = Utils::get_find_where_clause_quick(get_document(), m_table_name, Gnome::Gda::Value(criteria));
-    //std::cout << "debug: " << G_STRFUNC << ": where_clause=" << where_clause.serialize() << std::endl;
-    on_notebook_find_criteria(where_clause);
-  }
+  //This will get the criteria for the quick find:
+  on_notebook_find_criteria(Gnome::Gda::SqlExpr());
 }
 
 void Frame_Glom::on_notebook_find_criteria(const Gnome::Gda::SqlExpr& where_clause)
 {
-  //std::cout << "debug: " << G_STRFUNC << ": " << where_clause << std::endl;
-
-  AppWindow* pApp = dynamic_cast<AppWindow*>(get_app_window());
-  if(!pApp)
+  AppWindow* app = dynamic_cast<AppWindow*>(get_app_window());
+  if(!app)
   {
     std::cerr << G_STRFUNC << ": get_app_window() failed." << std::endl;
     return;
   }
   
+  Gnome::Gda::SqlExpr where_clause_to_use = where_clause;
+
+  //Prefer the quick find text if any was entered:
+  const Glib::ustring quickfind_criteria = m_pEntry_QuickFind->get_text();
+  if(!quickfind_criteria.empty())
+  {
+    where_clause_to_use = 
+      Utils::get_find_where_clause_quick(get_document(), m_table_name, Gnome::Gda::Value(quickfind_criteria));
+  }
+
+  if(where_clause_to_use.empty())
+  {
+    const Glib::ustring message = _("You have not entered any find criteria. Try entering information in the fields.");
+
+    Gtk::MessageDialog dialog(Utils::bold_message(_("No Find Criteria")), true, Gtk::MESSAGE_WARNING );
+    dialog.set_secondary_text(message);
+    dialog.set_transient_for(*app);
+    dialog.run();
+    return;
+  }
+
+  //std::cout << "debug: " << G_STRFUNC << ": " << where_clause << std::endl;
+  
   bool records_found = false;
 
   { //Extra scope, to control the lifetime of the busy cursor.
-    BusyCursor busy_cursor(pApp);
+    BusyCursor busy_cursor(app);
 
-    pApp->set_mode_data();
+    app->set_mode_data();
 
     //std::cout << "Frame_Glom::on_notebook_find_criteria: where_clause=" << where_clause << std::endl;
     FoundSet found_set;
     found_set.m_table_name = m_table_name;
-    found_set.m_where_clause = where_clause;
+    found_set.m_where_clause = where_clause_to_use;
     records_found = m_Notebook_Data.init_db_details(found_set);
 
     //std::cout << "debug: " << G_STRFUNC << ": BEFORE  m_Notebook_Data.select_page_for_find_results()" << std::endl;
@@ -1356,10 +1364,10 @@ void Frame_Glom::on_notebook_find_criteria(const Gnome::Gda::SqlExpr& where_clau
 
   if(!records_found)
   {
-    const bool find_again = Utils::show_warning_no_records_found(*get_app_window());
+    const bool find_again = Utils::show_warning_no_records_found(*app);
 
     if(find_again)
-      pApp->set_mode_find();
+      app->set_mode_find();
     else
       on_button_find_all();
   }
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index 37fb612..6561e4c 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -150,18 +150,11 @@ void Box_Data::on_Button_Find()
   //Make sure that the cell is updated:
   //m_AddDel.finish_editing();
 
+  //Call the virtual method to get the find criteria for a details or list view:
   const Gnome::Gda::SqlExpr where_clause = get_find_where_clause();
-  if(where_clause.empty())
-  {
-    const Glib::ustring message = _("You have not entered any find criteria. Try entering information in the fields.");
 
-    Gtk::MessageDialog dialog(Utils::bold_message(_("No Find Criteria")), true, Gtk::MESSAGE_WARNING );
-    dialog.set_secondary_text(message);
-    dialog.set_transient_for(*get_app_window());
-    dialog.run();
-  }
-  else
-    signal_find_criteria.emit(where_clause);
+  //The signal handler then checks and warns if no find criteria were entered.
+  signal_find_criteria.emit(where_clause);
 }
 
 void Box_Data::set_unstored_data(bool bVal)
diff --git a/glom/mode_data/box_data.h b/glom/mode_data/box_data.h
index 00c0dc6..8dcb477 100644
--- a/glom/mode_data/box_data.h
+++ b/glom/mode_data/box_data.h
@@ -108,10 +108,11 @@ protected:
 
   void execute_button_script(const sharedptr<const LayoutItem_Button>& layout_item, const Gnome::Gda::Value& primary_key_value);
 
+private:
+
   //Signal handlers:
-  virtual void on_Button_Find(); //only used by _Find sub-classes. Should be MI.
+  void on_Button_Find(); //only used by _Find sub-classes. Should be MI.
 
-private:
   //Signal handlers for the PyGlomUI callbacks:
   void on_python_requested_show_table_details(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value);
   void on_python_requested_show_table_list(const Glib::ustring& table_name);



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