[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461

Andrei Zavada johnhommer at gmail.com
Fri Nov 16 00:50:06 UTC 2012


The following commit has been merged in the master branch:
commit 787bfcca264775264f9ea7f5a438b42b75f07581
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sun Oct 7 01:20:06 2012 +0300

    split GTK pointer fields into separate *Widgets classes

diff --git a/data/sf.glade b/data/sf.glade
index 7db45cd..356b4ad 100644
--- a/data/sf.glade
+++ b/data/sf.glade
@@ -1,33 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkAdjustment" id="jHighPassCutoff">
-    <property name="upper">100</property>
-    <property name="step_increment">0.25</property>
-    <property name="page_increment">1</property>
-  </object>
-  <object class="GtkAdjustment" id="jHighPassOrder">
-    <property name="upper">5</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkAdjustment" id="jLowPassCutoff">
-    <property name="upper">100</property>
-    <property name="step_increment">0.25</property>
-    <property name="page_increment">1</property>
-  </object>
-  <object class="GtkAdjustment" id="jLowPassOrder">
-    <property name="lower">1</property>
-    <property name="upper">5</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkAdjustment" id="jPageNo">
-    <property name="lower">1</property>
-    <property name="upper">99999</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
   <object class="GtkAdjustment" id="jPatternEnvTightness">
     <property name="lower">1</property>
     <property name="upper">20</property>
@@ -184,6 +157,33 @@
     <property name="step_increment">0.5</property>
     <property name="page_increment">2</property>
   </object>
+  <object class="GtkAdjustment" id="jHighPassCutoff">
+    <property name="upper">100</property>
+    <property name="step_increment">0.25</property>
+    <property name="page_increment">1</property>
+  </object>
+  <object class="GtkAdjustment" id="jHighPassOrder">
+    <property name="upper">5</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="jLowPassCutoff">
+    <property name="upper">100</property>
+    <property name="step_increment">0.25</property>
+    <property name="page_increment">1</property>
+  </object>
+  <object class="GtkAdjustment" id="jLowPassOrder">
+    <property name="lower">1</property>
+    <property name="upper">5</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="jPageNo">
+    <property name="lower">1</property>
+    <property name="upper">99999</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkAdjustment" id="jSFICAEigVecFirst">
     <property name="lower">1</property>
     <property name="upper">100</property>
@@ -826,6 +826,41 @@
       </object>
     </child>
   </object>
+  <object class="GtkListStore" id="mScoringPageSize">
+    <columns>
+      <!-- column-name PageSize -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">4 sec</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">5 sec</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">10 sec</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">15 sec</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">20 sec</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">30 sec</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">1 min</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">2 min</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">5 min</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="wAnnotationLabel">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -2797,15 +2832,15 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" id="bScoreClear">
-                        <property name="label" translatable="yes">⌫</property>
+                      <object class="GtkButton" id="bScoreWake">
+                        <property name="label" translatable="yes">☺</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="tooltip_markup" translatable="yes">Clear (<b>q</b>)</property>
+                        <property name="tooltip_markup" translatable="yes">Wake (<b>w</b>)</property>
                         <property name="valign">center</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="q" signal="activate"/>
+                        <accelerator key="w" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -2814,15 +2849,15 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" id="bScoreWake">
-                        <property name="label" translatable="yes">☺</property>
+                      <object class="GtkButton" id="bScoreClear">
+                        <property name="label" translatable="yes">⌫</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="tooltip_markup" translatable="yes">Wake (<b>w</b>)</property>
+                        <property name="tooltip_markup" translatable="yes">Clear (<b>q</b>)</property>
                         <property name="valign">center</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="w" signal="activate"/>
+                        <accelerator key="q" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -3057,18 +3092,17 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkToggleButton" id="bSFShowFindDialog">
-                        <property name="label" translatable="yes">_Find</property>
+                      <object class="GtkToggleButton" id="bSFShowPhaseDiffDialog">
+                        <property name="label" translatable="yes">Δφ</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">Find/manage patterns (<b>F3</b>)</property>
-                        <property name="tooltip_text" translatable="yes">Find/manage patterns (F3)</property>
+                        <property name="tooltip_markup" translatable="yes">Interchannel signal shift (<b>F4</b>)</property>
+                        <property name="tooltip_text" translatable="yes">Interchannel signal shift (F4)</property>
                         <property name="valign">center</property>
-                        <property name="use_underline">True</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="F3" signal="activate"/>
+                        <accelerator key="F4" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -3078,17 +3112,18 @@ on individual parameters:</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkToggleButton" id="bSFShowPhaseDiffDialog">
-                        <property name="label" translatable="yes">Δφ</property>
+                      <object class="GtkToggleButton" id="bSFShowFindDialog">
+                        <property name="label" translatable="yes">_Find</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">Interchannel signal shift (<b>F4</b>)</property>
-                        <property name="tooltip_text" translatable="yes">Interchannel signal shift (F4)</property>
+                        <property name="tooltip_markup" translatable="yes">Find/manage patterns (<b>F3</b>)</property>
+                        <property name="tooltip_text" translatable="yes">Find/manage patterns (F3)</property>
                         <property name="valign">center</property>
+                        <property name="use_underline">True</property>
                         <property name="focus_on_click">False</property>
-                        <accelerator key="F4" signal="activate"/>
+                        <accelerator key="F3" signal="activate"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index 5eaa051..2d11e80 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -17,6 +17,7 @@ libaghui_a_SOURCES = \
 	session-chooser_cb.cc \
 	session-chooser_cb.hh \
 	expdesign.hh \
+	expdesign-widgets.hh \
 	expdesign_cb.hh \
 	expdesign.cc \
 	expdesign_cb.cc \
@@ -29,6 +30,7 @@ libaghui_a_SOURCES = \
 	expdesign-simulations.cc \
 	expdesign-simulations_cb.cc \
 	scoring-facility.hh \
+	scoring-facility-widgets.hh \
 	scoring-facility_cb.hh \
 	scoring-facility.cc \
 	scoring-facility-construct.cc \
@@ -63,8 +65,10 @@ BUILT_SOURCES = \
 	session-chooser.hh.gch \
 	session-chooser_cb.hh.gch \
 	expdesign.hh.gch \
+	expdesign-widgets.hh.gch \
 	expdesign_cb.hh.gch \
 	scoring-facility.hh.gch \
+	scoring-facility-widgets.hh.gch \
 	scoring-facility_cb.hh.gch \
 	modelrun-facility.hh.gch \
 	modelrun-facility_cb.hh.gch
diff --git a/src/ui/expdesign-construct.cc b/src/ui/expdesign-construct.cc
index 07adbc8..cd5060e 100644
--- a/src/ui/expdesign-construct.cc
+++ b/src/ui/expdesign-construct.cc
@@ -11,26 +11,28 @@
  */
 
 
-#include "globals.hh"
-#include "expdesign.hh"
+#include "ui.hh"
+#include "expdesign-widgets.hh"
 #include "expdesign_cb.hh"
 
 using namespace std;
 
 using namespace aghui;
 
+const char* const
+	aghui::SExpDesignUIWidgets::mannotations_column_names[] = {
+	"Recording", "Pages", "Channel", "Label"
+};
 
-int
-aghui::SExpDesignUI::
-construct_widgets()
+
+aghui::SExpDesignUIWidgets::
+SExpDesignUIWidgets ()
 {
       // load glade
 	builder = gtk_builder_new();
 	if ( !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/main.glade", NULL) ||
-	     !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/dialogs.glade", NULL) ) {
-		pop_ok_message( NULL, "Failed to load main resources");
-		return -1;
-	}
+	     !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/dialogs.glade", NULL) )
+		throw runtime_error ("Failed to load main resources");
 
 	gtk_builder_connect_signals( builder, NULL);
 
@@ -64,7 +66,7 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkListStore,	mFFTParamsPageSize) ||
 	     !AGH_GBGETOBJ (GtkListStore,	mFFTParamsBinSize) ||
 	     !AGH_GBGETOBJ (GtkListStore,	mFFTParamsWindowType) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 	// (some of) these are directly attached to combo boxes in dauaghter widgets, so ref
 	g_object_ref( (GObject*)mScoringPageSize);
 	g_object_ref( (GObject*)mFFTParamsPageSize);
@@ -92,7 +94,7 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkMenuItem,	iMontageNotch60Hz) ||
 	     !AGH_GBGETOBJ (GtkMenuItem,	iHelpAbout) ||
 	     !AGH_GBGETOBJ (GtkMenuItem,	iHelpUsage) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	g_signal_connect( iExpClose, "activate",
 			  (GCallback)iExpClose_activate_cb,
@@ -136,7 +138,7 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkVBox,		cMeasurements) ||
 	     !AGH_GBGETOBJ (GtkLabel,		lMsmtPSDInfo) ||
 	     !AGH_GBGETOBJ (GtkLabel,		lMsmtMCInfo) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	wMainWindow_delete_event_cb_handler_id =
 		g_signal_connect( wMainWindow, "delete-event",
@@ -160,7 +162,7 @@ construct_widgets()
 	// annotations
 	if ( !AGH_GBGETOBJ (GtkDialog,		wGlobalAnnotations) ||
 	     !AGH_GBGETOBJ (GtkTreeView,	tvGlobalAnnotations) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 	gtk_tree_view_set_model( tvGlobalAnnotations,
 				 (GtkTreeModel*)mGlobalAnnotations);
 
@@ -199,7 +201,7 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkLabel,		lTaskSelector1) ||
 	     !AGH_GBGETOBJ (GtkLabel,		lTaskSelector2) ||
 	     !AGH_GBGETOBJ (GtkLabel,		lSettings) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	g_signal_connect( tTaskSelector, "switch-page",
 			  (GCallback)tTaskSelector_switch_page_cb,
@@ -214,7 +216,7 @@ construct_widgets()
 
      // ------------- eMsmtSession
 	if ( !AGH_GBGETOBJ (GtkComboBox, eMsmtSession) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	gtk_combo_box_set_model( eMsmtSession,
 				 (GtkTreeModel*)mSessions);
@@ -232,7 +234,7 @@ construct_widgets()
 
      // ------------- eMsmtChannel
 	if ( !AGH_GBGETOBJ ( GtkComboBox, eMsmtChannel) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	gtk_combo_box_set_model( eMsmtChannel,
 				 (GtkTreeModel*)mEEGChannels);
@@ -262,7 +264,7 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkBox,		cMsmtMainToolbar) ||
 	     !AGH_GBGETOBJ (GtkBox,		cMsmtProfileParams2) ||
 	     !AGH_GBGETOBJ (GtkBox,		cMsmtProfileParamsContainer) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	renderer = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start( (GtkCellLayout*)eMsmtProfileType, renderer, FALSE);
@@ -296,7 +298,7 @@ construct_widgets()
 	     !(AGH_GBGETOBJ (GtkMenuItem,	iSubjectTimelineSaveAsSVG)) ||
 	     !(AGH_GBGETOBJ (GtkMenuItem,	iSubjectTimelineResetMontage)) ||
 	     !(AGH_GBGETOBJ (GtkMenuItem,	iSubjectTimelineBrowse)) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	g_object_ref( (GObject*)iiSubjectTimeline);
 	g_object_ref( (GObject*)iSubjectTimelineScore);
@@ -331,7 +333,7 @@ construct_widgets()
 
       // ------------ actions
 	if ( !(AGH_GBGETOBJ (GtkButton,		bMainCloseThatSF)) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	g_signal_connect( bMainCloseThatSF, "clicked",
 			  (GCallback)bMainCloseThatSF_clicked_cb,
@@ -340,7 +342,7 @@ construct_widgets()
    // ================ 2. Simulations
      // ------------- tvSimulations & controls
 	if ( !(AGH_GBGETOBJ (GtkTreeView, tvSimulations)) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	gtk_tree_view_set_model( tvSimulations,
 				 (GtkTreeModel*)mSimulations);
@@ -390,7 +392,7 @@ construct_widgets()
 	if ( !(AGH_GBGETOBJ (GtkMenuItem, iSimulationsRunBatch)) ||
 	     !(AGH_GBGETOBJ (GtkMenuItem, iSimulationsRunClearAll)) ||
 	     !(AGH_GBGETOBJ (GtkMenuItem, iSimulationsReportGenerate)) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	g_signal_connect( iSimulationsRunBatch, "activate",
 			  (GCallback)iSimulationsRunBatch_activate_cb,
@@ -406,17 +408,17 @@ construct_widgets()
 	if ( !AGH_GBGETOBJ (GtkLabel, lSimulationsProfile) ||
 	     !AGH_GBGETOBJ (GtkLabel, lSimulationsChannel) ||
 	     !AGH_GBGETOBJ (GtkLabel, lSimulationsSession) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
     // ======= statusbar
 	if ( !AGH_GBGETOBJ (GtkStatusbar,	sbMainStatusBar) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	sbMainContextIdGeneral = gtk_statusbar_get_context_id( sbMainStatusBar, "General context");
 
 	if ( !(AGH_GBGETOBJ (GtkDialog,		wScanLog)) ||
 	     !(AGH_GBGETOBJ (GtkTextView,	tScanLog)) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	gtk_widget_override_font( (GtkWidget*)tScanLog, font_desc);
 	// free? unref? leak some?
@@ -424,12 +426,12 @@ construct_widgets()
       // ****************** settings
       // ------------- fFFTParams
 	if ( !AGH_GBGETOBJ (GtkSpinButton,	eUltradianCycleDetectionAccuracy) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	if ( !AGH_GBGETOBJ (GtkComboBox,	eFFTParamsBinSize) ||
 	     !AGH_GBGETOBJ (GtkComboBox,	eFFTParamsPageSize) ||
 	     !AGH_GBGETOBJ (GtkComboBox,	eFFTParamsWindowType) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	renderer = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start( (GtkCellLayout*)eFFTParamsPageSize, renderer, FALSE);
@@ -449,7 +451,7 @@ construct_widgets()
       // ------------- fArtifacts
 	if ( !AGH_GBGETOBJ (GtkComboBox,	eArtifDampenWindowType) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eArtifDampenFactor) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	renderer = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start( (GtkCellLayout*)eArtifDampenWindowType, renderer, FALSE);
@@ -460,7 +462,7 @@ construct_widgets()
 	if ( !AGH_GBGETOBJ (GtkSpinButton,	eMCParamBandWidth) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eMCParamIIRBackpolate) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eMCParamMCGain) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
       // ------- custom score codes
 	if ( !(eScoreCode[sigfile::SPage::TScore::none]		= (GtkEntry*)gtk_builder_get_object( builder, "eScoreCodeUnscored")) ||
@@ -470,7 +472,7 @@ construct_widgets()
 	     !(eScoreCode[sigfile::SPage::TScore::nrem4]	= (GtkEntry*)gtk_builder_get_object( builder, "eScoreCodeNREM4")) ||
 	     !(eScoreCode[sigfile::SPage::TScore::rem]		= (GtkEntry*)gtk_builder_get_object( builder, "eScoreCodeREM")) ||
 	     !(eScoreCode[sigfile::SPage::TScore::wake]		= (GtkEntry*)gtk_builder_get_object( builder, "eScoreCodeWake")))
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
       // --------- Bands
 	if ( !(eBand[sigfile::TBand::delta][0]   = (GtkSpinButton*)gtk_builder_get_object( builder, "eBandDeltaFrom")) ||
@@ -483,7 +485,7 @@ construct_widgets()
 	     !(eBand[sigfile::TBand::beta ][1]   = (GtkSpinButton*)gtk_builder_get_object( builder, "eBandBetaUpto" )) ||
 	     !(eBand[sigfile::TBand::gamma][0]   = (GtkSpinButton*)gtk_builder_get_object( builder, "eBandGammaFrom")) ||
 	     !(eBand[sigfile::TBand::gamma][1]   = (GtkSpinButton*)gtk_builder_get_object( builder, "eBandGammaUpto")) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
       // --------- Misc
 	if ( !AGH_GBGETOBJ (GtkSpinButton, eDAMsmtPPH) ||
@@ -491,12 +493,10 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkSpinButton, eDAPageHeight) ||
 	     !AGH_GBGETOBJ (GtkSpinButton, eDAHypnogramHeight) ||
 	     !AGH_GBGETOBJ (GtkSpinButton, eDAEMGHeight) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	if ( !AGH_GBGETOBJ (GtkEntry,	eBrowseCommand) )
-		return -1;
-
-	gtk_entry_set_text( eBrowseCommand, browse_command.c_str());
+		throw runtime_error ("Failed to construct widgets");
 
 
      // ------------- eCtrlParam*
@@ -520,7 +520,7 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkRadioButton,	eCtlParamScoreUnscoredAsWake) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eCtlParamNSWAPpBeforeSimStart) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eCtlParamReqScoredPercent) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	g_signal_connect( eCtlParamDBAmendment1, "toggled",
 			  (GCallback)eCtlParamDBAmendment1_toggled_cb,
@@ -581,7 +581,7 @@ construct_widgets()
 	     !(eTunable[TTunable::gc][1]	= (GtkSpinButton*)gtk_builder_get_object( builder, "eTunable_gc_min")) ||
 	     !(eTunable[TTunable::gc][2]	= (GtkSpinButton*)gtk_builder_get_object( builder, "eTunable_gc_max")) ||
 	     !(eTunable[TTunable::gc][3]	= (GtkSpinButton*)gtk_builder_get_object( builder, "eTunable_gc_step")) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	for ( size_t t = 0; t < (size_t)TTunable::_basic_tunables; ++t )
 		for ( auto d = 0; d < 4; ++d )
@@ -589,7 +589,7 @@ construct_widgets()
 
 
 	if ( !AGH_GBGETOBJ (GtkButton,	bSimParamRevertTunables) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 	g_signal_connect( bSimParamRevertTunables, "clicked",
 			  (GCallback)bSimParamRevertTunables_clicked_cb,
 			  this);
@@ -630,7 +630,7 @@ construct_widgets()
 	     !(CwB[TColour::band_alpha	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandAlpha")) ||
 	     !(CwB[TColour::band_beta	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandBeta")) ||
 	     !(CwB[TColour::band_gamma	  ].btn = (GtkColorButton*)gtk_builder_get_object( builder, "bColourBandGamma")) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
       // scrub colours
 	for ( auto &C : CwB ) {
@@ -643,16 +643,16 @@ construct_widgets()
       // ----- wAbout
 	if ( !(AGH_GBGETOBJ (GtkDialog,		wAbout)) ||
 	     !(AGH_GBGETOBJ (GtkNotebook,	cAboutTabs)) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
       // ------- wEDFFileDetails
 	if ( !AGH_GBGETOBJ (GtkDialog,		wEDFFileDetails) ||
 	     !AGH_GBGETOBJ (GtkTextView,	lEDFFileDetailsReport) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	// used by two GtkTextView's, lEDFFileDetailsReport and lEdfImportFileInfo
 	if ( !AGH_GBGETOBJ (GtkTextBuffer,	tEDFFileDetailsReport) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 	gtk_widget_override_font( (GtkWidget*)lEDFFileDetailsReport, font_desc);
 	g_object_set( lEDFFileDetailsReport,
@@ -677,10 +677,11 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkButton,		bEdfImportAttachMove) ||
 	     !AGH_GBGETOBJ (GtkButton,		bEdfImportAdmit) ||
 	     !AGH_GBGETOBJ (GtkButton,		bEdfImportEdfhed) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
 
 	gtk_widget_override_font( (GtkWidget*)lEdfImportFileInfo, font_desc);
+
 	g_object_set( lEdfImportFileInfo,
 		      "tabs", pango_tab_array_new_with_positions( 2, TRUE,
 								  PANGO_TAB_LEFT, 130,
@@ -704,7 +705,7 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkRadioButton,	eSubjectDetailsGenderMale) ||
 	     !AGH_GBGETOBJ (GtkRadioButton,	eSubjectDetailsGenderFemale) ||
 	     !AGH_GBGETOBJ (GtkEntry,		eSubjectDetailsComment) )
-		return -1;
+		throw runtime_error ("Failed to construct widgets");
 
       // ------------- wBatchSetup
 	if ( !AGH_GBGETOBJ (GtkDialog,		wBatchSetup) ||
@@ -715,23 +716,17 @@ construct_widgets()
 	     !AGH_GBGETOBJ (GtkSpinButton,	eBatchSetupRangeWidth) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eBatchSetupRangeInc) ||
 	     !AGH_GBGETOBJ (GtkSpinButton,	eBatchSetupRangeSteps) )
-		return -1;
-
-
-      // ========= sister widget
+		throw runtime_error ("Failed to construct widgets");
 
 	pango_font_description_free( font_desc);
-
-	g_object_unref( (GObject*)builder);
-
-	return 0;
 }
 
 
-void
-aghui::SExpDesignUI::
-destruct_widgets()
+aghui::SExpDesignUIWidgets::
+~SExpDesignUIWidgets ()
 {
+	g_object_unref( (GObject*)builder);
+
       // destroy toplevels
 	gtk_widget_destroy( (GtkWidget*)wMainWindow);
 	gtk_widget_destroy( (GtkWidget*)wAbout);
@@ -764,4 +759,29 @@ destruct_widgets()
 }
 
 
+
+void
+aghui::SExpDesignUIWidgets::
+set_wMainWindow_interactive( bool indeed, bool flush)
+{
+	set_cursor_busy( not indeed, (GtkWidget*)wMainWindow);
+	//gtk_widget_set_sensitive( (GtkWidget*)wMainWindow, indeed);
+
+	gtk_widget_set_sensitive( (GtkWidget*)cMsmtProfileParamsContainer, indeed);
+	gtk_widget_set_sensitive( (GtkWidget*)cMeasurements, indeed);
+
+	gtk_widget_set_visible( (GtkWidget*)lTaskSelector2, indeed);
+	gtk_widget_set_visible( gtk_notebook_get_nth_page( tTaskSelector, 1), indeed);
+	gtk_widget_set_visible( (GtkWidget*)lSettings, indeed);
+	gtk_widget_set_sensitive( gtk_notebook_get_nth_page( tDesign, 1), indeed);
+
+	gtk_widget_set_sensitive( (GtkWidget*)iiMainMenu, indeed);
+	gtk_widget_set_sensitive( (GtkWidget*)eMsmtSession, indeed);
+	gtk_widget_set_sensitive( (GtkWidget*)eMsmtChannel, indeed);
+
+	if ( flush )
+		gtk_flush();
+}
+
+
 // eof
diff --git a/src/ui/expdesign-measurements.cc b/src/ui/expdesign-measurements.cc
index 54ad92e..408f6c2 100644
--- a/src/ui/expdesign-measurements.cc
+++ b/src/ui/expdesign-measurements.cc
@@ -24,11 +24,6 @@
 using namespace std;
 using namespace aghui;
 
-const char* const
-	aghui::SExpDesignUI::mannotations_column_names[] = {
-	"Recording", "Pages", "Channel", "Label"
-};
-
 
 bool
 aghui::SExpDesignUI::SSubjectPresentation::
diff --git a/src/ui/expdesign-widgets.hh b/src/ui/expdesign-widgets.hh
new file mode 100644
index 0000000..9339ee7
--- /dev/null
+++ b/src/ui/expdesign-widgets.hh
@@ -0,0 +1,341 @@
+// ;-*-C++-*-
+/*
+ *       File name:  ui/expdesign-widgets.hh
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2012-10-06
+ *
+ *         Purpose:  GTK widgets class for SExpDesignUI
+ *
+ *         License:  GPL
+ */
+
+#ifndef _AGHUI_EXPDESIGN_WIDGETS_H
+#define _AGHUI_EXPDESIGN_WIDGETS_H
+
+#include <map>
+#include <gtk/gtk.h>
+#include "../libsigfile/page.hh" // for various enums
+#include "../libsigfile/psd.hh"
+#include "../model/achermann-tunable.hh"
+#include "ui.hh"  // for SManagedColor
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+
+using namespace std;
+
+namespace aghui {
+
+// ui structures everything is public, mainly to give access to the
+// bulk of extern "C" GTK callbacks
+
+struct SExpDesignUIWidgets {
+
+	SExpDesignUIWidgets ();
+       ~SExpDesignUIWidgets ();
+
+	GtkBuilder
+		*builder;
+
+      // storage
+	GtkListStore
+		*mSessions,
+		*mEEGChannels,
+		*mAllChannels;
+	GtkTreeStore
+		*mGlobalAnnotations,
+		*mSimulations;
+
+	gulong 	wMainWindow_delete_event_cb_handler_id,
+		eMsmtSession_changed_cb_handler_id,
+		eMsmtChannel_changed_cb_handler_id;
+
+	GtkListStore
+		*mScoringPageSize,
+		*mFFTParamsPageSize,
+		*mFFTParamsBinSize,
+		*mFFTParamsWindowType,
+		*mMsmtProfileType;
+	static const auto
+		msimulations_visibility_switch_col = 14,
+		msimulations_modref_col = msimulations_visibility_switch_col + 1;
+	static const auto
+		mannotations_visibility_switch_col = 4,
+		mannotations_ref_col = mannotations_visibility_switch_col + 1;
+	static const char* const mannotations_column_names[];
+
+      // misc
+	PangoFontDescription
+		*monofont;
+
+      // main toplevel
+	GtkWindow
+		*wMainWindow;
+	void
+	set_wMainWindow_interactive( bool indeed, bool flush = true);
+
+	// tabs
+	GtkNotebook
+		*tTaskSelector,
+		*tDesign, *tSimulations,
+		*tSettings;
+	GtkLabel
+		*lTaskSelector1, *lTaskSelector2,
+		*lSettings;
+      // 1. Measurements
+	GtkMenu
+		*iiMainMenu;
+	GtkMenuItem
+		*iExpRefresh, *iExpPurgeComputed, *iExpAnnotations, *iExpClose, *iExpQuit,
+		*iExpBasicSADetectUltradianCycles,
+		*iMontageResetAll,
+		*iMontageNotchNone, *iMontageNotch50Hz, *iMontageNotch60Hz,
+		*iHelpAbout,
+		*iHelpUsage;
+
+	// profile mode & parameters
+	GtkComboBox
+		*eMsmtProfileType;
+	GtkToggleButton
+		*eMsmtProfileAutoscale;
+	GtkScaleButton
+		*eMsmtProfileSmooth;
+	GtkBox	*cMsmtProfileParams1,
+		*cMsmtProfileParams2;
+	GtkSpinButton
+		*eMsmtOpFreqFrom,
+		*eMsmtOpFreqWidth;
+	GtkAdjustment
+		*jMsmtOpFreqFrom,
+		*jMsmtOpFreqWidth;
+	GtkBox	*cMsmtMainToolbar,
+		*cMsmtProfileParamsContainer;
+	GtkLabel
+		*lMsmtPSDInfo,
+		*lMsmtMCInfo;
+
+	// view selectors
+	GtkComboBox
+		*eMsmtChannel,
+		*eMsmtSession;
+
+	// main area
+	GtkVBox
+		*cMeasurements;
+	GtkStatusbar
+		*sbMainStatusBar;
+	guint	sbMainContextIdGeneral;
+	// menus
+	GtkMenu
+		*iiSubjectTimeline;
+	GtkMenuItem
+		*iSubjectTimelineScore,
+		*iSubjectTimelineDetectUltradianCycle,
+		*iSubjectTimelineSubjectInfo,
+		*iSubjectTimelineEDFInfo,
+		*iSubjectTimelineSaveAsSVG,
+		*iSubjectTimelineBrowse,
+		*iSubjectTimelineResetMontage;
+
+	// settings
+	GtkSpinButton
+		*eUltradianCycleDetectionAccuracy;
+	GtkComboBox
+		*eFFTParamsWindowType,
+		*eFFTParamsPageSize,
+		*eFFTParamsBinSize,
+		*eArtifDampenWindowType;
+	GtkListStore
+		*mNotchFilter;
+	GtkEntry
+		*eScoreCode[(size_t)sigfile::SPage::TScore::_total];
+	GtkSpinButton
+		*eArtifDampenFactor,
+
+		*eMCParamBandWidth,
+		*eMCParamIIRBackpolate,
+		*eMCParamMCGain,
+
+		*eDAMsmtPPH,
+		*eDAMsmtTLHeight,
+		*eDAPageHeight,
+		*eDAHypnogramHeight,
+		*eDAEMGHeight;
+	GtkAdjustment
+		*jFreqFrom,
+		*jFreqWidth;
+	GtkSpinButton
+		*eBand[(size_t)sigfile::TBand::_total][2];
+	GtkEntry
+		*eBrowseCommand;
+
+	GtkButton
+		*bMainCloseThatSF;
+
+      // 2. Simulations
+	GtkTreeView
+		*tvSimulations;
+	GtkMenuItem
+		*iSimulationsRunBatch,
+		*iSimulationsRunClearAll,
+		*iSimulationsReportGenerate;
+	GtkLabel
+		*lSimulationsProfile,
+		*lSimulationsChannel,
+		*lSimulationsSession;
+
+	// settings
+	GtkSpinButton
+		*eCtlParamAnnlNTries,		*eCtlParamAnnlItersFixedT,
+		*eCtlParamAnnlStepSize,		*eCtlParamAnnlBoltzmannk,
+		*eCtlParamAnnlTInitialMantissa,	*eCtlParamAnnlTInitialExponent,
+		*eCtlParamAnnlDampingMu,	*eCtlParamAnnlTMinMantissa,
+		*eCtlParamAnnlTMinExponent,	*eCtlParamNSWAPpBeforeSimStart,
+		*eCtlParamReqScoredPercent;
+	GtkCheckButton
+		*eCtlParamDBAmendment1,		*eCtlParamDBAmendment2,
+		*eCtlParamAZAmendment1,		*eCtlParamAZAmendment2;
+	GtkLabel
+		*lCtlParamDBAmendment1,		*lCtlParamDBAmendment2,
+		*lCtlParamAZAmendment1,		*lCtlParamAZAmendment2;
+
+	GtkRadioButton
+		*eCtlParamScoreUnscoredAsWake;
+
+	GtkSpinButton
+		*eTunable[agh::ach::TTunable::_basic_tunables][4];
+	GtkAdjustment
+		*jTunable[agh::ach::TTunable::_basic_tunables][4];
+	GtkButton
+		*bSimParamRevertTunables;
+
+      // other toplevels
+	// about
+	GtkDialog
+		*wAbout;
+	GtkNotebook
+		*cAboutTabs;
+
+	// scan log
+	GtkDialog
+		*wScanLog;
+	GtkTextView
+		*tScanLog;
+
+	// edf header
+	GtkDialog
+		*wEDFFileDetails;
+	GtkTextView
+		*lEDFFileDetailsReport;
+	GtkTextBuffer
+		*tEDFFileDetailsReport;
+
+	// edf dnd import
+	GtkDialog
+		*wEdfImport;
+	GtkComboBox
+		*eEdfImportGroup,
+		*eEdfImportSession,
+		*eEdfImportEpisode;
+	GtkEntry
+		*eEdfImportGroupEntry,
+		*eEdfImportSessionEntry,
+		*eEdfImportEpisodeEntry;
+	GtkLabel
+		*lEdfImportSubject,
+		*lEdfImportCaption;
+	GtkTextView
+		*lEdfImportFileInfo;
+	// GtkTextBuffer
+	// 	*tEdfImportDetailsReport;
+	GtkButton
+		*bEdfImportAdmit,
+		*bEdfImportEdfhed,
+		*bEdfImportAttachCopy,
+		*bEdfImportAttachMove;
+
+	// annotations
+	GtkDialog
+		*wGlobalAnnotations;
+	GtkTreeView
+		*tvGlobalAnnotations;
+
+	// subject details
+	GtkDialog
+		*wSubjectDetails;
+	GtkEntry
+		*eSubjectDetailsName,
+		*eSubjectDetailsComment;
+	GtkSpinButton
+		*eSubjectDetailsAge;
+	GtkRadioButton
+		*eSubjectDetailsGenderMale,
+		*eSubjectDetailsGenderFemale;
+
+	// batch setup
+	GtkDialog
+		*wBatchSetup;
+	GtkEntry
+		*eBatchSetupSubjects,
+		*eBatchSetupSessions,
+		*eBatchSetupChannels;
+	GtkSpinButton
+		*eBatchSetupRangeFrom,
+		*eBatchSetupRangeWidth,
+		*eBatchSetupRangeInc,
+		*eBatchSetupRangeSteps;
+      // colours
+	enum TColour {
+		night,		day,
+
+		power_mt,	ticks_mt,	bounds,
+		labels_mt,	jinfo,
+
+		score_none,	score_nrem1,	score_nrem2,
+		score_nrem3,	score_nrem4,	score_rem,
+		score_wake,
+		score_invalid,  // has no color chooser
+
+		artifact,
+		annotations,
+		selection,
+
+		labels_sf,	ticks_sf,	profile_psd_sf,	profile_mc_sf,
+		hypnogram,	hypnogram_scoreline,
+		cursor,
+
+		spectrum,	spectrum_axes,	spectrum_grid,
+
+		emg,
+
+		band_delta,	band_theta,	band_alpha,
+		band_beta,	band_gamma,
+
+		swa,		swa_sim,	process_s,
+		paper_mr,
+		labels_mr,
+		ticks_mr,
+	};
+	map<TColour, SManagedColor>
+		CwB;
+
+	static TColour
+	score2colour( sigfile::SPage::TScore s)
+		{
+			return (TColour)((unsigned)s + (unsigned)TColour::score_none);
+		}
+	static TColour
+	band2colour( sigfile::TBand b)
+		{
+			return (TColour)((unsigned)b + (unsigned)TColour::band_delta);
+		}
+};
+
+} // namespace aghui
+
+#endif // _AGHUI_EXPDESIGN_WIDGETS_H
+
+// eof
diff --git a/src/ui/expdesign.cc b/src/ui/expdesign.cc
index d8988c8..02426ea 100644
--- a/src/ui/expdesign.cc
+++ b/src/ui/expdesign.cc
@@ -169,8 +169,6 @@ SExpDesignUI (aghui::SSessionChooser *parent,
 		confval::SValidator<float>("Common.OperatingRangeUpto",		&operating_range_upto,			confval::SValidator<float>::SVFRangeIn (0., 20.)),
 	})
 {
-	if ( construct_widgets() )
-		throw runtime_error ("SExpDesignUI::SExpDesignUI(): failed to construct widgets");
 	nodestroy_by_cb = true;
 
 	// scrub colors, get CwB color values from glade
@@ -180,38 +178,32 @@ SExpDesignUI (aghui::SSessionChooser *parent,
 	set_wMainWindow_interactive( false);
 	gtk_widget_show_all( (GtkWidget*)wMainWindow);
 
-	try {
-		if ( not dir.empty() and not agh::fs::exists_and_is_writable( dir) )
-			throw invalid_argument (string("Experiment directory ") + dir + " does not exist or is not writable");
-
-		if ( dir.empty() ) { // again? only happens when user has moved a previously valid expdir between sessions
-			string sure_dir = string (getenv("HOME")) + "/EmptyDummy";
-			if ( agh::fs::mkdir_with_parents( sure_dir) != 0 )
-				throw invalid_argument ("The last used experiment directory does not exist (or is not writable),"
-							" and a dummy fallback directory could not be created in your $HOME."
-							" Whatever the reason, this is really too bad: I can't fix it for you.");
-		}
-		ED = new agh::CExpDesign (dir,
-					  bind( &SExpDesignUI::sb_main_progress_indicator, this,
-					        placeholders::_1, placeholders::_2, placeholders::_3));
-		nodestroy_by_cb = false;
-
-		fft_params_welch_window_type_saved	= ED->fft_params.welch_window_type;
-		af_dampen_window_type_saved		= ED->af_dampen_window_type;
-		af_dampen_factor_saved			= ED->af_dampen_factor;
-		mc_params_saved				= ED->mc_params;
-
-		pagesize_item_saved = pagesize_item =
-			figure_pagesize_item();
-		binsize_item_saved = binsize_item =
-			figure_binsize_item();
-
-		populate( true);
-
-	} catch (invalid_argument ex) {
-		destruct_widgets();
-		throw ex; // rethrow
+	if ( not dir.empty() and not agh::fs::exists_and_is_writable( dir) )
+		throw invalid_argument (string("Experiment directory ") + dir + " does not exist or is not writable");
+
+	if ( dir.empty() ) { // again? only happens when user has moved a previously valid expdir between sessions
+		string sure_dir = string (getenv("HOME")) + "/EmptyDummy";
+		if ( agh::fs::mkdir_with_parents( sure_dir) != 0 )
+			throw invalid_argument ("The last used experiment directory does not exist (or is not writable),"
+						" and a dummy fallback directory could not be created in your $HOME."
+						" Whatever the reason, this is really too bad: I can't fix it for you.");
 	}
+	ED = new agh::CExpDesign (dir,
+				  bind( &SExpDesignUI::sb_main_progress_indicator, this,
+					placeholders::_1, placeholders::_2, placeholders::_3));
+	nodestroy_by_cb = false;
+
+	fft_params_welch_window_type_saved	= ED->fft_params.welch_window_type;
+	af_dampen_window_type_saved		= ED->af_dampen_window_type;
+	af_dampen_factor_saved			= ED->af_dampen_factor;
+	mc_params_saved				= ED->mc_params;
+
+	pagesize_item_saved = pagesize_item =
+		figure_pagesize_item();
+	binsize_item_saved = binsize_item =
+		figure_binsize_item();
+
+	populate( true);
 
 	set_wMainWindow_interactive( true);
 }
@@ -246,35 +238,11 @@ aghui::SExpDesignUI::
 	delete ED;
 
 	save_settings();
-	destruct_widgets();
 }
 
 
 
 
-void
-aghui::SExpDesignUI::
-set_wMainWindow_interactive( bool indeed, bool flush)
-{
-	set_cursor_busy( not indeed, (GtkWidget*)wMainWindow);
-	//gtk_widget_set_sensitive( (GtkWidget*)wMainWindow, indeed);
-
-	gtk_widget_set_sensitive( (GtkWidget*)cMsmtProfileParamsContainer, indeed);
-	gtk_widget_set_sensitive( (GtkWidget*)cMeasurements, indeed);
-
-	gtk_widget_set_visible( (GtkWidget*)lTaskSelector2, indeed);
-	gtk_widget_set_visible( gtk_notebook_get_nth_page( tTaskSelector, 1), indeed);
-	gtk_widget_set_visible( (GtkWidget*)lSettings, indeed);
-	gtk_widget_set_sensitive( gtk_notebook_get_nth_page( tDesign, 1), indeed);
-
-	gtk_widget_set_sensitive( (GtkWidget*)iiMainMenu, indeed);
-	gtk_widget_set_sensitive( (GtkWidget*)eMsmtSession, indeed);
-	gtk_widget_set_sensitive( (GtkWidget*)eMsmtChannel, indeed);
-
-	if ( flush )
-		gtk_flush();
-}
-
 
 int
 aghui::SExpDesignUI::
diff --git a/src/ui/expdesign.hh b/src/ui/expdesign.hh
index 2ef577d..7d179ba 100644
--- a/src/ui/expdesign.hh
+++ b/src/ui/expdesign.hh
@@ -19,15 +19,15 @@
 #include <map>
 #include <stdexcept>
 
-#include <gtk/gtk.h>
 #include <cairo/cairo.h>
 
-//#include "../common/misc.hh"
+#include "../common/lang.hh"
 #include "../common/config-validate.hh"
 #include "../model/forward-decls.hh"
 #include "../expdesign/primaries.hh"
 #include "ui.hh"
 #include "forward-decls.hh"
+#include "expdesign-widgets.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
 #  include "config.h"
@@ -38,10 +38,9 @@ using namespace std;
 
 namespace aghui {
 
-// ui structures everything is public, mainly to give access to the
-// bulk of extern "C" GTK callbacks
+class SExpDesignUI
+  : public SExpDesignUIWidgets {
 
-class SExpDesignUI {
 	DELETE_DEFAULT_METHODS(SExpDesignUI);
 
     public:
@@ -289,7 +288,6 @@ class SExpDesignUI {
       // status bar bits
 	void sb_main_progress_indicator( const char*, size_t n, size_t i);
 	void buf_on_main_status_bar();
-	guint	sbMainContextIdGeneral;
 
       // dnd
 	struct SDndIface {
@@ -312,311 +310,12 @@ class SExpDesignUI {
 	int load_settings();
 	int save_settings();
 
-	int construct_widgets();
-	void destruct_widgets();
-
-      // colours
-	enum TColour {
-		night,		day,
-
-		power_mt,	ticks_mt,	bounds,
-		labels_mt,	jinfo,
-
-		score_none,	score_nrem1,	score_nrem2,
-		score_nrem3,	score_nrem4,	score_rem,
-		score_wake,
-		score_invalid,  // has no color chooser
-
-		artifact,
-		annotations,
-		selection,
-
-		labels_sf,	ticks_sf,	profile_psd_sf,	profile_mc_sf,
-		hypnogram,	hypnogram_scoreline,
-		cursor,
-
-		spectrum,	spectrum_axes,	spectrum_grid,
-
-		emg,
-
-		band_delta,	band_theta,	band_alpha,
-		band_beta,	band_gamma,
-
-		swa,		swa_sim,	process_s,
-		paper_mr,
-		labels_mr,
-		ticks_mr,
-	};
-	map<TColour, SManagedColor>
-		CwB;
-
-	static TColour
-	score2colour( sigfile::SPage::TScore s)
-		{
-			return (TColour)((unsigned)s + (unsigned)TColour::score_none);
-		}
-	static TColour
-	band2colour( sigfile::TBand b)
-		{
-			return (TColour)((unsigned)b + (unsigned)TColour::band_delta);
-		}
-
-      // ---- constructibles
-	GtkBuilder
-		*builder;
-
-      // storage
-	GtkListStore
-		*mSessions,
-		*mEEGChannels,
-		*mAllChannels;
-	GtkTreeStore
-		*mGlobalAnnotations,
-		*mSimulations;
-
 	void populate_mSessions();
 	void populate_mChannels();
-	void __reconnect_channels_combo();
-	void __reconnect_sessions_combo();
-	gulong 	wMainWindow_delete_event_cb_handler_id,
-		eMsmtSession_changed_cb_handler_id,
-		eMsmtChannel_changed_cb_handler_id;
 	void populate_mGlobalAnnotations();
 	void __adjust_op_freq_spinbuttons();
-
-	GtkListStore
-		*mScoringPageSize,
-		*mFFTParamsPageSize,
-		*mFFTParamsBinSize,
-		*mFFTParamsWindowType,
-		*mMsmtProfileType;
-	static const auto
-		msimulations_visibility_switch_col = 14,
-		msimulations_modref_col = msimulations_visibility_switch_col + 1;
-	static const auto
-		mannotations_visibility_switch_col = 4,
-		mannotations_ref_col = mannotations_visibility_switch_col + 1;
-	static const char* const mannotations_column_names[];
-
-      // misc
-	PangoFontDescription*
-		monofont;
-
-      // main toplevel
-	GtkWindow
-		*wMainWindow;
-	void
-	set_wMainWindow_interactive( bool indeed, bool flush = true);
-
-	// tabs
-	GtkNotebook
-		*tTaskSelector,
-		*tDesign, *tSimulations,
-		*tSettings;
-	GtkLabel
-		*lTaskSelector1, *lTaskSelector2,
-		*lSettings;
-      // 1. Measurements
-	GtkMenu
-		*iiMainMenu;
-	GtkMenuItem
-		*iExpRefresh, *iExpPurgeComputed, *iExpAnnotations, *iExpClose, *iExpQuit,
-		*iExpBasicSADetectUltradianCycles,
-		*iMontageResetAll,
-		*iMontageNotchNone, *iMontageNotch50Hz, *iMontageNotch60Hz,
-		*iHelpAbout,
-		*iHelpUsage;
-
-	// profile mode & parameters
-	GtkComboBox
-		*eMsmtProfileType;
-	GtkToggleButton
-		*eMsmtProfileAutoscale;
-	GtkScaleButton
-		*eMsmtProfileSmooth;
-	GtkBox	*cMsmtProfileParams1,
-		*cMsmtProfileParams2;
-	GtkSpinButton
-		*eMsmtOpFreqFrom,
-		*eMsmtOpFreqWidth;
-	GtkAdjustment
-		*jMsmtOpFreqFrom,
-		*jMsmtOpFreqWidth;
-	GtkBox	*cMsmtMainToolbar,
-		*cMsmtProfileParamsContainer;
-	GtkLabel
-		*lMsmtPSDInfo,
-		*lMsmtMCInfo;
-
-	// view selectors
-	GtkComboBox
-		*eMsmtChannel,
-		*eMsmtSession;
-
-	// main area
-	GtkVBox
-		*cMeasurements;
-	GtkStatusbar
-		*sbMainStatusBar;
-	// menus
-	GtkMenu
-		*iiSubjectTimeline;
-	GtkMenuItem
-		*iSubjectTimelineScore,
-		*iSubjectTimelineDetectUltradianCycle,
-		*iSubjectTimelineSubjectInfo,
-		*iSubjectTimelineEDFInfo,
-		*iSubjectTimelineSaveAsSVG,
-		*iSubjectTimelineBrowse,
-		*iSubjectTimelineResetMontage;
-
-	// settings
-	GtkSpinButton
-		*eUltradianCycleDetectionAccuracy;
-	GtkComboBox
-		*eFFTParamsWindowType,
-		*eFFTParamsPageSize,
-		*eFFTParamsBinSize,
-		*eArtifDampenWindowType;
-	GtkListStore
-		*mNotchFilter;
-	GtkEntry
-		*eScoreCode[(size_t)sigfile::SPage::TScore::_total];
-	GtkSpinButton
-		*eArtifDampenFactor,
-
-		*eMCParamBandWidth,
-		*eMCParamIIRBackpolate,
-		*eMCParamMCGain,
-
-		*eDAMsmtPPH,
-		*eDAMsmtTLHeight,
-		*eDAPageHeight,
-		*eDAHypnogramHeight,
-		*eDAEMGHeight;
-	GtkAdjustment
-		*jFreqFrom,
-		*jFreqWidth;
-	GtkSpinButton
-		*eBand[(size_t)sigfile::TBand::_total][2];
-	GtkEntry
-		*eBrowseCommand;
-
-	GtkButton
-		*bMainCloseThatSF;
-
-      // 2. Simulations
-	GtkTreeView
-		*tvSimulations;
-	GtkMenuItem
-		*iSimulationsRunBatch,
-		*iSimulationsRunClearAll,
-		*iSimulationsReportGenerate;
-	GtkLabel
-		*lSimulationsProfile,
-		*lSimulationsChannel,
-		*lSimulationsSession;
-
-	// settings
-	GtkSpinButton
-		*eCtlParamAnnlNTries,		*eCtlParamAnnlItersFixedT,
-		*eCtlParamAnnlStepSize,		*eCtlParamAnnlBoltzmannk,
-		*eCtlParamAnnlTInitialMantissa,	*eCtlParamAnnlTInitialExponent,
-		*eCtlParamAnnlDampingMu,	*eCtlParamAnnlTMinMantissa,
-		*eCtlParamAnnlTMinExponent,	*eCtlParamNSWAPpBeforeSimStart,
-		*eCtlParamReqScoredPercent;
-	GtkCheckButton
-		*eCtlParamDBAmendment1,		*eCtlParamDBAmendment2,
-		*eCtlParamAZAmendment1,		*eCtlParamAZAmendment2;
-	GtkLabel
-		*lCtlParamDBAmendment1,		*lCtlParamDBAmendment2,
-		*lCtlParamAZAmendment1,		*lCtlParamAZAmendment2;
-
-	GtkRadioButton
-		*eCtlParamScoreUnscoredAsWake;
-
-	GtkSpinButton
-		*eTunable[agh::ach::TTunable::_basic_tunables][4];
-	GtkAdjustment
-		*jTunable[agh::ach::TTunable::_basic_tunables][4];
-	GtkButton
-		*bSimParamRevertTunables;
-
-      // other toplevels
-	// about
-	GtkDialog
-		*wAbout;
-	GtkNotebook
-		*cAboutTabs;
-
-	// scan log
-	GtkDialog
-		*wScanLog;
-	GtkTextView
-		*tScanLog;
-
-	// edf header
-	GtkDialog
-		*wEDFFileDetails;
-	GtkTextView
-		*lEDFFileDetailsReport;
-	GtkTextBuffer
-		*tEDFFileDetailsReport;
-
-	// edf dnd import
-	GtkDialog
-		*wEdfImport;
-	GtkComboBox
-		*eEdfImportGroup,
-		*eEdfImportSession,
-		*eEdfImportEpisode;
-	GtkEntry
-		*eEdfImportGroupEntry,
-		*eEdfImportSessionEntry,
-		*eEdfImportEpisodeEntry;
-	GtkLabel
-		*lEdfImportSubject,
-		*lEdfImportCaption;
-	GtkTextView
-		*lEdfImportFileInfo;
-	// GtkTextBuffer
-	// 	*tEdfImportDetailsReport;
-	GtkButton
-		*bEdfImportAdmit,
-		*bEdfImportEdfhed,
-		*bEdfImportAttachCopy,
-		*bEdfImportAttachMove;
-
-	// annotations
-	GtkDialog
-		*wGlobalAnnotations;
-	GtkTreeView
-		*tvGlobalAnnotations;
-
-	// subject details
-	GtkDialog
-		*wSubjectDetails;
-	GtkEntry
-		*eSubjectDetailsName,
-		*eSubjectDetailsComment;
-	GtkSpinButton
-		*eSubjectDetailsAge;
-	GtkRadioButton
-		*eSubjectDetailsGenderMale,
-		*eSubjectDetailsGenderFemale;
-
-	// batch setup
-	GtkDialog
-		*wBatchSetup;
-	GtkEntry
-		*eBatchSetupSubjects,
-		*eBatchSetupSessions,
-		*eBatchSetupChannels;
-	GtkSpinButton
-		*eBatchSetupRangeFrom,
-		*eBatchSetupRangeWidth,
-		*eBatchSetupRangeInc,
-		*eBatchSetupRangeSteps;
+	void __reconnect_channels_combo();
+	void __reconnect_sessions_combo();
 };
 
 
diff --git a/src/ui/scoring-facility-artifacts.cc b/src/ui/scoring-facility-artifacts.cc
index 3680eb2..6b3cc1d 100644
--- a/src/ui/scoring-facility-artifacts.cc
+++ b/src/ui/scoring-facility-artifacts.cc
@@ -12,6 +12,7 @@
 
 
 #include "scoring-facility.hh"
+#include "scoring-facility-widgets.hh"
 
 using namespace std;
 using namespace aghui;
@@ -22,27 +23,27 @@ SScoringFacility::get_mc_params_from_SFAD_widgets() const
 {
 	return SChannel::SDetectArtifactsParams {
 		(float)gtk_spin_button_get_value( eSFADScope),
-			(float)gtk_spin_button_get_value( eSFADUpperThr),
-			(float)gtk_spin_button_get_value( eSFADLowerThr),
-			(float)gtk_spin_button_get_value( eSFADF0),
-			(float)gtk_spin_button_get_value( eSFADFc),
-			(float)gtk_spin_button_get_value( eSFADBandwidth),
-			(float)gtk_spin_button_get_value( eSFADMCGain),
-			(float)gtk_spin_button_get_value( eSFADBackpolate),
-
-			gtk_toggle_button_get_active( (GtkToggleButton*)eSFADEstimateE)
+		(float)gtk_spin_button_get_value( eSFADUpperThr),
+		(float)gtk_spin_button_get_value( eSFADLowerThr),
+		(float)gtk_spin_button_get_value( eSFADF0),
+		(float)gtk_spin_button_get_value( eSFADFc),
+		(float)gtk_spin_button_get_value( eSFADBandwidth),
+		(float)gtk_spin_button_get_value( eSFADMCGain),
+		(float)gtk_spin_button_get_value( eSFADBackpolate),
+
+		gtk_toggle_button_get_active( (GtkToggleButton*)eSFADEstimateE)
 			? INFINITY
 			: (float)gtk_spin_button_get_value( eSFADEValue),
 
-			(float)gtk_spin_button_get_value( eSFADHistRangeMin),
-			(float)gtk_spin_button_get_value( eSFADHistRangeMax),
-			(size_t)round(gtk_spin_button_get_value( eSFADHistBins)),
+		(float)gtk_spin_button_get_value( eSFADHistRangeMin),
+		(float)gtk_spin_button_get_value( eSFADHistRangeMax),
+		(size_t)round(gtk_spin_button_get_value( eSFADHistBins)),
 
-			(size_t)round(gtk_spin_button_get_value( eSFADSmoothSide)),
+		(size_t)round(gtk_spin_button_get_value( eSFADSmoothSide)),
 
-			(bool)gtk_toggle_button_get_active( (GtkToggleButton*)eSFADClearOldArtifacts),
-			(bool)gtk_toggle_button_get_active( (GtkToggleButton*)eSFADUseThisRange)
-		};
+		(bool)gtk_toggle_button_get_active( (GtkToggleButton*)eSFADClearOldArtifacts),
+		(bool)gtk_toggle_button_get_active( (GtkToggleButton*)eSFADUseThisRange)
+	};
 }
 
 // eof
diff --git a/src/ui/scoring-facility-channel.cc b/src/ui/scoring-facility-channel.cc
index 3208d59..bdbac83 100644
--- a/src/ui/scoring-facility-channel.cc
+++ b/src/ui/scoring-facility-channel.cc
@@ -432,7 +432,7 @@ aghui::SScoringFacility::SChannel::
 mark_region_as_pattern()
 {
 	_p.find_dialog.load_pattern( *this);
-	gtk_widget_show_all( (GtkWidget*)_p.find_dialog.wPattern);
+	gtk_widget_show_all( (GtkWidget*)_p.wPattern);
 }
 
 
diff --git a/src/ui/scoring-facility-construct.cc b/src/ui/scoring-facility-construct.cc
index ed55764..7083dac 100644
--- a/src/ui/scoring-facility-construct.cc
+++ b/src/ui/scoring-facility-construct.cc
@@ -12,98 +12,108 @@
 
 
 #include "expdesign.hh"
-#include "scoring-facility.hh"
+#include <stdexcept>
+#include "ui.hh"
+#include "scoring-facility-widgets.hh"
 #include "scoring-facility_cb.hh"
 
 using namespace std;
 
 
-int
-aghui::SScoringFacility::
-construct_widgets()
+aghui::SScoringFacilityWidgets::
+SScoringFacilityWidgets (SExpDesignUI& _p)
 {
+	builder = gtk_builder_new();
+	if ( !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/sf.glade", NULL) ) {
+		g_object_unref( (GObject*)builder);
+		throw runtime_error( "Failed to load SF glade resource");
+	}
+	gtk_builder_connect_signals( builder, NULL);
+	//  we do it all mostly ourself, except for some delete-event binding to gtk_true()
+
 	GtkCellRenderer *renderer;
 
-	if ( !(AGH_GBGETOBJ3 (builder, GtkWindow,		wScoringFacility)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkLabel,		lSFHint)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkComboBox,		eSFPageSize)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFCurrentPage)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkAdjustment,		jPageNo)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkLabel,		lSFTotalPages)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		eSFCurrentPos)) ||
+	if ( !(AGH_GBGETOBJ (GtkWindow,		wScoringFacility)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,		lSFHint)) ||
+	     !(AGH_GBGETOBJ (GtkListStore,			mScoringPageSize) ) ||
+	     !(AGH_GBGETOBJ (GtkComboBox,		eSFPageSize)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFCurrentPage)) ||
+	     !(AGH_GBGETOBJ (GtkAdjustment,		jPageNo)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,		lSFTotalPages)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		eSFCurrentPos)) ||
 
-	     !(AGH_GBGETOBJ3 (builder, GtkExpander,		cSFHypnogram)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkHBox,			cSFControlBar)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkBox,			cSFScoringModeContainer)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkBox,			cSFICAModeContainer)) ||
+	     !(AGH_GBGETOBJ (GtkExpander,		cSFHypnogram)) ||
+	     !(AGH_GBGETOBJ (GtkHBox,			cSFControlBar)) ||
+	     !(AGH_GBGETOBJ (GtkBox,			cSFScoringModeContainer)) ||
+	     !(AGH_GBGETOBJ (GtkBox,			cSFICAModeContainer)) ||
 
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFBack)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFForward)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bSFBack)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bSFForward)) ||
 
 	     // 1. scoring
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreClear)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreNREM1)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreNREM2)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreNREM3)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreNREM4)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreREM))   ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreWake))  ||
-	     !(AGH_GBGETOBJ3 (builder, GtkTable,		cSFSleepStageStats)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkLabel,		lSFPercentScored)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkLabel,		lScoreStatsNREMPercent)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkLabel,		lScoreStatsREMPercent)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkLabel,		lScoreStatsWakePercent)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreGotoPrevUnscored)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreGotoNextUnscored)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreGotoPrevArtifact)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bScoreGotoNextArtifact)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkToggleButton,		bSFShowFindDialog)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkToggleButton,		bSFShowPhaseDiffDialog)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkToggleButton,		bSFDrawCrosshair)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFRunICA)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreClear)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreNREM1)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreNREM2)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreNREM3)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreNREM4)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreREM))   ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreWake))  ||
+	     !(AGH_GBGETOBJ (GtkTable,		cSFSleepStageStats)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,		lSFPercentScored)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,		lScoreStatsNREMPercent)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,		lScoreStatsREMPercent)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,		lScoreStatsWakePercent)) ||
+
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreGotoPrevUnscored)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreGotoNextUnscored)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreGotoPrevArtifact)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bScoreGotoNextArtifact)) ||
+
+	     !(AGH_GBGETOBJ (GtkToggleButton,		bSFShowFindDialog)) ||
+	     !(AGH_GBGETOBJ (GtkToggleButton,		bSFShowPhaseDiffDialog)) ||
+	     !(AGH_GBGETOBJ (GtkToggleButton,		bSFDrawCrosshair)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bSFRunICA)) ||
 
 	     // 2. ICA
-	     !(AGH_GBGETOBJ3 (builder, GtkComboBox,		eSFICARemixMode)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkComboBox,		eSFICANonlinearity)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkComboBox,		eSFICAApproach)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkListStore,		mSFICARemixMode)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkListStore,		mSFICANonlinearity)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkListStore,		mSFICAApproach)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckButton,		eSFICAFineTune)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckButton,		eSFICAStabilizationMode)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICAa1)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICAa2)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICAmu)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICAepsilon)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICANofICs)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkAdjustment,		jSFICANofICs)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICAEigVecFirst)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICAEigVecLast)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkAdjustment,		jSFICAEigVecFirst)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkAdjustment,		jSFICAEigVecLast)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICASampleSizePercent)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFICAMaxIterations)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFICATry)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkToggleButton,		bSFICAPreview)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkToggleButton,		bSFICAShowMatrix)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFICAApply)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFICACancel)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkDialog,		wSFICAMatrix)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkTextView,		tSFICAMatrix)) ||
+	     !(AGH_GBGETOBJ (GtkComboBox,		eSFICARemixMode)) ||
+	     !(AGH_GBGETOBJ (GtkComboBox,		eSFICANonlinearity)) ||
+	     !(AGH_GBGETOBJ (GtkComboBox,		eSFICAApproach)) ||
+	     !(AGH_GBGETOBJ (GtkListStore,		mSFICARemixMode)) ||
+	     !(AGH_GBGETOBJ (GtkListStore,		mSFICANonlinearity)) ||
+	     !(AGH_GBGETOBJ (GtkListStore,		mSFICAApproach)) ||
+	     !(AGH_GBGETOBJ (GtkCheckButton,		eSFICAFineTune)) ||
+	     !(AGH_GBGETOBJ (GtkCheckButton,		eSFICAStabilizationMode)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICAa1)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICAa2)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICAmu)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICAepsilon)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICANofICs)) ||
+	     !(AGH_GBGETOBJ (GtkAdjustment,		jSFICANofICs)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICAEigVecFirst)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICAEigVecLast)) ||
+	     !(AGH_GBGETOBJ (GtkAdjustment,		jSFICAEigVecFirst)) ||
+	     !(AGH_GBGETOBJ (GtkAdjustment,		jSFICAEigVecLast)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICASampleSizePercent)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFICAMaxIterations)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bSFICATry)) ||
+	     !(AGH_GBGETOBJ (GtkToggleButton,		bSFICAPreview)) ||
+	     !(AGH_GBGETOBJ (GtkToggleButton,		bSFICAShowMatrix)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bSFICAApply)) ||
+	     !(AGH_GBGETOBJ (GtkButton,		bSFICACancel)) ||
+	     !(AGH_GBGETOBJ (GtkDialog,		wSFICAMatrix)) ||
+	     !(AGH_GBGETOBJ (GtkTextView,		tSFICAMatrix)) ||
 
 	     // rest
-	     !(AGH_GBGETOBJ3 (builder, GtkDrawingArea,		daSFMontage)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkDrawingArea,		daSFHypnogram)) ||
+	     !(AGH_GBGETOBJ (GtkDrawingArea,		daSFMontage)) ||
+	     !(AGH_GBGETOBJ (GtkDrawingArea,		daSFHypnogram)) ||
 
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuToolButton,	bSFAccept)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu,			mSFAccept)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkStatusbar,		sbSF)) )
-		return -1;
+	     !(AGH_GBGETOBJ (GtkMenuToolButton,	bSFAccept)) ||
+	     !(AGH_GBGETOBJ (GtkMenu,			mSFAccept)) ||
+	     !(AGH_GBGETOBJ (GtkStatusbar,		sbSF)) )
+		throw runtime_error ("Failed to contruct SF widgets (1)");
 
-	gtk_combo_box_set_model( eSFPageSize, // reuse the one previously constructed in SExpDesignUI
-				 (GtkTreeModel*)_p.mScoringPageSize);
+	gtk_combo_box_set_model( eSFPageSize,
+				 (GtkTreeModel*)mScoringPageSize);
 	gtk_combo_box_set_id_column( eSFPageSize, 0);
 
 	renderer = gtk_cell_renderer_text_new();
@@ -153,98 +163,98 @@ construct_widgets()
 	sbSFContextIdGeneral = gtk_statusbar_get_context_id( sbSF, "General context");
 
 	// ------- menus
-	if ( !(AGH_GBGETOBJ3 (builder, GtkLabel, 		lSFOverChannel)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu, 		mSFPage)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu, 		mSFICAPage)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu, 		mSFPageSelection)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu, 		mSFPageAnnotation)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu, 		mSFPageHidden)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu, 		mSFPower)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenu, 		mSFScore)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPageShowOriginal)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPageShowProcessed)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPageUseResample)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPageDrawZeroline)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSeparatorMenuItem,	iSFPageProfileItemsSeparator)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem, 	iSFPageDrawPSDProfile)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem, 	iSFPageDrawPSDSpectrum)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem, 	iSFPageDrawMCProfile)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem, 	iSFPageDrawEMGProfile)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageFilter)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageSaveChannelAsSVG)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageSaveMontageAsSVG)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageExportSignal)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageUseThisScale)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageDetectArtifacts)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageClearArtifacts)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageHide)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem, 		iSFPageHidden)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem, 		iSFPageSpaceEvenly)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem, 		iSFPageLocateSelection)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageAnnotationSeparator)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageAnnotationDelete)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageAnnotationEdit)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageSelectionMarkArtifact)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageSelectionClearArtifact)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageSelectionFindPattern)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPageSelectionAnnotate)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPageSelectionDrawCourse)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPageSelectionDrawEnvelope)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPageSelectionDrawDzxdf)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPowerExportRange)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPowerExportAll)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPowerSmooth)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPowerDrawBands)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFPowerUseThisScale)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckMenuItem,	iSFPowerAutoscale)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFScoreAssist)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFScoreImport)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFScoreExport)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFScoreClear)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkMenuItem,		iSFAcceptAndTakeNext)) )
-		return -1;
+	if ( !(AGH_GBGETOBJ (GtkLabel, 		lSFOverChannel)) ||
+	     !(AGH_GBGETOBJ (GtkMenu, 		mSFPage)) ||
+	     !(AGH_GBGETOBJ (GtkMenu, 		mSFICAPage)) ||
+	     !(AGH_GBGETOBJ (GtkMenu, 		mSFPageSelection)) ||
+	     !(AGH_GBGETOBJ (GtkMenu, 		mSFPageAnnotation)) ||
+	     !(AGH_GBGETOBJ (GtkMenu, 		mSFPageHidden)) ||
+	     !(AGH_GBGETOBJ (GtkMenu, 		mSFPower)) ||
+	     !(AGH_GBGETOBJ (GtkMenu, 		mSFScore)) ||
+
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPageShowOriginal)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPageShowProcessed)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPageUseResample)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPageDrawZeroline)) ||
+	     !(AGH_GBGETOBJ (GtkSeparatorMenuItem,	iSFPageProfileItemsSeparator)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem, 		iSFPageDrawPSDProfile)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem, 		iSFPageDrawPSDSpectrum)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem, 		iSFPageDrawMCProfile)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem, 		iSFPageDrawEMGProfile)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageFilter)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageSaveChannelAsSVG)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageSaveMontageAsSVG)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageExportSignal)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageUseThisScale)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageDetectArtifacts)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageClearArtifacts)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageHide)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem, 		iSFPageHidden)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem, 		iSFPageSpaceEvenly)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem, 		iSFPageLocateSelection)) ||
+
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageAnnotationSeparator)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageAnnotationDelete)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageAnnotationEdit)) ||
+
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageSelectionMarkArtifact)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageSelectionClearArtifact)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageSelectionFindPattern)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPageSelectionAnnotate)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPageSelectionDrawCourse)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPageSelectionDrawEnvelope)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPageSelectionDrawDzxdf)) ||
+
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPowerExportRange)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPowerExportAll)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPowerSmooth)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPowerDrawBands)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFPowerUseThisScale)) ||
+	     !(AGH_GBGETOBJ (GtkCheckMenuItem,		iSFPowerAutoscale)) ||
+
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFScoreAssist)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFScoreImport)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFScoreExport)) ||
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFScoreClear)) ||
+
+	     !(AGH_GBGETOBJ (GtkMenuItem,		iSFAcceptAndTakeNext)) )
+		throw runtime_error ("Failed to contruct SF widgets (2)");
 
 	gtk_menu_tool_button_set_menu( bSFAccept, (GtkWidget*)mSFAccept);
 
 	gtk_menu_item_set_submenu( iSFPageHidden, (GtkWidget*)mSFPageHidden);
 
 	// petty dialogs
-	if ( !(AGH_GBGETOBJ3 (builder, GtkDialog,		wAnnotationLabel)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkEntry,		eAnnotationLabel)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkDialog,		wAnnotationSelector)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkComboBox,		eAnnotationSelectorWhich)) ||
-
-	     !(AGH_GBGETOBJ3 (builder, GtkDialog,		wSFArtifactDetectionSetup)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADScope)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADUpperThr)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADLowerThr)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADF0)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADFc)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADBandwidth)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADMCGain)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADBackpolate)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADEValue)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADHistRangeMin)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADHistRangeMax)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADHistBins)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkSpinButton,		eSFADSmoothSide)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckButton,		eSFADClearOldArtifacts)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkCheckButton,		eSFADEstimateE)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkRadioButton,		eSFADUseThisRange)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkRadioButton,		eSFADUseComputedRange)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkTable,		cSFADWhenEstimateEOn)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkTable,		cSFADWhenEstimateEOff)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkLabel,		lSFADInfo)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkToggleButton,		bSFADPreview)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFADApply)) ||
-	     !(AGH_GBGETOBJ3 (builder, GtkButton,		bSFADCancel)) )
-		return -1;
+	if ( !(AGH_GBGETOBJ (GtkDialog,			wAnnotationLabel)) ||
+	     !(AGH_GBGETOBJ (GtkEntry,			eAnnotationLabel)) ||
+	     !(AGH_GBGETOBJ (GtkDialog,			wAnnotationSelector)) ||
+	     !(AGH_GBGETOBJ (GtkComboBox,		eAnnotationSelectorWhich)) ||
+
+	     !(AGH_GBGETOBJ (GtkDialog,			wSFArtifactDetectionSetup)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADScope)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADUpperThr)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADLowerThr)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADF0)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADFc)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADBandwidth)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADMCGain)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADBackpolate)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADEValue)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADHistRangeMin)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADHistRangeMax)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADHistBins)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,		eSFADSmoothSide)) ||
+	     !(AGH_GBGETOBJ (GtkCheckButton,		eSFADClearOldArtifacts)) ||
+	     !(AGH_GBGETOBJ (GtkCheckButton,		eSFADEstimateE)) ||
+	     !(AGH_GBGETOBJ (GtkRadioButton,		eSFADUseThisRange)) ||
+	     !(AGH_GBGETOBJ (GtkRadioButton,		eSFADUseComputedRange)) ||
+	     !(AGH_GBGETOBJ (GtkTable,			cSFADWhenEstimateEOn)) ||
+	     !(AGH_GBGETOBJ (GtkTable,			cSFADWhenEstimateEOff)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,			lSFADInfo)) ||
+	     !(AGH_GBGETOBJ (GtkToggleButton,		bSFADPreview)) ||
+	     !(AGH_GBGETOBJ (GtkButton,			bSFADApply)) ||
+	     !(AGH_GBGETOBJ (GtkButton,			bSFADCancel)) )
+		throw runtime_error ("Failed to contruct SF widgets (3)");
 
 	mAnnotationsAtCursor = gtk_list_store_new(1, G_TYPE_STRING);
 	gtk_combo_box_set_model( eAnnotationSelectorWhich,
@@ -580,46 +590,36 @@ construct_widgets()
 	g_signal_connect( bSFADCancel, "clicked",
 			  (GCallback)bSFADCancel_clicked_cb,
 			  this);
-	return 0;
-}
-
 
-
-
-int
-aghui::SScoringFacility::SFindDialog::
-construct_widgets()
-{
+      // aghui::SScoringFacility::SFindDialog::
 	mPatterns =
 		gtk_list_store_new( 1, G_TYPE_STRING);
 
-	GtkCellRenderer *renderer;
-
-	if ( !AGH_GBGETOBJ3 (_p.builder, GtkDialog,		wPattern) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkDrawingArea,	daPatternSelection) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkScrolledWindow,	vpPatternSelection) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkButton,		bPatternFindPrevious) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkButton,		bPatternFindNext) ||
-//	     !AGH_GBGETOBJ3 (_p.builder, GtkButton,		bPatternDismiss) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkButton,		bPatternSave) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkButton,		bPatternDiscard) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternEnvTightness) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternFilterOrder) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternFilterCutoff) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternDZCDFStep) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternDZCDFSigma) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternDZCDFSmooth) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternParameterA) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternParameterB) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,		ePatternParameterC) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkHBox,		cPatternLabelBox) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkLabel,		lPatternSimilarity) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkComboBox,		ePatternList) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkComboBox,		ePatternChannel) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkDialog,		wPatternName) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkEntry,		ePatternNameName) ||
-	     !AGH_GBGETOBJ3 (_p.builder, GtkCheckButton,	ePatternNameSaveGlobally) )
-		return -1;
+	if ( !AGH_GBGETOBJ (GtkDialog,		wPattern) ||
+	     !AGH_GBGETOBJ (GtkDrawingArea,		daPatternSelection) ||
+	     !AGH_GBGETOBJ (GtkScrolledWindow,	vpPatternSelection) ||
+	     !AGH_GBGETOBJ (GtkButton,		bPatternFindPrevious) ||
+	     !AGH_GBGETOBJ (GtkButton,		bPatternFindNext) ||
+//	     !AGH_GBGETOBJ (GtkButton,		bPatternDismiss) ||
+	     !AGH_GBGETOBJ (GtkButton,		bPatternSave) ||
+	     !AGH_GBGETOBJ (GtkButton,		bPatternDiscard) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternEnvTightness) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternFilterOrder) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternFilterCutoff) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternDZCDFStep) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternDZCDFSigma) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternDZCDFSmooth) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternParameterA) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternParameterB) ||
+	     !AGH_GBGETOBJ (GtkSpinButton,		ePatternParameterC) ||
+	     !AGH_GBGETOBJ (GtkHBox,			cPatternLabelBox) ||
+	     !AGH_GBGETOBJ (GtkLabel,			lPatternSimilarity) ||
+	     !AGH_GBGETOBJ (GtkComboBox,		ePatternList) ||
+	     !AGH_GBGETOBJ (GtkComboBox,		ePatternChannel) ||
+	     !AGH_GBGETOBJ (GtkDialog,		wPatternName) ||
+	     !AGH_GBGETOBJ (GtkEntry,			ePatternNameName) ||
+	     !AGH_GBGETOBJ (GtkCheckButton,		ePatternNameSaveGlobally) )
+		throw runtime_error ("Failed to contruct SF widgets (4)");
 
 	gtk_combo_box_set_model( ePatternList,
 				 (GtkTreeModel*)mPatterns);
@@ -635,7 +635,7 @@ construct_widgets()
 				  this);
 
 	gtk_combo_box_set_model( ePatternChannel,
-				 (GtkTreeModel*)_p._p.mAllChannels);
+				 (GtkTreeModel*)_p.mAllChannels);
 	gtk_combo_box_set_id_column( ePatternChannel, 0);
 	renderer = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start( (GtkCellLayout*)ePatternChannel, renderer, FALSE);
@@ -701,28 +701,21 @@ construct_widgets()
 	g_signal_connect( wPattern, "hide",
 			  G_CALLBACK (wPattern_hide_cb),
 			  this);
-	return 0;
-}
 
 
-
-int
-aghui::SScoringFacility::SFiltersDialog::
-construct_widgets()
-{
-	GtkCellRenderer *renderer;
+	// aghui::SScoringFacility::SFiltersDialog::
 
       // ------- wFilter
-	if ( !(AGH_GBGETOBJ3 (_p.builder, GtkDialog,		wFilters)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkLabel,		lFilterCaption)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,	eFilterLowPassCutoff)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,	eFilterHighPassCutoff)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,	eFilterLowPassOrder)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkSpinButton,	eFilterHighPassOrder)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkComboBox,		eFilterNotchFilter)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkListStore,		mFilterNotchFilter)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkButton,		bFilterOK)) )
-		return -1;
+	if ( !(AGH_GBGETOBJ (GtkDialog,	wFilters)) ||
+	     !(AGH_GBGETOBJ (GtkLabel,	lFilterCaption)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,	eFilterLowPassCutoff)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,	eFilterHighPassCutoff)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,	eFilterLowPassOrder)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton,	eFilterHighPassOrder)) ||
+	     !(AGH_GBGETOBJ (GtkComboBox,	eFilterNotchFilter)) ||
+	     !(AGH_GBGETOBJ (GtkListStore,	mFilterNotchFilter)) ||
+	     !(AGH_GBGETOBJ (GtkButton,	bFilterOK)) )
+		throw runtime_error ("Failed to contruct SF widgets (5)");
 
 	gtk_combo_box_set_model( eFilterNotchFilter,
 				 (GtkTreeModel*)mFilterNotchFilter);
@@ -739,31 +732,22 @@ construct_widgets()
 	g_signal_connect( (GObject*)eFilterLowPassCutoff, "value-changed",
 			  (GCallback)eFilterLowPassCutoff_value_changed_cb,
 			  this);
-	return 0;
-}
-
-
-
 
 
-int
-aghui::SScoringFacility::SPhasediffDialog::
-construct_widgets()
-{
-	GtkCellRenderer *renderer;
+	// aghui::SScoringFacility::SPhasediffDialog::
 
       // ------- wPhaseDiff
-	if ( !(AGH_GBGETOBJ3 (_p.builder, GtkDialog, wSFPD)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkDrawingArea, daSFPD)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkComboBox, eSFPDChannelA)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkComboBox, eSFPDChannelB)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkSpinButton, eSFPDFreqFrom)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkSpinButton, eSFPDBandwidth)) ||
-	     !(AGH_GBGETOBJ3 (_p.builder, GtkScaleButton, eSFPDSmooth)) )
-		return -1;
+	if ( !(AGH_GBGETOBJ (GtkDialog, wSFPD)) ||
+	     !(AGH_GBGETOBJ (GtkDrawingArea, daSFPD)) ||
+	     !(AGH_GBGETOBJ (GtkComboBox, eSFPDChannelA)) ||
+	     !(AGH_GBGETOBJ (GtkComboBox, eSFPDChannelB)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton, eSFPDFreqFrom)) ||
+	     !(AGH_GBGETOBJ (GtkSpinButton, eSFPDBandwidth)) ||
+	     !(AGH_GBGETOBJ (GtkScaleButton, eSFPDSmooth)) )
+		throw runtime_error ("Failed to contruct SF widgets (6)");
 
 	gtk_combo_box_set_model( eSFPDChannelA,
-				 (GtkTreeModel*)_p._p.mEEGChannels);
+				 (GtkTreeModel*)_p.mEEGChannels);
 	renderer = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start( (GtkCellLayout*)eSFPDChannelA, renderer, FALSE);
 	gtk_cell_layout_set_attributes( (GtkCellLayout*)eSFPDChannelA, renderer,
@@ -775,7 +759,7 @@ construct_widgets()
 				  this);
 
 	gtk_combo_box_set_model( eSFPDChannelB,
-				 (GtkTreeModel*)_p._p.mEEGChannels);
+				 (GtkTreeModel*)_p.mEEGChannels);
 	renderer = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start( (GtkCellLayout*)eSFPDChannelB, renderer, FALSE);
 	gtk_cell_layout_set_attributes( (GtkCellLayout*)eSFPDChannelB, renderer,
@@ -813,12 +797,17 @@ construct_widgets()
 	g_signal_connect( wSFPD, "hide",
 			  G_CALLBACK (wSFPD_hide_cb),
 			  this);
-	return 0;
 }
 
 
 
 
-
+aghui::SScoringFacilityWidgets::
+~SScoringFacilityWidgets ()
+{
+	// destroy widgets
+	gtk_widget_destroy( (GtkWidget*)wScoringFacility);
+	g_object_unref( (GObject*)builder);
+}
 
 // eof
diff --git a/src/ui/scoring-facility-filter_cb.cc b/src/ui/scoring-facility-filter_cb.cc
index 92f2732..0667d8a 100644
--- a/src/ui/scoring-facility-filter_cb.cc
+++ b/src/ui/scoring-facility-filter_cb.cc
@@ -27,32 +27,32 @@ iSFPageFilter_activate_cb( GtkMenuItem *menuitem, gpointer userdata)
 	auto& SF = *(SScoringFacility*)userdata;
 	auto& FD =  SF.filters_dialog;
 	auto& H  = *SF.using_channel;
-	gtk_spin_button_set_value( FD.eFilterLowPassCutoff,
+	gtk_spin_button_set_value( FD._p.eFilterLowPassCutoff,
 				   SF.using_channel->filters.low_pass_cutoff);
-	gtk_spin_button_set_value( FD.eFilterLowPassOrder,
+	gtk_spin_button_set_value( FD._p.eFilterLowPassOrder,
 				   SF.using_channel->filters.low_pass_order);
-	gtk_spin_button_set_value( FD.eFilterHighPassCutoff,
+	gtk_spin_button_set_value( FD._p.eFilterHighPassCutoff,
 				   SF.using_channel->filters.high_pass_cutoff);
-	gtk_spin_button_set_value( FD.eFilterHighPassOrder,
+	gtk_spin_button_set_value( FD._p.eFilterHighPassOrder,
 				   SF.using_channel->filters.high_pass_order);
-	gtk_combo_box_set_active( FD.eFilterNotchFilter,
+	gtk_combo_box_set_active( FD._p.eFilterNotchFilter,
 				  (int)SF.using_channel->filters.notch_filter);
 
 	snprintf_buf( "<big>Filters for channel <b>%s</b></big>", SF.using_channel->name);
-	gtk_label_set_markup( FD.lFilterCaption,
+	gtk_label_set_markup( FD._p.lFilterCaption,
 			      __buf__);
 
-	if ( gtk_dialog_run( FD.wFilters) == GTK_RESPONSE_OK ) {
+	if ( gtk_dialog_run( FD._p.wFilters) == GTK_RESPONSE_OK ) {
 		H.filters.high_pass_cutoff
-			= roundf( gtk_spin_button_get_value( FD.eFilterHighPassCutoff)*10) / 10;
+			= roundf( gtk_spin_button_get_value( FD._p.eFilterHighPassCutoff)*10) / 10;
 		H.filters.low_pass_cutoff
-			= roundf( gtk_spin_button_get_value( FD.eFilterLowPassCutoff)*10) / 10;
+			= roundf( gtk_spin_button_get_value( FD._p.eFilterLowPassCutoff)*10) / 10;
 		H.filters.high_pass_order
-			= roundf( gtk_spin_button_get_value( FD.eFilterHighPassOrder)*10) / 10;
+			= roundf( gtk_spin_button_get_value( FD._p.eFilterHighPassOrder)*10) / 10;
 		H.filters.low_pass_order
-			= roundf( gtk_spin_button_get_value( FD.eFilterLowPassOrder)*10) / 10;
+			= roundf( gtk_spin_button_get_value( FD._p.eFilterLowPassOrder)*10) / 10;
 		H.filters.notch_filter =
-			(sigfile::SFilterPack::TNotchFilter)gtk_combo_box_get_active( FD.eFilterNotchFilter);
+			(sigfile::SFilterPack::TNotchFilter)gtk_combo_box_get_active( FD._p.eFilterNotchFilter);
 
 		SF.using_channel->get_signal_filtered();
 
@@ -76,8 +76,8 @@ eFilterHighPassCutoff_value_changed_cb( GtkSpinButton *spinbutton,
 					gpointer       userdata)
 {
 	auto& FD = *(SScoringFacility::SFiltersDialog*)userdata;
-	double other_freq = gtk_spin_button_get_value( FD.eFilterLowPassCutoff);
-	gtk_widget_set_sensitive( (GtkWidget*)FD.bFilterOK,
+	double other_freq = gtk_spin_button_get_value( FD._p.eFilterLowPassCutoff);
+	gtk_widget_set_sensitive( (GtkWidget*)FD._p.bFilterOK,
 				  fdim( other_freq, 0.) < 1e-5 || gtk_spin_button_get_value( spinbutton) < other_freq);
 }
 
@@ -86,8 +86,8 @@ eFilterLowPassCutoff_value_changed_cb( GtkSpinButton *spinbutton,
 				       gpointer       userdata)
 {
 	auto& FD = *(SScoringFacility::SFiltersDialog*)userdata;
-	gdouble other_freq = gtk_spin_button_get_value( FD.eFilterHighPassCutoff);
-	gtk_widget_set_sensitive( (GtkWidget*)FD.bFilterOK,
+	gdouble other_freq = gtk_spin_button_get_value( FD._p.eFilterHighPassCutoff);
+	gtk_widget_set_sensitive( (GtkWidget*)FD._p.bFilterOK,
 				  fdim( other_freq, 0.) < 1e-5 || gtk_spin_button_get_value( spinbutton) > other_freq);
 }
 
diff --git a/src/ui/scoring-facility-ica.cc b/src/ui/scoring-facility-ica.cc
index 2641c14..6661e05 100644
--- a/src/ui/scoring-facility-ica.cc
+++ b/src/ui/scoring-facility-ica.cc
@@ -24,7 +24,8 @@ const char
 	*aghui::SScoringFacility::ica_unmapped_menu_item_label = "(not mapped)";
 
 int
-aghui::SScoringFacility::setup_ica()
+aghui::SScoringFacility::
+setup_ica()
 {
 	if ( ica )
 		delete ica;
@@ -64,10 +65,13 @@ aghui::SScoringFacility::setup_ica()
 		src.emplace_back(
 			bind (&sigfile::CSource::get_signal_filtered<int>, &H.crecording.F(), H.h()));
 	}
+	FAFA;
+	printf( "checking_sr * pagesize() * total_pages(): %zu, %zu, %zu\n", checking_sr, pagesize(), total_pages());
 	ica = new ica::CFastICA (src, checking_sr * pagesize() * total_pages());
 
       // initialize
 	// has no independent default
+	FAFA;
 	gtk_spin_button_set_value( eSFICANofICs, channels.size());
 	gtk_adjustment_set_upper( jSFICANofICs, channels.size());
 	gtk_spin_button_set_value( eSFICAEigVecFirst, 1);
@@ -214,7 +218,8 @@ remix_ics()
 }
 
 int
-aghui::SScoringFacility::restore_ics()
+aghui::SScoringFacility::
+restore_ics()
 {
 	if ( ica == NULL )
 		return 1;
@@ -235,7 +240,8 @@ aghui::SScoringFacility::restore_ics()
 
 
 int
-aghui::SScoringFacility::apply_remix( bool do_backup)
+aghui::SScoringFacility::
+apply_remix( bool do_backup)
 {
 	if ( ica == nullptr )
 		return 1;
@@ -282,7 +288,8 @@ aghui::SScoringFacility::apply_remix( bool do_backup)
 
 int
 __attribute__ ((pure))
-aghui::SScoringFacility::ic_near( double y) const
+aghui::SScoringFacility::
+ic_near( double y) const
 {
 	int nearest = INT_MAX, thisd;
 	int nearest_h = 0;
@@ -307,7 +314,8 @@ aghui::SScoringFacility::ic_near( double y) const
 
 int
 __attribute__ ((pure))
-aghui::SScoringFacility::ic_of( const SChannel* ch) const
+aghui::SScoringFacility::
+ic_of( const SChannel* ch) const
 {
 	int h = 0;
 	for ( auto &H : channels ) {
diff --git a/src/ui/scoring-facility-ica_cb.cc b/src/ui/scoring-facility-ica_cb.cc
index b85dc50..a52bf43 100644
--- a/src/ui/scoring-facility-ica_cb.cc
+++ b/src/ui/scoring-facility-ica_cb.cc
@@ -13,6 +13,7 @@
 
 #include "misc.hh"
 #include "scoring-facility.hh"
+#include "scoring-facility-widgets.hh"
 
 using namespace std;
 using namespace aghui;
@@ -25,11 +26,14 @@ void
 bSFRunICA_clicked_cb( GtkButton *button, gpointer userdata)
 {
 	auto& SF = *(SScoringFacility*)userdata;
+	FAFA;
 	if ( SF.setup_ica() == 0 ) {
+	FAFA;
 		SF.mode = aghui::SScoringFacility::TMode::showing_ics;
 		gtk_widget_set_visible( (GtkWidget*)SF.cSFScoringModeContainer, FALSE);
 		gtk_widget_set_visible( (GtkWidget*)SF.cSFICAModeContainer, TRUE);
 
+	FAFA;
 		gtk_widget_set_sensitive( (GtkWidget*)SF.bSFICATry, TRUE);
 		gtk_widget_set_sensitive( (GtkWidget*)SF.bSFICAShowMatrix, FALSE);
 		gtk_widget_set_sensitive( (GtkWidget*)SF.bSFICAPreview, FALSE);
@@ -37,6 +41,7 @@ bSFRunICA_clicked_cb( GtkButton *button, gpointer userdata)
 
 		gtk_widget_set_sensitive( (GtkWidget*)SF.bSFAccept, FALSE);
 		SF.set_tooltip( aghui::SScoringFacility::TTipIdx::ica_mode);
+	FAFA;
 		SF.queue_redraw_all();
 	}
 }
diff --git a/src/ui/scoring-facility-patterns.cc b/src/ui/scoring-facility-patterns.cc
index 3aa6f2c..d6b8653 100644
--- a/src/ui/scoring-facility-patterns.cc
+++ b/src/ui/scoring-facility-patterns.cc
@@ -55,11 +55,11 @@ void
 aghui::SScoringFacility::SFindDialog::
 set_pattern_da_width( int width)
 {
-	g_object_set( (GObject*)daPatternSelection,
+	g_object_set( (GObject*)_p.daPatternSelection,
 		      "width-request", da_wd = width,
 		      "height-request", da_ht,
 		      NULL);
-	g_object_set( (GObject*)vpPatternSelection,
+	g_object_set( (GObject*)_p.vpPatternSelection,
 		      "width-request", min( width+5, 600),
 		      "height-request", da_ht + 30,
 		      NULL);
@@ -233,9 +233,9 @@ load_pattern( SScoringFacility::SChannel& field)
 
 	preselect_channel( field.name);
 	preselect_entry( NULL, 0);
-	gtk_label_set_markup( lPatternSimilarity, "");
+	gtk_label_set_markup( _p.lPatternSimilarity, "");
 
-	gtk_widget_queue_draw( (GtkWidget*)daPatternSelection);
+	gtk_widget_queue_draw( (GtkWidget*)_p.daPatternSelection);
 }
 
 
@@ -266,7 +266,7 @@ load_pattern( const char *label, bool do_globally)
 			if ( samplerate != field_channel->samplerate() ) {
 				snprintf_buf( "Loaded pattern has samplerate different from the current samplerate (%zu vs %zu)",
 					      samplerate, field_channel->samplerate());
-				pop_ok_message( (GtkWindow*)wPattern, __buf__);
+				pop_ok_message( (GtkWindow*)_p.wPattern, __buf__);
 			}
 			pattern.resize( full_sample);
 			for ( size_t i = 0; i < full_sample; ++i ) {
@@ -382,16 +382,16 @@ void
 aghui::SScoringFacility::SFindDialog::
 acquire_parameters()
 {
-	params.env_tightness = gtk_spin_button_get_value( ePatternEnvTightness);
-	params.bwf_order     = gtk_spin_button_get_value( ePatternFilterOrder);
-	params.bwf_cutoff    = gtk_spin_button_get_value( ePatternFilterCutoff);
-	params.dzcdf_step    = gtk_spin_button_get_value( ePatternDZCDFStep);
-	params.dzcdf_sigma   = gtk_spin_button_get_value( ePatternDZCDFSigma);
-	params.dzcdf_smooth  = gtk_spin_button_get_value( ePatternDZCDFSmooth);
+	params.env_tightness = gtk_spin_button_get_value( _p.ePatternEnvTightness);
+	params.bwf_order     = gtk_spin_button_get_value( _p.ePatternFilterOrder);
+	params.bwf_cutoff    = gtk_spin_button_get_value( _p.ePatternFilterCutoff);
+	params.dzcdf_step    = gtk_spin_button_get_value( _p.ePatternDZCDFStep);
+	params.dzcdf_sigma   = gtk_spin_button_get_value( _p.ePatternDZCDFSigma);
+	params.dzcdf_smooth  = gtk_spin_button_get_value( _p.ePatternDZCDFSmooth);
 
-	tolerance_a   = gtk_spin_button_get_value( ePatternParameterA);
-	tolerance_b   = gtk_spin_button_get_value( ePatternParameterB);
-	tolerance_c   = gtk_spin_button_get_value( ePatternParameterC);
+	tolerance_a   = gtk_spin_button_get_value( _p.ePatternParameterA);
+	tolerance_b   = gtk_spin_button_get_value( _p.ePatternParameterB);
+	tolerance_c   = gtk_spin_button_get_value( _p.ePatternParameterC);
 
 	// field_channel is set immediately in the ePatternChannel_changed_cb()
 }
@@ -400,26 +400,26 @@ void
 aghui::SScoringFacility::SFindDialog::
 update_displayed_parameters()
 {
-	gtk_spin_button_set_value( ePatternEnvTightness, params.env_tightness);
-	gtk_spin_button_set_value( ePatternFilterCutoff, params.bwf_cutoff   );
-	gtk_spin_button_set_value( ePatternFilterOrder,  params.bwf_order    );
-	gtk_spin_button_set_value( ePatternDZCDFStep,    params.dzcdf_step   );
-	gtk_spin_button_set_value( ePatternDZCDFSigma,   params.dzcdf_sigma  );
-	gtk_spin_button_set_value( ePatternDZCDFSmooth,  params.dzcdf_smooth );
-
-	gtk_spin_button_set_value( ePatternParameterA,	 tolerance_a  );
-	gtk_spin_button_set_value( ePatternParameterB,	 tolerance_b  );
-	gtk_spin_button_set_value( ePatternParameterC,	 tolerance_c  );
+	gtk_spin_button_set_value( _p.ePatternEnvTightness, params.env_tightness);
+	gtk_spin_button_set_value( _p.ePatternFilterCutoff, params.bwf_cutoff   );
+	gtk_spin_button_set_value( _p.ePatternFilterOrder,  params.bwf_order    );
+	gtk_spin_button_set_value( _p.ePatternDZCDFStep,    params.dzcdf_step   );
+	gtk_spin_button_set_value( _p.ePatternDZCDFSigma,   params.dzcdf_sigma  );
+	gtk_spin_button_set_value( _p.ePatternDZCDFSmooth,  params.dzcdf_smooth );
+
+	gtk_spin_button_set_value( _p.ePatternParameterA,	 tolerance_a  );
+	gtk_spin_button_set_value( _p.ePatternParameterB,	 tolerance_b  );
+	gtk_spin_button_set_value( _p.ePatternParameterC,	 tolerance_c  );
 }
 
 void
 aghui::SScoringFacility::SFindDialog::
 enable_controls( bool indeed)
 {
-	gtk_widget_set_sensitive( (GtkWidget*)bPatternFindNext, (gboolean)indeed);
-	gtk_widget_set_sensitive( (GtkWidget*)bPatternFindPrevious, (gboolean)indeed);
-	gtk_widget_set_sensitive( (GtkWidget*)bPatternSave, (gboolean)indeed);
-	gtk_widget_set_sensitive( (GtkWidget*)bPatternDiscard, (gboolean)indeed);
+	gtk_widget_set_sensitive( (GtkWidget*)_p.bPatternFindNext, (gboolean)indeed);
+	gtk_widget_set_sensitive( (GtkWidget*)_p.bPatternFindPrevious, (gboolean)indeed);
+	gtk_widget_set_sensitive( (GtkWidget*)_p.bPatternSave, (gboolean)indeed);
+	gtk_widget_set_sensitive( (GtkWidget*)_p.bPatternDiscard, (gboolean)indeed);
 }
 
 
@@ -441,8 +441,8 @@ const char
 void
 aghui::SScoringFacility::SFindDialog::enumerate_patterns_to_combo()
 {
-	g_signal_handler_block( ePatternList, ePatternList_changed_cb_handler_id);
-	gtk_list_store_clear( mPatterns);
+	g_signal_handler_block( _p.ePatternList, _p.ePatternList_changed_cb_handler_id);
+	gtk_list_store_clear( _p.mPatterns);
 
 	GtkTreeIter iter;
 
@@ -454,8 +454,8 @@ aghui::SScoringFacility::SFindDialog::enumerate_patterns_to_combo()
 	if ( n >= 0 ) {
 		for ( int cnt = 0; cnt < n; ++cnt ) {
 			snprintf_buf( "%s%s", globally_marker, eps[cnt]->d_name);
-			gtk_list_store_append( mPatterns, &iter);
-			gtk_list_store_set( mPatterns, &iter,
+			gtk_list_store_append( _p.mPatterns, &iter);
+			gtk_list_store_set( _p.mPatterns, &iter,
 					    0, __buf__,
 					    -1);
 			free( eps[cnt]);
@@ -468,16 +468,16 @@ aghui::SScoringFacility::SFindDialog::enumerate_patterns_to_combo()
 //	printf( "n = %d in %s\n", n, __buf__);
 	if ( n >= 0 ) {
 		for ( int cnt = 0; cnt < n; ++cnt ) {
-			gtk_list_store_append( mPatterns, &iter);
-			gtk_list_store_set( mPatterns, &iter,
+			gtk_list_store_append( _p.mPatterns, &iter);
+			gtk_list_store_set( _p.mPatterns, &iter,
 					    0, eps[cnt]->d_name,
 					    -1);
 			free( eps[cnt]);
 		}
 		free( (void*)eps);
 	}
-	gtk_combo_box_set_active_iter( ePatternList, NULL);
-	g_signal_handler_unblock( ePatternList, ePatternList_changed_cb_handler_id);
+	gtk_combo_box_set_active_iter( _p.ePatternList, NULL);
+	g_signal_handler_unblock( _p.ePatternList, _p.ePatternList_changed_cb_handler_id);
 }
 
 
@@ -486,26 +486,26 @@ void
 aghui::SScoringFacility::SFindDialog::preselect_entry( const char *label, bool do_globally)
 {
 	if ( label == NULL ) {
-		gtk_combo_box_set_active_iter( ePatternList, NULL);
+		gtk_combo_box_set_active_iter( _p.ePatternList, NULL);
 		return;
 	}
 
 	GtkTreeIter iter;
 	gboolean valid;
-	valid = gtk_tree_model_get_iter_first( (GtkTreeModel*)mPatterns, &iter);
+	valid = gtk_tree_model_get_iter_first( (GtkTreeModel*)_p.mPatterns, &iter);
 	while ( valid ) {
 		char *entry;
-		gtk_tree_model_get( (GtkTreeModel*)mPatterns, &iter,
+		gtk_tree_model_get( (GtkTreeModel*)_p.mPatterns, &iter,
 				    0, &entry,
 				    -1);
 		if ( (!do_globally && strcmp( entry, label) == 0) ||
 		     (do_globally && (strlen( entry) > strlen( globally_marker) && strcmp( entry+strlen(globally_marker), label) == 0)) ) {
-			gtk_combo_box_set_active_iter( ePatternList, &iter);
+			gtk_combo_box_set_active_iter( _p.ePatternList, &iter);
 			free( entry);
 			return;
 		}
 		free( entry);
-		valid = gtk_tree_model_iter_next( (GtkTreeModel*)mPatterns, &iter);
+		valid = gtk_tree_model_iter_next( (GtkTreeModel*)_p.mPatterns, &iter);
 	}
 }
 
@@ -513,11 +513,11 @@ void
 aghui::SScoringFacility::SFindDialog::preselect_channel( const char *ch)
 {
 	if ( ch == NULL ) {
-		gtk_combo_box_set_active_iter( ePatternChannel, NULL);
+		gtk_combo_box_set_active_iter( _p.ePatternChannel, NULL);
 		return;
 	}
 
-	GtkTreeModel *model = gtk_combo_box_get_model( ePatternChannel);
+	GtkTreeModel *model = gtk_combo_box_get_model( _p.ePatternChannel);
 	GtkTreeIter iter;
 	gboolean valid;
 	valid = gtk_tree_model_get_iter_first( model, &iter);
@@ -527,7 +527,7 @@ aghui::SScoringFacility::SFindDialog::preselect_channel( const char *ch)
 				    0, &entry,
 				    -1);
 		if ( strcmp( entry, ch) == 0 ) {
-			gtk_combo_box_set_active_iter( ePatternChannel, &iter);
+			gtk_combo_box_set_active_iter( _p.ePatternChannel, &iter);
 			return;
 		}
 		valid = gtk_tree_model_iter_next( model, &iter);
diff --git a/src/ui/scoring-facility-patterns_cb.cc b/src/ui/scoring-facility-patterns_cb.cc
index 5bfefc3..79963ea 100644
--- a/src/ui/scoring-facility-patterns_cb.cc
+++ b/src/ui/scoring-facility-patterns_cb.cc
@@ -26,7 +26,8 @@ extern "C" {
 gboolean
 daPatternSelection_draw_cb( GtkWidget *wid, cairo_t *cr, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
 	FD.acquire_parameters();
 
 	FD.draw( cr);
@@ -40,7 +41,8 @@ daPatternSelection_draw_cb( GtkWidget *wid, cairo_t *cr, gpointer userdata)
 gboolean
 daPatternSelection_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
 
 	switch ( event->direction ) {
 	case GDK_SCROLL_UP:
@@ -70,9 +72,10 @@ daPatternSelection_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpoin
 void
 bPatternFind_clicked_cb( GtkButton *button, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
 	gboolean
-		go_forward = button == FD.bPatternFindNext;
+		go_forward = button == FD._p.bPatternFindNext;
 
 	size_t from;
 	if ( FD.last_find == (size_t)-1 )
@@ -85,11 +88,11 @@ bPatternFind_clicked_cb( GtkButton *button, gpointer userdata)
 			   ? .2 * FD.samplerate
 			   : FD.pattern_size_essential());
 
-	aghui::SBusyBlock bb (FD.wPattern);
+	aghui::SBusyBlock bb (FD._p.wPattern);
 
 	FD.search( from);
 	if ( FD.last_find == (size_t)-1 )
-		pop_ok_message( (GtkWindow*)FD.wPattern, "Not found");
+		pop_ok_message( (GtkWindow*)FD._p.wPattern, "Not found");
 	else { // reach up and out
 		auto& SF = FD.field_channel->_p;
 		SF.using_channel = FD.field_channel;
@@ -102,10 +105,10 @@ bPatternFind_clicked_cb( GtkButton *button, gpointer userdata)
 
 		snprintf_buf( "at p. %zu (a = %4.2f, b = %4.2f, c = %4.2f)\n",
 			      SF.cur_vpage()+1, FD.match_a, FD.match_b, FD.match_c);
-		gtk_label_set_markup( FD.lPatternSimilarity, __buf__);
+		gtk_label_set_markup( FD._p.lPatternSimilarity, __buf__);
 
-		gtk_widget_queue_draw( (GtkWidget*)FD.lPatternSimilarity);
-		gtk_widget_queue_draw( (GtkWidget*)FD.daPatternSelection);
+		gtk_widget_queue_draw( (GtkWidget*)FD._p.lPatternSimilarity);
+		gtk_widget_queue_draw( (GtkWidget*)FD._p.daPatternSelection);
 	}
 }
 
@@ -116,23 +119,25 @@ bPatternFind_clicked_cb( GtkButton *button, gpointer userdata)
 void
 bPatternSave_clicked_cb( GtkButton *button, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
-	const char *label = gtk_combo_box_get_active_id( FD.ePatternList);
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
+
+	const char *label = gtk_combo_box_get_active_id( FD._p.ePatternList);
 	if ( label ) {
 		if ( strncmp( label, FD.globally_marker, strlen( FD.globally_marker)) == 0 )
 			label += strlen( FD.globally_marker);
-		gtk_entry_set_text( FD.ePatternNameName, label);
+		gtk_entry_set_text( FD._p.ePatternNameName, label);
 	}
-	if ( gtk_dialog_run( FD.wPatternName) == GTK_RESPONSE_OK ) {
-		const char *label = gtk_entry_get_text( FD.ePatternNameName);
-		gboolean do_globally = gtk_toggle_button_get_active( (GtkToggleButton*)FD.ePatternNameSaveGlobally);
+	if ( gtk_dialog_run( FD._p.wPatternName) == GTK_RESPONSE_OK ) {
+		const char *label = gtk_entry_get_text( FD._p.ePatternNameName);
+		gboolean do_globally = gtk_toggle_button_get_active( (GtkToggleButton*)FD._p.ePatternNameSaveGlobally);
 		FD.save_pattern( label, do_globally);
 
 		// add to dropdown list & select the newly added entry
 		FD.enumerate_patterns_to_combo();
-		g_signal_handler_block( FD.ePatternList, FD.ePatternList_changed_cb_handler_id);
+		g_signal_handler_block( FD._p.ePatternList, FD._p.ePatternList_changed_cb_handler_id);
 		FD.preselect_entry( label, do_globally);
-		g_signal_handler_unblock( FD.ePatternList, FD.ePatternList_changed_cb_handler_id);
+		g_signal_handler_unblock( FD._p.ePatternList, FD._p.ePatternList_changed_cb_handler_id);
 	}
 }
 
@@ -140,12 +145,14 @@ bPatternSave_clicked_cb( GtkButton *button, gpointer userdata)
 void
 bPatternDiscard_clicked_cb( GtkButton *button, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
+
 	GtkTreeIter iter;
-	if ( gtk_combo_box_get_active_iter( FD.ePatternList, &iter) == FALSE )
+	if ( gtk_combo_box_get_active_iter( FD._p.ePatternList, &iter) == FALSE )
 		return;
 	char *label;
-	gtk_tree_model_get( (GtkTreeModel*)FD.mPatterns, &iter,
+	gtk_tree_model_get( (GtkTreeModel*)FD._p.mPatterns, &iter,
 			    0, &label,
 			    -1);
 	gboolean do_globally = strncmp( label, FD.globally_marker,
@@ -155,21 +162,23 @@ bPatternDiscard_clicked_cb( GtkButton *button, gpointer userdata)
 		: label;
 	FD.discard_pattern( fname, do_globally);
 	free( label);
-	g_signal_handler_block( FD.ePatternList, FD.ePatternList_changed_cb_handler_id);
+	g_signal_handler_block( FD._p.ePatternList, FD._p.ePatternList_changed_cb_handler_id);
 	FD.preselect_entry( NULL, do_globally);
-	g_signal_handler_unblock( FD.ePatternList, FD.ePatternList_changed_cb_handler_id);
+	g_signal_handler_unblock( FD._p.ePatternList, FD._p.ePatternList_changed_cb_handler_id);
 }
 
 
 void
 ePatternList_changed_cb( GtkComboBox *combo, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
+
 	GtkTreeIter iter;
 	if ( gtk_combo_box_get_active_iter( combo, &iter) == FALSE )
 		return;
 	char *label;
-	gtk_tree_model_get( (GtkTreeModel*)FD.mPatterns, &iter,
+	gtk_tree_model_get( (GtkTreeModel*)FD._p.mPatterns, &iter,
 			    0, &label,
 			    -1);
 	gboolean do_globally = strncmp( label, FD.globally_marker, strlen( FD.globally_marker)) == 0;
@@ -179,16 +188,18 @@ ePatternList_changed_cb( GtkComboBox *combo, gpointer userdata)
 	FD.load_pattern( fname, do_globally);
 	free( label);
 
-	gtk_label_set_markup( FD.lPatternSimilarity, "");
+	gtk_label_set_markup( FD._p.lPatternSimilarity, "");
 
-	gtk_widget_queue_draw( (GtkWidget*)FD.daPatternSelection);
+	gtk_widget_queue_draw( (GtkWidget*)FD._p.daPatternSelection);
 }
 
 
 void
 ePatternChannel_changed_cb( GtkComboBox *combo, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
+
 	GtkTreeIter iter;
 	if ( gtk_combo_box_get_active_iter( combo, &iter) == FALSE )
 		return;
@@ -197,7 +208,6 @@ ePatternChannel_changed_cb( GtkComboBox *combo, gpointer userdata)
 	gtk_tree_model_get( gtk_combo_box_get_model( combo), &iter,
 			    0, &label,
 			    -1);
-	auto& SF = FD.field_channel->_p;
 	for ( auto &H : SF.channels ) {
 		if ( strcmp( H.name, label) == 0 ) {
 			FD.field_channel = SF.using_channel = &H;
@@ -210,16 +220,19 @@ ePatternChannel_changed_cb( GtkComboBox *combo, gpointer userdata)
 void
 ePattern_any_value_changed_cb( GtkSpinButton *spinbutton, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
-//	FD.acquire_parameters();
-	gtk_widget_queue_draw( (GtkWidget*)FD.daPatternSelection);
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
+
+	gtk_widget_queue_draw( (GtkWidget*)FD._p.daPatternSelection);
 }
 
 
 void
 wPattern_show_cb( GtkWidget *widget, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
+
 	FD.update_displayed_parameters();
 	FD.enumerate_patterns_to_combo();
 
@@ -233,9 +246,13 @@ wPattern_show_cb( GtkWidget *widget, gpointer userdata)
 void
 wPattern_hide_cb( GtkWidget *widget, gpointer userdata)
 {
-	auto& FD = *(SScoringFacility::SFindDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& FD = SF.find_dialog;
+
 	gtk_toggle_button_set_active( (GtkToggleButton*)FD.field_channel->_p.bSFShowFindDialog, FALSE);
 }
 
 
 } // extern "C"
+
+// eof
diff --git a/src/ui/scoring-facility-phasediff_cb.cc b/src/ui/scoring-facility-phasediff_cb.cc
index 51e8c1e..956657b 100644
--- a/src/ui/scoring-facility-phasediff_cb.cc
+++ b/src/ui/scoring-facility-phasediff_cb.cc
@@ -26,11 +26,13 @@ extern "C" {
 gboolean
 daSFPD_draw_cb( GtkWidget *wid, cairo_t *cr, gpointer userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	if ( PD.suspend_draw )
 		return TRUE;
 
-	aghui::SBusyBlock bb (PD.wSFPD);
+	aghui::SBusyBlock bb (PD._p.wSFPD);
 
 	PD.draw( cr, gtk_widget_get_allocated_width( wid), gtk_widget_get_allocated_height( wid));
 
@@ -41,7 +43,9 @@ daSFPD_draw_cb( GtkWidget *wid, cairo_t *cr, gpointer userdata)
 gboolean
 daSFPD_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	switch ( event->direction ) {
 	case GDK_SCROLL_UP:
 		PD.display_scale *= 1.05;
@@ -63,27 +67,31 @@ daSFPD_scroll_event_cb( GtkWidget *wid, GdkEventScroll *event, gpointer userdata
 void
 eSFPDChannelA_changed_cb( GtkComboBox *cbox, gpointer userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	if ( PD.suspend_draw )
 		return;
 
 	PD.channel1 = PD.channel_from_cbox( cbox);
 
 	PD.update_course();
-	gtk_widget_queue_draw( (GtkWidget*)PD.daSFPD);
+	gtk_widget_queue_draw( (GtkWidget*)PD._p.daSFPD);
 }
 
 void
 eSFPDChannelB_changed_cb( GtkComboBox *cbox, gpointer userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	if ( PD.suspend_draw )
 		return;
 
 	PD.channel2 = PD.channel_from_cbox( cbox);
 
 	PD.update_course();
-	gtk_widget_queue_draw( (GtkWidget*)PD.daSFPD);
+	gtk_widget_queue_draw( (GtkWidget*)PD._p.daSFPD);
 }
 
 
@@ -93,29 +101,33 @@ void
 eSFPDFreqFrom_value_changed_cb( GtkSpinButton *spinbutton,
 				gpointer       userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	if ( PD.suspend_draw )
 		return;
 
 	PD.from = gtk_spin_button_get_value( spinbutton);
-	PD.upto = PD.from + gtk_spin_button_get_value( PD.eSFPDBandwidth);
+	PD.upto = PD.from + gtk_spin_button_get_value( PD._p.eSFPDBandwidth);
 
 	PD.update_course();
-	gtk_widget_queue_draw( (GtkWidget*)PD.daSFPD);
+	gtk_widget_queue_draw( (GtkWidget*)PD._p.daSFPD);
 }
 
 void
 eSFPDBandwidth_value_changed_cb( GtkSpinButton *spinbutton,
 				 gpointer       userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	if ( PD.suspend_draw )
 		return;
 
 	PD.upto = PD.from + gtk_spin_button_get_value( spinbutton);
 
 	PD.update_course();
-	gtk_widget_queue_draw( (GtkWidget*)PD.daSFPD);
+	gtk_widget_queue_draw( (GtkWidget*)PD._p.daSFPD);
 }
 
 
@@ -125,14 +137,16 @@ eSFPDSmooth_value_changed_cb( GtkScaleButton *b,
 			      gdouble v,
 			      gpointer userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	snprintf_buf( "Smooth: %zu",
 		      PD.smooth_side = v);
 	gtk_button_set_label( (GtkButton*)b, __buf__);
 	if ( PD.suspend_draw )
 		return;
 
-	gtk_widget_queue_draw( (GtkWidget*)PD.daSFPD);
+	gtk_widget_queue_draw( (GtkWidget*)PD._p.daSFPD);
 }
 
 
@@ -140,34 +154,38 @@ eSFPDSmooth_value_changed_cb( GtkScaleButton *b,
 void
 wSFPD_show_cb( GtkWidget *wid, gpointer userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	PD.suspend_draw = true;
-	if ( gtk_combo_box_get_active( PD.eSFPDChannelA) == -1 ||
-	     gtk_combo_box_get_active( PD.eSFPDChannelB) == -1 ) {
+	if ( gtk_combo_box_get_active( PD._p.eSFPDChannelA) == -1 ||
+	     gtk_combo_box_get_active( PD._p.eSFPDChannelB) == -1 ) {
 		PD.channel1 = &*PD._p.channels.begin();
 		PD.channel2 = &*next(PD._p.channels.begin());
-		PD.preselect_channel( PD.eSFPDChannelA, PD.channel1->name);
-		PD.preselect_channel( PD.eSFPDChannelB, PD.channel2->name);
+		PD.preselect_channel( PD._p.eSFPDChannelA, PD.channel1->name);
+		PD.preselect_channel( PD._p.eSFPDChannelB, PD.channel2->name);
 	} else {
 		// they have been nicely set before, havent't they
 		// PD.channel1 = PD.channel_from_cbox( eSFPDChannelA);
 		// PD.channel2 = PD.channel_from_cbox( eSFPDChannelB);
 	}
 
-	gtk_spin_button_set_value( PD.eSFPDFreqFrom, PD.from);
-	gtk_spin_button_set_value( PD.eSFPDBandwidth, PD.upto - PD.from);
+	gtk_spin_button_set_value( PD._p.eSFPDFreqFrom, PD.from);
+	gtk_spin_button_set_value( PD._p.eSFPDBandwidth, PD.upto - PD.from);
 	snprintf_buf( "Smooth: %zu", PD.smooth_side);
-	gtk_button_set_label( (GtkButton*)PD.eSFPDSmooth, __buf__);
+	gtk_button_set_label( (GtkButton*)PD._p.eSFPDSmooth, __buf__);
 
 	PD.update_course();
 	PD.suspend_draw = false;
-	gtk_widget_queue_draw( (GtkWidget*)PD.daSFPD);
+	gtk_widget_queue_draw( (GtkWidget*)PD._p.daSFPD);
 }
 
 void
 wSFPD_hide_cb( GtkWidget *wid, gpointer userdata)
 {
-	auto& PD = *(SScoringFacility::SPhasediffDialog*)userdata;
+	auto& SF = *(SScoringFacility*)userdata;
+	auto& PD = SF.phasediff_dialog;
+
 	gtk_toggle_button_set_active( PD._p.bSFShowPhaseDiffDialog, FALSE);
 }
 
diff --git a/src/ui/scoring-facility-widgets.hh b/src/ui/scoring-facility-widgets.hh
new file mode 100644
index 0000000..9abc5c7
--- /dev/null
+++ b/src/ui/scoring-facility-widgets.hh
@@ -0,0 +1,287 @@
+// ;-*-C++-*-
+/*
+ *       File name:  ui/scoring-facility-widgets.hh
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2012-10-06
+ *
+ *         Purpose:  scoring facility widgets class
+ *
+ *         License:  GPL
+ */
+
+#ifndef _AGH_UI_SCORING_FACILITY_WIDGETS_H
+#define _AGH_UI_SCORING_FACILITY_WIDGETS_H
+
+#include <gtk/gtk.h>
+#include "forward-decls.hh"
+
+namespace aghui {
+
+struct SScoringFacilityWidgets {
+
+	// we load and construct own widget set (wScoringFacility and all its contents)
+	// ourself, for every SScoringFacility instance being created, so
+	// construct_widgets below takes an arg
+	GtkBuilder *builder;
+	SScoringFacilityWidgets (SExpDesignUI&);
+       ~SScoringFacilityWidgets ();
+
+	// storage
+	GtkListStore
+		*mScoringPageSize,
+		*mAnnotationsAtCursor;
+
+	// window
+	GtkWindow
+		*wScoringFacility;
+	// control bar
+	GtkLabel
+		*lSFHint;
+	GtkHBox
+		*cSFControlBar;
+	GtkComboBox
+		*eSFPageSize;
+	GtkSpinButton
+		*eSFCurrentPage;
+	GtkAdjustment
+		*jPageNo;
+	GtkLabel
+		*lSFTotalPages;
+	GtkBox
+		*cSFScoringModeContainer,
+		*cSFICAModeContainer;
+	// 1. scoring mode
+	GtkButton  // acting label
+		*eSFCurrentPos;
+	GtkButton
+		*bSFBack, *bSFForward,
+		*bScoreClear, *bScoreNREM1, *bScoreNREM2, *bScoreNREM3, *bScoreNREM4,
+		*bScoreREM, *bScoreWake,
+		*bScoreGotoPrevUnscored, *bScoreGotoNextUnscored,
+		*bScoreGotoPrevArtifact, *bScoreGotoNextArtifact;
+	GtkToggleButton
+		*bSFDrawCrosshair,
+		*bSFShowFindDialog, *bSFShowPhaseDiffDialog;
+	GtkButton
+	//*bSFResetMontage,
+		*bSFRunICA;
+	GtkTable
+		*cSFSleepStageStats;
+	GtkLabel
+		*lScoreStatsNREMPercent, *lScoreStatsREMPercent, *lScoreStatsWakePercent,
+		*lSFPercentScored;
+	GtkStatusbar
+		*sbSF;
+	guint	sbSFContextIdGeneral;
+
+	// 2. ICA mode
+	GtkComboBox
+		*eSFICARemixMode,
+		*eSFICANonlinearity,
+		*eSFICAApproach;
+	GtkListStore
+		*mSFICARemixMode,
+		*mSFICANonlinearity,
+		*mSFICAApproach;
+	GtkCheckButton
+		*eSFICAFineTune,
+		*eSFICAStabilizationMode;
+	GtkSpinButton
+		*eSFICAa1,
+		*eSFICAa2,
+		*eSFICAmu,
+		*eSFICAepsilon,
+		*eSFICANofICs,
+		*eSFICAEigVecFirst,
+		*eSFICAEigVecLast,
+		*eSFICASampleSizePercent,
+		*eSFICAMaxIterations;
+	GtkAdjustment
+		*jSFICANofICs,
+		*jSFICAEigVecFirst,
+		*jSFICAEigVecLast;
+	GtkButton
+		*bSFICATry,
+		*bSFICAApply,
+		*bSFICACancel;
+	GtkToggleButton
+		*bSFICAPreview,
+		*bSFICAShowMatrix;
+	GtkTextView
+		*tSFICAMatrix;
+	GtkDialog
+		*wSFICAMatrix;
+
+	// common controls (contd)
+	GtkMenuToolButton
+		*bSFAccept;
+	GtkMenu
+		*mSFAccept;
+
+	// montage area
+	GtkDrawingArea
+		*daSFMontage,
+		*daSFHypnogram;
+	GtkExpander
+		*cSFHypnogram;
+	GtkLabel
+		*lSFOverChannel;
+	// menus
+	GtkMenu
+		*mSFPage,
+		*mSFPageSelection,
+		*mSFPageAnnotation,
+		*mSFPageHidden,
+		*mSFPower,
+		*mSFScore,
+		*mSFICAPage;
+	GtkCheckMenuItem
+		*iSFPageShowOriginal, *iSFPageShowProcessed,
+		*iSFPageUseResample, *iSFPageDrawZeroline,
+		*iSFPageDrawPSDProfile,
+		*iSFPageDrawPSDSpectrum,
+		*iSFPageDrawMCProfile,
+		*iSFPageDrawEMGProfile,
+		*iSFPowerDrawBands,
+		*iSFPowerSmooth,
+		*iSFPowerAutoscale,
+		*iSFPageSelectionDrawCourse,
+		*iSFPageSelectionDrawEnvelope,
+		*iSFPageSelectionDrawDzxdf;
+	GtkMenuItem
+		*iSFPageFilter,
+		*iSFPageSaveChannelAsSVG, *iSFPageSaveMontageAsSVG,
+		*iSFPageExportSignal, *iSFPageUseThisScale,
+		*iSFPageDetectArtifacts, *iSFPageClearArtifacts, *iSFPageHide,
+		*iSFPageHidden,  // has a submenu
+		*iSFPageSpaceEvenly,
+		*iSFPageLocateSelection,
+		*iSFPageAnnotationSeparator,
+		*iSFPageAnnotationDelete,
+		*iSFPageAnnotationEdit,
+		*iSFPageSelectionMarkArtifact, *iSFPageSelectionClearArtifact,
+		*iSFPageSelectionFindPattern,
+		*iSFPageSelectionAnnotate,
+		*iSFPowerExportAll, *iSFPowerExportRange,
+		*iSFPowerUseThisScale,
+		*iSFScoreAssist, *iSFScoreImport, *iSFScoreExport, *iSFScoreClear,
+		*iSFAcceptAndTakeNext;
+	GtkSeparatorMenuItem
+		*iSFPageProfileItemsSeparator;
+
+	// more important dialogs
+	// find/patterns dialog
+	GtkListStore
+		*mPatterns;
+	GtkDialog
+		*wPattern;
+	GtkComboBox
+		*ePatternChannel,
+		*ePatternList;
+	GtkScrolledWindow
+		*vpPatternSelection;
+	GtkDrawingArea
+		*daPatternSelection;
+	GtkButton
+		*bPatternFindNext, *bPatternFindPrevious,
+		*bPatternSave, *bPatternDiscard;
+	GtkSpinButton
+		*ePatternEnvTightness, *ePatternFilterCutoff,
+		*ePatternFilterOrder, *ePatternDZCDFStep,
+		*ePatternDZCDFSigma, *ePatternDZCDFSmooth,
+		*ePatternParameterA, *ePatternParameterB,
+		*ePatternParameterC;
+	GtkHBox
+		*cPatternLabelBox;
+	GtkLabel
+		*lPatternSimilarity;
+	GtkDialog
+		*wPatternName;
+	GtkEntry
+		*ePatternNameName;
+	GtkCheckButton
+		*ePatternNameSaveGlobally;
+	gulong	ePatternChannel_changed_cb_handler_id,
+		ePatternList_changed_cb_handler_id;
+
+	// filters dialog
+	GtkDialog
+		*wFilters;
+	GtkLabel
+		*lFilterCaption;
+	GtkSpinButton
+		*eFilterLowPassCutoff, *eFilterHighPassCutoff,
+		*eFilterLowPassOrder, *eFilterHighPassOrder;
+	GtkComboBox
+		*eFilterNotchFilter;
+	GtkListStore
+		*mFilterNotchFilter;
+	GtkButton
+		*bFilterOK;
+
+	// phasediff dialog
+	GtkDialog
+		*wSFPD;
+	GtkComboBox
+		*eSFPDChannelA, *eSFPDChannelB;
+	GtkDrawingArea
+		*daSFPD;
+	GtkSpinButton
+		*eSFPDFreqFrom,
+		*eSFPDBandwidth;
+	GtkScaleButton
+		*eSFPDSmooth;
+	gulong
+		eSFPDChannelA_changed_cb_handler_id,
+		eSFPDChannelB_changed_cb_handler_id;
+
+	// less important dialogs
+	GtkDialog
+		*wAnnotationLabel,
+		*wAnnotationSelector;
+	GtkEntry
+		*eAnnotationLabel;
+	GtkComboBox
+		*eAnnotationSelectorWhich;
+
+	GtkDialog
+		*wSFArtifactDetectionSetup;
+	GtkSpinButton
+		*eSFADUpperThr,
+		*eSFADLowerThr,
+		*eSFADScope,
+		*eSFADF0,
+		*eSFADFc,
+		*eSFADBandwidth,
+		*eSFADMCGain,
+		*eSFADBackpolate,
+		*eSFADEValue,
+		*eSFADHistRangeMin,
+		*eSFADHistRangeMax,
+		*eSFADHistBins,
+		*eSFADSmoothSide;
+	GtkCheckButton
+		*eSFADClearOldArtifacts,
+		*eSFADEstimateE;
+	GtkRadioButton
+		*eSFADUseThisRange,
+		*eSFADUseComputedRange;
+	GtkTable
+		*cSFADWhenEstimateEOn,
+		*cSFADWhenEstimateEOff;
+	GtkLabel
+		*lSFADInfo;
+	GtkToggleButton
+		*bSFADPreview;
+	GtkButton
+		*bSFADApply,
+		*bSFADCancel;
+
+};
+
+} // namespace aghui
+
+#endif
+
+// eof
diff --git a/src/ui/scoring-facility.cc b/src/ui/scoring-facility.cc
index c1d505b..8d06f51 100644
--- a/src/ui/scoring-facility.cc
+++ b/src/ui/scoring-facility.cc
@@ -52,7 +52,8 @@ aghui::SScoringFacility::
 SScoringFacility (agh::CSubject& J,
 		  const string& D, const string& E,
 		  aghui::SExpDesignUI& parent)
-      : _p (parent),
+      : SScoringFacilityWidgets (parent),
+	_p (parent),
 	_csubject (J),
 	_session (D),
 	_sepisode (J.measurements.at(D)[E]),
@@ -91,19 +92,6 @@ SScoringFacility (agh::CSubject& J,
 	aghui::SBusyBlock bb (_p.wMainWindow);
 
       // complete widget construction
-	builder = gtk_builder_new();
-	if ( !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/sf.glade", NULL) ) {
-		g_object_unref( (GObject*)builder);
-		throw runtime_error( "SScoringFacility::SScoringFacility(): Failed to load GtkBuilder object");
-	}
-	if ( construct_widgets() ||
-	     find_dialog.construct_widgets() ||
-	     filters_dialog.construct_widgets() ||
-	     phasediff_dialog.construct_widgets() )
-		throw runtime_error( "SScoringFacility::SScoringFacility(): Failed to construct own widgets");
-	gtk_builder_connect_signals( builder, NULL);
-	//  we do it all mostly ourself, except for some delete-event binding to gtk_true()
-
       // histogram -> scores
 	get_hypnogram();
 	calculate_scored_percent();
@@ -279,10 +267,6 @@ aghui::SScoringFacility::
 	// save montage
 	save_montage();
 
-	// destroy widgets
-	gtk_widget_destroy( (GtkWidget*)wScoringFacility);
-	g_object_unref( (GObject*)builder);
-
 	// cause repopulate
 	redraw_ssubject_timeline();
 
diff --git a/src/ui/scoring-facility.hh b/src/ui/scoring-facility.hh
index 92643da..5549fb9 100644
--- a/src/ui/scoring-facility.hh
+++ b/src/ui/scoring-facility.hh
@@ -24,6 +24,7 @@
 #include "../ica/ica.hh"
 #include "globals.hh"
 #include "expdesign.hh"
+#include "scoring-facility-widgets.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
 #  include "config.h"
@@ -34,7 +35,9 @@ using namespace std;
 
 namespace aghui {
 
-class SScoringFacility {
+class SScoringFacility
+  : public SScoringFacilityWidgets {
+
 	DELETE_DEFAULT_METHODS (SScoringFacility);
 
     public:
@@ -567,40 +570,6 @@ class SScoringFacility {
 			da_ht = 280;
 		int	da_wd;
 		void set_pattern_da_width( int);
-
-		int construct_widgets();
-		GtkListStore
-			*mPatterns;
-		GtkDialog
-			*wPattern;
-		GtkComboBox
-			*ePatternChannel,
-			*ePatternList;
-		GtkScrolledWindow
-			*vpPatternSelection;
-		GtkDrawingArea
-			*daPatternSelection;
-		GtkButton
-			*bPatternFindNext, *bPatternFindPrevious,
-			*bPatternSave, *bPatternDiscard;
-		GtkSpinButton
-			*ePatternEnvTightness, *ePatternFilterCutoff,
-			*ePatternFilterOrder, *ePatternDZCDFStep,
-			*ePatternDZCDFSigma, *ePatternDZCDFSmooth,
-			*ePatternParameterA, *ePatternParameterB,
-			*ePatternParameterC;
-		GtkHBox
-			*cPatternLabelBox;
-		GtkLabel
-			*lPatternSimilarity;
-		GtkDialog
-			*wPatternName;
-		GtkEntry
-			*ePatternNameName;
-		GtkCheckButton
-			*ePatternNameSaveGlobally;
-		gulong	ePatternChannel_changed_cb_handler_id,
-			ePatternList_changed_cb_handler_id;
 	};
 	SFindDialog
 		find_dialog;
@@ -608,29 +577,13 @@ class SScoringFacility {
 	struct SFiltersDialog {
 		DELETE_DEFAULT_METHODS (SFiltersDialog);
 
-		SFiltersDialog( SScoringFacility& parent)
+		SFiltersDialog (SScoringFacility& parent)
 		      : _p (parent)
 			{}
-	       ~SFiltersDialog();
+	       ~SFiltersDialog ();
 
-	    private:
 		SScoringFacility&
 			_p;
-	    public:
-		int construct_widgets();
-		GtkDialog
-			*wFilters;
-		GtkLabel
-			*lFilterCaption;
-		GtkSpinButton
-			*eFilterLowPassCutoff, *eFilterHighPassCutoff,
-			*eFilterLowPassOrder, *eFilterHighPassOrder;
-		GtkComboBox
-			*eFilterNotchFilter;
-		GtkListStore
-			*mFilterNotchFilter;
-		GtkButton
-			*bFilterOK;
 	};
 	SFiltersDialog
 		filters_dialog;
@@ -660,27 +613,12 @@ class SScoringFacility {
 
 		void draw( cairo_t* cr, int wd, int ht);
 
-		SPhasediffDialog( SScoringFacility&);
-	       ~SPhasediffDialog();
+		SPhasediffDialog (SScoringFacility&);
+	       ~SPhasediffDialog ();
 
 		SScoringFacility&
 			_p;
 
-		int construct_widgets();
-		GtkDialog
-			*wSFPD;
-		GtkComboBox
-			*eSFPDChannelA, *eSFPDChannelB;
-		GtkDrawingArea
-			*daSFPD;
-		GtkSpinButton
-			*eSFPDFreqFrom,
-			*eSFPDBandwidth;
-		GtkScaleButton
-			*eSFPDSmooth;
-		gulong
-			eSFPDChannelA_changed_cb_handler_id,
-			eSFPDChannelB_changed_cb_handler_id;
 		bool suspend_draw;
 	};
 	SPhasediffDialog
@@ -703,12 +641,6 @@ class SScoringFacility {
     private:
 	static const char* const tooltips[2];
 
-      // own widgets
-	// we load and construct own widget set (wScoringFacility and all its contents)
-	// ourself, for every SScoringFacility instance being created, so
-	// construct_widgets below takes an arg
-	GtkBuilder *builder;
-	int construct_widgets();
     public:
 	// SGeometry
 	// 	geometry;
@@ -718,190 +650,6 @@ class SScoringFacility {
 		HypnogramHeight,
 		EMGProfileHeight;
 
-	// storage
-	GtkListStore
-		*mAnnotationsAtCursor;
-
-	// window
-	GtkWindow
-		*wScoringFacility;
-	// control bar
-	GtkLabel
-		*lSFHint;
-	GtkHBox
-		*cSFControlBar;
-	GtkComboBox
-		*eSFPageSize;
-	GtkSpinButton
-		*eSFCurrentPage;
-	GtkAdjustment
-		*jPageNo;
-	GtkLabel
-		*lSFTotalPages;
-	GtkBox
-		*cSFScoringModeContainer,
-		*cSFICAModeContainer;
-	// 1. scoring mode
-	GtkButton  // acting label
-		*eSFCurrentPos;
-	GtkButton
-		*bSFBack, *bSFForward,
-		*bScoreClear, *bScoreNREM1, *bScoreNREM2, *bScoreNREM3, *bScoreNREM4,
-		*bScoreREM, *bScoreWake,
-		*bScoreGotoPrevUnscored, *bScoreGotoNextUnscored,
-		*bScoreGotoPrevArtifact, *bScoreGotoNextArtifact;
-	GtkToggleButton
-		*bSFDrawCrosshair,
-		*bSFShowFindDialog, *bSFShowPhaseDiffDialog;
-	GtkButton
-	//*bSFResetMontage,
-		*bSFRunICA;
-	GtkTable
-		*cSFSleepStageStats;
-	GtkLabel
-		*lScoreStatsNREMPercent, *lScoreStatsREMPercent, *lScoreStatsWakePercent,
-		*lSFPercentScored;
-	GtkStatusbar
-		*sbSF;
-	guint	sbSFContextIdGeneral;
-
-	// 2. ICA mode
-	GtkComboBox
-		*eSFICARemixMode,
-		*eSFICANonlinearity,
-		*eSFICAApproach;
-	GtkListStore
-		*mSFICARemixMode,
-		*mSFICANonlinearity,
-		*mSFICAApproach;
-	GtkCheckButton
-		*eSFICAFineTune,
-		*eSFICAStabilizationMode;
-	GtkSpinButton
-		*eSFICAa1,
-		*eSFICAa2,
-		*eSFICAmu,
-		*eSFICAepsilon,
-		*eSFICANofICs,
-		*eSFICAEigVecFirst,
-		*eSFICAEigVecLast,
-		*eSFICASampleSizePercent,
-		*eSFICAMaxIterations;
-	GtkAdjustment
-		*jSFICANofICs,
-		*jSFICAEigVecFirst,
-		*jSFICAEigVecLast;
-	GtkButton
-		*bSFICATry,
-		*bSFICAApply,
-		*bSFICACancel;
-	GtkToggleButton
-		*bSFICAPreview,
-		*bSFICAShowMatrix;
-	GtkTextView
-		*tSFICAMatrix;
-	GtkDialog
-		*wSFICAMatrix;
-
-	// common controls (contd)
-	GtkMenuToolButton
-		*bSFAccept;
-	GtkMenu
-		*mSFAccept;
-
-	// montage area
-	GtkDrawingArea
-		*daSFMontage,
-		*daSFHypnogram;
-	GtkExpander
-		*cSFHypnogram;
-	GtkLabel
-		*lSFOverChannel;
-	// menus
-	GtkMenu
-		*mSFPage,
-		*mSFPageSelection,
-		*mSFPageAnnotation,
-		*mSFPageHidden,
-		*mSFPower,
-		*mSFScore,
-		*mSFICAPage;
-	GtkCheckMenuItem
-		*iSFPageShowOriginal, *iSFPageShowProcessed,
-		*iSFPageUseResample, *iSFPageDrawZeroline,
-		*iSFPageDrawPSDProfile,
-		*iSFPageDrawPSDSpectrum,
-		*iSFPageDrawMCProfile,
-		*iSFPageDrawEMGProfile,
-		*iSFPowerDrawBands,
-		*iSFPowerSmooth,
-		*iSFPowerAutoscale,
-		*iSFPageSelectionDrawCourse,
-		*iSFPageSelectionDrawEnvelope,
-		*iSFPageSelectionDrawDzxdf;
-	GtkMenuItem
-		*iSFPageFilter,
-		*iSFPageSaveChannelAsSVG, *iSFPageSaveMontageAsSVG,
-		*iSFPageExportSignal, *iSFPageUseThisScale,
-		*iSFPageDetectArtifacts, *iSFPageClearArtifacts, *iSFPageHide,
-		*iSFPageHidden,  // has a submenu
-		*iSFPageSpaceEvenly,
-		*iSFPageLocateSelection,
-		*iSFPageAnnotationSeparator,
-		*iSFPageAnnotationDelete,
-		*iSFPageAnnotationEdit,
-		*iSFPageSelectionMarkArtifact, *iSFPageSelectionClearArtifact,
-		*iSFPageSelectionFindPattern,
-		*iSFPageSelectionAnnotate,
-		*iSFPowerExportAll, *iSFPowerExportRange,
-		*iSFPowerUseThisScale,
-		*iSFScoreAssist, *iSFScoreImport, *iSFScoreExport, *iSFScoreClear,
-		*iSFAcceptAndTakeNext;
-	GtkSeparatorMenuItem
-		*iSFPageProfileItemsSeparator;
-
-	// less important dialogs
-	GtkDialog
-		*wAnnotationLabel,
-		*wAnnotationSelector;
-	GtkEntry
-		*eAnnotationLabel;
-	GtkComboBox
-		*eAnnotationSelectorWhich;
-
-	GtkDialog
-		*wSFArtifactDetectionSetup;
-	GtkSpinButton
-		*eSFADScope,
-		*eSFADUpperThr,
-		*eSFADLowerThr,
-		*eSFADF0,
-		*eSFADFc,
-		*eSFADBandwidth,
-		*eSFADMCGain,
-		*eSFADBackpolate,
-		*eSFADEValue,
-		*eSFADHistRangeMin,
-		*eSFADHistRangeMax,
-		*eSFADHistBins,
-		*eSFADSmoothSide;
-	GtkCheckButton
-		*eSFADClearOldArtifacts,
-		*eSFADEstimateE;
-	GtkRadioButton
-		*eSFADUseThisRange,
-		*eSFADUseComputedRange;
-	GtkTable
-		*cSFADWhenEstimateEOn,
-		*cSFADWhenEstimateEOff;
-	GtkLabel
-		*lSFADInfo;
-	GtkToggleButton
-		*bSFADPreview;
-	GtkButton
-		*bSFADApply,
-		*bSFADCancel;
-
     public:
 	// here's hoping configure-event comes before expose-event
 	gint	da_wd;
diff --git a/src/ui/scoring-facility_cb.cc b/src/ui/scoring-facility_cb.cc
index 43c7313..64001f2 100644
--- a/src/ui/scoring-facility_cb.cc
+++ b/src/ui/scoring-facility_cb.cc
@@ -13,6 +13,7 @@
 
 #include "expdesign.hh"
 #include "scoring-facility.hh"
+#include "scoring-facility-widgets.hh"
 
 
 using namespace std;
@@ -199,9 +200,9 @@ bSFShowFindDialog_toggled_cb( GtkToggleButton *togglebutton, gpointer userdata)
 {
 	auto& SF = *(SScoringFacility*)userdata;
 	if ( gtk_toggle_button_get_active( togglebutton) ) {
-		gtk_widget_show_all( (GtkWidget*)SF.find_dialog.wPattern);
+		gtk_widget_show_all( (GtkWidget*)SF.wPattern);
 	} else
-		gtk_widget_hide( (GtkWidget*)SF.find_dialog.wPattern);
+		gtk_widget_hide( (GtkWidget*)SF.wPattern);
 }
 
 
@@ -211,9 +212,9 @@ bSFShowPhaseDiffDialog_toggled_cb( GtkToggleButton *togglebutton, gpointer userd
 {
 	auto& SF = *(SScoringFacility*)userdata;
 	if ( gtk_toggle_button_get_active( togglebutton) ) {
-		gtk_widget_show_all( (GtkWidget*)SF.phasediff_dialog.wSFPD);
+		gtk_widget_show_all( (GtkWidget*)SF.wSFPD);
 	} else
-		gtk_widget_hide( (GtkWidget*)SF.phasediff_dialog.wSFPD);
+		gtk_widget_hide( (GtkWidget*)SF.wSFPD);
 }
 
 

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list