[gnote] Add helpers for ordering widgets in map
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add helpers for ordering widgets in map
- Date: Sat, 12 Dec 2015 18:30:41 +0000 (UTC)
commit 176f86ed0f3aee4f86723acd0c88d364cfa83e79
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Dec 12 20:08:48 2015 +0200
Add helpers for ordering widgets in map
src/utils.cpp | 15 +++++++++++++++
src/utils.hpp | 3 +++
2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/utils.cpp b/src/utils.cpp
index 1217f31..9a39255 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -283,6 +283,21 @@ namespace gnote {
}
+ void add_item_to_ordered_map(std::map<int, Gtk::Widget*> & dest, int order, Gtk::Widget *item)
+ {
+ for(; dest.find(order) != dest.end(); ++order);
+ dest[order] = item;
+ }
+
+
+ void merge_ordered_maps(std::map<int, Gtk::Widget*> & dest, const std::map<int, Gtk::Widget*> & adds)
+ {
+ for(std::map<int, Gtk::Widget*>::const_iterator iter = adds.begin(); iter != adds.end(); ++iter) {
+ add_item_to_ordered_map(dest, iter->first, iter->second);
+ }
+ }
+
+
void GlobalKeybinder::add_accelerator(const sigc::slot<void> & handler, guint key,
Gdk::ModifierType modifiers, Gtk::AccelFlags flags)
{
diff --git a/src/utils.hpp b/src/utils.hpp
index c16036f..62f55e9 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -69,6 +69,9 @@ namespace gnote {
Gtk::Widget * create_popover_button(const Glib::ustring & action, const Glib::ustring & label);
+ 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 GlobalKeybinder
{
public:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]