[glom] Make Find mode a toggle and move it to the Edit menu.



commit 577d13ece12a6154bdb4d4c911db42df54ddefa7
Author: Daniel Borgmann <danielb openismus com>
Date:   Mon May 10 11:57:30 2010 +0100

    Make Find mode a toggle and move it to the Edit menu.
    
    * glom/application.cc: Move Find menu item, remove Mode menu.
    * glom/frame_glom.cc/h: Replace on_menu_Mode_Find()/Data() with
    on_menu_Mode_Toggle().

 ChangeLog           |    8 ++++++++
 glom/application.cc |   27 ++++++++++++++-------------
 glom/frame_glom.cc  |   17 ++++++++++-------
 glom/frame_glom.h   |    3 +--
 4 files changed, 33 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d3de4b1..9d367e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-05-10  Daniel Borgmann  <danielb openismus com>
+
+	Make Find mode a toggle and move it to the Edit menu.
+
+	* glom/application.cc: Move Find menu item, remove Mode menu.
+	* glom/frame_glom.cc/h: Replace on_menu_Mode_Find()/Data() with
+	on_menu_Mode_Toggle().
+
 2010-05-06  Daniel Borgmann  <danielb openismus com>
 
 	Save extras alignment improvements.
diff --git a/glom/application.cc b/glom/application.cc
index f78e477..0bf56d9 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -402,7 +402,7 @@ void Application::init_menus()
 
   add_button_to_appmenu(m_maemo_appmenu,
     _("Find"), _("Search for records in the table"),
-    sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_Mode_Find) );
+    sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_Mode_Toggle) );
 
   add_button_to_appmenu(m_maemo_appmenu,
     _("Add Record"), _("Create a new record in the table"),
@@ -470,17 +470,12 @@ void Application::init_menus()
   //"Mode" menu:
   action =  Gtk::Action::create("Glom_Menu_Mode", _("_Mode"));
   m_refActionGroup_Others->add(action);
-  Gtk::RadioAction::Group group_mode;
 
   //We remember this action, so that it can be explicitly activated later.
-  m_action_mode_data = Gtk::RadioAction::create(group_mode, "GlomAction_Menu_Mode_Data", _("_Data"));
-  m_refActionGroup_Others->add(m_action_mode_data,
-                        sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_Mode_Data) );
-
-  m_action_mode_find = Gtk::RadioAction::create(group_mode, "GlomAction_Menu_Mode_Find", _("_Find"));
+  m_action_mode_find = Gtk::ToggleAction::create("GlomAction_Menu_Mode_Toggle", _("_Find"), "", false);
   m_refActionGroup_Others->add(m_action_mode_find,  Gtk::AccelKey("<control>F"),
-                        sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_Mode_Find) );
-  m_listTableSensitiveActions.push_back(action);
+                        sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_Mode_Toggle) );
+  m_listTableSensitiveActions.push_back(m_action_mode_find);
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   action = Gtk::Action::create("Glom_Menu_Developer", C_("Developer menu title", "_Developer"));
@@ -568,6 +563,16 @@ void Application::init_menus()
   static const Glib::ustring ui_description =
     "<ui>"
     "  <menubar name='Bakery_MainMenu'>"
+    "    <placeholder name='Bakery_MenuPH_Edit'>"
+    "      <menu action='BakeryAction_Menu_Edit'>"
+    "        <menuitem action='BakeryAction_Edit_Cut' />"
+    "        <menuitem action='BakeryAction_Edit_Copy' />"
+    "        <menuitem action='BakeryAction_Edit_Paste' />"
+    "        <menuitem action='BakeryAction_Edit_Clear' />"
+    "        <separator />"
+    "        <menuitem action='GlomAction_Menu_Mode_Toggle' />"
+    "      </menu>"
+    "    </placeholder>"
     "    <placeholder name='Bakery_MenuPH_Others'>"
     "      <menu action='Glom_Menu_Tables'>"
     "        <placeholder name='Menu_Tables_Dynamic' />"
@@ -584,10 +589,6 @@ void Application::init_menus()
     "        <menuitem action='GlomAction_Menu_EditReports' />"
 #endif // !GLOM_ENABLE_CLIENT_ONLY
     "     </menu>"
-    "      <menu action='Glom_Menu_Mode'>"
-    "        <menuitem action='GlomAction_Menu_Mode_Data' />"
-    "        <menuitem action='GlomAction_Menu_Mode_Find' />"
-    "      </menu>"
 #ifndef GLOM_ENABLE_CLIENT_ONLY
     "      <menu action='Glom_Menu_userlevel'>"
     "        <menuitem action='GlomAction_Menu_userlevel_Developer' />"
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 47077d4..c9389fe 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -1154,14 +1154,18 @@ void Frame_Glom::show_layout_toolbar (bool show)
 
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-void Frame_Glom::on_menu_Mode_Data()
+void Frame_Glom::on_menu_Mode_Toggle()
 {
-  if(set_mode(MODE_Data))
-    show_table(m_table_name);
-}
+  //Switch back to data mode if we are in find mode.
+  if(m_Mode == MODE_Find)
+  {
+    //Switch to data mode
+    if(set_mode(MODE_Data))
+      show_table(m_table_name);
+    return;
+  }
 
-void Frame_Glom::on_menu_Mode_Find()
-{
+  //Otherwise switch to find mode.
   //This can take quite a long time, flicking between 1 or 2 intermediate screens.
   //It shouldn't, but until we fix that, let's show the busy cursor while it's working:
   BusyCursor busy_cursor(get_app_window());
@@ -1469,7 +1473,6 @@ void Frame_Glom::on_button_quickfind()
 void Frame_Glom::on_notebook_find_criteria(const Glib::ustring& where_clause)
 {
   //std::cout << "Frame_Glom::on_notebook_find_criteria(): " << where_clause << std::endl;
-  //on_menu_Mode_Data();
 
   Application* pApp = dynamic_cast<Application*>(get_app_window());
   if(pApp)
diff --git a/glom/frame_glom.h b/glom/frame_glom.h
index 94fec74..3dca064 100644
--- a/glom/frame_glom.h
+++ b/glom/frame_glom.h
@@ -89,8 +89,7 @@ public:
   void on_menu_file_toggle_share(const Glib::RefPtr<Gtk::ToggleAction>& action);
   void on_menu_file_print();
 
-  void on_menu_Mode_Data();
-  void on_menu_Mode_Find();
+  void on_menu_Mode_Toggle();
 
   //TODO: Actually put this in the menu for non-maemo too? #ifdef GLOM_ENABLE_MAEMO
   void on_menu_add_record();



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