[glom] PyGlomUI: Simplify the callbacks object.



commit 5637ffb2ff4fdaa213857bc0193ed7dca46aecd0
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Feb 28 12:06:52 2010 +0100

    PyGlomUI: Simplify the callbacks object.
    
    * glom/libglom/python_embed/py_glom_ui.[h|cc]: Use public sigc::slots instead
      of signals, to simplify this.
    * glom/mode_data/box_data.cc
      Box_Data::execute_button_script(): Adapt.

 ChangeLog                               |    9 +++++++++
 glom/libglom/python_embed/py_glom_ui.cc |   19 +++++--------------
 glom/libglom/python_embed/py_glom_ui.h  |   19 +++++++------------
 glom/mode_data/box_data.cc              |    8 ++++----
 4 files changed, 25 insertions(+), 30 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eb31f14..e610c72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-02-28  Murray Cumming  <murrayc murrayc com>
+
+  PyGlomUI: Simplify the callbacks object.
+  
+	* glom/libglom/python_embed/py_glom_ui.[h|cc]: Use public sigc::slots instead 
+	  of signals, to simplify this. 
+	* glom/mode_data/box_data.cc
+	  Box_Data::execute_button_script(): Adapt.
+
 1.13.6:
 
 2010-02-28  Murray Cumming  <murrayc murrayc com>
diff --git a/glom/libglom/python_embed/py_glom_ui.cc b/glom/libglom/python_embed/py_glom_ui.cc
index 91a8084..629cdc8 100644
--- a/glom/libglom/python_embed/py_glom_ui.cc
+++ b/glom/libglom/python_embed/py_glom_ui.cc
@@ -25,20 +25,11 @@
 namespace Glom
 {
 
-PythonUICallbacks::type_signal_show_table_details PythonUICallbacks::signal_show_table_details()
-{
-  return m_signal_show_table_details;
-}
-
-PythonUICallbacks::type_signal_show_table_list PythonUICallbacks::signal_show_table_list()
-{
-  return m_signal_show_table_list;
-}
-
 PyGlomUI::PyGlomUI()
 : m_callbacks(0)
 {
 }
+
 PyGlomUI::PyGlomUI(const PythonUICallbacks& callbacks)
 : m_callbacks(&callbacks)
 {
@@ -50,7 +41,7 @@ PyGlomUI::~PyGlomUI()
 
 void PyGlomUI::show_table_details(const std::string& table_name, const boost::python::object& primary_key_value)
 {
-  if(!m_callbacks)
+  if(!m_callbacks && m_callbacks->m_slot_show_table_details)
     return;
     
   Gnome::Gda::Value gda_primary_key_value;
@@ -60,13 +51,13 @@ void PyGlomUI::show_table_details(const std::string& table_name, const boost::py
   if(test && G_IS_VALUE(&value))
     gda_primary_key_value = Gnome::Gda::Value(&value);
 
-  m_callbacks->m_signal_show_table_details.emit(table_name, gda_primary_key_value);
+  m_callbacks->m_slot_show_table_details(table_name, gda_primary_key_value);
 }
 
 void PyGlomUI::show_table_list(const std::string& table_name)
 {
-  if(m_callbacks)
-    m_callbacks->m_signal_show_table_list.emit(table_name);
+  if(m_callbacks && m_callbacks->m_slot_show_table_list)
+    m_callbacks->m_slot_show_table_list(table_name);
 }
 
 } //namespace Glom
diff --git a/glom/libglom/python_embed/py_glom_ui.h b/glom/libglom/python_embed/py_glom_ui.h
index 0424dbd..4290b37 100644
--- a/glom/libglom/python_embed/py_glom_ui.h
+++ b/glom/libglom/python_embed/py_glom_ui.h
@@ -33,23 +33,18 @@ namespace Glom
 /** UI code should connect to the signals to respond when Python code 
  * request a change in the UI.
  */
-class PythonUICallbacks : public sigc::trackable
+class PythonUICallbacks
 {
 public:
   /** For example,
    * void on_show_details(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value);
    */
-  typedef sigc::signal<void, const Glib::ustring&, const Gnome::Gda::Value&> type_signal_show_table_details;
-  type_signal_show_table_details signal_show_table_details();
-  
-  typedef sigc::signal<void, const Glib::ustring&> type_signal_show_table_list;
-  type_signal_show_table_list signal_show_table_list();
-  
-  friend class PyGlomUI;
-  
-private:
-  type_signal_show_table_details m_signal_show_table_details;
-  type_signal_show_table_list m_signal_show_table_list;
+  sigc::slot<void, const Glib::ustring&, const Gnome::Gda::Value&> m_slot_show_table_details;
+
+   /** For example,
+   * void on_show_list(const Glib::ustring& table_name);
+   */ 
+  sigc::slot<void, const Glib::ustring&> m_slot_show_table_list;
 };
 
 class PyGlomUI
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index 3854c7e..0852b04 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -386,10 +386,10 @@ void Box_Data::execute_button_script(const sharedptr<const LayoutItem_Button>& l
 
     //Allow this UI to respond to UI change requests from the Python code:
     PythonUICallbacks callbacks;
-    callbacks.signal_show_table_details().connect(
-      sigc::mem_fun(*this, &Box_Data::on_python_requested_show_table_details));
-    callbacks.signal_show_table_list().connect(
-      sigc::mem_fun(*this, &Box_Data::on_python_requested_show_table_list)); 
+    callbacks.m_slot_show_table_details = 
+      sigc::mem_fun(*this, &Box_Data::on_python_requested_show_table_details);
+    callbacks.m_slot_show_table_list = 
+      sigc::mem_fun(*this, &Box_Data::on_python_requested_show_table_list);
           
     glom_execute_python_function_implementation(layout_item->get_script(),
       field_values, //TODO: Maybe use the field's type here.



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