public StationGroup AddStation(Station station)
        {
            StationGroup new_group = FindGroupForStation(station);
            StationGroup old_group = station.Parent as StationGroup;

            if(new_group == old_group && old_group != null) {
                return new_group;
            }

            if(old_group != null) {
                old_group.RemoveChild(station);

                if(old_group.ChildCount == 0) {
                    RemoveNode(old_group);
                }
            }

            if(new_group == null || old_group == null) {
                new_group = CreateGroup(station.Group);
                AddNode(new_group);
            }

            new_group.AddChild(station);
            return new_group;
        }
        public LinkStore(Station station)
            : base(typeof(Link))
        {
            if(station.Links == null) {
                return;
            }

            foreach(Link link in station.Links) {
                AddNode(link);
            }
        }
 public RadioTrackInfo(Station station, string uri)
     : base()
 {
     Title = station.Title;
     Uri = new SafeUri(uri);
 }
 private void StationDialog(Station station)
 {
     StationDialog dialog = new StationDialog(stations, station);
     dialog.Saved += OnStationSaved;
     dialog.Run();
 }
 public void Remove(Station station)
 {
     SerializeList.Remove(station);
 }
 public void Add(Station station)
 {
     SerializeList.Add(station);
 }
        public void RemoveStation(Station station)
        {
            StationGroup group = station.Parent as StationGroup;
            if(group == null) {
                return;
            }

            group.RemoveChild(station);
            if(group.ChildCount == 0) {
                RemoveNode(group);
            }

            stations.Remove(station);
            stations.Save();
        }
        private StationGroup FindGroupForStation(Station station)
        {
            if(station == null) {
                return null;
            }

            foreach(TreeNode node in this) {
                if(!(node is StationGroup)) {
                    continue;
                }

                StationGroup group = node as StationGroup;
                if(group.Title != null && station.Group != null &&
                    group.Title.ToLower() == station.Group.ToLower()) {
                    return group;
                }
            }

            return null;
        }
        public StationDialog(Stations stations, Station station)
        {
            glade = new Glade.XML(null, "radio.glade", "StationDialog", "banshee");
            glade.Autoconnect(this);
            dialog = (Dialog)glade.GetWidget("StationDialog");
            Banshee.Base.IconThemeUtils.SetWindowIcon(dialog);

            if(station == null) {
                is_new = true;
                station = new Station();
            }

            this.stations = stations;
            this.station = station;

            link_store = new LinkStore(station);
            view = new NodeView(link_store);
            view.HeadersVisible = true;

            CellRendererToggle active_renderer = new CellRendererToggle();
            active_renderer.Activatable = true;
            active_renderer.Radio = true;
            active_renderer.Toggled += OnLinkToggled;

            view.AppendColumn(Catalog.GetString("Active"), active_renderer, ActiveDataFunc);
            view.AppendColumn(Catalog.GetString("Type"), new CellRendererText(), TypeDataFunc);
            view.AppendColumn(Catalog.GetString("Title"), EditTextRenderer(), "text", 1);
            view.AppendColumn(Catalog.GetString("URI"), EditTextRenderer(), "text", 2);
            view.Show();

            (glade["link_view_container"] as ScrolledWindow).Add(view);

            group_combo = ComboBoxEntry.NewText();
            group_combo.Show();
            (glade["group_combo_container"] as Box).PackStart(group_combo, true, true, 0);

            title_entry.Text = station.Title == null ? String.Empty : station.Title;
            description_entry.Text = station.Description == null ? String.Empty : station.Description;
            group_combo.Entry.Text = station.Group == null ? String.Empty : station.Group;

            foreach(string group in stations.Groups) {
                group_combo.AppendText(group);
            }
        }