[gnote] Refactor code and improve popover look



commit 437af5c59d0a7e53086e4d6444dc986960e04dce
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Dec 26 20:58:09 2015 +0200

    Refactor code and improve popover look

 src/notebooks/notebooknoteaddin.cpp |    9 +++------
 src/recentchanges.cpp               |    5 +----
 src/utils.cpp                       |   12 ++++++++++--
 src/utils.hpp                       |    1 +
 4 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/notebooks/notebooknoteaddin.cpp b/src/notebooks/notebooknoteaddin.cpp
index fb52e73..465a857 100644
--- a/src/notebooks/notebooknoteaddin.cpp
+++ b/src/notebooks/notebooknoteaddin.cpp
@@ -145,8 +145,7 @@ namespace notebooks {
     int top = 0;
     int sub_top = 0;
     Gtk::Grid *subgrid = manage(new Gtk::Grid);
-    subgrid->property_margin_top() = 10;
-    subgrid->property_margin_bottom() = 10;
+    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...")));
@@ -155,9 +154,8 @@ namespace notebooks {
 
     // 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;
-    subgrid->property_margin_top() = 10;
-    subgrid->property_margin_bottom() = 10;
     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(""));
@@ -177,8 +175,7 @@ namespace notebooks {
 
     subgrid = manage(new Gtk::Grid);
     sub_top = 0;
-    subgrid->property_margin_top() = 10;
-    subgrid->property_margin_bottom() = 10;
+    utils::set_common_popover_widget_props(*subgrid);
     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);
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 9086502..138ff99 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -724,8 +724,7 @@ namespace gnote {
   Gtk::Grid *NoteRecentChanges::create_inner_popover_grid(int & top)
   {
     Gtk::Grid *grid = manage(new Gtk::Grid);
-    grid->property_margin_top() = 10;
-    grid->property_margin_bottom() = 10;
+    utils::set_common_popover_widget_props(*grid);
     top = 0;
     return grid;
   }
@@ -735,8 +734,6 @@ namespace gnote {
     std::map<Glib::ustring, Gtk::Widget*> submenus;
     Gtk::PopoverMenu *menu = manage(new Gtk::PopoverMenu);
     Gtk::Grid *main_grid = manage(new Gtk::Grid);
-    main_grid->property_margin_start() = 10;
-    main_grid->property_margin_end() = 10;
     int main_top = 0;
     int top = 0;
     Gtk::Grid *grid = create_inner_popover_grid(top);
diff --git a/src/utils.cpp b/src/utils.cpp
index 3f9e453..449083a 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -123,8 +123,7 @@ namespace gnote {
         PopoverSubmenuGrid(const Glib::ustring & submenu)
           : PopoverSubmenu(submenu)
         {
-          property_margin_start() = 10;
-          property_margin_end() = 10;
+          set_common_popover_widget_props(*this);
         }
       };
     }
@@ -294,6 +293,7 @@ namespace gnote {
       gtk_actionable_set_action_name(GTK_ACTIONABLE(item->gobj()), action.c_str());
       item->set_label(label);
       item->set_use_underline(true);
+      set_common_popover_widget_props(*item);
       return item;
     }
 
@@ -304,6 +304,7 @@ namespace gnote {
       button->property_menu_name() = submenu;
       button->set_label(label);
       button->set_use_underline(true);
+      set_common_popover_widget_props(*button);
       return button;
     }
 
@@ -314,6 +315,13 @@ namespace gnote {
     }
 
 
+    void set_common_popover_widget_props(Gtk::Widget & widget)
+    {
+      widget.property_margin_top() = 5;
+      widget.property_margin_bottom() = 5;
+    }
+
+
     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 bbe422f..251d6e9 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -70,6 +70,7 @@ namespace gnote {
     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 set_common_popover_widget_props(Gtk::Widget & widget);
 
     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);


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