From eaf58fdd50a79aa4fa2760ca5dbeb2dd4cda2e15 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 Jun 2012 01:03:36 +0000 Subject: [PATCH] Marginal cleanup. git-svn-id: svn://localhost/ardour2/branches/3.0@12565 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/edit_note_dialog.cc | 18 +++++------ gtk2_ardour/editor_ops.cc | 6 ++-- gtk2_ardour/engine_dialog.cc | 51 ++++++++++-------------------- gtk2_ardour/option_editor.cc | 6 ++-- gtk2_ardour/patch_change_dialog.cc | 20 +++++------- gtk2_ardour/rc_option_editor.cc | 27 ++++++---------- libs/gtkmm2ext/gtkmm2ext/utils.h | 2 ++ libs/gtkmm2ext/utils.cc | 7 ++++ 8 files changed, 55 insertions(+), 82 deletions(-) diff --git a/gtk2_ardour/edit_note_dialog.cc b/gtk2_ardour/edit_note_dialog.cc index 4195ab8962..3c866cfe6f 100644 --- a/gtk2_ardour/edit_note_dialog.cc +++ b/gtk2_ardour/edit_note_dialog.cc @@ -20,6 +20,8 @@ #include #include +#include "gtkmm2ext/utils.h" + #include "canvas-note-event.h" #include "edit_note_dialog.h" #include "midi_region_view.h" @@ -27,6 +29,7 @@ #include "i18n.h" using namespace Gtk; +using namespace Gtkmm2ext; /** * EditNoteDialog constructor. @@ -46,8 +49,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, Gnome::Canvas::CanvasNoteEve int r = 0; - Label* l = manage (new Label (_("Channel"))); - l->set_alignment (0, 0.5); + Label* l = manage (left_aligned_label (_("Channel"))); table->attach (*l, 0, 1, r, r + 1); table->attach (_channel, 1, 2, r, r + 1); ++r; @@ -56,8 +58,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, Gnome::Canvas::CanvasNoteEve _channel.set_increments (1, 2); _channel.set_value (ev->note()->channel () + 1); - l = manage (new Label (_("Pitch"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Pitch"))); table->attach (*l, 0, 1, r, r + 1); table->attach (_pitch, 1, 2, r, r + 1); ++r; @@ -66,8 +67,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, Gnome::Canvas::CanvasNoteEve _pitch.set_increments (1, 10); _pitch.set_value (ev->note()->note ()); - l = manage (new Label (_("Velocity"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Velocity"))); table->attach (*l, 0, 1, r, r + 1); table->attach (_velocity, 1, 2, r, r + 1); ++r; @@ -76,8 +76,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, Gnome::Canvas::CanvasNoteEve _velocity.set_increments (1, 10); _velocity.set_value (ev->note()->velocity ()); - l = manage (new Label (_("Time"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Time"))); table->attach (*l, 0, 1, r, r + 1); table->attach (_time_clock, 1, 2, r, r + 1); ++r; @@ -86,8 +85,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, Gnome::Canvas::CanvasNoteEve _time_clock.set_mode (AudioClock::BBT); _time_clock.set (_region_view->source_relative_time_converter().to (ev->note()->time ()), true); - l = manage (new Label (_("Length"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Length"))); table->attach (*l, 0, 1, r, r + 1); table->attach (_length_clock, 1, 2, r, r + 1); ++r; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index d3ce0492c5..6d66c57b50 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6065,8 +6065,7 @@ Editor::close_region_gaps () Table table (2, 3); table.set_spacings (12); table.set_border_width (12); - Label* l = manage (new Label (_("Crossfade length"))); - l->set_alignment (0, 0.5); + Label* l = manage (left_aligned_label (_("Crossfade length"))); table.attach (*l, 0, 1, 0, 1); SpinButton spin_crossfade (1, 0); @@ -6077,8 +6076,7 @@ Editor::close_region_gaps () table.attach (*manage (new Label (_("ms"))), 2, 3, 0, 1); - l = manage (new Label (_("Pull-back length"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Pull-back length"))); table.attach (*l, 0, 1, 1, 2); SpinButton spin_pullback (1, 0); diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index de613f3cf4..6fe514b991 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -172,41 +172,35 @@ EngineControl::EngineControl () row = 0; - label = manage (new Label (_("Driver:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Driver:"))); basic_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); basic_packer.attach (driver_combo, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); row++; - label = manage (new Label (_("Audio Interface:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Audio Interface:"))); basic_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); basic_packer.attach (interface_combo, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); row++; - label = manage (new Label (_("Sample rate:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Sample rate:"))); basic_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); basic_packer.attach (sample_rate_combo, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); row++; - label = manage (new Label (_("Buffer size:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Buffer size:"))); basic_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); basic_packer.attach (period_size_combo, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); row++; #ifndef __APPLE__ - label = manage (new Label (_("Number of buffers:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Number of buffers:"))); basic_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); basic_packer.attach (periods_spinner, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); periods_spinner.set_value (2); row++; #endif - label = manage (new Label (_("Approximate latency:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Approximate latency:"))); basic_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); basic_packer.attach (latency_label, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); row++; @@ -219,8 +213,7 @@ EngineControl::EngineControl () /* no audio mode with CoreAudio, its duplex or nuthin' */ #ifndef __APPLE__ - label = manage (new Label (_("Audio mode:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Audio mode:"))); basic_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); basic_packer.attach (audio_mode_combo, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); row++; @@ -306,21 +299,18 @@ EngineControl::EngineControl () ++row; #endif /* PROVIDE_TOO_MANY_OPTIONS */ - label = manage (new Label (_("Number of ports:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Number of ports:"))); options_packer.attach (ports_spinner, 1, 2, row, row + 1, FILL|EXPAND, AttachOptions(0)); options_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); ++row; - label = manage (new Label (_("MIDI driver:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("MIDI driver:"))); options_packer.attach (midi_driver_combo, 1, 2, row, row + 1, FILL|EXPAND, AttachOptions(0)); options_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); ++row; #ifndef __APPLE__ - label = manage (new Label (_("Dither:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Dither:"))); options_packer.attach (dither_mode_combo, 1, 2, row, row + 1, FILL|EXPAND, AttachOptions(0)); options_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); ++row; @@ -337,9 +327,8 @@ EngineControl::EngineControl () serverpath_combo.set_active_text (server_strings.front()); if (server_strings.size() > 1) { - label = manage (new Label (_("Server:"))); + label = manage (left_aligned_label (_("Server:"))); options_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); - label->set_alignment (0.0, 0.5); options_packer.attach (serverpath_combo, 1, 2, row, row + 1, FILL|EXPAND, (AttachOptions) 0); ++row; } @@ -350,31 +339,25 @@ EngineControl::EngineControl () row = 0; #ifndef __APPLE__ - label = manage (new Label (_("Input device:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Input device:"))); device_packer.attach (*label, 0, 1, row, row+1, FILL|EXPAND, (AttachOptions) 0); device_packer.attach (input_device_combo, 1, 2, row, row+1, FILL|EXPAND, (AttachOptions) 0); ++row; - label = manage (new Label (_("Output device:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Output device:"))); device_packer.attach (*label, 0, 1, row, row+1, FILL|EXPAND, (AttachOptions) 0); device_packer.attach (output_device_combo, 1, 2, row, row+1, FILL|EXPAND, (AttachOptions) 0); ++row; #endif - label = manage (new Label (_("Hardware input latency:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Hardware input latency:"))); device_packer.attach (*label, 0, 1, row, row+1, FILL|EXPAND, (AttachOptions) 0); device_packer.attach (input_latency, 1, 2, row, row+1, FILL|EXPAND, (AttachOptions) 0); - label = manage (new Label (_("samples"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("samples"))); device_packer.attach (*label, 2, 3, row, row+1, FILL|EXPAND, (AttachOptions) 0); ++row; - label = manage (new Label (_("Hardware output latency:"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("Hardware output latency:"))); device_packer.attach (*label, 0, 1, row, row+1, FILL|EXPAND, (AttachOptions) 0); device_packer.attach (output_latency, 1, 2, row, row+1, FILL|EXPAND, (AttachOptions) 0); - label = manage (new Label (_("samples"))); - label->set_alignment (0, 0.5); + label = manage (left_aligned_label (_("samples"))); device_packer.attach (*label, 2, 3, row, row+1, FILL|EXPAND, (AttachOptions) 0); ++row; diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index ca8fa0a2cf..e1946002c1 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -87,8 +87,7 @@ OptionEditorHeading::OptionEditorHeading (string const & h) { std::stringstream s; s << "" << h << ""; - _label = manage (new Label (s.str())); - _label->set_alignment (0, 0.5); + _label = manage (left_aligned_label (s.str())); _label->set_use_markup (true); } @@ -141,8 +140,7 @@ EntryOption::EntryOption (string const & i, string const & n, sigc::slot _get (g), _set (s) { - _label = manage (new Label (n + ":")); - _label->set_alignment (0, 0.5); + _label = manage (left_aligned_label (n + ":")); _entry = manage (new Entry); _entry->signal_activate().connect (sigc::mem_fun (*this, &EntryOption::activated)); } diff --git a/gtk2_ardour/patch_change_dialog.cc b/gtk2_ardour/patch_change_dialog.cc index c7b80a5480..23feab8a77 100644 --- a/gtk2_ardour/patch_change_dialog.cc +++ b/gtk2_ardour/patch_change_dialog.cc @@ -21,6 +21,7 @@ #include #include #include +#include "gtkmm2ext/utils.h" #include "ardour/midi_patch_manager.h" #include "ardour/beats_frames_converter.h" #include "patch_change_dialog.h" @@ -28,6 +29,7 @@ using namespace std; using namespace Gtk; +using namespace Gtkmm2ext; /** @param tc If non-0, a time converter for this patch change. If 0, time control will be desensitized */ PatchChangeDialog::PatchChangeDialog ( @@ -55,8 +57,7 @@ PatchChangeDialog::PatchChangeDialog ( if (_time_converter) { - l = manage (new Label (_("Time"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Time"))); t->attach (*l, 0, 1, r, r + 1); t->attach (_time, 1, 2, r, r + 1); ++r; @@ -66,24 +67,21 @@ PatchChangeDialog::PatchChangeDialog ( _time.set (_time_converter->to (patch.time ()), true); } - l = manage (new Label (_("Patch Bank"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Patch Bank"))); t->attach (*l, 0, 1, r, r + 1); t->attach (_bank_combo, 1, 2, r, r + 1); ++r; _bank_combo.signal_changed().connect (sigc::mem_fun (*this, &PatchChangeDialog::bank_combo_changed)); - l = manage (new Label (_("Patch"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Patch"))); t->attach (*l, 0, 1, r, r + 1); t->attach (_patch_combo, 1, 2, r, r + 1); ++r; _patch_combo.signal_changed().connect (sigc::mem_fun (*this, &PatchChangeDialog::patch_combo_changed)); - l = manage (new Label (_("Channel"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Channel"))); t->attach (*l, 0, 1, r, r + 1); t->attach (_channel, 1, 2, r, r + 1); ++r; @@ -91,8 +89,7 @@ PatchChangeDialog::PatchChangeDialog ( _channel.set_value (patch.channel() + 1); _channel.signal_changed().connect (sigc::mem_fun (*this, &PatchChangeDialog::channel_changed)); - l = manage (new Label (_("Program"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Program"))); t->attach (*l, 0, 1, r, r + 1); t->attach (_program, 1, 2, r, r + 1); ++r; @@ -100,8 +97,7 @@ PatchChangeDialog::PatchChangeDialog ( _program.set_value (patch.program () + 1); _program.signal_changed().connect (sigc::mem_fun (*this, &PatchChangeDialog::program_changed)); - l = manage (new Label (_("Bank"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Bank"))); t->attach (*l, 0, 1, r, r + 1); t->attach (_bank, 1, 2, r, r + 1); ++r; diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index f5a8cc56f0..1d58443435 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -65,16 +65,14 @@ public: Table* t = manage (new Table (2, 3)); t->set_spacings (4); - Label* l = manage (new Label (_("Click audio file:"))); - l->set_alignment (0, 0.5); + Label* l = manage (left_aligned_label (_("Click audio file:"))); t->attach (*l, 0, 1, 0, 1, FILL); t->attach (_click_path_entry, 1, 2, 0, 1, FILL); Button* b = manage (new Button (_("Browse..."))); b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_browse_clicked)); t->attach (*b, 2, 3, 0, 1, FILL); - l = manage (new Label (_("Click emphasis audio file:"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Click emphasis audio file:"))); t->attach (*l, 0, 1, 1, 2, FILL); t->attach (_click_emphasis_path_entry, 1, 2, 1, 2, FILL); b = manage (new Button (_("Browse..."))); @@ -171,16 +169,14 @@ public: _limit_undo_spin.set_range (0, 512); _limit_undo_spin.set_increments (1, 10); t->attach (_limit_undo_spin, 1, 2, 0, 1, FILL | EXPAND); - Label* l = manage (new Label (_("commands"))); - l->set_alignment (0, 0.5); + Label* l = manage (left_aligned_label (_("commands"))); t->attach (*l, 2, 3, 0, 1); t->attach (_save_undo_button, 0, 1, 1, 2, FILL); _save_undo_spin.set_range (0, 512); _save_undo_spin.set_increments (1, 10); t->attach (_save_undo_spin, 1, 2, 1, 2, FILL | EXPAND); - l = manage (new Label (_("commands"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("commands"))); t->attach (*l, 2, 3, 1, 2); _box->pack_start (*t); @@ -318,9 +314,8 @@ public: Table* t = manage (new Table (4, 4)); t->set_spacings (4); - Label* l = manage (new Label (_("Edit using:"))); + Label* l = manage (left_aligned_label (_("Edit using:"))); l->set_name ("OptionsLabel"); - l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL); t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL); @@ -345,9 +340,8 @@ public: } } - l = manage (new Label (_("Delete using:"))); + l = manage (left_aligned_label (_("Delete using:"))); l->set_name ("OptionsLabel"); - l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL); t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL); @@ -373,9 +367,8 @@ public: } } - l = manage (new Label (_("Insert note using:"))); + l = manage (left_aligned_label (_("Insert note using:"))); l->set_name ("OptionsLabel"); - l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL); t->attach (_insert_note_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL); @@ -401,9 +394,8 @@ public: } } - l = manage (new Label (_("Toggle snap using:"))); + l = manage (left_aligned_label (_("Toggle snap using:"))); l->set_name ("OptionsLabel"); - l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL); t->attach (_snap_modifier_combo, 1, 2, 3, 4, FILL | EXPAND, FILL); @@ -418,9 +410,8 @@ public: _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name()); _keyboard_layout_selector.signal_changed().connect (sigc::mem_fun (*this, &KeyboardOptions::bindings_changed)); - l = manage (new Label (_("Keyboard layout:"))); + l = manage (left_aligned_label (_("Keyboard layout:"))); l->set_name ("OptionsLabel"); - l->set_alignment (0, 0.5); t->attach (*l, 0, 1, 4, 5, FILL | EXPAND, FILL); t->attach (_keyboard_layout_selector, 1, 2, 4, 5, FILL | EXPAND, FILL); diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h index 97c6e7758b..b7e27ea351 100644 --- a/libs/gtkmm2ext/gtkmm2ext/utils.h +++ b/libs/gtkmm2ext/gtkmm2ext/utils.h @@ -106,6 +106,8 @@ namespace Gtkmm2ext { void rounded_top_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); void rounded_bottom_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); + + Gtk::Label* left_aligned_label (std::string const &); }; #endif /* __gtkmm2ext_utils_h__ */ diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index 7ecb481e33..63d7655331 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -624,3 +624,10 @@ Gtkmm2ext::fit_to_pixels (cairo_t* cr, std::string name, double avail) return std::make_pair (name, width); } +Gtk::Label * +Gtkmm2ext::left_aligned_label (string const & t) +{ + Gtk::Label* l = new Gtk::Label (t); + l->set_alignment (0, 0.5); + return l; +}