[med-svn] [SCM] aghermann branch, master, updated. 99b1d5a023eee9df74b0e0d6f894516fc79435ad

Andrei Zavada johnhommer at gmail.com
Sun Jul 7 23:03:51 UTC 2013


The following commit has been merged in the master branch:
commit 0ac44730c616e0fb7ad4d19e1468d7736624ba5b
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sun Jun 9 19:47:40 2013 +0300

    make aghui::pop_question take same args as pop_ok_question, touch up strings

diff --git a/src/aghermann/globals.cc b/src/aghermann/globals.cc
index 0fec459..b73a91a 100644
--- a/src/aghermann/globals.cc
+++ b/src/aghermann/globals.cc
@@ -26,9 +26,11 @@
 
 using namespace std;
 
-
 gsl_rng *agh::global::rng = nullptr;
 
+int agh::global::num_procs = 1;
+
+
 void
 agh::global::
 init()
@@ -60,9 +62,13 @@ init()
 }
 
 
-
-
-int agh::global::num_procs = 1;
+void
+agh::global::
+fini()
+{
+	gsl_rng_free( rng);
+	rng = nullptr;
+}
 
 // Local Variables:
 // Mode: c++
diff --git a/src/aghermann/globals.hh b/src/aghermann/globals.hh
index 866f1b1..6115f3a 100644
--- a/src/aghermann/globals.hh
+++ b/src/aghermann/globals.hh
@@ -28,6 +28,7 @@ extern gsl_rng *rng;
 extern int num_procs;
 
 void init();
+void fini();
 
 } // namespace global
 } // namespace agh
diff --git a/src/aghermann/main.cc b/src/aghermann/main.cc
index 64cf7b1..7830f77 100644
--- a/src/aghermann/main.cc
+++ b/src/aghermann/main.cc
@@ -84,7 +84,9 @@ main( int argc, char **argv)
 			return -1;
 		}
 
+		agh::global::init();
 		agh::CExpDesign ED (explicit_session); // essentially a very thoughtful no-op
+		agh::global::fini();
 
 	} else {
 
@@ -114,6 +116,8 @@ main( int argc, char **argv)
 			// implicit read sessionrc, run
 
 			gtk_main();
+
+			agh::global::fini();
 		}
 		// g_object_unref (app); // abandon ship anyway
 	}
diff --git a/src/aghermann/ui/libcommon.cc b/src/aghermann/ui/libcommon.cc
index 69def52..48c7723 100644
--- a/src/aghermann/ui/libcommon.cc
+++ b/src/aghermann/ui/libcommon.cc
@@ -314,29 +314,34 @@ pop_ok_message( GtkWindow *parent,
 }
 
 
-int
+gint
 aghui::
-pop_question( GtkWindow* parent, const gchar *str, ...)
+pop_question( GtkWindow* parent,
+	      const char* primary_text,
+	      const char* fmt, ...)
 {
-	va_list ap;
-	va_start (ap, str);
-
-	static GString *buf = NULL;
-	if ( buf == NULL )
-		buf = g_string_new("");
-
-	g_string_vprintf( buf, str, ap);
-	va_end (ap);
-
-	GtkWidget *msg =
+	auto W = (GtkMessageDialog*)
 		gtk_message_dialog_new_with_markup(
 			parent,
 			(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
 			GTK_MESSAGE_INFO,
 			GTK_BUTTONS_YES_NO,
-			buf->str, NULL);
-	gint response = gtk_dialog_run( (GtkDialog*)msg);
-	gtk_widget_destroy( msg);
+			primary_text, NULL);
+
+	if ( fmt ) {
+		va_list ap;
+		va_start (ap, fmt);
+
+		char *_;
+		assert (vasprintf( &_, fmt, ap) > 0);
+		va_end (ap);
+		gtk_message_dialog_format_secondary_markup( W, "%s", _);
+		free( (void*)_);
+	}
+
+	gint response = gtk_dialog_run( (GtkDialog*)W);
+	gtk_widget_destroy( (GtkWidget*)W);
+
 	return response;
 }
 
diff --git a/src/aghermann/ui/sf/d/patterns-profiles.cc b/src/aghermann/ui/sf/d/patterns-profiles.cc
index 7ecb52c..75ea044 100644
--- a/src/aghermann/ui/sf/d/patterns-profiles.cc
+++ b/src/aghermann/ui/sf/d/patterns-profiles.cc
@@ -28,14 +28,19 @@ import_from_selection( SScoringFacility::SChannel& field)
 	if ( run == 0 )
 		return -1;
 	if ( run_time > 60. ) {
-		aghui::pop_ok_message( (GtkWindow*)wSFFD, "Selection greater than a minute", "This is surely the single occurrence, I tell you!");
+		aghui::pop_ok_message(
+			(GtkWindow*)wSFFD,
+			"<b>Selection greater than a minute</b>",
+			"This is surely the single occurrence, I tell you!");
 		return -2;
 	}
 	if ( run_time > 10. and
 	     GTK_RESPONSE_YES !=
-	     aghui::pop_question( (GtkWindow*)wSFFD, "The selection is greater than 10 sec. Sure to proceed with search?") ) {
+	     aghui::pop_question(
+		     (GtkWindow*)wSFFD,
+		     "<b>The selection is greater than 10 sec</b>",
+		     "Sure to proceed with search?") )
 		return -3;
-	}
 
 	size_t	context_before = // agh::alg::ensure_within(
 		(field.selection_start < current_pattern->context_pad)
diff --git a/src/aghermann/ui/sf/d/patterns_cb.cc b/src/aghermann/ui/sf/d/patterns_cb.cc
index 7f51849..dd689d9 100644
--- a/src/aghermann/ui/sf/d/patterns_cb.cc
+++ b/src/aghermann/ui/sf/d/patterns_cb.cc
@@ -480,7 +480,10 @@ wSFFD_hide_cb(
 
 	if ( not FD.occurrences.empty() ) { // closing while dialog is in matching state
 		if ( GTK_RESPONSE_YES !=
-		     pop_question( SF.wSF, "Keep annotations?") )
+		     pop_question(
+			     SF.wSF,
+			     "<b>Pattern found and marked</b>",
+			     "Keep annotated occurrences?") )
 			FD.restore_annotations();
 		else {
 			SF._p.populate_mGlobalAnnotations();
diff --git a/src/aghermann/ui/sf/ica.cc b/src/aghermann/ui/sf/ica.cc
index 3870742..d020af5 100644
--- a/src/aghermann/ui/sf/ica.cc
+++ b/src/aghermann/ui/sf/ica.cc
@@ -41,11 +41,13 @@ setup_ica()
 				; // good
 			} else {
 				if ( GTK_RESPONSE_NO ==
-				     pop_question( wSF,
-						   "It seems you have already run ICA on these channels\n"
-						   "(a backup file <i>\"%s.orig\"</i> exists, and\n"
-						   "will be overwritten if you proceed now)\n\n"
-						   "Sure you want to do it again?", fname.c_str()) )
+				     pop_question(
+					     wSF,
+					     "<b>You have already run ICA on these channels</b>",
+					     "A backup file <i>\"%s.orig\"</i> exists, and\n"
+					     "will be overwritten if you proceed now.\n\n"
+					     "Sure you want to do it again?",
+					     fname.c_str()) )
 					return 1;
 			}
 		}
@@ -58,9 +60,10 @@ setup_ica()
 		size_t	this_sr = H.crecording.F().samplerate(H.h()),
 			this_ts = H.crecording.total_samples();
 		if ( checking_sr and this_sr != checking_sr ) {
-			pop_ok_message( wSF,
-					"Variable sample rates not supported",
-					"Sorry, ICA cannot be performed on channels with different sample rates.");
+			pop_ok_message(
+				wSF,
+				"<b>Variable sample rates not supported</b>",
+				"Sorry, ICA cannot yet be performed on channels with different sample rates.");
 			return 1;
 		} else
 			checking_sr = this_sr;
diff --git a/src/aghermann/ui/sf/montage_cb.cc b/src/aghermann/ui/sf/montage_cb.cc
index 99e602d..558672d 100644
--- a/src/aghermann/ui/sf/montage_cb.cc
+++ b/src/aghermann/ui/sf/montage_cb.cc
@@ -785,27 +785,33 @@ iSFPageArtifactsClear_activate_cb(
 	auto& SF = *(SScoringFacility*)userdata;
 
 	char* chnamee = g_markup_escape_text( SF.using_channel->name(), -1);
-	if ( GTK_RESPONSE_YES == pop_question(
-		     SF.wSF,
-		     "All marked artifacts will be lost in channel <b>%s</b>.\n\n"
-		     "Continue?",
-		     chnamee) ) {
 
-		SF.using_channel->artifacts().clear();
-		SF.using_channel->get_signal_filtered();
+	if ( SF.using_channel->artifacts().empty() ) {
+		pop_ok_message( SF.wSF, "No artifacts to clear", "Channel <b>%s</b> is already clean.", chnamee);
 
-		if ( SF.using_channel->schannel().type() == sigfile::SChannel::TType::eeg ) {
-			SF.using_channel->get_psd_course();
-			SF.using_channel->get_psd_in_bands();
-			SF.using_channel->get_spectrum();
+	} else
+		if ( GTK_RESPONSE_YES ==
+		     pop_question(
+			     SF.wSF,
+			     "<b>All marked artifacts will be lost</b>",
+			     "Sure to clean all artifacts in channel <b>%s</b>?",
+			     chnamee) ) {
+
+			SF.using_channel->artifacts().clear();
+			SF.using_channel->get_signal_filtered();
+
+			if ( SF.using_channel->schannel().type() == sigfile::SChannel::TType::eeg ) {
+				SF.using_channel->get_psd_course();
+				SF.using_channel->get_psd_in_bands();
+				SF.using_channel->get_spectrum();
+
+				SF.redraw_ssubject_timeline();
+			}
 
-			SF.redraw_ssubject_timeline();
+			gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
+			gtk_widget_queue_draw( (GtkWidget*)SF.daSFHypnogram);
 		}
 
-		gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
-		gtk_widget_queue_draw( (GtkWidget*)SF.daSFHypnogram);
-	}
-
 	g_free( chnamee);
 }
 
@@ -901,6 +907,7 @@ iSFPageAnnotationDelete_activate_cb(
 	if ( SF.over_annotations.size() == 1 ) {
 		if ( GTK_RESPONSE_YES
 		     == pop_question( SF.wSF,
+				      "<b>Deleting annotation</b>",
 				      "Sure you want to delete annotation\n <b>%s</b>?",
 				      SF.over_annotations.front()->label.c_str()) )
 			SF.using_channel->annotations.remove(
@@ -908,6 +915,7 @@ iSFPageAnnotationDelete_activate_cb(
 	} else {
 		if ( GTK_RESPONSE_YES
 		     == pop_question( SF.wSF,
+				      "<b>Deleting annotations</b>",
 				      "Sure you want to delete <b>%zu annotations</b>?",
 				      SF.over_annotations.size()) )
 			for ( auto &rm : SF.over_annotations )
@@ -981,6 +989,7 @@ iSFPageAnnotationClearAll_activate_cb(
 	if ( GTK_RESPONSE_YES
 	     == pop_question(
 		     SF.wSF,
+		     "<b>Deleting annotations</b>",
 		     "Sure you want to delete all annotations in channel <b>%s</b>?",
 		     chnamee) ) {
 
diff --git a/src/aghermann/ui/ui.hh b/src/aghermann/ui/ui.hh
index baf4b13..cc0fcb9 100644
--- a/src/aghermann/ui/ui.hh
+++ b/src/aghermann/ui/ui.hh
@@ -22,7 +22,7 @@
 #include <gtk/gtk.h>
 
 #include "common/lang.hh"
-#include "globals.hh"
+#include "aghermann/ui/globals.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
 #  include "config.h"
@@ -169,7 +169,7 @@ cairo_put_banner( cairo_t *cr,
 
 
 void pop_ok_message( GtkWindow *parent, const char* primary, const gchar*, ...) __attribute__ ((format (printf, 3, 4)));
-gint pop_question( GtkWindow *parent, const gchar*, ...) __attribute__ ((format (printf, 2, 3)));
+gint pop_question( GtkWindow *parent, const char* primary, const char*, ...) __attribute__ ((format (printf, 3, 4)));
 void set_cursor_busy( bool busy, GtkWidget *wid);
 
 

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list