From: druid23 Date: Mon, 4 Oct 2010 00:44:56 +0000 (+0100) Subject: Reworked track settings. X-Git-Url: http://git.maemo.org/git/?p=demorecorder;a=commitdiff_plain;h=d78286b837d46480c687687e6cdf43d0b4814258 Reworked track settings. modified: ../build.sh modified: DemoRecorder.vala new file: TrackDetailsDialog.vala modified: TrackTransport.vala --- diff --git a/build.sh b/build.sh index 82be214..092aa36 100755 --- a/build.sh +++ b/build.sh @@ -43,6 +43,7 @@ src/SimpleHashMap.vala \ src/Tagging.vala \ src/Track.vala \ src/TrackBin.vala \ +src/TrackDetailsDialog.vala \ src/TrackEffectsPopUp.vala \ src/TrackPipeline.vala \ src/TrackTransport.vala \ diff --git a/src/DemoRecorder.vala b/src/DemoRecorder.vala index dec1c04..56b9001 100644 --- a/src/DemoRecorder.vala +++ b/src/DemoRecorder.vala @@ -29,7 +29,7 @@ public class DemoRecorder : Hildon.Program { RecordPipeline recordpipeline; PlayerTransport player; MixerBin mixer; - uint track_counter; + uint track_counter { get { return (null != tracks) ? tracks.get_children().length() : 0; }} bool recording; bool playing; bool encoding; @@ -112,7 +112,6 @@ public class DemoRecorder : Hildon.Program { project = SettingsStructures.ProjectSettings(); recording = false; playing = false; - track_counter = 0; window = new Hildon.StackableWindow(); window.destroy.connect(Gtk.main_quit); window.delete_event.connect(on_delete_event); @@ -504,10 +503,25 @@ public class DemoRecorder : Hildon.Program { private void remove_track(TrackTransport tt) { project.tracks.remove(tt.track); tracks.remove(tt); + // rebuild project.tracks + for (int idx = (int)project.tracks.length(); idx >= 0; --idx) { + project.tracks.remove_link(project.tracks.nth(idx)); + } + foreach (var child in tracks.get_children()) { + project.tracks.append(((TrackTransport)child).track); + } + project_dirty = true; tt = null; } private void save_project() { + // rebuild track settings + for (int idx = (int)project.tracks.length(); idx >= 0; --idx) { + project.tracks.remove_link(project.tracks.nth(idx)); + } + foreach (var child in tracks.get_children()) { + project.tracks.append(((TrackTransport)child).track); + } if (0 < project.location.length) { save_project_settings(project.location); } diff --git a/src/TrackDetailsDialog.vala b/src/TrackDetailsDialog.vala new file mode 100644 index 0000000..ce4aed8 --- /dev/null +++ b/src/TrackDetailsDialog.vala @@ -0,0 +1,80 @@ +/* Demo Recorder for MAEMO 5 +* Copyright (C) 2010 Dru Moore +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* or (at your option) any later version, as published by the Free +* Software Foundation +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +namespace IdWorks { + + public class TrackDetailsDialog : Hildon.Dialog { + + Hildon.Entry name_entry; + + public string get_name() { + return name_entry.get_text(); + } + public void set_name(string name) { + name_entry.set_text(name); + validate(); + } + + public TrackDetailsDialog(Gtk.Widget parent, string title) { + this.set_parent(parent); + this.set_title(title); + this.set_default_response(Gtk.ResponseType.CANCEL); + construct_interface(""); + } + + public TrackDetailsDialog.with_values(Gtk.Widget parent, string title, string name) { + this.set_parent(parent); + this.set_title(title); + this.set_default_response(Gtk.ResponseType.CANCEL); + construct_interface(name); + } + + private void construct_interface(string name) { + this.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK); + + Gtk.VBox control_area = (Gtk.VBox)this.get_content_area(); + + Gtk.HBox name_bar = new Gtk.HBox(false, 4); + + Gtk.Label name_label = new Gtk.Label("Name"); + name_bar.pack_start(name_label, false, false, 2); + name_entry = new Hildon.Entry(Hildon.SizeType.HALFSCREEN_WIDTH); + name_entry.set_text(name); + name_entry.set_placeholder("Project name"); + name_entry.changed.connect(name_entry_changed); + name_bar.pack_start(name_entry, true, true, 2); + + control_area.pack_start(name_bar, true, true, 4); + + validate(); + + this.show_all(); + } + + private void name_entry_changed() { + validate(); + } + + private void validate() { + bool good = true; + good &= (0 < get_name().length); + this.set_response_sensitive(Gtk.ResponseType.OK, good); + } + + } + +} \ No newline at end of file diff --git a/src/TrackTransport.vala b/src/TrackTransport.vala index 2e4b69d..1f28706 100644 --- a/src/TrackTransport.vala +++ b/src/TrackTransport.vala @@ -19,7 +19,10 @@ namespace IdWorks { public class TrackTransport : Gtk.HBox { - public TrackBin track_bin; + public TrackBin track_bin { + get { return this.track.bin; } + set { this.track.bin = value; } + } public Track track; public Gtk.Window window; @@ -40,10 +43,10 @@ public class TrackTransport : Gtk.HBox { Gtk.Button btn_delete; Gtk.Label lbl_title; - string _title; + //string _title; public string title { - get { return _title; /*lbl_title.get_text();*/ } - set { _title = value; lbl_title.set_markup("" + _title + ""); } + get { return this.track.label; /*lbl_title.get_text();*/ } + set { this.track.label = value; lbl_title.set_markup("" + value + ""); } } Gtk.ToggleButton btn_active; @@ -195,8 +198,14 @@ public class TrackTransport : Gtk.HBox { lbl_title = new Gtk.Label("New Track"); lbl_title.use_markup = true; lbl_title.set_alignment(0.1f, 0.4f); - lbl_title.set_ellipsize(Pango.EllipsizeMode.START); - this.pack_start(lbl_title, true, true, 2); + lbl_title.set_ellipsize(Pango.EllipsizeMode.END); + lbl_title.set_line_wrap(true); + Gtk.EventBox click_title = new Gtk.EventBox(); + click_title.set_above_child(true); + click_title.set_visible_window(true); + click_title.add(lbl_title); + click_title.button_release_event.connect((e) => {edit_title(lbl_title.get_text());}); + this.pack_start(click_title, true, true, 2); Gtk.HButtonBox buttons = new Gtk.HButtonBox(); btn_active = new Gtk.ToggleButton(); //.with_label("Active"); btn_mute.set_image(new Gtk.Image.from_icon_name("general_presence_online", Gtk.IconSize.SMALL_TOOLBAR)); @@ -221,7 +230,19 @@ public class TrackTransport : Gtk.HBox { btn_delete.clicked.connect((b) => { delete_clicked(); }); buttons.add(btn_delete); this.pack_start(buttons, false, false, 0); - } + } + + private bool edit_title(string text) { + TrackDetailsDialog dlg = new TrackDetailsDialog.with_values(window, "Track details", text); + dlg.set_transient_for(this.window); + int ret = dlg.run(); + if (Gtk.ResponseType.OK == ret) { + this.title = dlg.get_name(); + } + dlg.destroy(); + dlg = null; + return false; + } /* Overrides */ private override void add(Gtk.Widget w) {