public ImageMenuItem AddCustomColor(Color color)
    {
        ImageMenuItem item = CreateImageMenuItem(color, "Custom");

        if (!(Menu is Menu))
        {
            Menu = new Menu();
        }
        Menu m = Menu as Menu;

        if (numCustomItems == 0)
        {
            SeparatorMenuItem sep = new SeparatorMenuItem();
            m.Prepend(sep);
            sep.Show();
        }

        m.Prepend(item);
        numCustomItems++;

        if (numCustomItems > 5)
        {
            m.Remove(m.Children[5]);
            numCustomItems--;
        }

        item.ShowAll();
        return(item);
    }
        private void LoadBookmarks()
        {
            separator = new SeparatorMenuItem();

            foreach (Bookmark bookmark in Bookmark.LoadAll())
            {
                AddBookmark(bookmark);
            }

            bookmark_item.ShowAll();
        }
    public ImageMenuItem AddColor(Color color, string name)
    {
        ImageMenuItem item = CreateImageMenuItem(color, name);

        if (!(Menu is Menu))
        {
            Menu = new Menu();
        }
        Menu m = Menu as Menu;

        m.Insert(item, m.Children.Length - 2);

        item.ShowAll();
        return(item);
    }
Beispiel #4
0
        private void LoadBookmarks()
        {
            separator = new SeparatorMenuItem();

            foreach (var bookmark in Bookmark.Provider.FetchAllMatching("Type IS NULL"))
            {
                if (bookmark.Track != null)
                {
                    AddBookmark(bookmark);
                }
                else
                {
                    Hyena.Log.DebugFormat("Removing bookmark that points to missing track ({0})", bookmark.Position);
                    bookmark.Remove();
                }
            }

            bookmark_item.ShowAll();
        }
Beispiel #5
0
        /// <summary>
        /// Adds a menu item button to a menu button.
        /// </summary>
        /// <param name="menuId">ID of the sub-menu.</param>
        /// <param name="text">Text on the button.</param>
        /// <param name="image">Image on the button.</param>
        /// <param name="handler">Handler to call when button is clicked.</param>
        public void AddButtonToMenu(string parentButtonText, string text, Image image, EventHandler handler)
        {
            if (!ButtonsAreToolbar)
            {
                throw new NotImplementedException();
            }

            // Find the top-level menu button (the button which, when clicked, causes the menu to appear).
            MenuToolButton toplevel = btnToolbar.AllChildren.OfType <MenuToolButton>().FirstOrDefault(b => (b.LabelWidget as Label).Text == parentButtonText);

            if (toplevel.Menu as Menu == null)
            {
                toplevel.Menu = new Menu();
            }
            Menu menu = toplevel.Menu as Menu;

            ImageMenuItem menuItem = new ImageMenuItem(text);

            menuItem.Image      = image;
            menuItem.Activated += handler;
            menu.Append(menuItem);
            menuItem.ShowAll();
        }
Beispiel #6
0
    public void Activate(Widget toplevel, Gdk.EventButton eb)
    {
        // FIXME this is a hack to handle the --view case for the time being.
        creator = toplevel;

        if (MainWindow.Toplevel == null)
        {
            return;
        }

        int count = MainWindow.Toplevel.SelectedIds().Length;

        Gtk.Menu popup_menu     = this;
        bool     have_selection = count > 0;

        GtkUtil.MakeMenuItem(popup_menu, Catalog.GetString("Copy Photo Location"),
                             delegate { MainWindow.Toplevel.HandleCopyLocation(creator, null); }, have_selection);

        GtkUtil.MakeMenuSeparator(popup_menu);

        GtkUtil.MakeMenuItem(popup_menu, "f-spot-rotate-270",
                             delegate { MainWindow.Toplevel.HandleRotate270Command(creator, null); }, have_selection);
        GtkUtil.MakeMenuItem(popup_menu, "f-spot-rotate-90",
                             delegate { MainWindow.Toplevel.HandleRotate90Command(creator, null); }, have_selection);

        GtkUtil.MakeMenuSeparator(popup_menu);

        OpenWithMenu owm = OpenWithMenu.AppendMenuTo(popup_menu, MainWindow.Toplevel.SelectedMimeTypes, true);

        owm.IgnoreApp             = "f-spot";
        owm.ApplicationActivated += delegate(Gnome.Vfs.MimeApplication app) { MainWindow.Toplevel.HandleOpenWith(creator, app); };

        GtkUtil.MakeMenuItem(popup_menu, Catalog.GetString("Remove From Catalog"),
                             delegate { MainWindow.Toplevel.HandleRemoveCommand(creator, null); }, have_selection);
        GtkUtil.MakeMenuItem(popup_menu, Catalog.GetString("Delete From Drive"),
                             delegate { MainWindow.Toplevel.HandleDeleteCommand(creator, null); }, have_selection);

        GtkUtil.MakeMenuSeparator(popup_menu);

        //
        // FIXME TagMenu is ugly.
        //
        ImageMenuItem attach_item = new ImageMenuItem(Catalog.GetString("Attach Tag"));

        attach_item.Image = new Gtk.Image("gtk-add", IconSize.Menu);
        TagMenu attach_menu = new TagMenu(attach_item, MainWindow.Toplevel.Database.Tags);

        attach_menu.NewTagHandler += delegate { MainWindow.Toplevel.HandleCreateTagAndAttach(creator, null); };
        attach_menu.TagSelected   += MainWindow.Toplevel.HandleAttachTagMenuSelected;
        attach_item.ShowAll();
        popup_menu.Append(attach_item);

        //
        // FIXME finish the IPhotoSelection stuff and move the activate handler into the class
        // this current method is way too complicated.
        //
        ImageMenuItem remove_item = new ImageMenuItem(Catalog.GetString("Remove Tag"));

        remove_item.Image = new Gtk.Image("gtk-remove", IconSize.Menu);
        PhotoTagMenu remove_menu = new PhotoTagMenu();

        remove_menu.TagSelected += MainWindow.Toplevel.HandleRemoveTagMenuSelected;
        remove_item.Submenu      = remove_menu;
        remove_item.Activated   += MainWindow.Toplevel.HandleTagMenuActivate;
        remove_item.ShowAll();
        popup_menu.Append(remove_item);

        if (eb != null)
        {
            popup_menu.Popup(null, null, null, eb.Button, eb.Time);
        }
        else
        {
            popup_menu.Popup(null, null, null, 0, Gtk.Global.CurrentEventTime);
        }
    }