MimeTypePanelData AddPanel(string mt) { var chain = new List <string> (DesktopService.GetMimeTypeInheritanceChain(mt).Where(mimeTypesWithPolicies.Contains)); if (chain.Count == 0) { return(null); } MimeTypePanelData data = new MimeTypePanelData(); OptionsDialogSection sec = new MimetypeOptionsDialogSection(mt); sec.Fill = true; data.Section = sec; data.MimeType = mt; data.TypeDescription = DesktopService.GetMimeTypeDescription(mt); if (string.IsNullOrEmpty(data.TypeDescription)) { data.TypeDescription = mt; } data.DataObject = DataObject; data.PolicyContainer = policyContainer; sec.Label = data.TypeDescription; LoadPolicyTypeData(data, mt, chain); typeSections [mt] = data; ParentDialog.AddChildSection(this, sec, data); return(data); }
MimeTypePanelData AddPanel(string mt) { var chain = new List <string> (DesktopService.GetMimeTypeInheritanceChain(mt).Where(x => mimeTypesWithPolicies.Contains(x))); if (chain.Count == 0) { return(null); } MimeTypePanelData data = new MimeTypePanelData(); OptionsDialogSection sec = new OptionsDialogSection(typeof(MimeTypePolicyOptionsSection)); sec.Fill = true; Gdk.Pixbuf icon = DesktopService.GetPixbufForType(mt, Gtk.IconSize.Menu); sec.Icon = ImageService.GetStockId(icon, Gtk.IconSize.Menu); data.Section = sec; data.MimeType = mt; data.TypeDescription = DesktopService.GetMimeTypeDescription(mt); if (string.IsNullOrEmpty(data.TypeDescription)) { data.TypeDescription = mt; } data.DataObject = DataObject; data.PolicyContainer = policyContainer; sec.Label = data.TypeDescription; LoadPolicyTypeData(data, mt, chain); typeSections [mt] = data; ParentDialog.AddChildSection(this, sec, data); return(data); }
protected virtual void OnEntryChanged(object sender, System.EventArgs e) { string name = entry.Text; if (string.IsNullOrEmpty(name)) { buttonOk.Sensitive = false; labelDesc.Text = string.Empty; image.Visible = false; return; } image.Visible = true; Xwt.Drawing.Image img; string desc; string mt = TryGetFileType(name); if (mt != null && mt != "text/plain") { desc = DesktopService.GetMimeTypeDescription(mt); img = DesktopService.GetIconForType(mt, Gtk.IconSize.Menu); mimeType = mt; } else if (name.IndexOf('/') != -1) { desc = DesktopService.GetMimeTypeDescription(name); img = DesktopService.GetIconForType(name, Gtk.IconSize.Menu); mimeType = name; } else { img = ImageService.GetIcon(Gtk.Stock.DialogError, Gtk.IconSize.Menu); desc = GettextCatalog.GetString("Unknown type"); mimeType = null; } if (mimeType != null && currentTypes.Contains(mimeType)) { img = ImageService.GetIcon(Gtk.Stock.DialogError, Gtk.IconSize.Menu); desc = GettextCatalog.GetString("Type '{0}' already registered", desc); mimeType = null; } if (string.IsNullOrEmpty(desc)) { desc = mt; } buttonOk.Sensitive = mimeType != null; labelDesc.Text = desc ?? string.Empty; image.Pixbuf = img.ToPixbuf(Gtk.IconSize.Menu); }
Widget IMimeTypePolicyOptionsPanel.CreateMimePanelWidget() { panelWidget = CreatePanelWidget(); //HACK: work around bug 469427 - broken themes match on widget names if (panelWidget.Name.IndexOf("Panel") > 0) { panelWidget.Name = panelWidget.Name.Replace("Panel", "_"); } if (isExactMimeType) { return(panelWidget); } VBox box = new VBox(); box.Spacing = 6; string baseType = mimeTypeScopes.ElementAt(1); baseType = DesktopService.GetMimeTypeDescription(baseType); defaultSettingsButton = new CheckButton(GettextCatalog.GetString("Use default settings from '{0}'", baseType)); defaultSettingsButton.Clicked += delegate { if (defaultSettingsButton.Active) { panelWidget.Sensitive = false; List <string> baseTypes = new List <string> (mimeTypeScopes); baseTypes.RemoveAt(0); LoadFrom(GetInheritedPolicy(baseTypes)); } else { panelWidget.Sensitive = true; } }; defaultSettingsButton.SetCommonAccessibilityAttributes("MimePanel.DefaultCheckbox", null, GettextCatalog.GetString("Check to use the default settings from '{0}'", baseType)); defaultSettingsButton.Accessible.AddLinkedUIElement(panelWidget.Accessible); box.PackStart(defaultSettingsButton, false, false, 0); var hsep = new HSeparator(); hsep.Accessible.SetShouldIgnore(true); box.PackStart(hsep, false, false, 0); box.ShowAll(); box.PackStart(panelWidget, true, true, 0); panelWidget.Show(); return(box); }
void HandleOnEditMimeType(object o, Gtk.EditedArgs e) { Gtk.TreeIter iter; if (storeMimeTypes.GetIterFromString(out iter, e.Path)) { string mt = e.NewText; string oldmt = (string)storeMimeTypes.GetValue(iter, 0); if (mt.Length > 0) { if (!entry.MimeTypes.Contains(mt)) { entry.MimeTypes.Add(mt); storeMimeTypes.SetValue(iter, 0, mt); storeMimeTypes.SetValue(iter, 1, DesktopService.GetMimeTypeDescription(mt)); if (!string.IsNullOrEmpty(oldmt)) { // It is a modification. Remove the old name. entry.MimeTypes.Remove(oldmt); } else { // Add a new line, so the user can add several types at a time TreeIter newit = storeMimeTypes.AppendValues("", ""); treeMimeTypes.Selection.SelectIter(newit); treeMimeTypes.ScrollToCell(storeMimeTypes.GetPath(newit), treeMimeTypes.Columns [0], false, 0f, 0f); treeMimeTypes.SetCursor(storeMimeTypes.GetPath(newit), treeMimeTypes.Columns [0], true); NotifyChanged(); } } } else { storeMimeTypes.Remove(ref iter); if (!string.IsNullOrEmpty(oldmt)) { entry.MimeTypes.Remove(oldmt); } } } }
void Fill() { loading++; comboType.Active = (int)entry.Type; entryExec.Text = entry.Exec; entryTryExec.Text = entry.TryExec; entryPath.Text = entry.Path; entryUrl.Text = entry.Url; checkTerminal.Active = entry.Terminal; comboLocales.AppendText(Mono.Unix.Catalog.GetString("<Default>")); comboLocales.Active = 0; foreach (string loc in entry.GetLocales()) { comboLocales.AppendText(loc); } // Environments list if (entry.OnlyShowIn.Count > 0) { radioOnlyShowIn.Active = true; } else if (entry.NotShowIn.Count > 0) { radioNotShowIn.Active = true; } else { radioAlwaysShow.Active = true; } FillEnvironments(); // Fill mime types ArrayList sortedmt = new ArrayList(); sortedmt.AddRange(entry.MimeTypes); sortedmt.Sort(); foreach (string mt in sortedmt) { string desc = DesktopService.GetMimeTypeDescription(mt); storeMimeTypes.AppendValues(mt, desc); } checkShowInMenu.Active = !entry.NoDisplay; foreach (string s in entry.GetUnknownEntries()) { storeEntries.AppendValues("<b>" + s + "</b>", s, entry.GetEntry(s)); } FillNames(); FillCategs(); UpdateType(); UpdateShowInMenu(); loading--; }