openbsd-ports/x11/nitrogen/patches/patch-src_NWindow_cc
2012-04-10 18:23:55 +00:00

62 lines
1.8 KiB
Plaintext

$OpenBSD: patch-src_NWindow_cc,v 1.1 2012/04/10 18:23:55 jasper Exp $
Added keyboard shortcuts for quitting.
From upstream git commit: d66f9af886692c946b4144271d8cca23483ba489
--- src/NWindow.cc.orig Tue Apr 10 20:17:46 2012
+++ src/NWindow.cc Tue Apr 10 20:17:53 2012
@@ -79,6 +79,33 @@ NWindow::NWindow (void) : apply (Gtk::Stock::APPLY), i
// don't even worry about it!
}
+ // accel group for keyboard shortcuts
+ // unfortunately we have to basically make a menu which we never add to the UI
+ m_action_group = Gtk::ActionGroup::create();
+ m_action_group->add(Gtk::Action::create("FileMenu", ""));
+ m_action_group->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
+ Gtk::AccelKey("<control>Q"),
+ sigc::mem_fun(*this, &NWindow::sighandle_accel_quit));
+
+ m_action_group->add(Gtk::Action::create("Close", Gtk::Stock::CLOSE),
+ Gtk::AccelKey("<control>W"),
+ sigc::mem_fun(*this, &NWindow::sighandle_accel_quit));
+
+ m_ui_manager = Gtk::UIManager::create();
+ m_ui_manager->insert_action_group(m_action_group);
+
+ add_accel_group(m_ui_manager->get_accel_group());
+
+ Glib::ustring ui = "<ui>"
+ "<menubar name='MenuBar'>"
+ "<menu action='FileMenu'>"
+ "<menuitem action='Close' />"
+ "<menuitem action='Quit' />"
+ "</menu>"
+ "</menubar>"
+ "</ui>";
+ m_ui_manager->add_ui_from_string(ui);
+
m_dirty = false;
}
@@ -98,6 +125,13 @@ void NWindow::show (void) {
}
/**
+ * Handles the user pressing Ctrl+Q or Ctrl+W, standard quit buttons.
+ */
+void NWindow::sighandle_accel_quit() {
+ Gtk::Main::quit();
+}
+
+/**
* Handles the user double clicking on a row in the view.
*/
void NWindow::sighandle_dblclick_item (const Gtk::TreeModel::Path& path) {
@@ -443,4 +477,3 @@ void NWindow::sighandle_btn_prefs()
}
}
-