[gnote] Remove some leftover tray code
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Remove some leftover tray code
- Date: Sun, 18 Oct 2015 15:11:52 +0000 (UTC)
commit a1c1f10ecfba4272890b4f1c9d39e6caf7de057c
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Oct 18 17:06:14 2015 +0300
Remove some leftover tray code
src/actionmanager.cpp | 23 +-----
src/actionmanager.hpp | 8 +--
src/iactionmanager.hpp | 3 -
src/notebooks/notebookapplicationaddin.cpp | 119 +++-------------------------
src/notebooks/notebookapplicationaddin.hpp | 12 +---
5 files changed, 15 insertions(+), 150 deletions(-)
---
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index c7f460e..a50d1c3 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2014 Aurimas Cernius
+ * Copyright (C) 2011-2015 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -266,25 +266,4 @@ namespace gnote {
return res;
}
- void ActionManager::add_tray_menu_item(Gtk::MenuItem & item)
- {
- m_tray_menu_items.push_back(&item);
- }
-
- void ActionManager::remove_tray_menu_item(Gtk::MenuItem & item)
- {
- for(std::vector<Gtk::MenuItem*>::iterator iter = m_tray_menu_items.begin();
- iter != m_tray_menu_items.end(); ++iter) {
- if(*iter == &item) {
- m_tray_menu_items.erase(iter);
- break;
- }
- }
- }
-
- std::vector<Gtk::MenuItem*> ActionManager::get_tray_menu_items()
- {
- return m_tray_menu_items;
- }
-
}
diff --git a/src/actionmanager.hpp b/src/actionmanager.hpp
index fbec309..dffb33c 100644
--- a/src/actionmanager.hpp
+++ b/src/actionmanager.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012-2013 Aurimas Cernius
+ * Copyright (C) 2012-2013,2015 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -60,10 +60,6 @@ public:
virtual void add_main_window_search_action(const Glib::RefPtr<Gtk::Action> & action, int order) override;
virtual void remove_main_window_search_action(const std::string & name) override;
virtual std::vector<Glib::RefPtr<Gtk::Action> > get_main_window_search_actions() override;
-
- virtual void add_tray_menu_item(Gtk::MenuItem & item) override;
- virtual void remove_tray_menu_item(Gtk::MenuItem & item) override;
- virtual std::vector<Gtk::MenuItem*> get_tray_menu_items() override;
private:
void make_app_actions();
void make_app_menu_items();
@@ -100,8 +96,6 @@ private:
typedef std::multimap<int, AppMenuItem> AppMenuItemMultiMap;
AppMenuItemMultiMap m_app_menu_items;
std::map<int, Glib::RefPtr<Gtk::Action> > m_main_window_search_actions;
-
- std::vector<Gtk::MenuItem*> m_tray_menu_items;
};
diff --git a/src/iactionmanager.hpp b/src/iactionmanager.hpp
index e418934..6ac6725 100644
--- a/src/iactionmanager.hpp
+++ b/src/iactionmanager.hpp
@@ -60,9 +60,6 @@ public:
virtual void add_main_window_search_action(const Glib::RefPtr<Gtk::Action> & action, int order) = 0;
virtual void remove_main_window_search_action(const std::string & name) = 0;
virtual std::vector<Glib::RefPtr<Gtk::Action> > get_main_window_search_actions() = 0;
- virtual void add_tray_menu_item(Gtk::MenuItem & item) = 0;
- virtual void remove_tray_menu_item(Gtk::MenuItem & item) = 0;
- virtual std::vector<Gtk::MenuItem*> get_tray_menu_items() = 0;
sigc::signal<void> signal_main_window_search_actions_changed;
};
diff --git a/src/notebooks/notebookapplicationaddin.cpp b/src/notebooks/notebookapplicationaddin.cpp
index 7cb2fe3..356426a 100644
--- a/src/notebooks/notebookapplicationaddin.cpp
+++ b/src/notebooks/notebookapplicationaddin.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2014 Aurimas Cernius
+ * Copyright (C) 2011-2015 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -52,8 +52,6 @@ namespace gnote {
NotebookApplicationAddin::NotebookApplicationAddin()
: m_initialized(false)
- , m_tray_menu_item(NULL)
- , m_trayNotebookMenu(NULL)
{
}
@@ -61,20 +59,7 @@ namespace gnote {
void NotebookApplicationAddin::initialize ()
{
- m_tray_menu_item = new Gtk::ImageMenuItem(
- *manage(new Gtk::Image(IconManager::obj().get_icon(IconManager::NOTEBOOK, 16))),
- _("Notebooks"));
- m_tray_menu_item->set_tooltip_text(_("Create a new note in a notebook"));
- m_tray_menu_item->show();
IActionManager & am(IActionManager::obj());
- am.add_tray_menu_item(*m_tray_menu_item);
- m_trayNotebookMenu = manage(new Gtk::Menu());
- m_tray_menu_item->set_submenu(*m_trayNotebookMenu);
-
- m_trayNotebookMenu->signal_show()
- .connect(sigc::mem_fun(*this, &NotebookApplicationAddin::on_tray_notebook_menu_shown));
- m_trayNotebookMenu->signal_hide()
- .connect(sigc::mem_fun(*this, &NotebookApplicationAddin::on_tray_notebook_menu_hidden));
NoteManager & nm(note_manager());
@@ -84,7 +69,7 @@ namespace gnote {
note->signal_tag_removed.connect(
sigc::mem_fun(*this, &NotebookApplicationAddin::on_tag_removed));
}
-
+
nm.signal_note_added.connect(
sigc::mem_fun(*this, &NotebookApplicationAddin::on_note_added));
nm.signal_note_deleted.connect(
@@ -101,94 +86,14 @@ namespace gnote {
void NotebookApplicationAddin::shutdown ()
{
- IActionManager & am(IActionManager::obj());
- if(m_tray_menu_item) {
- am.remove_tray_menu_item(*m_tray_menu_item);
- Gtk::Container *container = m_tray_menu_item->get_parent();
- if(container) {
- container->remove(*m_tray_menu_item);
- }
- delete m_tray_menu_item;
- m_tray_menu_item = NULL;
- }
-
m_initialized = false;
}
-
+
bool NotebookApplicationAddin::initialized ()
{
return m_initialized;
}
- void NotebookApplicationAddin::on_tray_notebook_menu_shown()
- {
- add_menu_items(m_trayNotebookMenu, m_trayNotebookMenuItems);
- }
-
- void NotebookApplicationAddin::on_tray_notebook_menu_hidden()
- {
- remove_menu_items(m_trayNotebookMenu, m_trayNotebookMenuItems);
- }
-
-
- void NotebookApplicationAddin::add_menu_items(Gtk::Menu * menu,
- std::list<Gtk::MenuItem*> & menu_items)
- {
- remove_menu_items (menu, menu_items);
-
- NotebookNewNoteMenuItem *item;
-
- Glib::RefPtr<Gtk::TreeModel> model = NotebookManager::obj().get_notebooks();
- Gtk::TreeIter iter;
-
- // Add in the "New Notebook..." menu item
- Gtk::ImageMenuItem *newNotebookMenuItem =
- manage(new Gtk::ImageMenuItem (_("New Note_book..."), true));
- newNotebookMenuItem->set_image(*manage(new Gtk::Image(
- IconManager::obj().get_icon(IconManager::NOTEBOOK_NEW, 16))));
- newNotebookMenuItem->signal_activate()
- .connect(sigc::mem_fun(*this, &NotebookApplicationAddin::on_new_notebook_menu_item));
- newNotebookMenuItem->show_all ();
- menu->append (*newNotebookMenuItem);
- menu_items.push_back(newNotebookMenuItem);
-
-
- if (model->children().size() > 0) {
- Gtk::SeparatorMenuItem *separator = manage(new Gtk::SeparatorMenuItem ());
- separator->show_all ();
- menu->append (*separator);
- menu_items.push_back(separator);
-
- iter = model->children().begin();
- while (iter) {
- Notebook::Ptr notebook;
- iter->get_value(0, notebook);
- item = manage(new NotebookNewNoteMenuItem (notebook));
- item->show_all ();
- menu->append (*item);
- menu_items.push_back(item);
- ++iter;
- }
- }
- }
-
- void NotebookApplicationAddin::remove_menu_items(Gtk::Menu * menu,
- std::list<Gtk::MenuItem*> & menu_items)
- {
- for(std::list<Gtk::MenuItem*>::const_iterator iter = menu_items.begin();
- iter != menu_items.end(); ++iter) {
- menu->remove(**iter);
- }
- menu_items.clear();
- }
-
-
- void NotebookApplicationAddin::on_new_notebook_menu_item()
- {
- NotebookManager::prompt_create_new_notebook (NULL);
- }
-
-
void NotebookApplicationAddin::on_new_notebook_action(const Glib::VariantBase&)
{
NotebookManager::prompt_create_new_notebook (NULL);
@@ -200,25 +105,25 @@ namespace gnote {
if (NotebookManager::obj().is_adding_notebook()) {
return;
}
-
+
std::string megaPrefix(Tag::SYSTEM_TAG_PREFIX);
megaPrefix += Notebook::NOTEBOOK_TAG_PREFIX;
if (!tag->is_system() || !Glib::str_has_prefix(tag->name(), megaPrefix)) {
return;
}
-
+
std::string notebookName =
sharp::string_substring(tag->name(), megaPrefix.size());
-
+
Notebook::Ptr notebook =
NotebookManager::obj().get_or_create_notebook (notebookName);
-
+
NotebookManager::obj().signal_note_added_to_notebook() (static_cast<const Note&>(note), notebook);
}
-
- void NotebookApplicationAddin::on_tag_removed(const NoteBase::Ptr& note,
+
+ void NotebookApplicationAddin::on_tag_removed(const NoteBase::Ptr& note,
const std::string& normalizedTagName)
{
std::string megaPrefix(Tag::SYSTEM_TAG_PREFIX);
@@ -227,16 +132,16 @@ namespace gnote {
if (!Glib::str_has_prefix(normalizedTagName, megaPrefix)) {
return;
}
-
+
std::string normalizedNotebookName =
sharp::string_substring(normalizedTagName, megaPrefix.size());
-
+
Notebook::Ptr notebook =
NotebookManager::obj().get_notebook (normalizedNotebookName);
if (!notebook) {
return;
}
-
+
NotebookManager::obj().signal_note_removed_from_notebook() (*static_pointer_cast<Note>(note),
notebook);
}
diff --git a/src/notebooks/notebookapplicationaddin.hpp b/src/notebooks/notebookapplicationaddin.hpp
index 41a8920..8212592 100644
--- a/src/notebooks/notebookapplicationaddin.hpp
+++ b/src/notebooks/notebookapplicationaddin.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012-2014 Aurimas Cernius
+ * Copyright (C) 2012-2015 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -23,8 +23,6 @@
#ifndef __NOTEBOOK_APPLICATION_ADDIN_HPP__
#define __NOTEBOOK_APPLICATION_ADDIN_HPP__
-#include <list>
-
#include "base/macros.hpp"
#include "applicationaddin.hpp"
#include "note.hpp"
@@ -45,11 +43,6 @@ namespace gnote {
protected:
NotebookApplicationAddin();
private:
- void on_tray_notebook_menu_shown();
- void on_tray_notebook_menu_hidden();
- void add_menu_items(Gtk::Menu *, std::list<Gtk::MenuItem*> & menu_items);
- void remove_menu_items(Gtk::Menu *, std::list<Gtk::MenuItem*> & menu_items);
- void on_new_notebook_menu_item();
void on_tag_added(const NoteBase&, const Tag::Ptr&);
void on_tag_removed(const NoteBase::Ptr&, const std::string&);
void on_note_added(const NoteBase::Ptr &);
@@ -57,9 +50,6 @@ namespace gnote {
void on_new_notebook_action(const Glib::VariantBase&);
bool m_initialized;
- Gtk::MenuItem *m_tray_menu_item;
- Gtk::Menu *m_trayNotebookMenu;
- std::list<Gtk::MenuItem*> m_trayNotebookMenuItems;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]