[glom] Avoid GTK+ warning when clicking on the list button.



commit 140ef3b1bd100000bc6f3b21635ef8406a3255a5
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/mode_data/db_adddel/db_adddel.cc |   15 +++++++++++++--
 glom/mode_data/db_adddel/db_adddel.h  |    3 ++-
 3 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d11b5c0..7770780 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-02-10  Murray Cumming  <murrayc murrayc com>
 
 	Use the new Gtk::ComboBox CellArea API to align columns properly.
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 0d366aa..89ffcbc 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -112,7 +112,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();
 
@@ -159,6 +159,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)
@@ -170,7 +175,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/mode_data/db_adddel/db_adddel.h b/glom/mode_data/db_adddel/db_adddel.h
index cb61646..e2d6685 100644
--- a/glom/mode_data/db_adddel/db_adddel.h
+++ b/glom/mode_data/db_adddel/db_adddel.h
@@ -331,7 +331,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]