[gnote] Updated note addin for popover text menu
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Updated note addin for popover text menu
- Date: Sun, 13 Mar 2016 11:35:19 +0000 (UTC)
commit c3ff6290df6e805a57b0cbb0d9b5082926b6e3f1
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Mar 12 23:09:51 2016 +0200
Updated note addin for popover text menu
src/noteaddin.cpp | 29 ++++++++++++++++++-----------
src/noteaddin.hpp | 5 +++--
2 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/src/noteaddin.cpp b/src/noteaddin.cpp
index d79af9c..cc37886 100644
--- a/src/noteaddin.cpp
+++ b/src/noteaddin.cpp
@@ -46,9 +46,8 @@ namespace gnote {
void NoteAddin::dispose(bool disposing)
{
if (disposing) {
- for(std::list<Gtk::MenuItem*>::const_iterator iter = m_text_menu_items.begin();
- iter != m_text_menu_items.end(); ++iter) {
- delete *iter;
+ for (auto & iter : m_text_menu_items) {
+ delete iter;
}
for(ToolItemMap::const_iterator iter = m_toolbar_items.begin();
@@ -71,13 +70,10 @@ namespace gnote {
window->signal_foregrounded.connect(sigc::mem_fun(*this, &NoteAddin::on_note_foregrounded));
window->signal_backgrounded.connect(sigc::mem_fun(*this, &NoteAddin::on_note_backgrounded));
- for(std::list<Gtk::MenuItem*>::const_iterator iter = m_text_menu_items.begin();
- iter != m_text_menu_items.end(); ++iter) {
- Gtk::Widget *item = *iter;
+ for(auto & item : m_text_menu_items) {
if ((item->get_parent() == NULL) ||
(item->get_parent() != window->text_menu())) {
- window->text_menu()->add (*item);
- window->text_menu()->reorder_child(*(Gtk::MenuItem*)item, 7);
+ append_text_item(window->text_menu(), *item);
}
}
@@ -92,6 +88,18 @@ namespace gnote {
}
}
+ void NoteAddin::append_text_item(Gtk::Widget *text_menu, Gtk::Widget & item)
+ {
+ 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);
+ }
+ }
+ }
+
void NoteAddin::on_note_foregrounded()
{
auto host = get_window()->host();
@@ -132,7 +140,7 @@ namespace gnote {
}
}
- void NoteAddin::add_text_menu_item (Gtk::MenuItem * item)
+ void NoteAddin::add_text_menu_item(Gtk::Widget *item)
{
if (is_disposing())
throw sharp::Exception(_("Plugin is disposing already"));
@@ -140,8 +148,7 @@ namespace gnote {
m_text_menu_items.push_back(item);
if (m_note->is_opened()) {
- get_window()->text_menu()->add (*item);
- get_window()->text_menu()->reorder_child (*item, 7);
+ append_text_item(get_window()->text_menu(), *item);
}
}
diff --git a/src/noteaddin.hpp b/src/noteaddin.hpp
index 7cfb4ad..2553522 100644
--- a/src/noteaddin.hpp
+++ b/src/noteaddin.hpp
@@ -110,14 +110,15 @@ public:
}
void on_note_opened_event(Note & );
void add_tool_item (Gtk::ToolItem *item, int position);
- void add_text_menu_item (Gtk::MenuItem * item);
+ void add_text_menu_item(Gtk::Widget *item);
private:
void on_note_foregrounded();
void on_note_backgrounded();
+ void append_text_item(Gtk::Widget *text_menu, Gtk::Widget & item);
Note::Ptr m_note;
sigc::connection m_note_opened_cid;
- std::list<Gtk::MenuItem*> m_text_menu_items;
+ std::list<Gtk::Widget*> m_text_menu_items;
typedef std::map<Gtk::ToolItem*, int> ToolItemMap;
ToolItemMap m_toolbar_items;
typedef std::pair<Glib::ustring, sigc::slot<void, const Glib::VariantBase&>> ActionCallback;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]