[gnote] Add popover submenu to utils



commit 9e88ea46f62df0ba59e9eb79acbb90550cfee7bb
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Thu Dec 24 16:08:31 2015 +0200

    Add popover submenu to utils

 src/utils.cpp |   30 ++++++++++++++++++++++++++++++
 src/utils.hpp |   17 +++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/utils.cpp b/src/utils.cpp
index d7ebeef..3f9e453 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -113,6 +113,20 @@ namespace gnote {
         cond->signal();
         mutex->unlock();
       }
+
+
+      class PopoverSubmenuGrid
+        : public Gtk::Grid
+        , public PopoverSubmenu
+      {
+      public:
+        PopoverSubmenuGrid(const Glib::ustring & submenu)
+          : PopoverSubmenu(submenu)
+        {
+          property_margin_start() = 10;
+          property_margin_end() = 10;
+        }
+      };
     }
 
 
@@ -284,6 +298,22 @@ namespace gnote {
     }
 
 
+    Gtk::Widget * create_popover_submenu_button(const Glib::ustring & submenu, const Glib::ustring & label)
+    {
+      Gtk::ModelButton *button = new Gtk::ModelButton;
+      button->property_menu_name() = submenu;
+      button->set_label(label);
+      button->set_use_underline(true);
+      return button;
+    }
+
+
+    Gtk::Grid * create_popover_submenu(const Glib::ustring & name)
+    {
+      return new PopoverSubmenuGrid(name);
+    }
+
+
     void add_item_to_ordered_map(std::map<int, Gtk::Widget*> & dest, int order, Gtk::Widget *item)
     {
       for(; dest.find(order) != dest.end(); ++order);
diff --git a/src/utils.hpp b/src/utils.hpp
index 62f55e9..bbe422f 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -68,10 +68,27 @@ namespace gnote {
     void main_context_call(const sigc::slot<void> & slot);
 
     Gtk::Widget * create_popover_button(const Glib::ustring & action, const Glib::ustring & label);
+    Gtk::Widget * create_popover_submenu_button(const Glib::ustring & submenu, const Glib::ustring & label);
+    Gtk::Grid * create_popover_submenu(const Glib::ustring & name);
 
     void add_item_to_ordered_map(std::map<int, Gtk::Widget*> & dest, int order, Gtk::Widget *item);
     void merge_ordered_maps(std::map<int, Gtk::Widget*> & dest, const std::map<int, Gtk::Widget*> & adds);
 
+    class PopoverSubmenu
+    {
+    public:
+      PopoverSubmenu(const Glib::ustring & name)
+        : m_name(name)
+      {}
+
+      const Glib::ustring & name() const
+        {
+          return m_name;
+        }
+    private:
+      const Glib::ustring m_name;
+    };
+
     class GlobalKeybinder
     {
     public:


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