[glom] Improve the About box.



commit 0ac4c3c3bd9d221b846ff2a54388659f036a42d8
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jul 7 12:57:16 2011 +0200

    Improve the About box.
    
    * glom/application.[h|cc]:
    * glom/bakery/app.[h|cc]:
    * glom/bakery/app_withdoc_gtk.[h|cc]: Move the help menu out of the
    Bakery class, doing it all in our derived Application class, to give us
    more control over the GtkAboutDialog. We do not need the abstraction any
    more.
    This restores the application description, which was probably lost when
    converting to AboutDialog.

 ChangeLog                      |   13 ++++++
 glom/application.cc            |   92 +++++++++++++++++++++++++++------------
 glom/application.h             |    9 +++-
 glom/bakery/app.cc             |   34 +-------------
 glom/bakery/app.h              |   29 +------------
 glom/bakery/app_withdoc_gtk.cc |   93 +--------------------------------------
 glom/bakery/app_withdoc_gtk.h  |    8 ---
 7 files changed, 90 insertions(+), 188 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 07b30b6..db5a271 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-07-07  Murray Cumming  <murrayc murrayc com>
+
+	Improve the About box.
+
+	* glom/application.[h|cc]:
+	* glom/bakery/app.[h|cc]:
+	* glom/bakery/app_withdoc_gtk.[h|cc]: Move the help menu out of the 
+	Bakery class, doing it all in our derived Application class, to give us 
+	more control over the GtkAboutDialog. We do not need the abstraction any 
+	more.
+	This restores the application description, which was probably lost when 
+	converting to AboutDialog.
+	
 2011-07-06  Murray Cumming  <murrayc murrayc com>
 
 	Split up the developer .glade files into separate files.
diff --git a/glom/application.cc b/glom/application.cc
index 6a58b40..f2667f0 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -40,6 +40,8 @@
 #include <glom/python_embed/glom_python.h>
 #include <libglom/spawn_with_feedback.h>
 
+#include <gtkmm/aboutdialog.h>
+
 #include <cstdio>
 #include <memory> //For std::auto_ptr<>
 #include <giomm.h>
@@ -77,6 +79,8 @@ Application::Application(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builde
 : type_base(cobject, "Glom"),
   m_pBoxTop(0),
   m_pFrame(0),
+  m_bAboutShown(false),
+  m_pAbout(false),
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   m_window_translations(0),
 #endif // !GLOM_ENABLE_CLIENT_ONLY
@@ -141,6 +145,9 @@ Application::~Application()
   #ifdef GLOM_ENABLE_MAEMO
   m_pFrame->remove_view(&m_appmenu_button_table);
   #endif
+  
+  delete m_pAbout;
+  m_pAbout = 0;
 
   //This was set in the constructor:
   global_application = 0;
@@ -180,10 +187,6 @@ bool Application::init(const Glib::ustring& document_uri)
 
 bool Application::init(const Glib::ustring& document_uri, bool restore)
 {
-  type_vec_strings vecAuthors;
-  vecAuthors.push_back("Murray Cumming <murrayc murrayc com>");
-  set_about_information(PACKAGE_VERSION, vecAuthors, _("Â 2000-2010 Murray Cumming"), _("A Database GUI"));
-
   type_base::init(); //calls init_menus() and init_toolbars()
 
   //m_pFrame->set_shadow_type(Gtk::SHADOW_IN);
@@ -566,6 +569,16 @@ void Application::init_menus()
 
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
+  m_refHelpActionGroup = Gtk::ActionGroup::create("Glom_Menu_Help");
+  m_refHelpActionGroup->add(Gtk::Action::create("GlomAction_Menu_Help", _("_Help")));
+  
+  m_refHelpActionGroup->add( Gtk::Action::create("GlomAction_Menu_Help_About",
+                        _("_About"), _("About the application")),
+                        sigc::mem_fun(*this, &Application::on_menu_help_about) );
+  m_refHelpActionGroup->add( Gtk::Action::create("GlomAction_Menu_Help_Contents",
+                        _("_Contents"), _("Help with the application")),
+                        sigc::mem_fun(*this, &Application::on_menu_help_contents) );
+                        
   m_refUIManager->insert_action_group(m_refActionGroup_Others);
 
   //Build part of the menu structure, to be merged in by using the "Bakery_MenuPH_Others" placeholder:
@@ -626,6 +639,10 @@ void Application::init_menus()
     "        <menuitem action='GlomAction_Menu_Developer_ExportBackup' />"
     "        <menuitem action='GlomAction_Menu_Developer_RestoreBackup' />"
     "      </menu>"
+    "      <menu action='Glom_Menu_Help'>"
+    "        <menuitem action='GlomAction_Menu_Help_About' />"
+    "        <menuitem action='GlomAction_Menu_Help_Contents' />"
+    "      </menu>"
 #endif // !GLOM_ENABLE_CLIENT_ONLY
     "    </placeholder>"
     "  </menubar>"
@@ -636,8 +653,6 @@ void Application::init_menus()
   //Add menu:
   add_ui_from_string(ui_description);
 
-  init_menus_help();
-
   update_table_sensitive_ui();
 
   fill_menu_tables();
@@ -645,6 +660,48 @@ void Application::init_menus()
 #endif //GLOM_ENABLE_MAEMO
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
+
+void Application::on_menu_help_about()
+{
+  if(m_pAbout && m_bAboutShown) // "About" box hasn't been closed, so just raise it
+  {
+    m_pAbout->set_transient_for(*this);
+
+    Glib::RefPtr<Gdk::Window> about_win = m_pAbout->get_window();
+    about_win->show();
+    about_win->raise();
+  }
+  else
+  {
+    //Re-create About box:
+    delete m_pAbout;
+    m_pAbout = 0;
+
+    m_pAbout = new Gtk::AboutDialog;
+
+    m_pAbout->set_name(m_strAppName);
+    m_pAbout->set_version(m_strVersion);
+    m_pAbout->set_comments(_("A Database GUI"));
+    m_pAbout->set_copyright(_("Â 2000-2011 Murray Cumming, Openismus GmbH"));
+    std::vector<Glib::ustring> vecAuthors;
+    vecAuthors.push_back("Murray Cumming <murrayc murrayc com>");
+    m_pAbout->set_authors(vecAuthors);
+    //Glib::RefPtr<Gdk::Pixbuf> logo = Gdk::Pixbuf::create_from_file();
+    //m_pAbout->set_logo(logo);
+
+    m_pAbout->signal_hide().connect( sigc::mem_fun(*this, &Application::on_about_close) );
+    m_bAboutShown = true;
+    static_cast<Gtk::Dialog*>(m_pAbout)->run(); //show() would be better. see below:
+    m_pAbout->hide();
+    //m_pAbout->show(); //TODO: respond to the OK button.
+  }
+}
+
+void Application::on_about_close()
+{
+  m_bAboutShown = false;
+}
+
 void Application::on_menu_file_toggle_share()
 {
   if(!m_pFrame)
@@ -1623,29 +1680,6 @@ void Application::set_mode_find()
 }
 
 #ifndef GLOM_ENABLE_MAEMO
-void Application::init_menus_help()
-{
-  //Call base class:
-  App_WithDoc_Gtk::init_menus_help();
-  m_refHelpActionGroup->add( Gtk::Action::create("BakeryAction_Help_Contents",
-                        _("_Contents"), _("Help with the application")),
-                        sigc::mem_fun(*this, &Application::on_menu_help_contents) );
-
-  //Build part of the menu structure, to be merged in by using the "PH" plaeholders:
-  static const Glib::ustring ui_description =
-    "<ui>"
-    "  <menubar name='Bakery_MainMenu'>"
-    "    <placeholder name='Bakery_MenuPH_Help'>"
-    "      <menu action='BakeryAction_Menu_Help'>"
-    "        <menuitem action='BakeryAction_Help_Contents' />"
-    "      </menu>"
-    "    </placeholder>"
-    "  </menubar>"
-    "</ui>";
-
-  //Add menu:
-  add_ui_from_string(ui_description);
-}
 
 void Application::on_menu_help_contents()
 {
diff --git a/glom/application.h b/glom/application.h
index 58ba0b1..a03ed35 100644
--- a/glom/application.h
+++ b/glom/application.h
@@ -155,7 +155,6 @@ private:
 
 #ifndef GLOM_ENABLE_MAEMO
   virtual void init_menus_file(); //override.
-  virtual void init_menus_help(); //override
 #endif //GLOM_ENABLE_MAEMO
 
   bool offer_new_or_existing();
@@ -202,6 +201,9 @@ private:
   void on_connection_avahi_done();
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
+  void on_menu_help_about();
+  void on_about_close();
+
 #ifndef G_OS_WIN32
   /** Offer a file chooser dialog, with a Browse Network button.
    * @param browsed This will be set to true if the user chose a networked glom instance to open.
@@ -253,12 +255,16 @@ private:
   Gtk::VBox* m_pBoxTop;
   Gtk::VBox* m_pBoxSidebar;
   Frame_Glom* m_pFrame;
+  
+  bool m_bAboutShown;
+  Gtk::AboutDialog* m_pAbout; //About box.
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   Window_Translations* m_window_translations;
 
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
+  Glib::RefPtr<Gtk::ActionGroup> m_refHelpActionGroup;
   Glib::RefPtr<Gtk::ActionGroup> m_refNavTablesActionGroup, m_refNavReportsActionGroup, m_refNavPrintLayoutsActionGroup;
   type_listActions m_listNavTableActions, m_listNavReportActions, m_listNavPrintLayoutActions;
   Gtk::UIManager::ui_merge_id m_menu_tables_ui_merge_id, m_menu_reports_ui_merge_id, m_menu_print_layouts_ui_merge_id;
@@ -278,7 +284,6 @@ private:
   Dialog_ProgressCreating* m_dialog_progress_creating;
   Dialog_ProgressCreating* m_dialog_progess_save_backup;
   Dialog_ProgressCreating* m_dialog_progess_convert_backup;
-
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
   // This is set to the URI of an example file that is loaded to be able to
diff --git a/glom/bakery/app.cc b/glom/bakery/app.cc
index e7df4cc..6fb847e 100644
--- a/glom/bakery/app.cc
+++ b/glom/bakery/app.cc
@@ -24,9 +24,8 @@ namespace GlomBakery
 {
 
 //Initialize static member data:
-HelpInfo App::m_HelpInfo;
+Glib::ustring App::m_strVersion;
 
-bool App::m_bAboutShown = false;
 bool App::m_bOperationCancelled = false;
 Glib::ustring App::m_strCommandLine_0;
 Glib::ustring App::m_strAppName;
@@ -38,6 +37,7 @@ App::App(const Glib::ustring& appname)
 
 App::~App()
 {
+
 }
 
 void App::init_app_name(const Glib::ustring& appname) //static
@@ -65,7 +65,6 @@ void App::init_menus()
 {
   init_menus_file();
   init_menus_edit();
-  init_menus_help();
 
   //create_menus(m_menu_UI_Infos);
   //install_menu_hints();
@@ -78,8 +77,6 @@ void App::init_toolbars()
   
 }
 
-
-
 void App::on_menu_file_new()
 {
   new_instance();
@@ -112,36 +109,11 @@ void App::on_menu_edit_clear()
   
 }
 
-void App::on_about_close()
-{
-  m_bAboutShown = false;
-}
-
-void App::set_about_information(const Glib::ustring& strVersion, const type_vec_strings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription)
-{
-  m_HelpInfo.m_strVersion = strVersion;
-  m_HelpInfo.m_vecAuthors = vecAuthors;
-  m_HelpInfo.m_strCopyright = strCopyright;
-  m_HelpInfo.m_strDescription = strDescription;
-}
-
-void App::set_about_information(const Glib::ustring& strVersion, const type_vec_strings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription, const type_vec_strings& vecDocumenters, const Glib::ustring& strTranslatorCredits)
-{
-  m_HelpInfo.m_strVersion = strVersion;
-  m_HelpInfo.m_vecAuthors = vecAuthors;
-  m_HelpInfo.m_strCopyright = strCopyright;
-  m_HelpInfo.m_strDescription = strDescription;
-  m_HelpInfo.m_vecDocumenters = vecDocumenters;
-  m_HelpInfo.m_strTranslatorCredits = strTranslatorCredits;
-}
-
 Glib::ustring App::get_version() const
 {
-  return m_HelpInfo.m_strVersion;
+  return m_strVersion;
 }
 
-
-
 void App::set_operation_cancelled(bool bVal /* = true */)
 {
   m_bOperationCancelled = bVal;
diff --git a/glom/bakery/app.h b/glom/bakery/app.h
index d486dd9..f9767f2 100644
--- a/glom/bakery/app.h
+++ b/glom/bakery/app.h
@@ -26,17 +26,6 @@
 namespace GlomBakery
 {
 
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-class HelpInfo
-{
-public:
-  typedef std::vector<Glib::ustring> type_vec_strings;	
-  Glib::ustring m_strVersion, m_strCopyright, m_strDescription, m_strTranslatorCredits;
-
-  type_vec_strings m_vecAuthors, m_vecDocumenters;
-};
-#endif //DOXYGEN_SHOULD_SKIP_THIS
-
 /** Bakery's Main Window.
  * This is an abstract class. You must use a class such as App_Gtk, which implements
  * the ui_* methods for a particular GUI toolkit.
@@ -44,7 +33,6 @@ public:
  * Features:
  * - Override methods to add/change menus/toolbars/statusbar.
  *   - Default is basic File, Edit, Help menus and toolbar icons.
- * - Configurable about box via set_about_information().
  *
  
  *
@@ -69,10 +57,6 @@ public:
 
   virtual void init(); //Sets it up and shows it.
 
-  //'About Box' information:
-  typedef std::vector<Glib::ustring> type_vec_strings;	
-  static void set_about_information(const Glib::ustring& strVersion, const type_vec_strings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription);
-  static void set_about_information(const Glib::ustring& strVersion, const type_vec_strings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription, const type_vec_strings& vecDocumenters, const Glib::ustring& strTranslatorCredits);
   virtual Glib::ustring get_version() const;
 
   static void set_command_line_args(int argc, char** &argv); //Needed for session management.
@@ -100,10 +84,6 @@ protected:
    */ 
   virtual void init_menus_edit() = 0;
 
-  /** Call this from init_menus() to add the standard help menu
-   */
-  virtual void init_menus_help() = 0;
-
   virtual void init_toolbars();
   
   virtual void new_instance(const Glib::ustring& uri = Glib::ustring()) = 0; //Must override in order to new() the derived document class.
@@ -126,8 +106,6 @@ public: // We can not take function pointers of these methods in a
 
   virtual void on_menu_help_about() = 0;
 
-  virtual void on_about_close();
-
 protected:
   //GUI abstractions:
   virtual void ui_hide() = 0;
@@ -143,17 +121,12 @@ protected:
   
   //'About Box'/WM Class information:
   static Glib::ustring m_strAppName;
-
-  //'About Box' information:
-  static HelpInfo m_HelpInfo;
+  static Glib::ustring m_strVersion;
 
   //Instances
 
   static bool m_bOperationCancelled; //see set/get_operation_cancelled().
 
-  //All instances share 1 About box:
-  static bool m_bAboutShown;
-
   //Command line args:
   static Glib::ustring m_strCommandLine_0;
 
diff --git a/glom/bakery/app_withdoc_gtk.cc b/glom/bakery/app_withdoc_gtk.cc
index dee1e0f..793a31d 100644
--- a/glom/bakery/app_withdoc_gtk.cc
+++ b/glom/bakery/app_withdoc_gtk.cc
@@ -25,7 +25,6 @@
 #include <gtkmm/recentchoosermenu.h>
 #include <gtkmm/messagedialog.h>
 #include <gtkmm/filechooserdialog.h>
-#include <gtkmm/aboutdialog.h>
 #include <giomm.h>
 #include <algorithm>
 #include <iostream>
@@ -47,8 +46,7 @@ namespace GlomBakery
 
 App_WithDoc_Gtk::App_WithDoc_Gtk(const Glib::ustring& appname)
 : App_WithDoc(appname),
-  m_pVBox(0),
-  m_pAbout(0)
+  m_pVBox(0)
 {
   init_app_name(appname);
 }
@@ -57,8 +55,7 @@ App_WithDoc_Gtk::App_WithDoc_Gtk(const Glib::ustring& appname)
 App_WithDoc_Gtk::App_WithDoc_Gtk(BaseObjectType* cobject, const Glib::ustring& appname)
 : App_WithDoc(appname),
   ParentWindow(cobject), 
-  m_pVBox(0),
-  m_pAbout(0)
+  m_pVBox(0)
 {
   init_app_name(appname);
 
@@ -73,9 +70,6 @@ App_WithDoc_Gtk::~App_WithDoc_Gtk()
 {
   delete m_pVBox;
   m_pVBox = 0;
-  
-  delete m_pAbout;
-  m_pAbout = 0;
 }
 
 
@@ -204,9 +198,8 @@ void App_WithDoc_Gtk::init_menus()
   //Override this to add more menus
   init_menus_file();
   init_menus_edit();
-  init_menus_help();
-
 }
+
 void App_WithDoc_Gtk::init_menus_file_recentfiles(const Glib::ustring& path)
 {
   if(!m_mime_types.empty()) //"Recent-files" is useless unless it knows what documents (which MIME-types) to show.
@@ -352,86 +345,6 @@ void App_WithDoc_Gtk::init_menus_edit()
   add_ui_from_string(ui_description);
 }
 
-void App_WithDoc_Gtk::init_menus_help()
-{
-  using namespace Gtk;
-  //Help menu
-
-  //Build actions:
-  m_refHelpActionGroup = ActionGroup::create("BakeryHelpActions");
-  m_refHelpActionGroup->add(Action::create("BakeryAction_Menu_Help", _("_Help")));
-
-  //TODO: Use stock?
-  m_refHelpActionGroup->add(Action::create("BakeryAction_Help_About",
-                        _("_About"), _("About the application")),
-                        sigc::mem_fun((GlomBakery::App&)*this, &App::on_menu_help_about));
-
-  m_refUIManager->insert_action_group(m_refHelpActionGroup);
-
-  //Build part of the menu structure, to be merged in by using the "PH" plaeholders:
-  static const Glib::ustring ui_description =
-    "<ui>"
-#ifdef GLOM_ENABLE_MAEMO
-    "  <popup name='Bakery_MainMenu'>"
-#else
-    "  <menubar name='Bakery_MainMenu'>"
-#endif
-    "    <placeholder name='Bakery_MenuPH_Help'>"
-    "      <menu action='BakeryAction_Menu_Help'>"
-    "        <menuitem action='BakeryAction_Help_About' />"
-    "      </menu>"
-    "    </placeholder>"
-#ifdef GLOM_ENABLE_MAEMO
-    "  </popup>"
-#else
-    "  </menubar>"
-#endif
-    "</ui>";
-
-  //Add menu:
-  add_ui_from_string(ui_description);
-}
-
-
-void App_WithDoc_Gtk::on_menu_help_about()
-{
-  if(m_pAbout && m_bAboutShown) // "About" box hasn't been closed, so just raise it
-  {
-    m_pAbout->set_transient_for(*this);
-
-    Glib::RefPtr<Gdk::Window> about_win = m_pAbout->get_window();
-    about_win->show();
-    about_win->raise();
-  }
-  else
-  {
-    //Re-create About box:
-    delete m_pAbout;
-    m_pAbout = 0;
-
-    Gtk::AboutDialog* pDerived = new Gtk::AboutDialog;
-    m_pAbout = pDerived;
-
-    pDerived->set_name(m_strAppName);
-    pDerived->set_version(m_HelpInfo.m_strVersion);
-    pDerived->set_copyright(m_HelpInfo.m_strCopyright);
-    pDerived->set_authors(m_HelpInfo.m_vecAuthors);
-    pDerived->set_documenters(m_HelpInfo.m_vecDocumenters);
-    pDerived->set_translator_credits(m_HelpInfo.m_strTranslatorCredits);
-
-    m_pAbout->signal_hide().connect(sigc::mem_fun((App&)*this, &App::on_about_close));
-    m_bAboutShown = true;
-    static_cast<Gtk::Dialog*>(m_pAbout)->run(); //show() would be better. see below:
-    m_pAbout->hide();
-    //m_pAbout->show(); //TODO: respond to the OK button.
-  }
-}
-
-void App_WithDoc_Gtk::on_about_close()
-{
-  m_bAboutShown = false;
-}
-
 void App_WithDoc_Gtk::add(Gtk::Widget& child)
 {
   m_VBox_PlaceHolder.pack_start(child);
diff --git a/glom/bakery/app_withdoc_gtk.h b/glom/bakery/app_withdoc_gtk.h
index 46da096..573ce29 100644
--- a/glom/bakery/app_withdoc_gtk.h
+++ b/glom/bakery/app_withdoc_gtk.h
@@ -89,7 +89,6 @@ protected:
   virtual void init_menus(); //Override this to add more or different menus.
   virtual void init_menus_file(); //Call this from init_menus() to add the standard file menu.
   virtual void init_menus_edit(); //Call this from init_menus() to add the standard edit menu
-  virtual void init_menus_help(); //Call this from init_menus() to add the standard help menu.
   virtual void init_toolbars();
 
   void add_ui_from_string(const Glib::ustring& ui_description); //Convenience function
@@ -111,10 +110,6 @@ protected:
 
   //Menus:
 
-  //Overrides from App:
-  virtual void on_menu_help_about();
-  virtual void on_about_close();
-
 
   virtual void ui_hide();
   virtual void ui_bring_to_front();
@@ -127,14 +122,11 @@ protected:
   Glib::RefPtr<Gtk::UIManager> m_refUIManager;
   Glib::RefPtr<Gtk::ActionGroup> m_refFileActionGroup;
   Glib::RefPtr<Gtk::ActionGroup> m_refEditActionGroup;
-  Glib::RefPtr<Gtk::ActionGroup> m_refHelpActionGroup;
 
   //Member widgets:
   Gtk::VBox* m_pVBox;
   Gtk::VBox m_VBox_PlaceHolder;
 
-  Gtk::Window* m_pAbout; //About box.
-
   //Menu stuff:
   Glib::RefPtr<Gtk::Action> m_action_save, m_action_saveas;
 };



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