[glom/spread-table] FlowTable: Avoid some runtime warnings.



commit 902380fc645978b992e603f706436db3f6a1e0db
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Oct 12 10:44:32 2010 +0200

    FlowTable: Avoid some runtime warnings.
    
    * glom/utility_widgets/flowtable.[h|cc]: Re-add remove().
      get_column_for_first_widget(): Fix the implementation when it deals with
      children of the hbox.
    * glom/mode_data/flowtablewithfields.cc: Destructor: Avoid use of
      remove(widget), because it is complicated.

 ChangeLog                             |   10 ++++++++++
 glom/mode_data/flowtablewithfields.cc |    4 ++--
 glom/utility_widgets/flowtable.cc     |   20 +++++++++++++++++++-
 glom/utility_widgets/flowtable.h      |    1 +
 4 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bae383a..47fac4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-10-12  Murray Cumming  <murrayc murrayc com>
 
+	FlowTable: Avoid some runtime warnings.
+
+	* glom/utility_widgets/flowtable.[h|cc]: Re-add remove().
+  get_column_for_first_widget(): Fix the implementation when it deals with
+  children of the hbox.
+	* glom/mode_data/flowtablewithfields.cc: Destructor: Avoid use of
+  remove(widget), because it is complicated.
+
+2010-10-12  Murray Cumming  <murrayc murrayc com>
+
 	FlowTable: Implement insert_before().
 
 	* glom/utility_widgets/flowtable.[h|cc]: Re-added insert_before() which
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 2011bc2..869f502 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -1034,6 +1034,8 @@ void FlowTableWithFields::change_group(const Glib::ustring& /* id */, const Glib
 
 void FlowTableWithFields::remove_all()
 {
+  FlowTable::remove_all();
+
   m_listFields.clear();
 
   for(type_sub_flow_tables::iterator iter = m_sub_flow_tables.begin(); iter != m_sub_flow_tables.end(); ++iter)
@@ -1042,7 +1044,6 @@ void FlowTableWithFields::remove_all()
     if(pSub)
     {
       remove_view(*iter);
-      remove(*pSub);
 
       delete pSub;
     }
@@ -1055,7 +1056,6 @@ void FlowTableWithFields::remove_all()
   {
     Box_Data_Portal* pPortal = *iter;
     remove_view(pPortal);
-    remove(*pPortal);
     delete pPortal;
   }
   m_portals.clear();
diff --git a/glom/utility_widgets/flowtable.cc b/glom/utility_widgets/flowtable.cc
index 942f1b3..1e08161 100644
--- a/glom/utility_widgets/flowtable.cc
+++ b/glom/utility_widgets/flowtable.cc
@@ -137,6 +137,19 @@ void FlowTable::remove_all()
   }
 }
 
+void FlowTable::remove(Gtk::Widget& first)
+{
+  const int index = get_child_index(first);
+  typedef std::vector<Widget*> type_children;
+  type_children children = get_children();
+  if((index >= 0) && ((guint)index < children.size()))
+  {
+    Gtk::Widget* child = children[index];
+    if(child)
+      Gtk::SpreadTable::remove(*child);
+  }
+}
+
 bool FlowTable::get_column_for_first_widget(const Gtk::Widget& first, guint& column) const
 {
   //Initialize output parameter:
@@ -153,6 +166,7 @@ bool FlowTable::get_column_for_first_widget(const Gtk::Widget& first, guint& col
     if(!widget)
       continue;
 
+    //Get the widget that GtkSpreadTable thinks of as the child:
     const Gtk::Widget* child = 0;
 
     if(widget == &first) //It must be a single item.
@@ -164,7 +178,11 @@ bool FlowTable::get_column_for_first_widget(const Gtk::Widget& first, guint& col
       {
         const type_children box_children = hbox->get_children();
         if(!box_children.empty())
-          child = box_children[0]; //TODO: Is this definitely the left-most one?
+        {
+          const Gtk::Widget* child_widget = box_children[0]; //TODO: Is this definitely the left-most one?
+          if(child_widget == &first)
+            child = hbox;
+        }
       }
 
       if(child)
diff --git a/glom/utility_widgets/flowtable.h b/glom/utility_widgets/flowtable.h
index 09e85ca..42c442f 100644
--- a/glom/utility_widgets/flowtable.h
+++ b/glom/utility_widgets/flowtable.h
@@ -44,6 +44,7 @@ public:
    */
   virtual void set_design_mode(bool value = true);
 
+  void remove(Gtk::Widget& first);
   void remove_all();
 
 protected:



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