[glom] Related Records: Show enough records.



commit e7253fc9600c9bea1c5d205105fe3040f039386d
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jul 8 12:53:36 2011 +0200

    Related Records: Show enough records.
    
    * glom/mode_data/db_adddel/db_adddel.[h|cc]: Added set_height_rows(), so
    we can set the minimum size based on the number of rows, though this
    currently hard-codes a size for the non-rows part of the GtkTreeView, such
    as the column headers.
    * glom/mode_data/box_data_portal.cc:
    * glom/mode_data/box_data_list_related.cc: Constructors: Remove unnecessary
    calls to set_size_request().
    Call set_height_rows() instead.
    
      The related records Gtk::TreeViews probably became too small since the port to
      gtkmm3. We now need to use Gtk::ScrolledArea::set_min_content_height().
    
      However, the number of rows should probably be something for the layout to
      specify per portal.

 ChangeLog                               |   19 +++++++++++++++++++
 glom/mode_data/box_data_list_related.cc |    3 +--
 glom/mode_data/box_data_portal.cc       |    2 --
 glom/mode_data/db_adddel/db_adddel.cc   |   11 ++++++++++-
 glom/mode_data/db_adddel/db_adddel.h    |    4 ++++
 5 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9f5f9e7..8966075 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2011-07-08  Murray Cumming  <murrayc murrayc com>
 
+	Related Records: Show enough records.
+
+	* glom/mode_data/db_adddel/db_adddel.[h|cc]: Added set_height_rows(), so 
+	we can set the minimum size based on the number of rows, though this 
+	currently hard-codes a size for the non-rows part of the GtkTreeView, such 
+	as the column headers.
+	* glom/mode_data/box_data_portal.cc:
+	* glom/mode_data/box_data_list_related.cc: Constructors: Remove unnecessary 
+	calls to set_size_request().
+	Call set_height_rows() instead.
+
+  The related records Gtk::TreeViews probably became too small since the port to 
+  gtkmm3. We now need to use Gtk::ScrolledArea::set_min_content_height().
+  
+  However, the number of rows should probably be something for the layout to 
+  specify per portal.
+	
+2011-07-08  Murray Cumming  <murrayc murrayc com>
+
 	Minor int->guint change.
 
 	* glom/mode_data/db_adddel/db_adddel.[h|cc]: get_fixed_cell_height(): 
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 06524f5..aa7095f 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -32,11 +32,10 @@ namespace Glom
 
 Box_Data_List_Related::Box_Data_List_Related()
 {
-  set_size_request(400, -1); //An arbitrary default.
-
   m_Alignment.add(m_AddDel);
   add_view(&m_AddDel); //Give it access to the document.
   m_AddDel.show();
+  m_AddDel.set_height_rows(5);
   m_Alignment.show();
 
   //Connect signals:
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 429b5ba..1e7b6ca 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -44,8 +44,6 @@ Box_Data_Portal::Box_Data_Portal()
   m_box_maemo_details(0)
 #endif
 {
-  set_size_request(400, -1); //An arbitrary default.
-
   //m_Frame.set_label_widget(m_Label_Related);
   m_Frame.set_shadow_type(Gtk::SHADOW_NONE);
 
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index cb55580..c0d12cc 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -103,7 +103,7 @@ DbAddDel::DbAddDel()
   m_TreeView.show();
 
   //Make sure that the TreeView doesn't start out only big enough for zero items.
-  m_TreeView.set_size_request(-1, 150);
+  set_height_rows(5);
 
   //Allow the user to change the column order:
   //m_TreeView.set_column_drag_function( sigc::mem_fun(*this, &DbAddDel::on_treeview_column_drop) );
@@ -146,6 +146,15 @@ DbAddDel::~DbAddDel()
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 }
 
+void DbAddDel::set_height_rows(guint rows)
+{
+  //TODO: File a bug about API for this in GtkTreeView.
+  const guint height_for_rows = rows * get_fixed_cell_height();
+  //std::cout << "debug: height_for_rows = " << height_for_rows << std::endl;
+  const guint extra_for_treeview = 50; //TODO: Find some way to guess this.
+  m_ScrolledWindow.set_min_content_height(height_for_rows + extra_for_treeview);
+}
+
 void DbAddDel::do_user_requested_edit()
 {
   Gtk::TreeModel::iterator iter = get_item_selected();
diff --git a/glom/mode_data/db_adddel/db_adddel.h b/glom/mode_data/db_adddel/db_adddel.h
index a38459b..85cdc02 100644
--- a/glom/mode_data/db_adddel/db_adddel.h
+++ b/glom/mode_data/db_adddel/db_adddel.h
@@ -259,6 +259,10 @@ public:
    * adding the generated primary key if necessary.
    */
   bool start_new_record();
+  
+  /** Request a height for this widget, based on the number of rows to show.
+   */
+  void set_height_rows(guint rows);
 
 private:
 



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