[gnote] Add accelerators for open actions
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add accelerators for open actions
- Date: Sat, 27 Oct 2012 15:58:25 +0000 (UTC)
commit b9579fc50fed6cc643946d78358b16da096bda4f
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Sat Oct 27 15:56:33 2012 +0300
Add accelerators for open actions
<Control>O for Open Note.
<Alt>W for Open In New Window.
src/searchnoteswidget.cpp | 11 +++++++++++
src/searchnoteswidget.hpp | 1 +
2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index bda2bda..278c3b8 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -63,6 +63,7 @@ void SearchNotesWidget::_init_static()
SearchNotesWidget::SearchNotesWidget(NoteManager & m)
: Gtk::VBox(false, 0)
+ , m_accel_group(Gtk::AccelGroup::create())
, m_find_combo(Glib::RefPtr<Gtk::TreeModel>::cast_static(Gtk::ListStore::create(m_find_combo_columns)), true)
, m_clear_search_button(Gtk::Stock::CLEAR)
, m_entry_changed_timeout(NULL)
@@ -1461,10 +1462,12 @@ Gtk::Menu *SearchNotesWidget::get_note_list_context_menu()
Gtk::MenuItem *item = manage(new Gtk::MenuItem);
item->set_related_action(m_open_note_action);
+ item->add_accelerator("activate", m_accel_group, GDK_KEY_O, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
m_note_list_context_menu->add(*item);
item = manage(new Gtk::MenuItem);
item->set_related_action(m_open_note_new_window_action);
+ item->add_accelerator("activate", m_accel_group, GDK_KEY_W, Gdk::MOD1_MASK, Gtk::ACCEL_VISIBLE);
m_note_list_context_menu->add(*item);
item = manage(new Gtk::MenuItem);
@@ -1551,12 +1554,20 @@ void SearchNotesWidget::foreground()
{
utils::EmbedableWidget::foreground();
restore_position();
+ Gtk::Window *win = dynamic_cast<Gtk::Window*>(host());
+ if(win) {
+ win->add_accel_group(m_accel_group);
+ }
}
void SearchNotesWidget::background()
{
utils::EmbedableWidget::background();
save_position();
+ Gtk::Window *win = dynamic_cast<Gtk::Window*>(host());
+ if(win) {
+ win->remove_accel_group(m_accel_group);
+ }
}
}
diff --git a/src/searchnoteswidget.hpp b/src/searchnoteswidget.hpp
index 13900ff..1151b7d 100644
--- a/src/searchnoteswidget.hpp
+++ b/src/searchnoteswidget.hpp
@@ -148,6 +148,7 @@ private:
Gtk::TreeModelColumn<Note::Ptr> note;
};
+ Glib::RefPtr<Gtk::AccelGroup> m_accel_group;
Glib::RefPtr<Gtk::Action> m_open_note_action;
Glib::RefPtr<Gtk::Action> m_open_note_new_window_action;
Glib::RefPtr<Gtk::Action> m_delete_note_action;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]