[gnote] Move insert timestamp menu item to gears menu
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Move insert timestamp menu item to gears menu
- Date: Fri, 31 May 2013 19:54:22 +0000 (UTC)
commit 7f4fcee95c8b3c47d6ab320e1097881b386f1576
Author: Aurimas Černius <aurisc4 gmail com>
Date: Fri May 31 22:51:38 2013 +0300
Move insert timestamp menu item to gears menu
Part of Bug 700655.
Also fix accelerator (Bug 700605).
.../inserttimestamp/inserttimestampnoteaddin.cpp | 39 ++++++++++++++++----
.../inserttimestamp/inserttimestampnoteaddin.hpp | 1 -
2 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
b/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
index c4ba8a1..b4cf23d 100644
--- a/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
+++ b/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
@@ -30,6 +30,34 @@
namespace inserttimestamp {
+ namespace {
+ class InsertTimestampAction
+ : public Gtk::Action
+ {
+ public:
+ static Glib::RefPtr<Gtk::Action> create(gnote::NoteWindow *note_window)
+ {
+ return Glib::RefPtr<Gtk::Action>(new InsertTimestampAction(note_window));
+ }
+ private:
+ InsertTimestampAction(gnote::NoteWindow *note_window)
+ : Gtk::Action("InsertTimestampAction", "", _("Insert Timestamp"),
+ _("Insert Timestamp into note"))
+ , m_note_window(note_window)
+ {}
+
+ virtual Gtk::Widget *create_menu_item_vfunc()
+ {
+ Gtk::MenuItem *item = new Gtk::MenuItem;
+ item->add_accelerator("activate", m_note_window->get_accel_group(),
+ GDK_KEY_d, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
+ return item;
+ }
+
+ gnote::NoteWindow *m_note_window;
+ };
+ }
+
InsertTimeStampModule::InsertTimeStampModule()
{
ADD_INTERFACE_IMPL(InsertTimestampNoteAddin);
@@ -50,15 +78,10 @@ namespace inserttimestamp {
void InsertTimestampNoteAddin::on_note_opened()
{
- // Add the menu item when the window is created
- m_item = manage(new Gtk::MenuItem(_("Insert Timestamp")));
- m_item->signal_activate().connect(
+ Glib::RefPtr<Gtk::Action> action = InsertTimestampAction::create(get_window());
+ action->signal_activate().connect(
sigc::mem_fun(*this, &InsertTimestampNoteAddin::on_menu_item_activated));
- m_item->add_accelerator ("activate", get_window()->get_accel_group(),
- GDK_KEY_d, Gdk::CONTROL_MASK,
- Gtk::ACCEL_VISIBLE);
- m_item->show ();
- add_plugin_menu_item (m_item);
+ add_note_action(action, 300);
Glib::RefPtr<Gio::Settings> settings =
gnote::Preferences::obj().get_schema_settings(SCHEMA_INSERT_TIMESTAMP);
m_date_format = settings->get_string(INSERT_TIMESTAMP_FORMAT);
diff --git a/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
b/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
index 7bfd77d..9dd26a9 100644
--- a/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
+++ b/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
@@ -59,7 +59,6 @@ private:
void on_format_setting_changed(const Glib::ustring & key);
std::string m_date_format;
- Gtk::MenuItem *m_item;
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]