Exemplo n.º 1
0
        void UpdateMenu()
        {
            //
            // Clear out the old list
            //
            foreach (Gtk.MenuItem oldItem in menu.Children)
            {
                menu.Remove(oldItem);
            }

            //
            // Build a new menu
            //

            // Add the "New Notebook..."
            Gtk.ImageMenuItem newNotebookMenuItem =
                new Gtk.ImageMenuItem(Catalog.GetString("_New notebook..."));
            newNotebookMenuItem.Image      = new Gtk.Image(NewNotebookIcon);
            newNotebookMenuItem.Activated += OnNewNotebookMenuItem;
            newNotebookMenuItem.Show();
            menu.Append(newNotebookMenuItem);

            // Add the "(no notebook)" item at the top of the list
            NotebookMenuItem noNotebookMenuItem = new NotebookMenuItem(Note, null);

            noNotebookMenuItem.ShowAll();
            menu.Append(noNotebookMenuItem);

            // Add in all the real notebooks
            List <NotebookMenuItem> notebookMenuItems = GetNotebookMenuItems();

            if (notebookMenuItems.Count > 0)
            {
                Gtk.SeparatorMenuItem separator = new Gtk.SeparatorMenuItem();
                separator.ShowAll();
                menu.Append(separator);

                foreach (NotebookMenuItem item in GetNotebookMenuItems())
                {
                    item.ShowAll();
                    menu.Append(item);
                }
            }
        }
Exemplo n.º 2
0
        List <NotebookMenuItem> GetNotebookMenuItems()
        {
            List <NotebookMenuItem> items = new List <NotebookMenuItem> ();

            Gtk.TreeModel model = NotebookManager.Notebooks;
            Gtk.TreeIter  iter;

            if (model.GetIterFirst(out iter) == true)
            {
                do
                {
                    Notebook         notebook = model.GetValue(iter, 0) as Notebook;
                    NotebookMenuItem item     = new NotebookMenuItem(Note, notebook);
                    items.Add(item);
                } while (model.IterNext(ref iter) == true);
            }

            items.Sort();

            return(items);
        }