The following commit has been merged in the master branch:
commit b32ee56e23c1003be741395a8abd97f4fcfc2b2d
Author: andrei zavada <[email protected]>
Date:   Sat Oct 27 16:12:50 2012 +0300

    move some common code to ui/libcommon.cc

diff --git a/src/ui/libcommon.cc b/src/ui/libcommon.cc
index 52582d7..52731a8 100644
--- a/src/ui/libcommon.cc
+++ b/src/ui/libcommon.cc
@@ -224,6 +224,21 @@ cairo_draw_signal( cairo_t *cr, const valarray<TFloat>& V,
 
 // gtk
 
+
+void
+aghui::
+gtk_combo_box_set_model_properly( GtkComboBox *cb, GtkListStore *m)
+{
+       gtk_combo_box_set_model( cb, (GtkTreeModel*)m);
+       gtk_combo_box_set_id_column( cb, 0);
+       GtkCellRenderer *r = gtk_cell_renderer_text_new();
+       gtk_cell_layout_pack_start( (GtkCellLayout*)cb, r, FALSE);
+       gtk_cell_layout_set_attributes( (GtkCellLayout*)cb, r,
+                                       "text", 0,
+                                       NULL);
+}
+
+
 void
 aghui::
 pop_ok_message( GtkWindow *parent, const char* primary_text, const char *fmt, 
...)
diff --git a/src/ui/mw/mw-construct.cc b/src/ui/mw/mw-construct.cc
index dddd2ad..dd11be2 100644
--- a/src/ui/mw/mw-construct.cc
+++ b/src/ui/mw/mw-construct.cc
@@ -177,43 +177,25 @@ SExpDesignUIWidgets ()
                          this);
 
 
-     // ------------- eMsmtSession
-       if ( !AGH_GBGETOBJ (GtkComboBox, eMsmtSession) )
+     // ------------- eMsmtSession, eMsmtChannel
+       if ( !AGH_GBGETOBJ (GtkComboBox, eMsmtSession) ||
+            !AGH_GBGETOBJ ( GtkComboBox, eMsmtChannel) )
                throw runtime_error ("Failed to construct widgets");
 
-       gtk_combo_box_set_model( eMsmtSession,
-                                (GtkTreeModel*)mSessions);
-       gtk_combo_box_set_id_column( eMsmtSession, 0);
-
+       gtk_combo_box_set_model_properly(
+               eMsmtSession, mSessions);
        eMsmtSession_changed_cb_handler_id =
                g_signal_connect( eMsmtSession, "changed",
                                  (GCallback)eMsmtSession_changed_cb,
                                  this);
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eMsmtSession, renderer, 
FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eMsmtSession, renderer,
-                                       "text", 0,
-                                       NULL);
-
-     // ------------- eMsmtChannel
-       if ( !AGH_GBGETOBJ ( GtkComboBox, eMsmtChannel) )
-               throw runtime_error ("Failed to construct widgets");
-
-       gtk_combo_box_set_model( eMsmtChannel,
-                                (GtkTreeModel*)mEEGChannels);
-       gtk_combo_box_set_id_column( eMsmtChannel, 0);
 
+       gtk_combo_box_set_model_properly(
+               eMsmtChannel, mEEGChannels);
        eMsmtChannel_changed_cb_handler_id =
                g_signal_connect( eMsmtChannel, "changed",
                                  (GCallback)eMsmtChannel_changed_cb,
                                  this);
 
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eMsmtChannel, renderer, 
FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eMsmtChannel, renderer,
-                                       "text", 0,
-                                       NULL);
-
      // ------------- eMsmtProfile*
        if ( !AGH_GBGETOBJ (GtkToggleButton,    eMsmtProfileAutoscale) ||
             !AGH_GBGETOBJ (GtkScaleButton,     eMsmtProfileSmooth) ||
@@ -234,6 +216,8 @@ SExpDesignUIWidgets ()
        gtk_cell_layout_set_attributes( (GtkCellLayout*)eMsmtProfileType, 
renderer,
                                        "text", 0,
                                        NULL);
+       // and when was the list store attached to it, eh?
+
        g_signal_connect( eMsmtProfileType, "changed",
                          (GCallback)eMsmtProfileType_changed_cb,
                          this);
@@ -651,9 +635,10 @@ SExpDesignUIWidgets ()
        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,
-                                                                 
PANGO_TAB_LEFT, 190),
+                     "tabs", pango_tab_array_new_with_positions(
+                               2, TRUE,
+                               PANGO_TAB_LEFT, 130,
+                               PANGO_TAB_LEFT, 190),
                      NULL);
 
        g_signal_connect( eEdfImportGroupEntry,
@@ -704,6 +689,8 @@ SExpDesignUIWidgets ()
             !AGH_GBGETOBJ (GtkListStore,       mGlobalFiltersNotchFilter) ||
             !AGH_GBGETOBJ (GtkComboBox,        eGlobalFiltersNotchFilter) )
                throw runtime_error ("Failed to construct widgets");
+       gtk_combo_box_set_model_properly(
+               eGlobalFiltersNotchFilter, mGlobalFiltersNotchFilter);
 
       // ----------- wGlobalAnnotations
        if ( !AGH_GBGETOBJ (GtkDialog,          wGlobalAnnotations) ||
@@ -746,16 +733,8 @@ SExpDesignUIWidgets ()
             !AGH_GBGETOBJ (GtkButton,          bGlobalADOK) )
                throw runtime_error ("Failed to construct widgets");
 
-       gtk_combo_box_set_model( eGlobalADProfiles,
-                                (GtkTreeModel*)mGlobalADProfiles);
-       gtk_combo_box_set_id_column( eGlobalADProfiles, 0);
-
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eGlobalADProfiles, 
renderer, FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eGlobalADProfiles, 
renderer,
-                                       "text", 0,
-                                       NULL);
-
+       gtk_combo_box_set_model_properly(
+               eGlobalADProfiles, mGlobalADProfiles);
        g_signal_connect( eGlobalADProfiles, "changed",
                          (GCallback)eGlobalADProfiles_changed_cb,
                          this);
diff --git a/src/ui/sf/sf-construct.cc b/src/ui/sf/sf-construct.cc
index e667969..41450a2 100644
--- a/src/ui/sf/sf-construct.cc
+++ b/src/ui/sf/sf-construct.cc
@@ -31,8 +31,6 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
        gtk_builder_connect_signals( builder, NULL);
        //  we do it all mostly ourself, except for some delete-event binding 
to gtk_true()
 
-       GtkCellRenderer *renderer;
-
        // general & montage page navigation
        if ( !(AGH_GBGETOBJ (GtkWindow,         wScoringFacility)) ||
             !(AGH_GBGETOBJ (GtkLabel,          lSFHint)) ||
@@ -65,15 +63,8 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
                          (GCallback)wScoringFacility_delete_event_cb,
                          this);
 
-       gtk_combo_box_set_model( eSFPageSize,
-                                (GtkTreeModel*)mScoringPageSize);
-       gtk_combo_box_set_id_column( eSFPageSize, 0);
-
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eSFPageSize, renderer, 
FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eSFPageSize, renderer,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly(
+               eSFPageSize, mScoringPageSize);
 
        g_signal_connect( eSFPageSize, "changed",
                          (GCallback)eSFPageSize_changed_cb,
@@ -240,32 +231,9 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
             !(AGH_GBGETOBJ (GtkTextView,       tSFICAMatrix)) )
                throw runtime_error ("Failed to construct SF widgets");
 
-       gtk_combo_box_set_model( eSFICANonlinearity,
-                                (GtkTreeModel*)mSFICANonlinearity);
-       gtk_combo_box_set_id_column( eSFICANonlinearity, 0);
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eSFICANonlinearity, 
renderer, FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eSFICANonlinearity, 
renderer,
-                                       "text", 0,
-                                       NULL);
-
-       gtk_combo_box_set_model( eSFICAApproach,
-                                (GtkTreeModel*)mSFICAApproach);
-       gtk_combo_box_set_id_column( eSFICAApproach, 0);
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eSFICAApproach, renderer, 
FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eSFICAApproach, 
renderer,
-                                       "text", 0,
-                                       NULL);
-
-       gtk_combo_box_set_model( eSFICARemixMode,
-                                (GtkTreeModel*)mSFICARemixMode);
-       gtk_combo_box_set_id_column( eSFICARemixMode, 0);
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eSFICARemixMode, renderer, 
FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eSFICARemixMode, 
renderer,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly( eSFICANonlinearity, 
mSFICANonlinearity);
+       gtk_combo_box_set_model_properly( eSFICAApproach, mSFICAApproach);
+       gtk_combo_box_set_model_properly( eSFICARemixMode, mSFICARemixMode);
 
        auto tabarray = pango_tab_array_new( 20, FALSE);  // 20 channels is 
good enough
        for ( int t = 1; t < 20; ++t )
@@ -524,15 +492,8 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
                throw runtime_error ("Failed to construct widgets");
 
        mAnnotationsAtCursor = gtk_list_store_new(1, G_TYPE_STRING);
-       gtk_combo_box_set_model( eAnnotationSelectorWhich,
-                                (GtkTreeModel*)mAnnotationsAtCursor);
-       gtk_combo_box_set_id_column( eAnnotationSelectorWhich, 0);
-
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eAnnotationSelectorWhich, 
renderer, FALSE);
-       gtk_cell_layout_set_attributes( 
(GtkCellLayout*)eAnnotationSelectorWhich, renderer,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly( eAnnotationSelectorWhich, 
mAnnotationsAtCursor);
+
        // artifact detection
        if ( !(AGH_GBGETOBJ (GtkDialog,                 wSFArtifactDetection)) 
||
             !(AGH_GBGETOBJ (GtkComboBox,               eSFADProfiles)) ||
@@ -569,15 +530,7 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
        mSFADProfiles = gtk_list_store_new( 1, G_TYPE_STRING);
        // this GtkListStore is populated from the same source, but something
        // haunting GTK+ forbids reuse of _p.mGlobalArtifactDetectionProfiles
-       gtk_combo_box_set_model( eSFADProfiles,
-                                (GtkTreeModel*)mSFADProfiles);
-       gtk_combo_box_set_id_column( eSFADProfiles, 0);
-
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eSFADProfiles, renderer, 
FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eSFADProfiles, renderer,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly( eSFADProfiles, mSFADProfiles);
 
        g_signal_connect( wSFArtifactDetection, "close",
                          (GCallback)wSFArtifactDetection_close_cb,
@@ -643,28 +596,13 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
             !AGH_GBGETOBJ (GtkCheckButton,     ePatternNameSaveGlobally) )
                throw runtime_error ("Failed to construct SF widgets");
 
-       gtk_combo_box_set_model( ePatternList,
-                                (GtkTreeModel*)mPatterns);
-       gtk_combo_box_set_id_column( ePatternList, 0);
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)ePatternList, renderer, 
FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)ePatternList, renderer,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly( ePatternList, mPatterns);
        ePatternList_changed_cb_handler_id =
                g_signal_connect( ePatternList, "changed",
                                  G_CALLBACK (ePatternList_changed_cb),
                                  this);
 
-       gtk_combo_box_set_model( ePatternChannel,
-                                (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);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)ePatternChannel, 
renderer,
-                                       "text", 0,
-                                       NULL);
-
+       gtk_combo_box_set_model_properly( ePatternChannel, _p.mAllChannels);
        ePatternChannel_changed_cb_handler_id =
                g_signal_connect( ePatternChannel, "changed",
                                  G_CALLBACK (ePatternChannel_changed_cb),
@@ -739,14 +677,8 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
             !AGH_GBGETOBJ (GtkButton,          bFilterOK) )
                throw runtime_error ("Failed to construct SF widgets");
 
-       gtk_combo_box_set_model( eFilterNotchFilter,
-                                (GtkTreeModel*)mFilterNotchFilter); // can't 
reuse _p.mNotchFilter
-       gtk_combo_box_set_id_column( eFilterNotchFilter, 0);
-       renderer = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start( (GtkCellLayout*)eFilterNotchFilter, 
renderer, FALSE);
-       gtk_cell_layout_set_attributes( (GtkCellLayout*)eFilterNotchFilter, 
renderer,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly(
+               eFilterNotchFilter, mFilterNotchFilter); // can't reuse 
_p.mNotchFilter
 
        g_signal_connect( (GObject*)eFilterHighPassCutoff, "value-changed",
                          (GCallback)eFilterHighPassCutoff_value_changed_cb,
@@ -765,25 +697,14 @@ SScoringFacilityWidgets (SExpDesignUI& _p)
             !(AGH_GBGETOBJ (GtkScaleButton,    eSFPDSmooth)) )
                throw runtime_error ("Failed to construct SF widgets");
 
-       gtk_combo_box_set_model( eSFPDChannelA,
-                                (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,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly(
+               eSFPDChannelA, _p.mEEGChannels);
        eSFPDChannelA_changed_cb_handler_id =
                g_signal_connect( eSFPDChannelA, "changed",
                                  G_CALLBACK (eSFPDChannelA_changed_cb),
                                  this);
 
-       gtk_combo_box_set_model( eSFPDChannelB,
-                                (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,
-                                       "text", 0,
-                                       NULL);
+       gtk_combo_box_set_model_properly( eSFPDChannelB, _p.mEEGChannels);
        eSFPDChannelB_changed_cb_handler_id =
                g_signal_connect( eSFPDChannelB, "changed",
                                  G_CALLBACK (eSFPDChannelB_changed_cb),
diff --git a/src/ui/ui.hh b/src/ui/ui.hh
index 4afe8e5..635abba 100644
--- a/src/ui/ui.hh
+++ b/src/ui/ui.hh
@@ -113,6 +113,10 @@ gtk_flush()
                gtk_main_iteration();
 }
 
+void gtk_combo_box_set_model_properly( GtkComboBox*, GtkListStore*);
+
+
+
 enum TDrawSignalDirection { Forward, Backward };
 void
 cairo_draw_signal( cairo_t *cr,

-- 
Sleep experiment manager

_______________________________________________
debian-med-commit mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to