Ejemplo n.º 1
0
 void SetDockNotebookTabTitle()
 {
     tab.Text   = Title;
     tab.Notify = show_notification;
     tab.Dirty  = content.IsDirty;
     if (content.ContentName != null && content.ContentName != "")
     {
         tab.Tooltip = content.ContentName;
     }
     try {
         if (content.StockIconId != null)
         {
             tab.Icon = ImageService.GetIcon(content.StockIconId, IconSize.Menu);
         }
         else
         if (content.ContentName != null && content.ContentName.IndexOfAny(new char[] {
             '*',
             '+'
         }) == -1)
         {
             tab.Icon = DesktopService.GetIconForFile(content.ContentName, Gtk.IconSize.Menu);
         }
     }
     catch (Exception ex) {
         LoggingService.LogError(ex.ToString());
         tab.Icon = DesktopService.GetIconForType("gnome-fs-regular", Gtk.IconSize.Menu);
     }
 }
Ejemplo n.º 2
0
 void Fill()
 {
     foreach (MimeTypePanelData mt in panel.GetMimeTypeData())
     {
         store.AppendValues(mt, DesktopService.GetIconForType(mt.MimeType, Gtk.IconSize.Menu), mt.TypeDescription);
     }
 }
Ejemplo n.º 3
0
        protected virtual void OnTitleChanged(EventArgs e)
        {
            fileTypeCondition.SetFileName(content.ContentName ?? content.UntitledName);

            tab.Text   = Title;
            tab.Notify = show_notification;
            tab.Dirty  = content.IsDirty;

            if (content.ContentName != null && content.ContentName != "")
            {
                tab.Tooltip = content.ContentName;
            }

            try {
                if (content.StockIconId != null)
                {
                    tab.Icon = ImageService.GetIcon(content.StockIconId, IconSize.Menu);
                }
                else if (content.ContentName != null && content.ContentName.IndexOfAny(new char[] { '*', '+' }) == -1)
                {
                    tab.Icon = DesktopService.GetIconForFile(content.ContentName, Gtk.IconSize.Menu);
                }
            } catch (Exception ex) {
                LoggingService.LogError(ex.ToString());
                tab.Icon = DesktopService.GetIconForType("gnome-fs-regular", Gtk.IconSize.Menu);
            }

            if (TitleChanged != null)
            {
                TitleChanged(this, e);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        protected virtual void OnButtonAddClicked(object sender, System.EventArgs e)
        {
            AddMimeTypeDialog dlg = new AddMimeTypeDialog(panel.GetItemMimeTypes());

            try {
                if (MessageService.RunCustomDialog(dlg, this.Toplevel as Gtk.Window) == (int)Gtk.ResponseType.Ok)
                {
                    MimeTypePanelData mt = panel.AddGlobalMimeType(dlg.MimeType);
                    store.AppendValues(mt, DesktopService.GetIconForType(mt.MimeType, Gtk.IconSize.Menu), mt.TypeDescription);
                }
            } finally {
                dlg.Destroy();
            }
        }
Ejemplo n.º 6
0
        static void PixbufCellDataFunc(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            TreeIter parent;
            bool     toplevel = !model.IterParent(out parent, iter);

            var crp = (CellRendererImage)cell;

            crp.Visible = !toplevel;

            if (toplevel)
            {
                return;
            }

            var section = (OptionsDialogSection)model.GetValue(iter, 0);

            //HACK: The mimetype panels can't register a single fake stock ID for all the possible image size.
            // Instead, give this some awareness of the mime system.
            var mimeSection = section as MonoDevelop.Ide.Projects.OptionPanels.MimetypeOptionsDialogSection;

            if (mimeSection != null && !string.IsNullOrEmpty(mimeSection.MimeType))
            {
                var pix = DesktopService.GetIconForType(mimeSection.MimeType, treeIconSize);
                if (pix != null)
                {
                    crp.Image = pix;
                }
                else
                {
                    crp.Image = ImageService.GetIcon(emptyCategoryIcon, treeIconSize);
                }
            }
            else
            {
                string icon = section.Icon.IsNull? emptyCategoryIcon : section.Icon.ToString();
                crp.Image = ImageService.GetIcon(icon, treeIconSize);
            }
        }
Ejemplo n.º 7
0
        internal void ShowPage(OptionsDialogSection section)
        {
            if (!IsRealized)
            {
                // Defer this until the dialog is realized due to the sizing logic in CreatePageWidget.
                EventHandler deferredShowPage = null;
                deferredShowPage = delegate {
                    ShowPage(section);
                    Realized -= deferredShowPage;
                };
                Realized += deferredShowPage;
                return;
            }
            SectionPage page;

            if (!pages.TryGetValue(section, out page))
            {
                return;
            }

            if (page.Panels.Count == 0)
            {
                foreach (ExtensionNode node in section.ChildNodes)
                {
                    if (node is OptionsDialogSection)
                    {
                        if (HasVisiblePanel((OptionsDialogSection)node))
                        {
                            ShowPage((OptionsDialogSection)node);
                            return;
                        }
                    }
                }
            }

            foreach (Gtk.Widget w in pageFrame.Children)
            {
                Container cc = w as Gtk.Container;
                if (cc != null)
                {
                    foreach (Gtk.Widget cw in cc)
                    {
                        cw.Hide();
                    }
                }
                pageFrame.Remove(w);
            }

            if (page.Widget == null)
            {
                CreatePageWidget(page);
            }

            if (section.HeaderImage == null)
            {
                labelTitle.Markup = "<span weight=\"bold\" size=\"large\">" + GLib.Markup.EscapeText(section.Label) + "</span>";
                textHeader.Show();
                imageHeader.Hide();
            }
            else
            {
                imageHeader.SetImage(section.HeaderImage, section.HeaderFillerImageResource);
                imageHeader.Show();
                textHeader.Hide();
            }

            //HACK: mimetype panels can't provide stock ID for mimetype images. Give this some awareness of mimetypes.
            var mimeSection = section as MonoDevelop.Ide.Projects.OptionPanels.MimetypeOptionsDialogSection;

            if (mimeSection != null && !string.IsNullOrEmpty(mimeSection.MimeType))
            {
                var pix = DesktopService.GetIconForType(mimeSection.MimeType, headerIconSize);
                if (pix != null)
                {
                    image.Image = pix;
                }
                else
                {
                    image.Image = ImageService.GetIcon(emptyCategoryIcon, headerIconSize);
                }
            }
            else
            {
                string icon = section.Icon.IsNull? emptyCategoryIcon : section.Icon.ToString();
                image.Image = ImageService.GetIcon(icon, headerIconSize);
            }

/*			var algn = new HeaderBox ();
 *                      algn.SetPadding (12, 12, 12, 12);
 *                      if (page.Widget.Parent != null)
 *                              ((Gtk.Container)page.Widget).Remove (page.Widget);
 *                      algn.Add (page.Widget);*/
            pageFrame.PackStart(page.Widget, true, true, 0);

            // Ensures that the Shown event is fired for each panel
            Container c = page.Widget as Gtk.Container;

            if (c != null)
            {
                foreach (Gtk.Widget cw in c)
                {
                    cw.Show();
                }
                //HACK: weird bug - switching page away and back selects last tab. should preserve the selection.
                if (c is Notebook)
                {
                    ((Notebook)c).Page = 0;
                }
            }

            tree.ExpandToPath(store.GetPath(page.Iter));
            tree.Selection.SelectIter(page.Iter);
        }