[gnote] Base popover menus on Gtk::Box



commit 6947854a3cfaf7ff44aa84809e2150e81c32f983
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Dec 11 19:28:17 2016 +0200

    Base popover menus on Gtk::Box

 src/noteaddin.cpp                   |    5 +--
 src/notebooks/notebooknoteaddin.cpp |   30 +++++-----------
 src/notebooks/notebooknoteaddin.hpp |    4 +-
 src/notewindow.cpp                  |   66 +++++++++++++++++------------------
 4 files changed, 45 insertions(+), 60 deletions(-)
---
diff --git a/src/noteaddin.cpp b/src/noteaddin.cpp
index cc37886..b222318 100644
--- a/src/noteaddin.cpp
+++ b/src/noteaddin.cpp
@@ -93,9 +93,8 @@ namespace gnote {
     NoteTextMenu *txt_menu = dynamic_cast<NoteTextMenu*>(text_menu);
     for(auto child : dynamic_cast<Gtk::Container*>(txt_menu->get_children().front())->get_children()) {
       if(child->get_name() == "formatting") {
-        Gtk::Grid *grid = dynamic_cast<Gtk::Grid*>(child);
-        int pos = grid->get_children().size();
-        grid->attach(item, 0, pos, 1, 1);
+        Gtk::Box *box = dynamic_cast<Gtk::Box*>(child);
+        box->add(item);
       }
     }
   }
diff --git a/src/notebooks/notebooknoteaddin.cpp b/src/notebooks/notebooknoteaddin.cpp
index 465a857..aa40a80 100644
--- a/src/notebooks/notebooknoteaddin.cpp
+++ b/src/notebooks/notebooknoteaddin.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2015 Aurimas Cernius
+ * Copyright (C) 2010-2016 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -22,6 +22,7 @@
 
 #include <glibmm/i18n.h>
 #include <gtkmm/modelbutton.h>
+#include <gtkmm/separator.h>
 
 #include "notebooks/notebooknoteaddin.hpp"
 #include "notebooks/notebookmanager.hpp"
@@ -140,46 +141,33 @@ namespace notebooks {
   }
 
 
-  void NotebookNoteAddin::update_menu(Gtk::Grid *menu) const
+  void NotebookNoteAddin::update_menu(Gtk::Box *menu) const
   {
-    int top = 0;
-    int sub_top = 0;
-    Gtk::Grid *subgrid = manage(new Gtk::Grid);
-    utils::set_common_popover_widget_props(*subgrid);
-
     // Add new notebook item
     Gtk::Widget *new_notebook_item = manage(utils::create_popover_button("win.new-notebook", _("_New 
notebook...")));
-    subgrid->attach(*new_notebook_item, 0, sub_top++, 1, 1);
-    menu->attach(*subgrid, 0, top++, 1, 1);
+    menu->add(*new_notebook_item);
+    menu->add(*manage(new Gtk::Separator));
 
     // Add the "(no notebook)" item at the top of the list
-    subgrid = manage(new Gtk::Grid);
-    utils::set_common_popover_widget_props(*subgrid);
-    sub_top = 0;
     Gtk::ModelButton *no_notebook_item = dynamic_cast<Gtk::ModelButton*>(manage(
       utils::create_popover_button("win.move-to-notebook", _("No notebook"))));
     gtk_actionable_set_action_target_value(GTK_ACTIONABLE(no_notebook_item->gobj()), 
g_variant_new_string(""));
-    subgrid->attach(*no_notebook_item, 0, sub_top++, 1, 1);
+    menu->add(*no_notebook_item);
 
     // Add in all the real notebooks
     std::list<Gtk::ModelButton*> notebook_menu_items;
     get_notebook_menu_items(notebook_menu_items);
     if(!notebook_menu_items.empty()) {
       FOREACH(Gtk::ModelButton *item, notebook_menu_items) {
-        subgrid->attach(*item, 0, sub_top++, 1, 1);
+        menu->add(*item);
       }
 
     }
 
-    menu->attach(*subgrid, 0, top++, 1, 1);
-
-    subgrid = manage(new Gtk::Grid);
-    sub_top = 0;
-    utils::set_common_popover_widget_props(*subgrid);
+    menu->add(*manage(new Gtk::Separator));
     Gtk::Widget *back_button = utils::create_popover_submenu_button("main", _("_Back"));
     dynamic_cast<Gtk::ModelButton*>(back_button)->property_inverted() = true;
-    subgrid->attach(*back_button, 0, sub_top++, 1, 1);
-    menu->attach(*subgrid, 0, top++, 1, 1);
+    menu->add(*back_button);
   }
   
 
diff --git a/src/notebooks/notebooknoteaddin.hpp b/src/notebooks/notebooknoteaddin.hpp
index 28e319f..2473300 100644
--- a/src/notebooks/notebooknoteaddin.hpp
+++ b/src/notebooks/notebooknoteaddin.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2015 Aurimas Cernius
+ * Copyright (C) 2011-2016 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -53,7 +53,7 @@ namespace notebooks {
     void on_move_to_notebook(const Glib::VariantBase &);
     void on_notebooks_changed();
     void get_notebook_menu_items(std::list<Gtk::ModelButton*> &) const;
-    void update_menu(Gtk::Grid *) const;
+    void update_menu(Gtk::Box *) const;
 
     sigc::connection          m_new_notebook_cid;
     sigc::connection          m_move_to_notebook_cid;
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 998d76a..60d539a 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -30,6 +30,7 @@
 #include <gtkmm/image.h>
 #include <gtkmm/imagemenuitem.h>
 #include <gtkmm/stock.h>
+#include <gtkmm/separator.h>
 #include <gtkmm/separatortoolitem.h>
 #include <gtkmm/separatormenuitem.h>
 
@@ -820,18 +821,14 @@ namespace gnote {
       m_widget.signal_backgrounded.connect(sigc::mem_fun(*this, &NoteTextMenu::on_widget_backgrounded));
 
       set_position(Gtk::POS_BOTTOM);
-      Gtk::Grid *main_grid = manage(new Gtk::Grid);
-      int main_top = 0;
-
-      Gtk::Grid *grid = manage(utils::create_popover_inner_grid());
-      int top = 0;
+      Gtk::Box *menu_box = manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
 
       Gtk::Widget *undo = manage(utils::create_popover_button("win.undo", _("_Undo")));
-      grid->attach(*undo, 0, top++, 1, 1);
+      menu_box->add(*undo);
 
       Gtk::Widget *redo = manage(utils::create_popover_button("win.redo", _("_Redo")));
-      grid->attach(*redo, 0, top++, 1, 1);
-      main_grid->attach(*grid, 0, main_top++, 1, 1);
+      menu_box->add(*redo);
+      menu_box->add(*manage(new Gtk::Separator));
 
       // Listen to events so we can sensitize and
       // enable keybinding
@@ -854,36 +851,37 @@ namespace gnote {
       Gtk::Widget *large = create_font_size_item(_("_Large"), "large", "size:large");
       Gtk::Widget *huge = create_font_size_item(_("Hu_ge"), "x-large", "size:huge");
 
-      grid = manage(utils::create_popover_inner_grid(&top));
-      grid->attach(*link, 0, top++, 1, 1);
-      main_grid->attach(*grid, 0, main_top++, 1, 1);
-
-      grid = manage(utils::create_popover_inner_grid(&top));
-      grid->set_name("formatting");
-      grid->attach(*bold, 0, top++, 1, 1);
-      grid->attach(*italic, 0, top++, 1, 1);
-      grid->attach(*strikeout, 0, top++, 1, 1);
-      grid->attach(*highlight, 0, top++, 1, 1);
-      main_grid->attach(*grid, 0, main_top++, 1, 1);
-
-      grid = manage(utils::create_popover_inner_grid(&top));
-      grid->set_name("font-size");
-      grid->attach(*small, 0, top++, 1, 1);
-      grid->attach(*normal, 0, top++, 1, 1);
-      grid->attach(*large, 0, top++, 1, 1);
-      grid->attach(*huge, 0, top++, 1, 1);
-      main_grid->attach(*grid, 0, main_top++, 1, 1);
-
-      grid = manage(utils::create_popover_inner_grid(&top));
+      menu_box->add(*link);
+      menu_box->add(*manage(new Gtk::Separator));
+
+      auto box = manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
+      utils::set_common_popover_widget_props(*box);
+      box->set_name("formatting");
+      box->add(*bold);
+      box->add(*italic);
+      box->add(*strikeout);
+      box->add(*highlight);
+      menu_box->add(*box);
+      menu_box->add(*manage(new Gtk::Separator));
+
+      box = manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
+      utils::set_common_popover_widget_props(*box);
+      box->set_name("font-size");
+      box->add(*small);
+      box->add(*normal);
+      box->add(*large);
+      box->add(*huge);
+      menu_box->add(*box);
+      menu_box->add(*manage(new Gtk::Separator));
+
       Gtk::Widget *bullets = manage(utils::create_popover_button("win.enable-bullets", _("⦁ Bullets")));
-      grid->attach(*bullets, 0, top++, 1, 1);
+      menu_box->add(*bullets);
       Gtk::Widget *increase_indent = manage(utils::create_popover_button("win.increase-indent", _("→ 
Increase indent")));
-      grid->attach(*increase_indent, 0, top++, 1, 1);
+      menu_box->add(*increase_indent);
       Gtk::Widget *decrease_indent = manage(utils::create_popover_button("win.decrease-indent", _("← 
Decrease indent")));
-      grid->attach(*decrease_indent, 0, top++, 1, 1);
-      main_grid->attach(*grid, 0, main_top++, 1, 1);
+      menu_box->add(*decrease_indent);
 
-      add(*main_grid);
+      add(*menu_box);
 
       refresh_state();
     }


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