private void OnVisualizationChanged(object o, ExtensionNodeEventArgs args) { VisualizationExtensionNode node = (VisualizationExtensionNode)args.ExtensionNode; if (args.Change == ExtensionChange.Add) { RadioMenuItem group = visualizationMenu.Children.OfType <RadioMenuItem>().FirstOrDefault(); RadioMenuItem menu = group != null ? new RadioMenuItem(group, node.Label) : new RadioMenuItem(node.Label); menu.Show(); visualizationMenuMap[node] = menu; visualizationMenu.Add(menu); bool force = false; if (restoreFromSchema && node.IsSchemaSelected) { restoreFromSchema = false; force = true; } if (force || group == null) { menu.Active = true; activeVisualization = node; ConnectVisualization(); } menu.Activated += delegate { if (!menu.Active) { return; } activeVisualization = node; ConnectVisualization(); restoreFromSchema = false; Banshee.OpenVP.Settings.SelectedVisualizationSchema.Set(node.Type.FullName); }; noVisualizationsMenuItem.Hide(); } else { RadioMenuItem menu; if (visualizationMenuMap.TryGetValue(node, out menu)) { visualizationMenu.Remove(menu); visualizationMenuMap.Remove(node); } bool haveVis = visualizationMenu.Children.Length != 1; if (node == activeVisualization) { restoreFromSchema = true; if (haveVis) { ((MenuItem)visualizationMenu.Children[1]).Activate(); } else { activeVisualization = null; } ConnectVisualization(); } noVisualizationsMenuItem.Visible = !haveVis; } }
private SharpMusique(string [] args) { int i; string strPath; TreeViewColumn tvc; CellRenderer rendr; string [] strColumns = new string[] { "Title", "Artist", "Album", "Time", "Price" }; string [] strCWidths = new string[] { "260", "190", "180", "70", "70" }; if (Environment.OSVersion.ToString().IndexOf("Unix") != -1) { strHomeDir = Environment.GetEnvironmentVariable("HOME"); strSongDir = Path.Combine(strHomeDir, "Music"); strDataDir = Path.Combine(strHomeDir, ".SharpMusique"); } else { strHomeDir = Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData); strSongDir = Environment.GetFolderPath( Environment.SpecialFolder.MyMusic); strDataDir = Path.Combine(strHomeDir, "SharpMusique"); } Utility.CreateDirectory(strDataDir); strPath = Path.Combine(strDataDir, "songdir"); if (File.Exists(strPath)) { StreamReader sr = new StreamReader(strPath); strSongDir = sr.ReadToEnd().Trim(); sr.Close(); } Utility.CreateDirectory(strSongDir); strPath = Path.Combine(strDataDir, "cwidths"); if (File.Exists(strPath)) { StreamReader sr = new StreamReader(strPath); string [] strTmp = sr.ReadToEnd().Split(','); sr.Close(); if (strTmp.Length == strCWidths.Length) { strCWidths = strTmp; } } Application.Init(); Glade.XML gxml = new Glade.XML(null, "SharpMusique.glade", "MainWindow", null); gxml.Autoconnect(this); MainWindow.Icon = new Gdk.Pixbuf(null, "sharpmusique.png"); songls = new ListStore(GType.String, GType.String, GType.String, GType.String, GType.String, GType.Int); songtv.Model = songls; songtv.HeadersClickable = true; songtv.Selection.Changed += new EventHandler(OnTreeViewSelection); for (i = 0; i < strColumns.Length; i++) { tvc = new TreeViewColumn(); rendr = new CellRendererText(); tvc.Title = strColumns[i]; tvc.PackStart(rendr, true); tvc.AddAttribute(rendr, "text", i); tvc.Sizing = TreeViewColumnSizing.Fixed; tvc.FixedWidth = Convert.ToInt32(strCWidths[i]); tvc.Resizable = true; tvc.SortColumnId = i; songtv.AppendColumn(tvc); } strPath = Path.Combine(strDataDir, "country"); if (File.Exists(strPath)) { StreamReader sr = new StreamReader(strPath); strCountry = sr.ReadToEnd().Trim(); sr.Close(); } SList group = new SList(IntPtr.Zero); Menu cmenu = new Menu(); micountry.Submenu = cmenu; string [] countries = FairStore.Countries.AllKeys; for (i = 0; i < countries.Length; i++) { RadioMenuItem rmi = new RadioMenuItem(group, countries[i]); rmi.Toggled += new EventHandler(OnCountrySelect); rmi.Name = countries[i]; if ((((i + 1) == countries.Length) && (strCountry == null)) || countries[i].Equals(strCountry)) { rmi.Active = true; } group = rmi.Group; cmenu.Append(rmi); rmi.Show(); } mipending.Sensitive = false; mipepsicap.Sensitive = false; migiftcert.Sensitive = false; mipreview.Sensitive = false; mipurchase.Sensitive = false; mipurchasealbum.Sensitive = false; miviewalbum.Sensitive = false; cidStatus = sbar.GetContextId("Status"); cidProgress = sbar.GetContextId("Progress"); sbar.Push(cidStatus, "Not Logged In"); mutex = new Mutex(); Application.Run(); }