[glom/glom-1-18] Avoid GTK+ warning when clicking on the list button.



commit 59d0da8ae6e498a7358c648dfb961d6e3368e6a9
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Feb 25 15:17:18 2011 +0100

    Avoid GTK+ warning when clicking on the list button.
    
    * glom/mode_data/db_adddel/db_adddel.[h|cc]: on_cell_button_clicked():
    Delay the response to the click, to an idle handler, to avoid confusing
    GtkTreeView, which was showing a warning with GTK+ 3 about a NULL GtkAdjustment.

 ChangeLog                                   |    8 ++++++++
 glom/utility_widgets/db_adddel/db_adddel.cc |   15 +++++++++++++--
 glom/utility_widgets/db_adddel/db_adddel.h  |    3 ++-
 3 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c72b6a9..fee6a9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-02-25  Murray Cumming  <murrayc murrayc com>
+
+	Avoid GTK+ warning when clicking on the list button.
+
+	* glom/mode_data/db_adddel/db_adddel.[h|cc]: on_cell_button_clicked(): 
+	Delay the response to the click, to an idle handler, to avoid confusing 
+	GtkTreeView, which was showing a warning with GTK+ 3 about a NULL GtkAdjustment.
+
 2011-01-28  Murray Cumming  <murrayc murrayc com>
 
 	Adapt to the gtkmm 3 change to using vectors.
diff --git a/glom/utility_widgets/db_adddel/db_adddel.cc b/glom/utility_widgets/db_adddel/db_adddel.cc
index 602a659..215241f 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.cc
+++ b/glom/utility_widgets/db_adddel/db_adddel.cc
@@ -137,7 +137,7 @@ DbAddDel::DbAddDel()
   m_TreeView.add_events(Gdk::BUTTON_PRESS_MASK); //Allow us to catch button_press_event and button_release_event
   m_TreeView.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &DbAddDel::on_treeview_button_press_event) );
   m_TreeView.signal_columns_changed().connect( sigc::mem_fun(*this, &DbAddDel::on_treeview_columns_changed) );
-  signal_button_press_event().connect(sigc::mem_fun(*this, &DbAddDel::on_button_press_event_Popup));
+  //signal_button_press_event().connect(sigc::mem_fun(*this, &DbAddDel::on_button_press_event_Popup));
   #endif //GLOM_ENABLE_MAEMO
   //add_blank();
 
@@ -184,6 +184,11 @@ void DbAddDel::do_user_requested_edit()
 
 #ifndef GLOM_ENABLE_MAEMO
 
+void DbAddDel::on_idle_row_edit()
+{
+  on_MenuPopup_activate_Edit();
+}
+
 void DbAddDel::on_cell_button_clicked(const Gtk::TreeModel::Path& path)
 {
   if(!m_refListStore)
@@ -195,7 +200,13 @@ void DbAddDel::on_cell_button_clicked(const Gtk::TreeModel::Path& path)
     select_item(iter, false /* start_editing */);
   }
 
-  on_MenuPopup_activate_Edit();
+  //This delayed action avoids a warning about a NULL GtkAdjustment.
+  //It's fairly understandable that GtkTreeView doesn't like to be destroyed 
+  //as a side-effect of a click on one of its GtkCellRenderers.
+  //That's unlikely to be fixed properly until GtkTreeView supports a real 
+  //button cell-renderer.
+  Glib::signal_idle().connect_once(
+    sigc::mem_fun(*this, &DbAddDel::on_idle_row_edit));
 }
 
 void DbAddDel::on_MenuPopup_activate_Edit()
diff --git a/glom/utility_widgets/db_adddel/db_adddel.h b/glom/utility_widgets/db_adddel/db_adddel.h
index 52298bf..d4bfe45 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.h
+++ b/glom/utility_widgets/db_adddel/db_adddel.h
@@ -347,7 +347,8 @@ private:
   virtual bool on_treeview_columnheader_button_press_event(GdkEventButton* event);
   virtual void on_treeview_column_clicked(int model_column_index);
   void on_treeview_column_resized(int model_column_index, DbTreeViewColumnGlom* view_column);
-  virtual void on_cell_button_clicked(const Gtk::TreeModel::Path& path);
+  void on_idle_row_edit();
+  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);
   #endif //GLOM_ENABLE_MAEMO
 



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