[niepce] Add a headerbar



commit e4dc0d9ecfbd61ce1b34d3e1e87800585d214fc3
Author: Hubert Figuière <hub figuiere net>
Date:   Sat Aug 30 22:55:46 2014 -0400

    Add a headerbar

 src/fwk/toolkit/frame.cpp      |    8 +++++++-
 src/fwk/toolkit/frame.hpp      |   33 +++++++++++++++++++++++----------
 src/niepce/ui/niepcewindow.cpp |    8 +++++---
 3 files changed, 35 insertions(+), 14 deletions(-)
---
diff --git a/src/fwk/toolkit/frame.cpp b/src/fwk/toolkit/frame.cpp
index 1d77807..3546ace 100644
--- a/src/fwk/toolkit/frame.cpp
+++ b/src/fwk/toolkit/frame.cpp
@@ -35,6 +35,7 @@ namespace fwk {
 
 Frame::Frame(Gtk::Window* win, const std::string & layout_cfg_key)
     : m_window(win),
+      m_header(nullptr),
       m_builder(nullptr),
       m_layout_cfg_key(layout_cfg_key)
 {
@@ -102,7 +103,12 @@ void Frame::set_icon_from_theme(const Glib::ustring & name)
 
 void Frame::set_title(const std::string & title)
 {
-               gtkWindow().set_title(Glib::ustring(title));
+    if (m_header) {
+        m_header->set_title(Glib::ustring(title));
+    }
+    else {
+        gtkWindow().set_title(Glib::ustring(title));
+    }
 }
 
 
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index 983050e..e65959b 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -30,6 +30,7 @@
 #include <giomm/actiongroup.h>
 #include <giomm/menu.h>
 #include <gtkmm/builder.h>
+#include <gtkmm/headerbar.h>
 
 #include "fwk/toolkit/uicontroller.hpp"
 
@@ -66,16 +67,27 @@ public:
     Glib::RefPtr<Gtk::Builder> & builder()
         { return m_builder; }
 
-               /** set the title of the window.
-                * @param title the title of the window.
-                * 
-                * override to provide you own hooks - behaviour.
-                */
-               virtual void set_title(const std::string & title);
-               /** set the window icon from the theme 
-                * @param name the icon name in the theme
-                */
-               void set_icon_from_theme(const Glib::ustring & name);
+    /** @param header MUST be managed */
+    void setHeaderBar(Gtk::HeaderBar* header)
+        {
+            m_header = header;
+            if (m_header) {
+                m_window->set_titlebar(*m_header);
+            }
+        }
+    Gtk::HeaderBar* getHeaderBar() const
+        { return m_header; }
+
+    /** set the title of the window.
+     * @param title the title of the window.
+     *
+     * override to provide you own hooks - behaviour.
+     */
+    virtual void set_title(const std::string & title);
+    /** set the window icon from the theme
+     * @param name the icon name in the theme
+     */
+    void set_icon_from_theme(const Glib::ustring & name);
 
     void toggle_tools_visible();
 
@@ -105,6 +117,7 @@ private:
     void frameRectToConfig();
 
     Gtk::Window *m_window;
+    Gtk::HeaderBar *m_header;
     Glib::RefPtr<Gtk::Builder> m_builder;
     std::string m_layout_cfg_key;
 };
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index c4746a6..e19208a 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -59,14 +59,16 @@ NiepceWindow::NiepceWindow()
     : fwk::AppFrame("mainWindow-frame")
     , m_vbox(Gtk::ORIENTATION_VERTICAL)
 {
-//    gtkWindow().property_hide_titlebar_when_maximized() = true;
+    // headerbar.
+    Gtk::HeaderBar *header = Gtk::manage(new Gtk::HeaderBar);
+    header->set_show_close_button(true);
+    header->set_has_subtitle(true);
+    setHeaderBar(header);
 }
 
 
 NiepceWindow::~NiepceWindow()
 {
-//    Application::Ptr pApp = Application::app();
-//    pApp->uiManager()->remove_action_group(m_refActionGroup);
 }
 
 void


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