[glom/maemo5] On Maemo, show the details in a separate window.



commit 83856b82c8944a1c9de8eb8fdb71dd969aff4f47
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Sep 22 19:11:53 2009 +0200

    On Maemo, show the details in a separate window.
    
    * glom/mode_data/notebook_data.[h|cc]: On maemo, hide the tabs, and don't
    add the details box to the notebook. Instead add it to a window and show that
    window instead of switching to a details tab when details are requested.

 ChangeLog                                   |    8 +++
 glom/dialog_glom.cc                         |    2 +
 glom/dialog_glom.h                          |    4 ++
 glom/frame_glom.cc                          |    1 -
 glom/mode_data/notebook_data.cc             |   66 +++++++++++++++++++--------
 glom/mode_data/notebook_data.h              |   21 ++++++---
 glom/utility_widgets/db_adddel/db_adddel.cc |   13 +++++-
 7 files changed, 88 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 63d9f36..f2c62bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-22  Murray Cumming  <murrayc murrayc com>
+
+	On Maemo, show the details in a separate window.
+	
+	* glom/mode_data/notebook_data.[h|cc]: On maemo, hide the tabs, and don't 
+	add the details box to the notebook. Instead add it to a window and show that 	
+	window instead of switching to a details tab when details are requested.
+
 2009-09-21  Murray Cumming  <murrayc murrayc com>
 
 	import tests: Fix the no-exceptions build.
diff --git a/glom/dialog_glom.cc b/glom/dialog_glom.cc
index b3b7a4d..038b23c 100644
--- a/glom/dialog_glom.cc
+++ b/glom/dialog_glom.cc
@@ -38,6 +38,8 @@ Dialog_Glom::Dialog_Glom(Box_WithButtons* pBox, const Glib::ustring& title)
     m_pBox->signal_cancelled.connect(sigc::mem_fun(*this, &Dialog_Glom::on_box_cancelled));
     m_pBox->show();
   }
+  else
+    std::cerr << "Dialog_Glom::Dialog_Glom(): pBox was NULL." << std::endl;
 
   //Set the default button, if there is one:
   Gtk::Widget* default_button = m_pBox->get_default_button();
diff --git a/glom/dialog_glom.h b/glom/dialog_glom.h
index bdd36de..81d0dac 100644
--- a/glom/dialog_glom.h
+++ b/glom/dialog_glom.h
@@ -28,6 +28,9 @@
 namespace Glom
 {
 
+//TODO: Use a Window instead of a Dialog?
+/** A window that can hold a Box_WithButtons.
+ */
 class Dialog_Glom :
   public Gtk::Dialog
 {
@@ -35,6 +38,7 @@ public:
   Dialog_Glom(Box_WithButtons* pBox, const Glib::ustring& title = Glib::ustring());
   virtual ~Dialog_Glom();
 
+//TODO: Make this private and non-virtual?
   //Signal handlers:
   virtual void on_box_cancelled();
 
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 9fb27f8..f33bcfd 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -153,7 +153,6 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
 
   m_Notebook_Find.signal_find_criteria.connect(sigc::mem_fun(*this, &Frame_Glom::on_notebook_find_criteria));
   m_Notebook_Find.show();
-
   m_Notebook_Data.signal_record_details_requested().connect(sigc::mem_fun(*this, &Frame_Glom::on_notebook_data_record_details_requested));
   m_Notebook_Data.signal_switch_page().connect(sigc::mem_fun(*this, &Frame_Glom::on_notebook_data_switch_page));
   m_Notebook_Data.show();
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index 250bd04..4edd3e9 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -18,7 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "notebook_data.h"
+#include <glom/mode_data/notebook_data.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <glibmm/i18n.h>
 
@@ -26,13 +26,30 @@ namespace Glom
 {
 
 Notebook_Data::Notebook_Data()
+: m_iPage_Details(0), m_iPage_List(0)
+  #ifndef GLOM_ENABLE_MAEMO
+  , m_window_maemo_details(0)
+  #endif
 {
   //Add Pages:
   pages().push_back(Gtk::Notebook_Helpers::TabElem(m_Box_List, _("List")));
   m_iPage_List = 0;
 
+  #ifndef GLOM_ENABLE_MAEMO
   pages().push_back(Gtk::Notebook_Helpers::TabElem(m_Box_Details, _("Details")));
   m_iPage_Details = 1;
+  #else
+  //On Maemo, we add the box to m_window_maemo_details instead:
+  m_window_maemo_details = new Dialog_Glom(&m_Box_Details, _("Details"));
+  
+  Gtk::Window* pWindow = get_app_window();
+  if(pWindow)
+    m_window_maemo_details->set_transient_for(*pWindow);
+
+  //TODO: Avoid having to add this to the Dialog_Glom _again_:
+  m_window_maemo_details->get_vbox()->pack_start(m_Box_Details);
+  m_Box_Details.show_all();
+  #endif //GLOM_ENABLE_MAEMO
 
   // Set accessible name for the notebook, to be able to access it via LDTP
 #ifdef GTKMM_ATKMM_ENABLED
@@ -46,6 +63,7 @@ Notebook_Data::Notebook_Data()
   m_Box_List.signal_user_requested_details().connect(sigc::mem_fun(*this, &Notebook_Data::on_list_user_requested_details));
 
   //Allow Details to ask List to ask Details to show a different record:
+  #ifndef GLOM_ENABLE_MAEMO //These navigation buttons are not visible on Maemo.
   m_Box_Details.signal_nav_first().connect(sigc::mem_fun(m_Box_List, &Box_Data_List::on_details_nav_first));
   m_Box_Details.signal_nav_prev().connect(sigc::mem_fun(m_Box_List, &Box_Data_List::on_details_nav_previous));
   m_Box_Details.signal_nav_next().connect(sigc::mem_fun(m_Box_List, &Box_Data_List::on_details_nav_next));
@@ -53,7 +71,8 @@ Notebook_Data::Notebook_Data()
 
   //Allow Details to tell List about record deletion:
   m_Box_Details.signal_record_deleted().connect(sigc::mem_fun(m_Box_List, &Box_Data_List::on_details_record_deleted));
-
+  #endif //GLOM_ENABLE_MAEMO
+  
   //Allow Details to ask to show a different record in a different table:
   m_Box_Details.signal_requested_related_details().connect(sigc::mem_fun(*this, &Notebook_Data::on_details_user_requested_related_details));
 
@@ -78,6 +97,9 @@ Notebook_Data::~Notebook_Data()
 {
   remove_view(&m_Box_List);
   remove_view(&m_Box_Details);
+
+  if(m_window_maemo_details)
+    delete m_window_maemo_details;
 }
 
 bool Notebook_Data::init_db_details(const FoundSet& found_set, const Gnome::Gda::Value& primary_key_value_for_details)
@@ -119,7 +141,7 @@ bool Notebook_Data::init_db_details(const FoundSet& found_set, const Gnome::Gda:
       {
         primary_key_for_details = primary_key_value_for_details;
       }
-
+      
       //If the specified (or remembered) primary key value is not in the found set, 
       //then ignore it:
       if(!found_set.m_where_clause.empty() && !get_primary_key_is_in_foundset(found_set, primary_key_for_details))
@@ -189,26 +211,32 @@ FoundSet Notebook_Data::get_found_set() const
   return m_Box_List.get_found_set();
 }
 
-FoundSet Notebook_Data::get_found_set_details() const
-{
-  return m_Box_Details.get_found_set();
-}
-  
-
-void Notebook_Data::on_list_user_requested_details(const Gnome::Gda::Value& primary_key_value)
+void Notebook_Data::show_details(const Gnome::Gda::Value& primary_key_value)
 {
   //Prevent n_switch_page_handler() from doing the same thing:
   if(m_connection_switch_page)
     m_connection_switch_page.block();
-    
-  m_Box_Details.refresh_data_from_database_with_primary_key(primary_key_value);
   
+  std::cout << "DEBUG: Notebook_Data::show_details() primary_key_value=" << primary_key_value.to_string() << std::endl;
+  m_Box_Details.refresh_data_from_database_with_primary_key(primary_key_value);
+
+#if GLOM_ENABLE_MAEMO
+  //Details are shown in a separate window on Maemo,
+  //though that window contains the regular m_Box_Details.
+  m_window_maemo_details->show();
+#else  
   if(get_current_view() != DATA_VIEW_Details)
     set_current_view(DATA_VIEW_Details);
+#endif
   
   //Re-enable this handler, so we can respond to notebook page changes:
   if(m_connection_switch_page)
-    m_connection_switch_page.unblock();
+    m_connection_switch_page.unblock();  
+}
+
+void Notebook_Data::on_list_user_requested_details(const Gnome::Gda::Value& primary_key_value)
+{
+  show_details(primary_key_value);
 }
 
 void Notebook_Data::on_details_user_requested_related_details(const Glib::ustring& table_name, Gnome::Gda::Value primary_key_value)
@@ -224,6 +252,12 @@ void Notebook_Data::on_details_user_requested_related_details(const Glib::ustrin
   */
 }
 
+FoundSet Notebook_Data::get_found_set_details() const
+{
+  return m_Box_Details.get_found_set();
+}
+
+
 void Notebook_Data::set_current_view(dataview view)
 {
   if(view == DATA_VIEW_List)
@@ -300,12 +334,6 @@ Notebook_Data::type_signal_record_details_requested Notebook_Data::signal_record
   return m_signal_record_details_requested;
 }
 
-void Notebook_Data::show_details(const Gnome::Gda::Value& primary_key_value)
-{
-  //Reuse this implementation:
-  on_list_user_requested_details(primary_key_value);
-}
-
 void Notebook_Data::on_switch_page_handler(GtkNotebookPage* pPage, guint uiPageNumber)
 {
   //Call base class:
diff --git a/glom/mode_data/notebook_data.h b/glom/mode_data/notebook_data.h
index 7ce0235..4e5cd66 100644
--- a/glom/mode_data/notebook_data.h
+++ b/glom/mode_data/notebook_data.h
@@ -21,9 +21,13 @@
 #ifndef NOTEBOOK_DATA_H
 #define NOTEBOOK_DATA_H
 
-#include "../notebook_glom.h"
-#include "box_data_list.h"
-#include "box_data_details.h"
+#include <glom/notebook_glom.h>
+#include <glom/mode_data/box_data_list.h>
+#include <glom/mode_data/box_data_details.h>
+
+#ifdef GLOM_ENABLE_MAEMO 
+#include <glom/dialog_glom.h>
+#endif
 
 namespace Glom
 {
@@ -47,7 +51,7 @@ public:
   ///Get the found set for the currently-visible record in the details tab:
   FoundSet get_found_set_details() const;
 
-  ///Show the details for a particular record, without affecting the list view:
+  ///Show the details for a particular record, without affecting the list view.
   void show_details(const Gnome::Gda::Value& primary_key_value);
 
   void select_page_for_find_results(); //Details for 1, List for > 1.
@@ -72,7 +76,7 @@ public:
 
   typedef sigc::signal<void, const Glib::ustring&, Gnome::Gda::Value> type_signal_record_details_requested;
   type_signal_record_details_requested signal_record_details_requested();
-
+  
 protected:
 
   ///Show the counts of all records and found records.
@@ -87,9 +91,14 @@ protected:
   //Member widgets:
   Box_Data_List m_Box_List;
   Box_Data_Details m_Box_Details;
-
+  
+  #ifdef GLOM_ENABLE_MAEMO //Details are in a separate window on Maemo.
+  Dialog_Glom* m_window_maemo_details;
+  #endif
+  
   guint m_iPage_Details, m_iPage_List;
   Glib::ustring m_table_name;
+  
   type_signal_record_details_requested m_signal_record_details_requested;
 };
 
diff --git a/glom/utility_widgets/db_adddel/db_adddel.cc b/glom/utility_widgets/db_adddel/db_adddel.cc
index de84771..6036006 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.cc
+++ b/glom/utility_widgets/db_adddel/db_adddel.cc
@@ -114,6 +114,12 @@ DbAddDel::DbAddDel()
   m_ScrolledWindow.add(m_TreeView);
   pack_start(m_ScrolledWindow);
   #else
+  //Do not let the treeview emit activated as soon as a row is pressed.
+  //TODO: Allow this default mamoe behaviour?
+  g_object_set(m_TreeView.gobj(), "hildon-ui-mode", HILDON_UI_MODE_NORMAL, (void*)0);
+  
+  //Let get_selected() and get_active() to work:
+  m_TreeView.set_column_selection_mode(Hildon::TOUCH_SELECTOR_SELECTION_MODE_SINGLE);
   pack_start(m_TreeView);
   #endif //GLOM_ENABLE_MAEMO
 
@@ -439,7 +445,12 @@ Gtk::TreeModel::iterator DbAddDel::get_item_selected()
 Gtk::TreeModel::iterator DbAddDel::get_item_selected() const
 {
   #ifdef GLOM_ENABLE_MAEMO
-  return m_TreeView.get_active();
+  Hildon::TouchSelector& unconst = const_cast<Hildon::TouchSelector&>(m_TreeView);
+  return unconst.get_selected(0);
+  
+  //TODO: What would this mean?
+  //See https://bugs.maemo.org/show_bug.cgi?id=4641
+  // return m_TreeView.get_active();
   #else
   Glib::RefPtr<const Gtk::TreeSelection> refTreeSelection = m_TreeView.get_selection();
   if(refTreeSelection)



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