[glom/maemo5] Maemo: Add a Add Record to the App Menu and remove it from the List View.



commit 2baafe62b88e89e9ae0edadfa701a3772ade9d18
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Oct 13 18:05:07 2009 +0200

    Maemo: Add a Add Record to the App Menu and remove it from the List View.
    
    * glom/application.cc: init_menus(): Add an Add Record item to the AppMenu
    on Maemo.
    * glom/frame_glom.[h|cc]: Added on_menu_add_record() on Maemo, calling
    Notebook_Data::do_menu_file_add_record().
    * glom/mode_data/box_data_details.[h|cc]: Added do_new_record().
    * glom/mode_data/notebook_data.[h|cc]: Added do_menu_file_add_record() to call
    the Box_Data_Details::do_new_record().
    * glom/utility_widgets/db_adddel/db_adddel.h: Made start_new_record() public
    and documented it.
    * glom/utility_widgets/db_adddel/db_adddel_withbuttons.[h|cc]: Remove the
    Add button on Maemo.

 ChangeLog                                          |   16 ++++++++++++++++
 glom/application.cc                                |    7 +++----
 glom/frame_glom.cc                                 |   11 +++++++++++
 glom/frame_glom.h                                  |    6 +++++-
 glom/mode_data/box_data_details.cc                 |    9 ++++++++-
 glom/mode_data/box_data_details.h                  |    9 +++++++--
 glom/mode_data/box_data_list.h                     |    1 +
 glom/mode_data/box_data_manyrecords.h              |    1 -
 glom/mode_data/notebook_data.cc                    |   20 +++++++++++++++++---
 glom/mode_data/notebook_data.h                     |    6 +++++-
 glom/utility_widgets/db_adddel/db_adddel.h         |   12 ++++++++----
 .../db_adddel/db_adddel_withbuttons.cc             |   11 ++++++-----
 .../db_adddel/db_adddel_withbuttons.h              |    3 +--
 13 files changed, 88 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 449e371..651400d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2009-10-13  Murray Cumming  <murrayc murrayc com>
 
+	Maemo: Add a Add Record to the App Menu and remove it from the List View.
+
+	* glom/application.cc: init_menus(): Add an Add Record item to the AppMenu 
+	on Maemo.
+	* glom/frame_glom.[h|cc]: Added on_menu_add_record() on Maemo, calling 
+	Notebook_Data::do_menu_file_add_record().
+	* glom/mode_data/box_data_details.[h|cc]: Added do_new_record().
+	* glom/mode_data/notebook_data.[h|cc]: Added do_menu_file_add_record() to call 
+	the Box_Data_Details::do_new_record().
+	* glom/utility_widgets/db_adddel/db_adddel.h: Made start_new_record() public 
+	and documented it.
+	* glom/utility_widgets/db_adddel/db_adddel_withbuttons.[h|cc]: Remove the 
+	Add button on Maemo.
+
+2009-10-13  Murray Cumming  <murrayc murrayc com>
+
 	* *.cc: Replace use of NULL with 0, because this is C++.
 	Replace use of != NULL with nothing. 
 
diff --git a/glom/application.cc b/glom/application.cc
index e616c63..31bfa2c 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -385,10 +385,9 @@ void App_Glom::init_menus()
     _("Find"), _("Search for records in the table"),
     sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_Mode_Find) );
     
-  //TODO:
-  //add_button_to_appmenu(m_maemo_appmenu, 
-  //  _("Add Record"), _("Create a new record in the table"),
-  //  sigc::mem_fun(*this, &App_Glom::on_menu_add_record) );
+  add_button_to_appmenu(m_maemo_appmenu, 
+    _("Add Record"), _("Create a new record in the table"),
+    sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_add_record) );
 
   //set_app_menu(*appmenu); //TODO: Use this instead?
   Hildon::Program::get_instance()->set_common_app_menu(m_maemo_appmenu);
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index c2f36d8..e32b3e2 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -1213,6 +1213,17 @@ void Frame_Glom::on_menu_Mode_Find()
   #endif
 }
 
+#ifdef GLOM_ENABLE_MAEMO
+void Frame_Glom::on_menu_add_record()
+{
+  BusyCursor busy_cursor(get_app_window());
+  
+  //Note: This should only be called in Data mode.
+  m_Notebook_Data.do_menu_file_add_record();
+}
+#endif //GLOM_ENABLE_MAEMO
+
+
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 void Frame_Glom::on_menu_Reports_EditReports()
 {
diff --git a/glom/frame_glom.h b/glom/frame_glom.h
index 59d8d0a..a5afb06 100644
--- a/glom/frame_glom.h
+++ b/glom/frame_glom.h
@@ -91,7 +91,11 @@ public:
 
   void on_menu_Mode_Data();
   void on_menu_Mode_Find();
-
+  
+  #ifdef GLOM_ENABLE_MAEMO
+  void on_menu_add_record();
+  #endif
+  
   void on_menu_report_selected(const Glib::ustring& report_name);
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 0074fef..38a2141 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -429,7 +429,6 @@ bool Box_Data_Details::fill_from_database()
   return bResult;
 }
 
-#ifndef GLOM_ENABLE_MAEMO
 void Box_Data_Details::on_button_new()
 {
   if(!confirm_discard_unstored_data())
@@ -467,6 +466,7 @@ void Box_Data_Details::on_button_new()
   }
 }
 
+#ifndef GLOM_ENABLE_MAEMO
 void Box_Data_Details::on_button_del()
 {
   if( Conversions::value_is_empty(get_primary_key_value_selected()) )
@@ -1068,4 +1068,11 @@ void Box_Data_Details::show_layout_toolbar(bool show)
 
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
+#ifdef GLOM_ENABLE_MAEMO
+void Box_Data_Details::do_new_record()
+{
+  on_button_new();
+}
+#endif
+
 } //namespace Glom
diff --git a/glom/mode_data/box_data_details.h b/glom/mode_data/box_data_details.h
index e5843f7..ca638e1 100644
--- a/glom/mode_data/box_data_details.h
+++ b/glom/mode_data/box_data_details.h
@@ -69,6 +69,10 @@ public:
   void show_layout_toolbar(bool show = true);
 #endif
 
+  #ifdef GLOM_ENABLE_MAEMO
+  void do_new_record();
+  #endif
+
 protected:
 
 
@@ -90,11 +94,12 @@ protected:
   void set_found_set_from_primary_key_value();
 
   void print_layout_group(xmlpp::Element* node_parent, const sharedptr<const LayoutGroup>& group);
-
+  
 private:
   //Signal handlers:
-#ifndef GLOM_ENABLE_MAEMO
   void on_button_new();
+    
+#ifndef GLOM_ENABLE_MAEMO
   void on_button_del();
 
   void on_button_nav_first();
diff --git a/glom/mode_data/box_data_list.h b/glom/mode_data/box_data_list.h
index ed44cf7..245fcfe 100644
--- a/glom/mode_data/box_data_list.h
+++ b/glom/mode_data/box_data_list.h
@@ -61,6 +61,7 @@ public:
 
 
   //Signal Handlers:
+  //TODO: Remove virtual?
   virtual void on_details_nav_first();
   virtual void on_details_nav_previous();
   virtual void on_details_nav_next();
diff --git a/glom/mode_data/box_data_manyrecords.h b/glom/mode_data/box_data_manyrecords.h
index e5c9b8b..eb71253 100644
--- a/glom/mode_data/box_data_manyrecords.h
+++ b/glom/mode_data/box_data_manyrecords.h
@@ -53,7 +53,6 @@ public:
 
   void get_record_counts(gulong& total, gulong& found) const;
 
-
 protected:
   //virtual Document::type_list_layout_groups create_layout_get_layout(); //overriden in Box_Data_ManyRecords_Related.
   void create_layout_add_group(const sharedptr<LayoutGroup>& layout_group);
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index 679c0bb..679b042 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -22,14 +22,19 @@
 #include <libglom/data_structure/glomconversions.h>
 #include <glibmm/i18n.h>
 
+#ifdef GLOM_ENABLE_MAEMO
+#include <hildonmm/program.h>
+#endif
+
 namespace Glom
 {
 
 Notebook_Data::Notebook_Data()
-: m_iPage_Details(0), m_iPage_List(0)
+: 
   #ifdef GLOM_ENABLE_MAEMO
-  , m_window_maemo_details(0)
+  m_window_maemo_details(0),
   #endif
+  m_iPage_Details(0), m_iPage_List(0)
 {
   //Add Pages:
   pages().push_back(Gtk::Notebook_Helpers::TabElem(m_Box_List, _("List")));
@@ -42,6 +47,9 @@ Notebook_Data::Notebook_Data()
   //On Maemo, we add the box to m_window_maemo_details instead:
   m_window_maemo_details = new Window_BoxHolder(&m_Box_Details, _("Details"));
   
+  //Let this window have the main AppMenu:
+  Hildon::Program::get_instance()->add_window(*m_window_maemo_details);
+  
   Gtk::Window* pWindow = get_app_window();
   if(pWindow)
     m_window_maemo_details->set_transient_for(*pWindow);
@@ -222,7 +230,7 @@ void Notebook_Data::show_details(const Gnome::Gda::Value& 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.
+  //though that window contains the regular m_Box_Details. 
   m_window_maemo_details->show();
 #else  
   if(get_current_view() != DATA_VIEW_Details)
@@ -372,4 +380,10 @@ void Notebook_Data::get_record_counts(gulong& total, gulong& found)
   m_Box_List.get_record_counts(total, found);
 }
 
+void Notebook_Data::do_menu_file_add_record()
+{
+  show_details(Gnome::Gda::Value());
+  m_Box_Details.do_new_record();
+}
+
 } //namespace Glom
diff --git a/glom/mode_data/notebook_data.h b/glom/mode_data/notebook_data.h
index ed99258..4e4f504 100644
--- a/glom/mode_data/notebook_data.h
+++ b/glom/mode_data/notebook_data.h
@@ -62,7 +62,11 @@ public:
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
   virtual void do_menu_file_print(); //override
-
+  
+  #ifdef GLOM_ENABLE_MAEMO
+  void do_menu_file_add_record();
+  #endif
+  
   void get_record_counts(gulong& total, gulong& found);
 
   enum dataview
diff --git a/glom/utility_widgets/db_adddel/db_adddel.h b/glom/utility_widgets/db_adddel/db_adddel.h
index b7ef658..03a5848 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.h
+++ b/glom/utility_widgets/db_adddel/db_adddel.h
@@ -259,6 +259,12 @@ public:
   virtual Gtk::TreeModel::iterator get_last_row() const;
 
   virtual void set_open_button_title(const Glib::ustring& title);
+  
+  
+  /** Add a new row to the list, for the user to enter record details,
+   * adding the generated primary key if necessary.
+   */
+  bool start_new_record();
 
 private:
   
@@ -430,7 +436,7 @@ private:
   bool m_bIgnoreTreeViewSignals;
 
   type_vec_strings m_vecColumnIDs; //We give each ViewColumn a special ID, so we know where they are after a reorder.
-
+  
 protected:
   bool m_allow_add;
   bool m_allow_delete;
@@ -504,15 +510,13 @@ private:
   Glib::RefPtr<Gtk::ListStore> m_model_hint;
 
   int m_fixed_cell_height;
-    
-    
+  
 private:
   
   /// Discover the right-most text column, so we can make it expand.
   bool get_column_to_expand(guint& column_to_expand) const;
   
   //TODO_refactor: Give these better names, and document them:
-  bool start_new_record();
   void user_changed(const Gtk::TreeModel::iterator& row, guint col);
   void user_requested_delete(const Gtk::TreeModel::iterator& rowStart, const Gtk::TreeModel::iterator&  /* rowEnd TODO */);
 
diff --git a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
index 7a02256..a17bf12 100644
--- a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
+++ b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
@@ -40,15 +40,18 @@ DbAddDel_WithButtons::DbAddDel_WithButtons()
   pack_start(m_HBox, Gtk::PACK_SHRINK);
 
   //Link buttons to handlers:
-  m_Button_Add.signal_clicked().connect(sigc::mem_fun(*this, &DbAddDel_WithButtons::on_button_add));
-  m_HBox.pack_end(m_Button_Add, Gtk::PACK_SHRINK);
     
   #ifndef GLOM_ENABLE_MAEMO
+  m_Button_Add.signal_clicked().connect(sigc::mem_fun(*this, &DbAddDel_WithButtons::on_button_add));
+  m_HBox.pack_end(m_Button_Add, Gtk::PACK_SHRINK);
+ 
   m_Button_Del.signal_clicked().connect(sigc::mem_fun(*this, &DbAddDel_WithButtons::on_button_del));
   m_Button_Edit.signal_clicked().connect(sigc::mem_fun(*this, &DbAddDel_WithButtons::on_button_edit));
 
   m_HBox.pack_end(m_Button_Edit, Gtk::PACK_SHRINK);
   m_HBox.pack_end(m_Button_Del, Gtk::PACK_SHRINK);
+  #else
+  m_HBox.hide();
   #endif //GLOM_ENABLE_MAEMO
 
   #ifdef GLOM_ENABLE_MAEMO
@@ -68,14 +71,12 @@ DbAddDel_WithButtons::~DbAddDel_WithButtons()
 {
 }
 
+#ifndef GLOM_ENABLE_MAEMO
 void DbAddDel_WithButtons::on_button_add()
 {
-#ifndef GLOM_ENABLE_MAEMO
   on_MenuPopup_activate_Add();
-#endif
 }
 
-#ifndef GLOM_ENABLE_MAEMO
 void DbAddDel_WithButtons::on_button_del()
 {
   on_MenuPopup_activate_Delete();
diff --git a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h
index e009508..f6e9650 100644
--- a/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h
+++ b/glom/utility_widgets/db_adddel/db_adddel_withbuttons.h
@@ -45,10 +45,9 @@ public:
 
 private:
   void setup_buttons();
-
-  void on_button_add();
   
   #ifndef GLOM_ENABLE_MAEMO
+  void on_button_add();
   void on_button_del();
   void on_button_edit();
   #endif //GLOM_ENABLE_MAEMO



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