/[svn]/gigedit/trunk/src/gigedit/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3619 by schoenebeck, Tue Oct 1 16:21:28 2019 UTC revision 3637 by schoenebeck, Thu Oct 24 13:12:52 2019 UTC
# Line 1484  MainWindow::MainWindow() : Line 1484  MainWindow::MainWindow() :
1484          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
1485      instrumentProps.signal_changed().connect(      instrumentProps.signal_changed().connect(
1486          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
1487      propDialog.signal_changed().connect(      sampleProps.signal_changed().connect(
1488            sigc::mem_fun(*this, &MainWindow::file_changed));
1489        fileProps.signal_changed().connect(
1490          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
1491      midiRules.signal_changed().connect(      midiRules.signal_changed().connect(
1492          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
# Line 2603  void MainWindow::__import_queued_samples Line 2605  void MainWindow::__import_queued_samples
2605    
2606  void MainWindow::on_action_file_properties()  void MainWindow::on_action_file_properties()
2607  {  {
2608      propDialog.show();      fileProps.show();
2609      propDialog.deiconify();      fileProps.deiconify();
2610  }  }
2611    
2612  void MainWindow::on_action_warn_user_on_extensions() {  void MainWindow::on_action_warn_user_on_extensions() {
# Line 2675  void MainWindow::on_action_help_about() Line 2677  void MainWindow::on_action_help_about()
2677      dialog.run();      dialog.run();
2678  }  }
2679    
2680  PropDialog::PropDialog()  FilePropDialog::FilePropDialog()
2681      : eFileFormat(_("File Format")),      : eFileFormat(_("File Format")),
2682        eName(_("Name")),        eName(_("Name")),
2683        eCreationDate(_("Creation date")),        eCreationDate(_("Creation date")),
# Line 2709  PropDialog::PropDialog() Line 2711  PropDialog::PropDialog()
2711      set_title(_("File Properties"));      set_title(_("File Properties"));
2712      eName.set_width_chars(50);      eName.set_width_chars(50);
2713    
2714      connect(eFileFormat, &PropDialog::set_FileFormat);      connect(eFileFormat, &FilePropDialog::set_FileFormat);
2715      connect(eName, &DLS::Info::Name);      connect(eName, &DLS::Info::Name);
2716      connect(eCreationDate, &DLS::Info::CreationDate);      connect(eCreationDate, &DLS::Info::CreationDate);
2717      connect(eComments, &DLS::Info::Comments);      connect(eComments, &DLS::Info::Comments);
# Line 2770  PropDialog::PropDialog() Line 2772  PropDialog::PropDialog()
2772      quitButton.set_can_default();      quitButton.set_can_default();
2773      quitButton.grab_focus();      quitButton.grab_focus();
2774      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
2775          sigc::mem_fun(*this, &PropDialog::hide));          sigc::mem_fun(*this, &FilePropDialog::hide));
2776    
2777      quitButton.show();      quitButton.show();
2778      vbox.show();      vbox.show();
# Line 2779  PropDialog::PropDialog() Line 2781  PropDialog::PropDialog()
2781  #endif  #endif
2782  }  }
2783    
2784  void PropDialog::set_file(gig::File* file)  void FilePropDialog::set_file(gig::File* file)
2785  {  {
2786      m_file = file;      m_file = file;
2787      update(file->pInfo);      update(file->pInfo);
# Line 2805  void PropDialog::set_file(gig::File* fil Line 2807  void PropDialog::set_file(gig::File* fil
2807      update_model--;      update_model--;
2808  }  }
2809    
2810  void PropDialog::set_FileFormat(int value)  void FilePropDialog::set_FileFormat(int value)
2811  {  {
2812      m_file->pVersion->major = value;      m_file->pVersion->major = value;
2813  }  }
# Line 2856  InstrumentProps::InstrumentProps() : Line 2858  InstrumentProps::InstrumentProps() :
2858      ePitchbendRange(_("Pitchbend range"), 0, 48),      ePitchbendRange(_("Pitchbend range"), 0, 48),
2859      ePianoReleaseMode(_("Piano release mode")),      ePianoReleaseMode(_("Piano release mode")),
2860      eDimensionKeyRangeLow(_("Keyswitching range low")),      eDimensionKeyRangeLow(_("Keyswitching range low")),
2861      eDimensionKeyRangeHigh(_("Keyswitching range high"))      eDimensionKeyRangeHigh(_("Keyswitching range high")),
2862        table2(2,1),
2863        eName2(_("Name")),
2864        eCreationDate(_("Creation date")),
2865        eComments(_("Comments")),
2866        eProduct(_("Product")),
2867        eCopyright(_("Copyright")),
2868        eArtists(_("Artists")),
2869        eGenre(_("Genre")),
2870        eKeywords(_("Keywords")),
2871        eEngineer(_("Engineer")),
2872        eTechnician(_("Technician")),
2873        eSoftware(_("Software")),
2874        eMedium(_("Medium")),
2875        eSource(_("Source")),
2876        eSourceForm(_("Source form")),
2877        eCommissioned(_("Commissioned")),
2878        eSubject(_("Subject"))
2879  {  {
2880      if (!Settings::singleton()->autoRestoreWindowDimension) {      if (!Settings::singleton()->autoRestoreWindowDimension) {
2881          //set_default_size(470, 390);          //set_default_size(470, 390);
# Line 2865  InstrumentProps::InstrumentProps() : Line 2884  InstrumentProps::InstrumentProps() :
2884    
2885      set_title(_("Instrument Properties"));      set_title(_("Instrument Properties"));
2886    
2887        tabs.append_page(vbox[1], _("Settings"));
2888        tabs.append_page(vbox[2], _("Info"));
2889    
2890      eDimensionKeyRangeLow.set_tip(      eDimensionKeyRangeLow.set_tip(
2891          _("start of the keyboard area which should switch the "          _("start of the keyboard area which should switch the "
2892            "\"keyswitching\" dimension")            "\"keyswitching\" dimension")
# Line 2889  InstrumentProps::InstrumentProps() : Line 2911  InstrumentProps::InstrumentProps() :
2911    
2912      eName.signal_value_changed().connect(sig_name_changed.make_slot());      eName.signal_value_changed().connect(sig_name_changed.make_slot());
2913    
2914        connect(eName2, &InstrumentProps::set_Name);
2915        connectLambda(eCreationDate, [this](gig::String s) {
2916            m->pInfo->CreationDate = s;
2917        });
2918        connectLambda(eComments, [this](gig::String s) {
2919            m->pInfo->Comments = s;
2920        });
2921        connectLambda(eProduct, [this](gig::String s) {
2922            m->pInfo->Product = s;
2923        });
2924        connectLambda(eCopyright, [this](gig::String s) {
2925            m->pInfo->Copyright = s;
2926        });
2927        connectLambda(eArtists, [this](gig::String s) {
2928            m->pInfo->Artists = s;
2929        });
2930        connectLambda(eGenre, [this](gig::String s) {
2931            m->pInfo->Genre = s;
2932        });
2933        connectLambda(eKeywords, [this](gig::String s) {
2934            m->pInfo->Keywords = s;
2935        });
2936        connectLambda(eEngineer, [this](gig::String s) {
2937            m->pInfo->Engineer = s;
2938        });
2939        connectLambda(eTechnician, [this](gig::String s) {
2940            m->pInfo->Technician = s;
2941        });
2942        connectLambda(eSoftware, [this](gig::String s) {
2943            m->pInfo->Software = s;
2944        });
2945        connectLambda(eMedium, [this](gig::String s) {
2946            m->pInfo->Medium = s;
2947        });
2948        connectLambda(eSource, [this](gig::String s) {
2949            m->pInfo->Source = s;
2950        });
2951        connectLambda(eSourceForm, [this](gig::String s) {
2952            m->pInfo->SourceForm = s;
2953        });
2954        connectLambda(eCommissioned, [this](gig::String s) {
2955            m->pInfo->Commissioned = s;
2956        });
2957        connectLambda(eSubject, [this](gig::String s) {
2958            m->pInfo->Subject = s;
2959        });
2960    
2961        // tab 1
2962  #if USE_GTKMM_GRID  #if USE_GTKMM_GRID
2963      table.set_column_spacing(5);      table.set_column_spacing(5);
2964  #else  #else
2965      table.set_col_spacings(5);      table.set_col_spacings(5);
2966  #endif  #endif
   
2967      table.add(eName);      table.add(eName);
2968      table.add(eIsDrum);      table.add(eIsDrum);
2969      table.add(eMIDIBank);      table.add(eMIDIBank);
# Line 2908  InstrumentProps::InstrumentProps() : Line 2977  InstrumentProps::InstrumentProps() :
2977      table.add(eDimensionKeyRangeLow);      table.add(eDimensionKeyRangeLow);
2978      table.add(eDimensionKeyRangeHigh);      table.add(eDimensionKeyRangeHigh);
2979    
2980      add(vbox);      // tab 2
2981    #if USE_GTKMM_GRID
2982        table2.set_column_spacing(5);
2983    #else
2984        table2.set_col_spacings(5);
2985    #endif
2986        table2.add(eName2);
2987        table2.add(eCreationDate);
2988        table2.add(eComments);
2989        table2.add(eProduct);
2990        table2.add(eCopyright);
2991        table2.add(eArtists);
2992        table2.add(eGenre);
2993        table2.add(eKeywords);
2994        table2.add(eEngineer);
2995        table2.add(eTechnician);
2996        table2.add(eSoftware);
2997        table2.add(eMedium);
2998        table2.add(eSource);
2999        table2.add(eSourceForm);
3000        table2.add(eCommissioned);
3001        table2.add(eSubject);
3002    
3003        add(vbox[0]);
3004  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3005      table.set_margin(5);      table.set_margin(5);
3006  #else  #else
3007      table.set_border_width(5);      table.set_border_width(5);
3008  #endif  #endif
3009      vbox.pack_start(table);      vbox[1].pack_start(table);
3010        vbox[2].pack_start(table2);
3011      table.show();      table.show();
3012      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      table2.show();
3013        vbox[0].pack_start(tabs);
3014        vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK);
3015      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
3016  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3017      buttonBox.set_margin(5);      buttonBox.set_margin(5);
# Line 2932  InstrumentProps::InstrumentProps() : Line 3027  InstrumentProps::InstrumentProps() :
3027          sigc::mem_fun(*this, &InstrumentProps::hide));          sigc::mem_fun(*this, &InstrumentProps::hide));
3028    
3029      quitButton.show();      quitButton.show();
3030      vbox.show();      vbox[0].show();
3031  #if HAS_GTKMM_SHOW_ALL_CHILDREN  #if HAS_GTKMM_SHOW_ALL_CHILDREN
3032      show_all_children();      show_all_children();
3033  #endif  #endif
# Line 2943  void InstrumentProps::set_instrument(gig Line 3038  void InstrumentProps::set_instrument(gig
3038      update(instrument);      update(instrument);
3039    
3040      update_model++;      update_model++;
3041    
3042        // tab 1
3043      eName.set_value(instrument->pInfo->Name);      eName.set_value(instrument->pInfo->Name);
3044      eIsDrum.set_value(instrument->IsDrum);      eIsDrum.set_value(instrument->IsDrum);
3045      eMIDIBank.set_value(instrument->MIDIBank);      eMIDIBank.set_value(instrument->MIDIBank);
3046      eMIDIProgram.set_value(instrument->MIDIProgram);      eMIDIProgram.set_value(instrument->MIDIProgram);
3047        // tab 2
3048        eName2.set_value(instrument->pInfo->Name);
3049        eCreationDate.set_value(instrument->pInfo->CreationDate);
3050        eComments.set_value(instrument->pInfo->Comments);
3051        eProduct.set_value(instrument->pInfo->Product);
3052        eCopyright.set_value(instrument->pInfo->Copyright);
3053        eArtists.set_value(instrument->pInfo->Artists);
3054        eGenre.set_value(instrument->pInfo->Genre);
3055        eKeywords.set_value(instrument->pInfo->Keywords);
3056        eEngineer.set_value(instrument->pInfo->Engineer);
3057        eTechnician.set_value(instrument->pInfo->Technician);
3058        eSoftware.set_value(instrument->pInfo->Software);
3059        eMedium.set_value(instrument->pInfo->Medium);
3060        eSource.set_value(instrument->pInfo->Source);
3061        eSourceForm.set_value(instrument->pInfo->SourceForm);
3062        eCommissioned.set_value(instrument->pInfo->Commissioned);
3063        eSubject.set_value(instrument->pInfo->Subject);
3064    
3065        update_model--;
3066    }
3067    
3068    
3069    SampleProps::SampleProps() :
3070    #if HAS_GTKMM_STOCK
3071        quitButton(Gtk::Stock::CLOSE),
3072    #else
3073        quitButton(_("_Close")),
3074    #endif
3075        table(2,1),
3076        eName(_("Name")),
3077        eUnityNote(_("Unity Note")),
3078        eSampleGroup(_("Sample Group")),
3079        eSampleFormatInfo(_("Sample Format")),
3080        eSampleID("Sample ID"),
3081        eChecksum("Wave Data CRC-32"),
3082        eLoopsCount(_("Loops"), 0, 1), // we might support more than 1 loop in future
3083        eLoopStart(_("Loop start position"), 0, 9999999),
3084        eLoopLength(_("Loop size"), 0, 9999999),
3085        eLoopType(_("Loop type")),
3086        eLoopPlayCount(_("Playback count")),
3087        table2(2,1),
3088        eName2(_("Name")),
3089        eCreationDate(_("Creation date")),
3090        eComments(_("Comments")),
3091        eProduct(_("Product")),
3092        eCopyright(_("Copyright")),
3093        eArtists(_("Artists")),
3094        eGenre(_("Genre")),
3095        eKeywords(_("Keywords")),
3096        eEngineer(_("Engineer")),
3097        eTechnician(_("Technician")),
3098        eSoftware(_("Software")),
3099        eMedium(_("Medium")),
3100        eSource(_("Source")),
3101        eSourceForm(_("Source form")),
3102        eCommissioned(_("Commissioned")),
3103        eSubject(_("Subject"))
3104    {
3105        if (!Settings::singleton()->autoRestoreWindowDimension) {
3106            //set_default_size(470, 390);
3107            set_position(Gtk::WIN_POS_MOUSE);
3108        }
3109    
3110        set_title(_("Sample Properties"));
3111    
3112        tabs.append_page(vbox[1], _("Settings"));
3113        tabs.append_page(vbox[2], _("Info"));
3114    
3115        connect(eName, &SampleProps::set_Name);
3116        connect(eUnityNote, &gig::Sample::MIDIUnityNote);
3117        connect(eLoopsCount, &gig::Sample::Loops);
3118        connectLambda(eLoopStart, [this](uint32_t start){
3119            m->LoopStart = start;
3120            m->LoopEnd = start + m->LoopSize;
3121        });
3122        connectLambda(eLoopLength, [this](uint32_t length){
3123            m->LoopSize = length;
3124            m->LoopEnd = m->LoopStart + length;
3125        });
3126        {
3127            const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
3128            static const gig::loop_type_t values[] = {
3129                gig::loop_type_normal,
3130                gig::loop_type_bidirectional,
3131                gig::loop_type_backward
3132            };
3133            eLoopType.set_choices(choices, values);
3134        }
3135        connect(eLoopType, &gig::Sample::LoopType);
3136        connect(eLoopPlayCount, &gig::Sample::LoopPlayCount);
3137    
3138        eName.signal_value_changed().connect(sig_name_changed.make_slot());
3139    
3140        connect(eName2, &SampleProps::set_Name);
3141        connectLambda(eCreationDate, [this](gig::String s) {
3142            m->pInfo->CreationDate = s;
3143        });
3144        connectLambda(eComments, [this](gig::String s) {
3145            m->pInfo->Comments = s;
3146        });
3147        connectLambda(eProduct, [this](gig::String s) {
3148            m->pInfo->Product = s;
3149        });
3150        connectLambda(eCopyright, [this](gig::String s) {
3151            m->pInfo->Copyright = s;
3152        });
3153        connectLambda(eArtists, [this](gig::String s) {
3154            m->pInfo->Artists = s;
3155        });
3156        connectLambda(eGenre, [this](gig::String s) {
3157            m->pInfo->Genre = s;
3158        });
3159        connectLambda(eKeywords, [this](gig::String s) {
3160            m->pInfo->Keywords = s;
3161        });
3162        connectLambda(eEngineer, [this](gig::String s) {
3163            m->pInfo->Engineer = s;
3164        });
3165        connectLambda(eTechnician, [this](gig::String s) {
3166            m->pInfo->Technician = s;
3167        });
3168        connectLambda(eSoftware, [this](gig::String s) {
3169            m->pInfo->Software = s;
3170        });
3171        connectLambda(eMedium, [this](gig::String s) {
3172            m->pInfo->Medium = s;
3173        });
3174        connectLambda(eSource, [this](gig::String s) {
3175            m->pInfo->Source = s;
3176        });
3177        connectLambda(eSourceForm, [this](gig::String s) {
3178            m->pInfo->SourceForm = s;
3179        });
3180        connectLambda(eCommissioned, [this](gig::String s) {
3181            m->pInfo->Commissioned = s;
3182        });
3183        connectLambda(eSubject, [this](gig::String s) {
3184            m->pInfo->Subject = s;
3185        });
3186    
3187        // tab 1
3188    #if USE_GTKMM_GRID
3189        table.set_column_spacing(5);
3190    #else
3191        table.set_col_spacings(5);
3192    #endif
3193        table.add(eName);
3194        table.add(eUnityNote);
3195        table.add(eSampleGroup);
3196        table.add(eSampleFormatInfo);
3197        table.add(eSampleID);
3198        table.add(eChecksum);
3199        table.add(eLoopsCount);
3200        table.add(eLoopStart);
3201        table.add(eLoopLength);
3202        table.add(eLoopType);
3203        table.add(eLoopPlayCount);
3204    
3205        // tab 2
3206    #if USE_GTKMM_GRID
3207        table2.set_column_spacing(5);
3208    #else
3209        table2.set_col_spacings(5);
3210    #endif
3211        table2.add(eName2);
3212        table2.add(eCreationDate);
3213        table2.add(eComments);
3214        table2.add(eProduct);
3215        table2.add(eCopyright);
3216        table2.add(eArtists);
3217        table2.add(eGenre);
3218        table2.add(eKeywords);
3219        table2.add(eEngineer);
3220        table2.add(eTechnician);
3221        table2.add(eSoftware);
3222        table2.add(eMedium);
3223        table2.add(eSource);
3224        table2.add(eSourceForm);
3225        table2.add(eCommissioned);
3226        table2.add(eSubject);
3227    
3228        add(vbox[0]);
3229    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3230        table.set_margin(5);
3231    #else
3232        table.set_border_width(5);
3233    #endif
3234        vbox[1].pack_start(table);
3235        vbox[2].pack_start(table2);
3236        table.show();
3237        table2.show();
3238        vbox[0].pack_start(tabs);
3239        vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK);
3240        buttonBox.set_layout(Gtk::BUTTONBOX_END);
3241    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3242        buttonBox.set_margin(5);
3243    #else
3244        buttonBox.set_border_width(5);
3245    #endif
3246        buttonBox.show();
3247        buttonBox.pack_start(quitButton);
3248        quitButton.set_can_default();
3249        quitButton.grab_focus();
3250    
3251        quitButton.signal_clicked().connect(
3252            sigc::mem_fun(*this, &SampleProps::hide));
3253    
3254        quitButton.show();
3255        vbox[0].show();
3256    #if HAS_GTKMM_SHOW_ALL_CHILDREN
3257        show_all_children();
3258    #endif
3259    }
3260    
3261    void SampleProps::set_sample(gig::Sample* sample)
3262    {
3263        update(sample);
3264    
3265        update_model++;
3266    
3267        // tab 1
3268        eName.set_value(sample->pInfo->Name);
3269        eUnityNote.set_value(sample->MIDIUnityNote);
3270        // show sample group name
3271        {
3272            Glib::ustring s = "---";
3273            if (sample && sample->GetGroup())
3274                s = sample->GetGroup()->Name;
3275            eSampleGroup.text.set_text(s);
3276        }
3277        // assemble sample format info string
3278        {
3279            Glib::ustring s;
3280            if (sample) {
3281                switch (sample->Channels) {
3282                    case 1: s = _("Mono"); break;
3283                    case 2: s = _("Stereo"); break;
3284                    default:
3285                        s = ToString(sample->Channels) + _(" audio channels");
3286                        break;
3287                }
3288                s += " " + ToString(sample->BitDepth) + " Bits";
3289                s += " " + ToString(sample->SamplesPerSecond/1000) + "."
3290                         + ToString((sample->SamplesPerSecond%1000)/100) + " kHz";
3291            } else {
3292                s = _("No sample assigned to this dimension region.");
3293            }
3294            eSampleFormatInfo.text.set_text(s);
3295        }
3296        // generate sample's memory address pointer string
3297        {
3298            Glib::ustring s;
3299            if (sample) {
3300                char buf[64] = {};
3301                snprintf(buf, sizeof(buf), "%p", sample);
3302                s = buf;
3303            } else {
3304                s = "---";
3305            }
3306            eSampleID.text.set_text(s);
3307        }
3308        // generate raw wave form data CRC-32 checksum string
3309        {
3310            Glib::ustring s = "---";
3311            if (sample) {
3312                char buf[64] = {};
3313                snprintf(buf, sizeof(buf), "%x", sample->GetWaveDataCRC32Checksum());
3314                s = buf;
3315            }
3316            eChecksum.text.set_text(s);
3317        }
3318        eLoopsCount.set_value(sample->Loops);
3319        eLoopStart.set_value(sample->LoopStart);
3320        eLoopLength.set_value(sample->LoopSize);
3321        eLoopType.set_value(sample->LoopType);
3322        eLoopPlayCount.set_value(sample->LoopPlayCount);
3323        // tab 2
3324        eName2.set_value(sample->pInfo->Name);
3325        eCreationDate.set_value(sample->pInfo->CreationDate);
3326        eComments.set_value(sample->pInfo->Comments);
3327        eProduct.set_value(sample->pInfo->Product);
3328        eCopyright.set_value(sample->pInfo->Copyright);
3329        eArtists.set_value(sample->pInfo->Artists);
3330        eGenre.set_value(sample->pInfo->Genre);
3331        eKeywords.set_value(sample->pInfo->Keywords);
3332        eEngineer.set_value(sample->pInfo->Engineer);
3333        eTechnician.set_value(sample->pInfo->Technician);
3334        eSoftware.set_value(sample->pInfo->Software);
3335        eMedium.set_value(sample->pInfo->Medium);
3336        eSource.set_value(sample->pInfo->Source);
3337        eSourceForm.set_value(sample->pInfo->SourceForm);
3338        eCommissioned.set_value(sample->pInfo->Commissioned);
3339        eSubject.set_value(sample->pInfo->Subject);
3340    
3341        update_model--;
3342    }
3343    
3344    void SampleProps::set_Name(const gig::String& name)
3345    {
3346        m->pInfo->Name = name;
3347    }
3348    
3349    void SampleProps::update_name()
3350    {
3351        update_model++;
3352        eName.set_value(m->pInfo->Name);
3353      update_model--;      update_model--;
3354  }  }
3355    
# Line 3042  void MainWindow::load_gig(gig::File* gig Line 3445  void MainWindow::load_gig(gig::File* gig
3445      file_has_name = filename;      file_has_name = filename;
3446      file_is_changed = false;      file_is_changed = false;
3447    
3448      propDialog.set_file(gig);      fileProps.set_file(gig);
3449    
3450      instrument_name_connection.block();      instrument_name_connection.block();
3451      int index = 0;      int index = 0;
# Line 3182  void MainWindow::instr_name_changed_by_i Line 3585  void MainWindow::instr_name_changed_by_i
3585      }      }
3586  }  }
3587    
3588    bool MainWindow::sample_props_set_sample()
3589    {
3590        sampleProps.signal_name_changed().clear();
3591    
3592        std::vector<Gtk::TreeModel::Path> rows = m_TreeViewSamples.get_selection()->get_selected_rows();
3593        if (rows.empty()) {
3594            sampleProps.hide();
3595            return false;
3596        }
3597        //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
3598        Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
3599        if (it) {
3600            Gtk::TreeModel::Row row = *it;
3601            gig::Sample* sample = row[m_SamplesModel.m_col_sample];
3602    
3603            sampleProps.set_sample(sample);
3604    
3605            // make sure sample tree is updated when user changes the
3606            // sample name in sample properties window
3607            sampleProps.signal_name_changed().connect(
3608                sigc::bind(
3609                    sigc::mem_fun(*this,
3610                        &MainWindow::sample_name_changed_by_sample_props
3611                    ), it
3612                )
3613            );
3614        } else {
3615            sampleProps.hide();
3616        }
3617        //NOTE: explicit boolean cast required for GTKMM4 development branch here
3618        return it ? true : false;
3619    }
3620    
3621    void MainWindow::show_sample_props()
3622    {
3623        if (sample_props_set_sample()) {
3624            sampleProps.show();
3625            sampleProps.deiconify();
3626        }
3627    }
3628    
3629    void MainWindow::sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it)
3630    {
3631        Gtk::TreeModel::Row row = *it;
3632        Glib::ustring name = row[m_SamplesModel.m_col_name];
3633    
3634        gig::Sample* sample = row[m_SamplesModel.m_col_sample];
3635        Glib::ustring gigname(gig_to_utf8(sample->pInfo->Name));
3636        if (gigname != name) {
3637            Gtk::TreeModel::Path path(*it);
3638            row[m_SamplesModel.m_col_name] = gigname;
3639        }
3640    }
3641    
3642  void MainWindow::show_midi_rules()  void MainWindow::show_midi_rules()
3643  {  {
3644      if (gig::Instrument* instrument = get_instrument())      if (gig::Instrument* instrument = get_instrument())
# Line 3888  void MainWindow::on_action_remove_instru Line 4345  void MainWindow::on_action_remove_instru
4345  }  }
4346    
4347  void MainWindow::on_action_sample_properties() {  void MainWindow::on_action_sample_properties() {
4348      //TODO: show a dialog where the selected sample's properties can be edited      show_sample_props();
     Gtk::MessageDialog msg(  
         *this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO  
     );  
     msg.run();  
4349  }  }
4350    
4351  void MainWindow::on_action_add_script_group() {  void MainWindow::on_action_add_script_group() {
# Line 4691  void MainWindow::sample_name_changed(con Line 5144  void MainWindow::sample_name_changed(con
5144              file_changed();              file_changed();
5145          }          }
5146      }      }
5147        // change name in the sample properties window
5148        if (sampleProps.get_sample() == sample && sample) {
5149            sampleProps.set_sample(sample);
5150        }
5151  }  }
5152    
5153  void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path,  void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path,

Legend:
Removed from v.3619  
changed lines
  Added in v.3637

  ViewVC Help
Powered by ViewVC