summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow.cc33
-rw-r--r--src/mainwindow.h1
2 files changed, 34 insertions, 0 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 6a7e04c..ac41831 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -159,6 +159,39 @@ void MainWindow::on_realize() {
#endif /* HAVE_GTK3 */
}
+bool MainWindow::on_key_press_event(GdkEventKey* event) {
+
+ if (GDK_KEY_Escape == event->keyval) {
+ Gtk::Main::quit();
+ return true;
+ }
+ if (event->state & GDK_CONTROL_MASK) {
+ switch (event->keyval) {
+ case GDK_KEY_KP_1:
+ case GDK_KEY_KP_2:
+ case GDK_KEY_KP_3:
+ case GDK_KEY_KP_4:
+ case GDK_KEY_KP_5:
+ notebook->set_current_page(event->keyval - GDK_KEY_KP_1);
+ return true;
+ case GDK_KEY_1:
+ case GDK_KEY_2:
+ case GDK_KEY_3:
+ case GDK_KEY_4:
+ case GDK_KEY_5:
+ notebook->set_current_page(event->keyval - GDK_KEY_1);
+ return true;
+ case GDK_KEY_W:
+ case GDK_KEY_Q:
+ case GDK_KEY_w:
+ case GDK_KEY_q:
+ Gtk::Main::quit();
+ return true;
+ }
+ }
+ return Gtk::Window::on_key_press_event(event);
+}
+
MainWindow::~MainWindow() {
GKeyFile* config = g_key_file_new();
g_assert(config);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index bad9e47..559b639 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -100,6 +100,7 @@ public:
protected:
virtual void on_realize();
+ virtual bool on_key_press_event(GdkEventKey* event);
private:
gboolean m_connected;