[niepce: 9/22] Refactor Preferences to be in the app section of the actions.



commit 74ed3c4c499d3ede43f579a3f056657931e7efa1
Author: Hubert Figuière <hub figuiere net>
Date:   Fri Jul 18 02:09:45 2014 -0400

    Refactor Preferences to be in the app section of the actions.

 camerawire/src/cwapplication.cpp            |    6 +++++-
 camerawire/src/cwapplication.hpp            |    4 +++-
 camerawire/src/cwwindow.cpp                 |   14 --------------
 camerawire/src/cwwindow.hpp                 |    1 -
 magellan/src/mgapplication.cpp              |    3 +++
 magellan/src/mgapplication.hpp              |    3 ++-
 magellan/src/mgwindow.cpp                   |   15 ---------------
 magellan/src/mgwindow.hpp                   |    3 +--
 src/fwk/toolkit/application.cpp             |    8 ++++++++
 src/fwk/toolkit/application.hpp             |    1 +
 src/niepce/ui/dialogs/preferencesdialog.hpp |    3 ++-
 src/niepce/ui/niepceapplication.cpp         |   10 ++++++++++
 src/niepce/ui/niepceapplication.hpp         |    1 +
 src/niepce/ui/niepcewindow.cpp              |   23 -----------------------
 src/niepce/ui/niepcewindow.hpp              |    4 ----
 15 files changed, 36 insertions(+), 63 deletions(-)
---
diff --git a/camerawire/src/cwapplication.cpp b/camerawire/src/cwapplication.cpp
index a21fae9..8c4796b 100644
--- a/camerawire/src/cwapplication.cpp
+++ b/camerawire/src/cwapplication.cpp
@@ -1,7 +1,7 @@
 /*
  * niepce - cwapplication.cpp
  *
- * Copyright (C) 2009, 2013 Hubert Figuiere
+ * Copyright (C) 2009-2014 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -47,4 +47,8 @@ namespace cw {
     return m_main_frame;
   }
 
+void CwApplication::on_action_preferences()
+{
+}
+
 }
diff --git a/camerawire/src/cwapplication.hpp b/camerawire/src/cwapplication.hpp
index ae6280d..3aa9aea 100644
--- a/camerawire/src/cwapplication.hpp
+++ b/camerawire/src/cwapplication.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - cwwindow.hpp
  *
- * Copyright (C) 2009, 2013 Hubert Figuiere
+ * Copyright (C) 2009-2014 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -37,6 +37,8 @@ public:
 protected:
   CwApplication(int & argc, char** & argv);
 
+  virtual void on_action_preferences();
+
 };
 
 }
diff --git a/camerawire/src/cwwindow.cpp b/camerawire/src/cwwindow.cpp
index 07cb624..bd3c43a 100644
--- a/camerawire/src/cwwindow.cpp
+++ b/camerawire/src/cwwindow.cpp
@@ -120,14 +120,6 @@ void CwWindow::init_actions()
                     Gio::ActionMap::ActivateSlot(), section,
                     _("Paste"), "win" "<control>v");
 
-    section = Gio::Menu::create();
-    submenu->append_section(section);
-    fwk::add_action(m_actionGroup,
-                    "Preferences",
-                    sigc::mem_fun(*this,
-                                  &CwWindow::on_preferences),
-                    section, _("Preferences"), "win", nullptr);
-
     submenu = Gio::Menu::create();
     m_menu->append_submenu(_("Tools"), submenu);
 
@@ -149,12 +141,6 @@ void CwWindow::on_action_import()
 {
 }
 
-
-void CwWindow::on_preferences()
-{
-}
-
-
 void CwWindow::reload_camera_list()
 {
   using fwk::GpDeviceList;
diff --git a/camerawire/src/cwwindow.hpp b/camerawire/src/cwwindow.hpp
index d9189fa..e642680 100644
--- a/camerawire/src/cwwindow.hpp
+++ b/camerawire/src/cwwindow.hpp
@@ -63,7 +63,6 @@ private:
   void init_ui();
   void init_actions();
   void on_action_import();
-  void on_preferences();
 
   void reload_camera_list();
 
diff --git a/magellan/src/mgapplication.cpp b/magellan/src/mgapplication.cpp
index ad6661a..5506b0e 100644
--- a/magellan/src/mgapplication.cpp
+++ b/magellan/src/mgapplication.cpp
@@ -47,4 +47,7 @@ namespace mg {
     return m_main_frame;
   }
 
+  void MgApplication::on_action_preferences()
+  {
+  }
 }
diff --git a/magellan/src/mgapplication.hpp b/magellan/src/mgapplication.hpp
index 9d8b64a..bbb7e40 100644
--- a/magellan/src/mgapplication.hpp
+++ b/magellan/src/mgapplication.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - mgapplication.hpp
  *
- * Copyright (C) 2013 Hubert Figuiere
+ * Copyright (C) 2013-2014 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@ public:
 protected:
   MgApplication(int & argc, char** & argv);
 
+  virtual void on_action_preferences();
 };
 
 }
diff --git a/magellan/src/mgwindow.cpp b/magellan/src/mgwindow.cpp
index e0a7306..13ed106 100644
--- a/magellan/src/mgwindow.cpp
+++ b/magellan/src/mgwindow.cpp
@@ -116,14 +116,6 @@ void MgWindow::init_actions()
                     Gio::ActionMap::ActivateSlot(), section,
                     _("Paste"), "win" "<control>v");
 
-    section = Gio::Menu::create();
-    submenu->append_section(section);
-    fwk::add_action(m_actionGroup,
-                    "Preferences",
-                    sigc::mem_fun(*this,
-                                  &MgWindow::on_preferences),
-                    section, _("Preferences"), "win", nullptr);
-
     submenu = Gio::Menu::create();
     m_menu->append_submenu(_("Tools"), submenu);
 
@@ -146,13 +138,6 @@ void MgWindow::on_action_import()
   DBG_OUT("import");
 }
 
-
-void MgWindow::on_preferences()
-{
-  DBG_OUT("prefs");
-}
-
-
 void MgWindow::detect_devices()
 {
   DBG_OUT("detect");
diff --git a/magellan/src/mgwindow.hpp b/magellan/src/mgwindow.hpp
index 3c27eac..a962262 100644
--- a/magellan/src/mgwindow.hpp
+++ b/magellan/src/mgwindow.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - mgwindow.hpp
  *
- * Copyright (C) 2013 Hubert Figuiere
+ * Copyright (C) 2013-2014 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -46,7 +46,6 @@ private:
 
   void init_actions();
   void on_action_import();
-  void on_preferences();
 
   void detect_devices();
 
diff --git a/src/fwk/toolkit/application.cpp b/src/fwk/toolkit/application.cpp
index de55c65..b735ec3 100644
--- a/src/fwk/toolkit/application.cpp
+++ b/src/fwk/toolkit/application.cpp
@@ -124,6 +124,14 @@ void Application::init_actions()
                     section, _("Open"), "app", "<Primary>o");
 
 
+    // separator
+    section = Gio::Menu::create();
+    menu->append_section(section);
+    fwk::add_action(m_gtkapp, "Preferences",
+                    sigc::mem_fun(*this,
+                                  &Application::on_action_preferences),
+                    section, _("Preferences..."), "app", nullptr);
+
     section = Gio::Menu::create();
     menu->append_section(section);
     fwk::add_action(m_gtkapp, "Help",
diff --git a/src/fwk/toolkit/application.hpp b/src/fwk/toolkit/application.hpp
index 5dd7f0f..9a9661b 100644
--- a/src/fwk/toolkit/application.hpp
+++ b/src/fwk/toolkit/application.hpp
@@ -87,6 +87,7 @@ protected:
     void _add(const Controller::Ptr & sub, bool attach = true);
     virtual void on_action_file_open();
     virtual void on_about();
+    virtual void on_action_preferences() = 0;
 
     void init_actions();
 
diff --git a/src/niepce/ui/dialogs/preferencesdialog.hpp b/src/niepce/ui/dialogs/preferencesdialog.hpp
index 3a169bc..cecda25 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.hpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - ui/dialogs/preferencesdialog.hpp
  *
- * Copyright (C) 2009 Hubert Figuiere
+ * Copyright (C) 2009-2014 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
 #ifndef _UI_PREFERENCESDIALOG_H_
 #define _UI_PREFERENCESDIALOG_H_
 
+#include "fwk/toolkit/gtkutils.hpp"
 #include "fwk/toolkit/dialog.hpp"
 
 namespace ui {
diff --git a/src/niepce/ui/niepceapplication.cpp b/src/niepce/ui/niepceapplication.cpp
index cf86408..aaf27c9 100644
--- a/src/niepce/ui/niepceapplication.cpp
+++ b/src/niepce/ui/niepceapplication.cpp
@@ -25,6 +25,7 @@
 
 #include "fwk/utils/modulemanager.hpp"
 #include "fwk/toolkit/appframe.hpp"
+#include "dialogs/preferencesdialog.hpp"
 #include "niepceapplication.hpp"
 #include "niepcewindow.hpp"
 
@@ -80,6 +81,15 @@ void NiepceApplication::on_about()
     dlg.run();
 }
 
+void NiepceApplication::on_action_preferences()
+{
+    DBG_OUT("on_preferences");
+
+    auto dlg(new PreferencesDialog());
+    dlg->run_modal(m_main_frame);
+
+    DBG_OUT("end on_preferences");
+}
 
 }
 
diff --git a/src/niepce/ui/niepceapplication.hpp b/src/niepce/ui/niepceapplication.hpp
index 7a47e39..4eb04c6 100644
--- a/src/niepce/ui/niepceapplication.hpp
+++ b/src/niepce/ui/niepceapplication.hpp
@@ -37,6 +37,7 @@ protected:
 
     virtual void on_action_file_open();
     virtual void on_about();
+    virtual void on_action_preferences();
 };
 
 }
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index 47e26c1..1fbcb8a 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -44,7 +44,6 @@
 #include "thumbstripview.hpp"
 #include "niepcewindow.hpp"
 #include "dialogs/importdialog.hpp"
-#include "dialogs/preferencesdialog.hpp"
 #include "dialogs/editlabels.hpp"
 #include "selectioncontroller.hpp"
 
@@ -233,13 +232,6 @@ void NiepceWindow::init_actions()
                     "Delete",
                     sigc::mem_fun(*this, &NiepceWindow::on_action_edit_delete),
                     section, _("Delete"), "win", nullptr);
-    // separator
-    section = Gio::Menu::create();
-    submenu->append_section(section);
-    fwk::add_action(m_action_group, "Preferences",
-                    sigc::mem_fun(*this,
-                                  &NiepceWindow::on_preferences),
-                    section, _("Preferences..."), "win", nullptr);
 
     submenu = Gio::Menu::create();
     m_menu->append_submenu(_("Tools"), submenu);
@@ -314,21 +306,6 @@ void NiepceWindow::on_open_library()
     }
 }
 
-
-
-
-void NiepceWindow::on_preferences()
-{
-    DBG_OUT("on_preferences");
-
-    fwk::Dialog::Ptr dlg(new PreferencesDialog());
-    dlg->run_modal(shared_frame_ptr());
-
-    DBG_OUT("end on_preferences");
-}
-
-
-
 void NiepceWindow::create_initial_labels()
 {
     // TODO make this parametric from resources
diff --git a/src/niepce/ui/niepcewindow.hpp b/src/niepce/ui/niepcewindow.hpp
index 6074513..9964c88 100644
--- a/src/niepce/ui/niepcewindow.hpp
+++ b/src/niepce/ui/niepcewindow.hpp
@@ -65,10 +65,6 @@ private:
     void on_action_edit_labels();
     void on_action_edit_delete();
 
-    void preference_dialog_setup(const Glib::RefPtr<Gtk::Builder> &,
-                                 Gtk::Dialog *);
-    void on_preferences();
-
     void create_initial_labels();
     void on_lib_notification(const eng::LibNotification & n);
 


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