[med-svn] [SCM] aghermann branch, master, updated. 551e213a23b59b71cba6a9c3a282d1b60e21b854

Andrei Zavada johnhommer at gmail.com
Sun Apr 21 23:18:17 UTC 2013


The following commit has been merged in the master branch:
commit 9c2fcf03e6156918ca612b6c686aed84e5421c22
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sun Apr 21 21:17:39 2013 +0300

    bind F1-3 to cycle combos on main window

diff --git a/src/ui/mw/construct.cc b/src/ui/mw/construct.cc
index 7f731bd..24c75a4 100644
--- a/src/ui/mw/construct.cc
+++ b/src/ui/mw/construct.cc
@@ -84,6 +84,7 @@ SExpDesignUIWidgets ()
 	wMainWindow_delete_event_cb_handler_id =
 		G_CONNECT_2 (wMainWindow, delete, event);
 	G_CONNECT_2 (wMainWindow, configure, event);
+	G_CONNECT_3 (wMainWindow, key, press, event);
 
 	G_CONNECT_3 (cMeasurements, drag, data, received);
 	G_CONNECT_2 (cMeasurements, drag, drop);
diff --git a/src/ui/mw/mw_cb.cc b/src/ui/mw/mw_cb.cc
index e3fb4d3..8fb941a 100644
--- a/src/ui/mw/mw_cb.cc
+++ b/src/ui/mw/mw_cb.cc
@@ -9,6 +9,8 @@
  *         License:  GPL
  */
 
+#include <gdk/gdkkeysyms.h>
+
 #include "ui/misc.hh"
 #include "ui/sf/sf.hh"
 #include "mw.hh"
@@ -50,6 +52,45 @@ wMainWindow_delete_event_cb( GtkWidget*, GdkEvent*, gpointer userdata)
 }
 
 
+namespace {
+
+inline void
+cycle_combo( GtkComboBox* c, int n, int by)
+{
+	gtk_combo_box_set_active(
+		c, (gtk_combo_box_get_active( c) + by) % n);
+}
+}
+
+gboolean
+wMainWindow_key_press_event_cb( GtkWidget*, GdkEventKey* event, gpointer userdata)
+{
+	auto& ED = *(SExpDesignUI*)userdata;
+
+	int by = (event->state & GDK_SHIFT_MASK) ? -1 : 1;
+
+	switch ( event->keyval ) {
+	case GDK_KEY_F1:
+		cycle_combo(
+			ED.eMsmtProfileType, 3, // three profiles
+			by);
+		return TRUE;
+	case GDK_KEY_F2:
+		cycle_combo(
+			ED.eMsmtSession, ED.AghDD.size(),
+			by);
+		return TRUE;
+	case GDK_KEY_F3:
+		cycle_combo(
+			ED.eMsmtChannel, ED.AghTT.size(),
+			by);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+
 // tab switch
 void
 tTaskSelector_switch_page_cb( GtkNotebook*, gpointer, guint page_num, gpointer userdata)
diff --git a/src/ui/mw/mw_cb.hh b/src/ui/mw/mw_cb.hh
index 5b0f735..8f21c06 100644
--- a/src/ui/mw/mw_cb.hh
+++ b/src/ui/mw/mw_cb.hh
@@ -22,6 +22,7 @@ extern "C" {
 
 gboolean wMainWindow_delete_event_cb( GtkWidget*, GdkEvent*, gpointer);
 gboolean wMainWindow_configure_event_cb( GtkWidget*, GdkEventConfigure*, gpointer);
+gboolean wMainWindow_key_press_event_cb( GtkWidget*, GdkEventKey*, gpointer);
 
 void iExpRefresh_activate_cb( GtkMenuItem*, gpointer);
 void iExpPurgeComputed_activate_cb( GtkMenuItem*, gpointer);

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list