Ejemplo n.º 1
0
        /// <summary>
        /// Creates menu from actions list.
        /// </summary>
        private void BuildMenu()
        {
            if (this.submenu != null)
            {
                foreach (Gtk.Widget w in this.submenu.Children)
                {
                    this.submenu.Remove(w);
                    w.Destroy();
                    w.Dispose();
                }

                this.submenu.Destroy();
                this.submenu.Dispose();
            }

            Action action;

            Gtk.MenuItem mi;
            this.submenu = new Gtk.Menu();

            foreach (object[] o in this.list)
            {
                action = ((Action)o[0]);
                string content = action.Content;
                mi = new Gtk.MenuItem(action.Label);
                this.submenu.Append(mi);
                mi.Activated          += (s, e) => ExecuteCommand(content, Clipboard.Instance.Items.FirstOrDefault(i => i.IsText));
                mi.ButtonReleaseEvent += (s, e) => ExecuteCommand(content, Clipboard.Instance.Items.FirstOrDefault(i => i.IsText));
            }
        }
        public Gtk.MenuItem AddMenuItem(string label)
        {
            var item = new Gtk.MenuItem(label);

            menu.Append(item);
            return(item);
        }
Ejemplo n.º 3
0
        public void AddMenuItem(Gtk.MenuItem menu_item, string label)
        {
            IntPtr native_label = GLib.Marshaller.StringToPtrGStrdup(label);

            ige_mac_menu_add_app_menu_item(Handle, menu_item == null ? IntPtr.Zero : menu_item.Handle, native_label);
            GLib.Marshaller.Free(native_label);
        }
Ejemplo n.º 4
0
        private void BuildMenu()
        {
            var menuBar = new Gtk.MenuBar();
            var miFile = new Gtk.MenuItem( "File" );
            var mFile = new Gtk.Menu();
            var miHelp = new Gtk.MenuItem( "Help" );
            var mHelp = new Gtk.Menu();
            var miView = new Gtk.MenuItem( "View" );
            var mView = new Gtk.Menu();

            miFile.Submenu = mFile;
            mFile.Append( this.actQuit.CreateMenuItem() );
            miHelp.Submenu = mHelp;
            mHelp.Append( this.actAbout.CreateMenuItem() );
            miView.Submenu = mView;
            mView.Append( this.actViewBoxes.CreateMenuItem() );
            mView.Append( this.actViewFrames.CreateMenuItem() );
            mView.Append( this.actViewNotebook.CreateMenuItem() );
            mView.Append( this.actViewDrawing.CreateMenuItem() );

            menuBar.Append( miFile );
            menuBar.Append( miView );
            menuBar.Append( miHelp );
            this.vbMain.PackStart( menuBar, false, false, 5 );
        }
Ejemplo n.º 5
0
        private void PopulateAlbums()
        {
            Gtk.Menu menu = new Gtk.Menu();
            if (gallery.Version == GalleryVersion.Version1)
            {
                Gtk.MenuItem top_item = new Gtk.MenuItem(Catalog.GetString("(TopLevel)"));
                menu.Append(top_item);
            }

            foreach (Album album in gallery.Albums)
            {
                System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                for (int i = 0; i < album.Parents.Count; i++)
                {
                    label_builder.Append("  ");
                }
                label_builder.Append(album.Title);

                Gtk.MenuItem item = new Gtk.MenuItem(label_builder.ToString());
                ((Gtk.Label)item.Child).UseUnderline = false;
                menu.Append(item);

                AlbumPermission create_sub = album.Perms & AlbumPermission.CreateSubAlbum;

                if (create_sub == 0)
                {
                    item.Sensitive = false;
                }
            }

            album_optionmenu.Sensitive = true;
            menu.ShowAll();
            album_optionmenu.Menu = menu;
        }
Ejemplo n.º 6
0
            public GameDBPlugin()
                : base("gamedb",
						     Catalog.
						     GetString
						     ("Games Database Plugin"),
						     Catalog.
						     GetString
						     ("Game database"))
            {
                saveItem = new MenuItem (Catalog.
                             GetString
                             ("Add Games to _Database"));
                saveItem.Activated += on_add_to_db_activate;
                saveItem.Show ();

                /*
                   openDbItem = new MenuItem (Catalog.
                   GetString
                   ("Games _Database"));

                   openDbItem.Activated +=
                   on_open_games_db_activate;
                   openDbItem.Show ();
                 */
            }
Ejemplo n.º 7
0
        private void PopulateAlbums()
        {
            Gtk.Menu menu = new Gtk.Menu();
            if (gallery.Version == GalleryVersion.Version1)
            {
                Gtk.MenuItem top_item = new Gtk.MenuItem(Catalog.GetString("(TopLevel)"));
                menu.Append(top_item);
            }

            foreach (Album album in gallery.Albums)
            {
                System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                for (int i = 0; i < album.Parents.Count; i++)
                {
                    label_builder.Append("  ");
                }

                label_builder.Append(album.Title);
                album_optionmenu.AppendText(label_builder.ToString());
            }

            album_optionmenu.Sensitive = true;
            menu.ShowAll();
        }
Ejemplo n.º 8
0
        private void AddTemplate(Gtk.Menu menu, Wrappers.Wrapper template)
        {
            if (!(d_filter == null || d_filter(template) || (template is Wrappers.Node && d_recursive)))
            {
                return;
            }

            string lbl = template.FullId.Replace("_", "__");

            Gtk.MenuItem item = new Gtk.MenuItem(lbl);
            item.Show();

            item.Activated += delegate {
                if (item.Submenu == null)
                {
                    Activated(this, template);
                }
            };

            menu.Append(item);

            d_map[template] = new MenuInfo(item, menu);

            if (d_recursive && template is Wrappers.Node)
            {
                Gtk.Menu sub = new Gtk.Menu();
                item.Submenu = sub;

                Traverse((Wrappers.Node)template, sub);
            }

            template.WrappedObject.AddNotification("id", HandleIdChanged);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a version of the given command for use in a context menu.
        /// </summary>
        /// <param name="command">The command to clone for use in a context menu.</param>
        /// <param name="name">Overriding name for the command; if <c>null</c> or empty, use command's ContextMenuItemName.</param>
        /// <param name="weight">Weight for the command. If this value is <c>double.NaN</c>, the weight is the same as the original command's weight.</param>
        /// <returns>The command to use in a context menu.</returns>
        public static VisualRelayCommand CreateContextMenuItemCommand(this VisualRelayCommand command, string name, double weight)
        {
            var contextCommand = command.Clone();

            contextCommand.MenuParent                = null;
            contextCommand.VisualParent              = null;
            contextCommand.Visual                    = null;
            contextCommand.MenuItem                  = null;
            contextCommand.KeyboardShortcutKey       = null;
            contextCommand.KeyboardShortcutModifiers = OSModifierKeys.None;
            if (!double.IsNaN(weight))
            {
                contextCommand.Weight = weight;
            }
            if (command.UniqueId != RootCommandGroup.MenuSeparatorCommand.UniqueId)
            {
                name = name ?? command.ContextMenuItemName;
                name = name ?? command.MenuItemName;
                name = name ?? command.Name;
                var menuItem = new Gtk.MenuItem(name ?? command.ContextMenuItemName);
                if (command.SmallIcon != null)
                {
                    throw new System.NotImplementedException("CreateContextMenuItemCommand with Image");
                    ////menuItem.Icon = new Image() { Source = command.SmallIcon };
                }
                throw new System.NotImplementedException("CreateContextMenuItemCommand wire up command to MenuItem");
                ////menuItem.Command = command;
                contextCommand.MenuItem = menuItem;
            }
            else
            {
                contextCommand.MenuItem = new Gtk.SeparatorMenuItem();
            }
            return(contextCommand);
        }
Ejemplo n.º 10
0
		void UpdateMenu ()
		{
			//
			// Clear out the old list
			//
			foreach (Gtk.MenuItem old_item in menu.Children) {
				menu.Remove (old_item);
			}

			//
			// Build a new list
			//
			foreach (BacklinkMenuItem item in GetBacklinkMenuItems ()) {
				item.ShowAll ();
				menu.Append (item);
			}

			// If nothing was found, add in a "dummy" item
			if (menu.Children.Length == 0) {
				// This is a disabled placeholder item for an empty menu
				Gtk.MenuItem blank_item = new Gtk.MenuItem (Catalog.GetString ("(none)"));
				blank_item.Sensitive = false;
				blank_item.ShowAll ();
				menu.Append (blank_item);
			}

			submenu_built = true;
		}
Ejemplo n.º 11
0
        void UpdateMenu()
        {
            //
            // Clear out the old list
            //
            foreach (Gtk.MenuItem old_item in menu.Children)
            {
                menu.Remove(old_item);
            }

            //
            // Build a new list
            //
            foreach (BacklinkMenuItem item in GetBacklinkMenuItems())
            {
                item.ShowAll();
                menu.Append(item);
            }

            // If nothing was found, add in a "dummy" item
            if (menu.Children.Length == 0)
            {
                Gtk.MenuItem blank_item = new Gtk.MenuItem(Catalog.GetString("(none)"));
                blank_item.Sensitive = false;
                blank_item.ShowAll();
                menu.Append(blank_item);
            }

            submenu_built = true;
        }
Ejemplo n.º 12
0
		protected void SetupUi()
		{
			var box = new Gtk.VBox();

			var menu = new Gtk.MenuBar();
			var fileMenu = new Gtk.Menu();
			var file = new Gtk.MenuItem("File");
			file.Submenu = fileMenu;
			menu.Append(file);

			var save = new Gtk.MenuItem("Save");
			save.Activated += OnSaveMenuActivated;
			var load = new Gtk.MenuItem("Load");
			load.Activated += OnLoadMenuActivated;

			var exit = new Gtk.MenuItem("Exit");
			exit.Activated += (sender, e) => Gtk.Application.Quit();

			fileMenu.Append(save);
			fileMenu.Append(load);
			fileMenu.Append(exit);


			box.PackStart(menu, false, false, 0);

			nb = new Gtk.Notebook();
			nb.ShowTabs = false;
			nb.AppendPage(SetupOverviewPage(), new Gtk.Label("Overview"));
			nb.AppendPage(SetupNewNotePage(), new Gtk.Label("New"));
			box.PackStart(nb, true, true, 2);

			Add(box);
		}
Ejemplo n.º 13
0
        void PopupQuickFixMenu(Gdk.EventButton evt)
        {
            Gtk.Menu menu = new Gtk.Menu();

            Dictionary <Gtk.MenuItem, ContextAction> fixTable = new Dictionary <Gtk.MenuItem, ContextAction> ();
            int mnemonic = 1;

            foreach (ContextAction fix in fixes)
            {
                var escapedLabel = fix.GetMenuText(document, loc).Replace("_", "__");
                var label        = (mnemonic <= 10)
                                                ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel
                                                : "  " + escapedLabel;
                Gtk.MenuItem menuItem = new Gtk.MenuItem(label);
                fixTable [menuItem] = fix;
                menuItem.Activated += delegate(object sender, EventArgs e) {
                    // ensure that the Ast is recent.
                    document.UpdateParseDocument();
                    var runFix = fixTable [(Gtk.MenuItem)sender];
                    runFix.Run(document, loc);

                    document.Editor.Document.CommitUpdateAll();
                    menu.Destroy();
                };
                menu.Add(menuItem);
            }
            menu.ShowAll();
            menu.SelectFirst(true);
            menuPushed      = true;
            menu.Destroyed += delegate {
                menuPushed = false;
                QueueDraw();
            };
            GtkWorkarounds.ShowContextMenu(menu, this, evt, Allocation);
        }
Ejemplo n.º 14
0
        public static Gtk.MenuItem MakeMenuItem(Gtk.Menu menu, string l, EventHandler e, bool enabled)
        {
            Gtk.MenuItem  i;
            Gtk.StockItem item = Gtk.StockItem.Zero;

            if (Gtk.StockManager.Lookup(l, ref item))
            {
                i = new Gtk.ImageMenuItem(l, new Gtk.AccelGroup());
            }
            else
            {
                i = new Gtk.MenuItem(l);
            }

            if (e != null)
            {
                i.Activated += e;
            }

            i.Sensitive = enabled;

            menu.Append(i);
            i.Show();

            return(i);
        }
Ejemplo n.º 15
0
        private void BuildMenu()
        {
            var menuBar = new Gtk.MenuBar();
            var miFile  = new Gtk.MenuItem("File");
            var mFile   = new Gtk.Menu();
            var miHelp  = new Gtk.MenuItem("Help");
            var mHelp   = new Gtk.Menu();
            var miView  = new Gtk.MenuItem("View");
            var mView   = new Gtk.Menu();

            miFile.Submenu = mFile;
            mFile.Append(this.actQuit.CreateMenuItem());
            miHelp.Submenu = mHelp;
            mHelp.Append(this.actAbout.CreateMenuItem());
            miView.Submenu = mView;
            mView.Append(this.actViewBoxes.CreateMenuItem());
            mView.Append(this.actViewFrames.CreateMenuItem());
            mView.Append(this.actViewNotebook.CreateMenuItem());
            mView.Append(this.actViewDrawing.CreateMenuItem());

            menuBar.Append(miFile);
            menuBar.Append(miView);
            menuBar.Append(miHelp);
            this.vbMain.PackStart(menuBar, false, false, 5);
        }
        public void ShowContextMenu(ActionItem aitem)
        {
            ActionToolItem menuItem = aitem as ActionToolItem;

            Gtk.Menu     m    = new Gtk.Menu();
            Gtk.MenuItem item = new Gtk.MenuItem(Catalog.GetString("Insert Before"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, false, false);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert After"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, true, false);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert Separator Before"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, false, true);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert Separator After"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                InsertActionAt(menuItem, true, true);
            };

            m.Add(new Gtk.SeparatorMenuItem());

            item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                menuItem.Cut();
            };
            item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                menuItem.Copy();
            };
            item = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                Paste(menuItem);
            };
            item = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a)
            {
                menuItem.Delete();
            };
            m.ShowAll();
            m.Popup();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Adds Gtk.MenuItem to Gtk.Menu.
        /// </summary>
        /// <param name="menu">Gtk.Menu object.</param>
        /// <param name="label">Menu item label.</param>
        /// <param name="atEnd">Whether item will be added to begining or end of menu.</param>
        /// <param name="handler">Activated event handler.</param>		
        /// <param name="sensitive">Whether item is sensitive.</param>
        public static Gtk.MenuItem AddMenuItem(this Gtk.Menu menu, string label, bool atEnd = true, System.EventHandler handler = null, bool sensitive = true)
        {
            Gtk.MenuItem menuitem = new Gtk.MenuItem(label);
            menu.AddWidget(menuitem, atEnd, handler);
            menuitem.Sensitive = sensitive;

            return menuitem;
        }
Ejemplo n.º 18
0
 public override Gtk.MenuItem GetMenuItem(object parent)
 {
     Gtk.MenuItem item = base.GetMenuItem(parent);
     menu_generator  = (IMenuGenerator)Addin.CreateInstance(command_type);
     item.Submenu    = menu_generator.GetMenu();
     item.Activated += menu_generator.OnActivated;
     return(item);
 }
Ejemplo n.º 19
0
		public override Gtk.MenuItem GetMenuItem ()
		{
			if (item == null) {
				item = new Gtk.MenuItem (_label != null ? Catalog.GetString (_label) : Id);
				item.Activated += OnActivated;
			}
			return item;
		}
Ejemplo n.º 20
0
        Gtk.MenuItem CreateNoteMenuItem(Note n)
        {
            var item = new Gtk.MenuItem(n.Title);

            item.Activated += (o, a) => SetMenuItems();
            item.Activated += (o, a) => n.Window.Present();
            return(item);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Adds Gtk.MenuItem to Gtk.Menu.
        /// </summary>
        /// <param name="menu">Gtk.Menu object.</param>
        /// <param name="label">Menu item label.</param>
        /// <param name="atEnd">Whether item will be added to begining or end of menu.</param>
        /// <param name="handler">Activated event handler.</param>
        /// <param name="sensitive">Whether item is sensitive.</param>
        public static Gtk.MenuItem AddMenuItem(this Gtk.Menu menu, string label, bool atEnd = true, System.EventHandler handler = null, bool sensitive = true)
        {
            Gtk.MenuItem menuitem = new Gtk.MenuItem(label);
            menu.AddWidget(menuitem, atEnd, handler);
            menuitem.Sensitive = sensitive;

            return(menuitem);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates menu from snippets list.
        /// </summary>
        /// <param name="menuItem">Menu item.</param>
        private void BuildMenu()
        {
            if (this.submenu != null)
            {
                foreach (Gtk.Widget w in this.submenu)
                {
                    this.submenu.Remove(w);
                    w.Destroy();
                    w.Dispose();
                }

                this.submenu.Destroy();
                this.submenu.Dispose();
            }

            Snippet snippet;

            Gtk.MenuItem mi;
            this.submenu = new Gtk.Menu();

            foreach (object[] o in this.list)
            {
                snippet = ((Snippet)o[0]);
                string content = snippet.Content;
                mi = new Gtk.MenuItem(snippet.Label);
                this.submenu.Append(mi);
                mi.Activated += (s, e) =>
                {
                    Item item = new Item(content);
                    Clipboard.Instance.SetAsContent(item);

                    if (Settings.Instance[SettingsKeys.PasteOnSelection].AsBoolean())
                    {
                        XHotkeys.Hotkeys.Instance.Paste();
                    }
                };
                mi.ButtonReleaseEvent += (s, e) =>
                {
                    Item item = new Item(content);
                    Clipboard.Instance.SetAsContent(item);

                    if (Settings.Instance[SettingsKeys.PasteOnSelection].AsBoolean())
                    {
                        XHotkeys.Hotkeys.Instance.Paste();
                    }
                };
            }

            if (!this.list.IsEmpty())
            {
                this.submenu.Append(new Gtk.SeparatorMenuItem());
            }

            mi = new Gtk.MenuItem(Catalog.GetString("_Make snippet from current content"));
            this.submenu.Append(mi);
            mi.Activated          += this.OnMakeSnippetMenuItemActivated;
            mi.ButtonReleaseEvent += this.OnMakeSnippetMenuItemActivated;
        }
Ejemplo n.º 23
0
 public override Gtk.MenuItem GetMenuItem()
 {
     if (item == null)
     {
         item            = new Gtk.MenuItem(_label != null ? Catalog.GetString(_label) : Id);
         item.Activated += OnActivated;
     }
     return(item);
 }
Ejemplo n.º 24
0
		public override Gtk.MenuItem GetMenuItem ()
		{
			Gtk.MenuItem it = new Gtk.MenuItem (label);
			Gtk.Menu submenu = new Gtk.Menu ();
			foreach (MenuNode node in ChildNodes)
				submenu.Insert (node.GetMenuItem (), -1);
			it.Submenu = submenu;
			return it;
		}
Ejemplo n.º 25
0
        private void PopulateAlbumOptionMenu(PicasaWeb picasa)
        {
            PicasaAlbumCollection albums = null;

            if (picasa != null)
            {
                try {
                    albums = picasa.GetAlbums();
                } catch {
                    Console.WriteLine("Can't get the albums");
                    picasa = null;
                }
            }

            Gtk.Menu menu = new Gtk.Menu();

            bool disconnected = picasa == null || !account.Connected || albums == null;

            if (disconnected || albums.Count == 0)
            {
                string msg = disconnected ? Catalog.GetString("(Not Connected)")
                                        : Catalog.GetString("(No Albums)");

                Gtk.MenuItem item = new Gtk.MenuItem(msg);
                menu.Append(item);

                ok_button.Sensitive        = false;
                album_optionmenu.Sensitive = false;
                album_button.Sensitive     = false;

                if (disconnected)
                {
                    album_button.Sensitive = false;
                }
            }
            else
            {
                foreach (PicasaAlbum album in albums.AllValues)
                {
                    System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                    label_builder.Append(album.Title);

                    Gtk.MenuItem item = new Gtk.MenuItem(label_builder.ToString());
                    ((Gtk.Label)item.Child).UseUnderline = false;
                    menu.Append(item);
                }

                ok_button.Sensitive        = items.Length > 0;
                album_optionmenu.Sensitive = true;
                album_button.Sensitive     = true;
            }

            menu.ShowAll();
            album_optionmenu.Menu = menu;
        }
Ejemplo n.º 26
0
 public override void Hook_Initialise(Forms.Main main)
 {
     menu = new Gtk.MenuItem("Display ignored text");
     collector = new Graphics.Window();
     collector.CreateChat(null, false, false, false);
     menu.Activated += new EventHandler(Display);
     collector.WindowName = "Ignored";
     main.ToolsMenu.Append(menu);
     menu.Show();
 }
Ejemplo n.º 27
0
		public override Gtk.MenuItem GetMenuItem ()
		{
			Gtk.MenuItem item;
			if (icon != null)
				item = new Gtk.ImageMenuItem (icon, accelGroup);
			else
				item = new Gtk.MenuItem (label);
			item.Activated += OnClicked;
			return item;
		}
        void OnSelectIcon(object s, Gtk.ButtonPressEventArgs args)
        {
            Gtk.Menu menu = new Gtk.Menu();

            Gtk.CheckMenuItem item = new Gtk.CheckMenuItem(Catalog.GetString("Action"));
            item.DrawAsRadio = true;
            item.Active      = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action);
            item.Activated  += OnSetActionType;
            menu.Insert(item, -1);

            item             = new Gtk.CheckMenuItem(Catalog.GetString("Radio Action"));
            item.DrawAsRadio = true;
            item.Active      = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio);
            item.Activated  += OnSetRadioType;
            menu.Insert(item, -1);

            item             = new Gtk.CheckMenuItem(Catalog.GetString("Toggle Action"));
            item.DrawAsRadio = true;
            item.Active      = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle);
            item.Activated  += OnSetToggleType;
            menu.Insert(item, -1);

            menu.Insert(new Gtk.SeparatorMenuItem(), -1);

            Gtk.MenuItem itIcons = new Gtk.MenuItem(Catalog.GetString("Select Icon"));
            menu.Insert(itIcons, -1);
            IconSelectorMenu menuIcons = new IconSelectorMenu(GetProject());

            menuIcons.IconSelected += OnStockSelected;
            itIcons.Submenu         = menuIcons;

            Gtk.MenuItem it = new Gtk.MenuItem(Catalog.GetString("Clear Icon"));
            it.Sensitive  = (node.Action.GtkAction.StockId != null);
            it.Activated += OnClearIcon;
            menu.Insert(it, -1);

            menu.ShowAll();

            uint but = args != null ? args.Event.Button : 1;

            menu.Popup(null, null, new Gtk.MenuPositionFunc(OnDropMenuPosition), but, Gtk.Global.CurrentEventTime);

            // Make sure we get the focus after closing the menu, so we can keep browsing buttons
            // using the keyboard.
            menu.Hidden += delegate(object sender, EventArgs a)
            {
                GrabFocus();
            };

            if (args != null)
            {
                args.RetVal = false;
            }
        }
Ejemplo n.º 29
0
        public override void OnNoteOpened()
        {
            // Add the menu item when the window is created.
            menu_item = new Gtk.MenuItem (
                Catalog.GetString ("Note Statistics"));

            menu_item.Activated += OnMenuItemActivated;

            menu_item.Show ();
            AddPluginMenuItem (menu_item);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates a menu item for a command.
        /// </summary>
        /// <param name="command">The command for which a menu item must be created.</param>
        /// <returns>The menu item.</returns>
        public virtual OSMenuItem CreateMenuItemForCommand(ICommand command)
        {
            Gtk.MenuItem menuItem      = null;
            var          visualCommand = command as VisualRelayCommand;

            if (visualCommand != null)
            {
                menuItem = visualCommand.CreateMenuItemForCommand(visualCommand.MenuParent != null);
            }
            return(menuItem);
        }
Ejemplo n.º 31
0
        private void HandleIdChanged(object source, GLib.NotifyArgs args)
        {
            Wrappers.Wrapper wrapped = Wrappers.Wrapper.Wrap((Cdn.Object)source);
            Gtk.MenuItem     item    = d_map[wrapped].Item;

            item.Remove(item.Child);
            Gtk.Label lbl = new Gtk.Label(wrapped.Id.Replace("_", "__"));
            lbl.Show();

            item.Add(lbl);
        }
Ejemplo n.º 32
0
 public override Gtk.MenuItem GetMenuItem()
 {
     Gtk.MenuItem it      = new Gtk.MenuItem(label);
     Gtk.Menu     submenu = new Gtk.Menu();
     foreach (MenuNode node in ChildNodes)
     {
         submenu.Insert(node.GetMenuItem(), -1);
     }
     it.Submenu = submenu;
     return(it);
 }
Ejemplo n.º 33
0
        public void PopulateFixes(Gtk.Menu menu)
        {
            int mnemonic = 1;

            foreach (var fix_ in fixes.OrderByDescending(i => GetUsage(i.IdString)))
            {
                var fix          = fix_;
                var escapedLabel = fix.Title.Replace("_", "__");
                var label        = (mnemonic <= 10)
                        ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel
                        : "  " + escapedLabel;
                var menuItem = new Gtk.MenuItem(label);
                menuItem.Activated += new ContextActionRunner(fix, document, loc).Run;
                menuItem.Activated += delegate
                {
                    ConfirmUsage(fix.IdString);
                    menu.Destroy();
                };
                menu.Add(menuItem);
            }
            var first           = true;
            var alreadyInserted = new HashSet <CodeIssueProvider> ();

            foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where(f => f.Result is InspectorResults))
            {
                var analysisFix = analysisFix_;
                var ir          = analysisFix.Result as InspectorResults;
                if (ir == null)
                {
                    continue;
                }

                if (first)
                {
                    menu.Add(new Gtk.SeparatorMenuItem());
                    first = false;
                }
                if (alreadyInserted.Contains(ir.Inspector))
                {
                    continue;
                }
                alreadyInserted.Add(ir.Inspector);

                var label    = GettextCatalog.GetString("_Inspection options for \"{0}\"", ir.Inspector.Title);
                var menuItem = new Gtk.MenuItem(label);
                menuItem.Activated += analysisFix.ShowOptions;
                menuItem.Activated += delegate
                {
                    menu.Destroy();
                };
                menu.Add(menuItem);
            }
        }
        public void Initialize(IPadWindow window)
        {
            //
            // Handle normal input
            //
            view.ConsoleInput += HandleConsoleInput;

            //
            // Setup Ctrl + / as the interrupt handler
            //
            view.Child.KeyPressEvent += (o, args) => {
                if ((args.Event.State & ModifierType.ControlMask) == ModifierType.ControlMask &&
                    args.Event.Key == Key.slash)
                {
                    if (session != null)
                    {
                        session.Interrupt();
                    }
                }
            };

            //
            // Watch the active doc
            //
            IdeApp.Workbench.ActiveDocumentChanged += HandleActiveDocumentChanged;

            //
            //
            //
            UpdateFont();
            UpdateColors();
            view.ShadowType = Gtk.ShadowType.None;
            view.ShowAll();

            //
            // Add a Restart item to the pop up menu
            //
            var v = view.Child as Gtk.TextView;

            if (v != null)
            {
                v.PopulatePopup += (o, args) => {
                    var item = new Gtk.MenuItem(GettextCatalog.GetString("Reset"));
                    item.Activated += (sender, e) => RestartCsi();
                    item.Show();
                    args.Menu.Add(item);
                };
            }

            //
            // Create the toolbar
            //
        }
Ejemplo n.º 35
0
 public override void Hook_Initialise(Forms.Main main)
 {
     _m = main;
     item = new Gtk.MenuItem("#pidgeon");
     item.Activated += new EventHandler(pidgeonToolStripMenuItem_Click);
     separator = new Gtk.SeparatorMenuItem();
     main.HelpMenu.Append(separator);
     main.HelpMenu.Append(item);
     separator.Show();
     item.Show();
     Core.DebugLog("Registered #pidgeon in menu");
 }
 public override void OnNoteOpened()
 {
     if (this.Note.Title.StartsWith("GTD")) {
         item = new Gtk.MenuItem("Update Tasks");
         item.Activated += OnMenuItemActivated;
         item.AddAccelerator ("activate", Window.AccelGroup,
             (uint) Gdk.Key.d, Gdk.ModifierType.ControlMask,
             Gtk.AccelFlags.Visible);
         item.Show ();
         AddPluginMenuItem (item);
     }
 }
Ejemplo n.º 37
0
        void IPlugin.Init(object context)
        {
            reflector = context as ISolidReflector;

            mainWindow = reflector.GetMainWindow();
            Gtk.MenuBar mainMenuBar = reflector.GetMainMenu();
            reflector.OnShutDown += HandleOnShutDown;

            Gtk.MenuItem fileMenu = null;
            // Find the File menu if present
            foreach (Gtk.Widget w in mainMenuBar.Children)
            {
                if (w.Name == "FileAction")
                {
                    fileMenu = w as Gtk.MenuItem;
                }
            }

            // If not present - create it
            if (fileMenu == null)
            {
                Gtk.Menu menu = new Gtk.Menu();
                fileMenu         = new Gtk.MenuItem("File");
                fileMenu.Submenu = menu;
                mainMenuBar.Append(fileMenu);
            }

            // Setting up the Open menu item in File
            Gtk.MenuItem open = new Gtk.MenuItem("Open");
            open.Activated += OnActivated;
            (fileMenu.Submenu as Gtk.Menu).Prepend(open);

            // Setting up the window scrollers
            Gtk.ScrolledWindow scrollWindow = new Gtk.ScrolledWindow();
            Gtk.Viewport       viewport     = new Gtk.Viewport();
            scrollWindow.Add(viewport);
            viewport.Add(assemblyTree);
            scrollWindow.ShowAll();

            // Attaching the current dockItem in the DockFrame
            dockItem           = mainWindow.DockFrame.AddItem("AssemblyBrowser");
            dockItem.DrawFrame = true;
            dockItem.Label     = "Assembly";
            dockItem.Content   = scrollWindow;

            LoadEnvironment();

            assemblyTree.RowActivated += HandleRowActivated;

            assemblyTree.Realized += delegate(object sender, EventArgs e) {
                LoadSelectedAssembliesTreePaths();
            };
        }
Ejemplo n.º 38
0
 public void InsertItem(int index, IMenuItemBackend menuItem)
 {
     Gtk.MenuItem item = ((MenuItemBackend)menuItem).MenuItem;
     if (customFont != null)
     {
         foreach (Gtk.Widget w in item.AllChildren)
         {
             w.ModifyFont(customFont);
         }
     }
     menu.Insert(item, index);
 }
Ejemplo n.º 39
0
        internal void ShowDockPopupMenu(uint time)
        {
            Gtk.Menu menu = new Gtk.Menu();

            // Hide menuitem
            if ((Behavior & DockItemBehavior.CantClose) == 0)
            {
                Gtk.MenuItem mitem = new Gtk.MenuItem(Catalog.GetString("Hide"));
                mitem.Activated += delegate { Visible = false; };
                menu.Append(mitem);
            }

            Gtk.MenuItem citem;

            // Auto Hide menuitem
            if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide)
            {
                citem            = new Gtk.MenuItem(Catalog.GetString("Minimize"));
                citem.Activated += delegate { Status = DockItemStatus.AutoHide; };
                menu.Append(citem);
            }

            if (Status != DockItemStatus.Dockable)
            {
                // Dockable menuitem
                citem            = new Gtk.MenuItem(Catalog.GetString("Dock"));
                citem.Activated += delegate { Status = DockItemStatus.Dockable; };
                menu.Append(citem);
            }

            // Floating menuitem
            if ((Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating)
            {
                citem            = new Gtk.MenuItem(Catalog.GetString("Undock"));
                citem.Activated += delegate { Status = DockItemStatus.Floating; };
                menu.Append(citem);
            }

            if (menu.Children.Length == 0)
            {
                menu.Destroy();
                return;
            }

            ShowingContextMemu = true;

            menu.ShowAll();
            menu.Hidden += (o, e) => {
                ShowingContextMemu = false;
            };
            menu.Popup(null, null, null, 3, time);
        }
Ejemplo n.º 40
0
        protected override void Run(RefactoringOptions options)
        {
            Gtk.Menu menu = new Gtk.Menu();

            bool          resolveDirect;
            List <string> namespaces = GetResolveableNamespaces(options, out resolveDirect);

            foreach (string ns in namespaces)
            {
                // remove used namespaces for conflict resolving.
                if (options.Document.CompilationUnit.IsNamespaceUsedAt(ns, options.ResolveResult.ResolvedExpression.Region.Start))
                {
                    continue;
                }
                Gtk.MenuItem menuItem = new Gtk.MenuItem(string.Format(GettextCatalog.GetString("Add using '{0}'"), ns));
                CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation(options.Dom, options.Document, options.ResolveResult, ns);
                menuItem.Activated += delegate
                {
                    resolveNameOperation.AddImport();
                };
                menu.Add(menuItem);
            }
            if (resolveDirect)
            {
                foreach (string ns in namespaces)
                {
                    Gtk.MenuItem menuItem = new Gtk.MenuItem(string.Format(GettextCatalog.GetString("Add '{0}'"), ns));
                    CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation(options.Dom, options.Document, options.ResolveResult, ns);
                    menuItem.Activated += delegate
                    {
                        resolveNameOperation.ResolveName();
                    };
                    menu.Add(menuItem);
                }
            }

            if (menu.Children != null && menu.Children.Length > 0)
            {
                menu.ShowAll();

                ICompletionWidget     widget = options.Document.GetContent <ICompletionWidget> ();
                CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext(options.GetTextEditorData().Caret.Offset);

                menu.Popup(null, null, delegate(Gtk.Menu menu2, out int x, out int y, out bool pushIn)
                {
                    x      = codeCompletionContext.TriggerXCoord;
                    y      = codeCompletionContext.TriggerYCoord;
                    pushIn = false;
                }, 0, Gtk.Global.CurrentEventTime);
                menu.SelectFirst(true);
            }
        }
Ejemplo n.º 41
0
		internal static CommandSource GetMenuCommandSource (Gtk.MenuItem item)
		{
			Gtk.Widget w = item.Parent;
			while (w != null) {
				if (w is Gtk.MenuBar)
					return CommandSource.MainMenu;
				else if (!(w is Gtk.MenuItem) && !(w is Gtk.MenuShell))
					return CommandSource.ContextMenu;
				else
					w = w.Parent;
			}
			return CommandSource.Unknown;
		}
Ejemplo n.º 42
0
 void AddCreateItemLabel()
 {
     HideSpacerItem();
     Gtk.Label emptyLabel = new Gtk.Label();
     emptyLabel.Xalign = 0;
     emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString("Click to create menu") + "</span></i>";
     Gtk.MenuItem mit = new Gtk.MenuItem();
     mit.Child             = emptyLabel;
     mit.ButtonPressEvent += OnNewItemPress;
     Insert(mit, -1);
     mit.ShowAll();
     addLabel = mit;
 }
Ejemplo n.º 43
0
        public static void Create(Tag [] tags, Gtk.Menu menu)
        {
            var findWithString = Catalog.GetPluralString ("Find _With", "Find _With", tags.Length);
            var item = new Gtk.MenuItem (String.Format (findWithString, tags.Length));

            Gtk.Menu submenu = GetSubmenu (tags);
            if (submenu == null)
                item.Sensitive = false;
            else
                item.Submenu = submenu;

            menu.Append (item);
            item.Show ();
        }
Ejemplo n.º 44
0
		public override Gtk.MenuItem GetMenuItem ()
		{
			lock (this) {
				if (item == null || changed) {
					changed = false;
					item = new Gtk.MenuItem (_label != null ? Catalog.GetString (_label) : Id);
					Gtk.Menu submenu = new Gtk.Menu ();

					foreach (MenuNode node in ChildNodes)
						submenu.Insert (node.GetMenuItem (), -1);
					item.Submenu = submenu;
				}
			}
			return item;
		}
Ejemplo n.º 45
0
 public override void Hook_BeforeTextMenu(Extension.ScrollbackArgs Args)
 {
     text = Args.scrollback.SelectedText;
     Gtk.SeparatorMenuItem xx = new Gtk.SeparatorMenuItem();
     xx.Show();
     Args.menu.Add(xx);
     Gtk.MenuItem wiki = new Gtk.MenuItem("Search using wiki");
     wiki.Activated += new EventHandler(SearchWiki);
     wiki.Show();
     Args.menu.Add(wiki);
     Gtk.MenuItem goog = new Gtk.MenuItem("Search using google");
     goog.Show();
     goog.Activated += new EventHandler(SearchGoogle);
     Args.menu.Add(goog);
 }
		public override void OnNoteOpened ()
		{
			// Add the menu item when the window is created
			item = new Gtk.MenuItem (
				Catalog.GetString ("Insert Timestamp"));
			item.Activated += OnMenuItemActivated;
			item.AddAccelerator ("activate", Window.AccelGroup,
				(uint) Gdk.Key.d, Gdk.ModifierType.ControlMask,
				Gtk.AccelFlags.Visible);
			item.Show ();
			AddPluginMenuItem (item);

			// Get the format from GConf and subscribe to changes
			date_format = (string) Preferences.Get (
				Preferences.INSERT_TIMESTAMP_FORMAT);
			Preferences.SettingChanged += OnFormatSettingChanged;
		}
Ejemplo n.º 47
0
		protected override void Run (RefactoringOptions options)
		{
			Gtk.Menu menu = new Gtk.Menu ();
			
			bool resolveDirect;
			List<string> namespaces = GetResolveableNamespaces (options, out resolveDirect);
			
			foreach (string ns in namespaces) {
				// remove used namespaces for conflict resolving.
				if (options.Document.CompilationUnit.IsNamespaceUsedAt (ns, options.ResolveResult.ResolvedExpression.Region.Start))
					continue;
				Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add using '{0}'"), ns));
				CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns);
				menuItem.Activated += delegate {
					resolveNameOperation.AddImport ();
				};
				menu.Add (menuItem);
			}
			if (resolveDirect) {
				foreach (string ns in namespaces) {
					Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add '{0}'"), ns));
					CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns);
					menuItem.Activated += delegate {
						resolveNameOperation.ResolveName ();
					};
					menu.Add (menuItem);
				}
			}
			
			if (menu.Children != null && menu.Children.Length > 0) {
				menu.ShowAll ();
				
				ICompletionWidget widget = options.Document.GetContent<ICompletionWidget> ();
				CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext (options.GetTextEditorData ().Caret.Offset);

				menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) {
					x = codeCompletionContext.TriggerXCoord; 
					y = codeCompletionContext.TriggerYCoord; 
					pushIn = false;
				}, 0, Gtk.Global.CurrentEventTime);
				menu.SelectFirst (true);
			}
		}
Ejemplo n.º 48
0
		public void PopupQuickFixMenu ()
		{
			Gtk.Menu menu = new Gtk.Menu ();
			
			Dictionary<Gtk.MenuItem, ContextAction> fixTable = new Dictionary<Gtk.MenuItem, ContextAction> ();
			int mnemonic = 1;
			foreach (ContextAction fix in fixes) {
				var escapedLabel = fix.GetMenuText (document, loc).Replace ("_", "__");
				var label = (mnemonic <= 10)
						? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
						: "  " + escapedLabel;
				Gtk.MenuItem menuItem = new Gtk.MenuItem (label);
				fixTable [menuItem] = fix;
				menuItem.Activated += delegate(object sender, EventArgs e) {
					// ensure that the Ast is recent.
					document.UpdateParseDocument ();
					var runFix = fixTable [(Gtk.MenuItem)sender];
					runFix.Run (document, loc);
					
					document.Editor.Document.CommitUpdateAll ();
					menu.Destroy ();
				};
				menu.Add (menuItem);
			}
			menu.ShowAll ();
			int dx, dy;
			this.ParentWindow.GetOrigin (out dx, out dy);
			dx += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).X;
			dy += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).Y - (int)document.Editor.VAdjustment.Value;
					
			menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) {
				x = dx; 
				y = dy + Allocation.Height; 
				pushIn = false;
				menuPushed = true;
				QueueDraw ();
			}, 0, Gtk.Global.CurrentEventTime);
			menu.SelectFirst (true);
			menu.Destroyed += delegate {
				menuPushed = false;
				QueueDraw ();
			};
		}
Ejemplo n.º 49
0
        public static Gtk.MenuItem MakeMenuItem(Gtk.Menu menu, string l, EventHandler e, bool enabled)
        {
            Gtk.MenuItem i;
            Gtk.StockItem item = Gtk.StockItem.Zero;

            if (Gtk.StockManager.Lookup (l, ref item)) {
                i = new Gtk.ImageMenuItem (l, new Gtk.AccelGroup ());
            } else {
                i = new Gtk.MenuItem (l);
            }

            if (e != null)
                i.Activated += e;

                    i.Sensitive = enabled;

            menu.Append (i);
            i.Show ();

            return i;
        }
Ejemplo n.º 50
0
		public IconSelectorMenu (IProject project)
		{
			this.project = project;
			
			// Stock icon selector
			IconSelectorMenuItem selStock = new IconSelectorMenuItem (new StockIconSelectorItem ());
			selStock.IconSelected += OnStockSelected;
			Insert (selStock, -1);
			
			// Project icon selector
			if (project != null && project.IconFactory.Icons.Count > 0) {
				IconSelectorMenuItem selProject = new IconSelectorMenuItem (new ProjectIconSelectorItem (project));
				selProject.IconSelected += OnStockSelected;
				Insert (selProject, -1);
			}
			
			Insert (new Gtk.SeparatorMenuItem (), -1);
			
			Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("More..."));
			it.Activated += OnSetStockActionType;
			Insert (it, -1);
		}
Ejemplo n.º 51
0
        public void Step1_SetWidget(Gtk.Widget widget)
        {
            // Add right-click context menu to control.
            var menu = new Gtk.Menu();
            var resetMenuItem = new Gtk.MenuItem("Reset Camera Offset");
            resetMenuItem.Activated += delegate(object sender, EventArgs e) {
                SetCameraOffset(0, 0);
            };
            menu.Add(resetMenuItem);

            // Handle mouse move events.
            widget.MotionNotifyEvent += delegate(object o, Gtk.MotionNotifyEventArgs args) {
                if (!m_enabled) return;
                if (!m_mouseDown) return;

                double x = args.Event.X;
                double y = args.Event.Y;
                double dx = x - m_mouseDownX;
                double dy = y - m_mouseDownY;

                SetCameraOffset(m_offsetDownX + dx, m_offsetDownY + dy);
            };
            widget.ButtonPressEvent += delegate(object o, Gtk.ButtonPressEventArgs args) {
                if (m_enablePopupMenu && (args.Event.Button & 2) == 2) {
                    menu.ShowAll();
                    menu.Popup();
                    return;
                }

                m_mouseDown = true;
                m_mouseDownX = args.Event.X;
                m_mouseDownY = args.Event.Y;
                m_offsetDownX = m_offsetX;
                m_offsetDownY = m_offsetY;
            };
            widget.ButtonReleaseEvent += delegate(object o, Gtk.ButtonReleaseEventArgs args) {
                m_mouseDown = false;
            };
        }
Ejemplo n.º 52
0
        /// <summary>
        /// Loads plugin.
        /// </summary>
        public void Load()
        {
            this.rootWindow = Global.DefaultRootWindow;
            this.architecture = Stuff.Architecture();

            this.submenu = new Gtk.Menu();

            Gtk.MenuItem mi = new Gtk.MenuItem(Catalog.GetString("_Take region screenshot"));
            this.submenu.Append(mi);
            mi.Activated += (s, e) => this.TakeRegionScreenshot();
            mi.ButtonPressEvent += (s, e) => this.TakeRegionScreenshot();

            mi = new Gtk.MenuItem(Catalog.GetString("Take screenshot of _entire screen"));
            this.submenu.Append(mi);
            mi.Activated += (s, e) => this.TakeScreenScreenshot();
            mi.ButtonPressEvent += (s, e) => this.TakeScreenScreenshot();

            mi = new Gtk.MenuItem(Catalog.GetString("_Pick color"));
            this.submenu.Append(mi);
            mi.Activated += (s, e) => this.PickColor();
            mi.ButtonPressEvent += (s, e) => this.PickColor();
        }
Ejemplo n.º 53
0
 public Gtk.MenuItem AddMenuItem(string label)
 {
     var item = new Gtk.MenuItem (label);
     menu.Append (item);
     return item;
 }
Ejemplo n.º 54
0
		internal void ShowDockPopupMenu (uint time)
		{
			Gtk.Menu menu = new Gtk.Menu ();
			
			// Hide menuitem
			if ((Behavior & DockItemBehavior.CantClose) == 0) {
				Gtk.MenuItem mitem = new Gtk.MenuItem (Catalog.GetString("Hide"));
				mitem.Activated += delegate { Visible = false; };
				menu.Append (mitem);
			}

			Gtk.MenuItem citem;

			// Auto Hide menuitem
			if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide) {
				citem = new Gtk.MenuItem (Catalog.GetString("Minimize"));
				citem.Activated += delegate { Status = DockItemStatus.AutoHide; };
				menu.Append (citem);
			}

			if (Status != DockItemStatus.Dockable) {
				// Dockable menuitem
				citem = new Gtk.MenuItem (Catalog.GetString("Dock"));
				citem.Activated += delegate { Status = DockItemStatus.Dockable; };
				menu.Append (citem);
			}

			// Floating menuitem
			if ((Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating) {
				citem = new Gtk.MenuItem (Catalog.GetString("Undock"));
				citem.Activated += delegate { Status = DockItemStatus.Floating; };
				menu.Append (citem);
			}

			if (menu.Children.Length == 0) {
				menu.Destroy ();
				return;
			}

			ShowingContextMemu = true;

			menu.ShowAll ();
			menu.Hidden += (o,e) => {
				ShowingContextMemu = false;
			};
			menu.Popup (null, null, null, 3, time);
		}
Ejemplo n.º 55
0
		void PopupQuickFixMenu (Gdk.EventButton evt)
		{
			var menu = new Gtk.Menu ();

			var caretOffset = document.Editor.Caret.Offset;
			Gtk.Menu fixMenu = menu;
			DomRegion region;
			var resolveResult = document.GetLanguageItem (caretOffset, out region);
			if (resolveResult != null) {
				var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (document, resolveResult);
	
				bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
				if (addUsing) {
					foreach (string ns_ in possibleNamespaces) {
						string ns = ns_;
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Import Namespace {0}", ns));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run ();
						};
						menu.Add (menuItem);
					}
				}
				
				bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
				if (resolveDirect) {
					foreach (string ns in possibleNamespaces) {
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Use {0}", ns + "." + document.Editor.GetTextBetween (region.Begin, region.End)));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run ();
						};
						menu.Add (menuItem);
					}
				}
				if (menu.Children.Any () && fixes.Any ()) {
					fixMenu = new Gtk.Menu ();
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes"));
					menuItem.Submenu = fixMenu;
					menu.Add (menuItem);
				}
			}
			
			PopulateFixes (fixMenu);
			
			menu.ShowAll ();
			menu.SelectFirst (true);
			menuPushed = true;
			menu.Destroyed += delegate {
				menuPushed = false;
			};
			var container = (TextEditorContainer)document.Editor.Parent.Parent;
			var child = (TextEditorContainer.EditorContainerChild)container [this];
			GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0));
		}
Ejemplo n.º 56
0
		public void PopulateFixes (Gtk.Menu menu, ref int items)
		{
			int mnemonic = 1;
			foreach (var fix_ in fixes.OrderByDescending (i => GetUsage (i.IdString))) {
				var fix = fix_;
				var escapedLabel = fix.Title.Replace ("_", "__");
				var label = (mnemonic <= 10)
					? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
						: "  " + escapedLabel;
				var menuItem = new Gtk.MenuItem (label);
				menuItem.Activated += new ContextActionRunner (fix, document, loc).Run;
				menuItem.Activated += delegate {
					ConfirmUsage (fix.IdString);
					menu.Destroy ();
				};
				menu.Add (menuItem);
				items++;
			}
			var first = true;
			var alreadyInserted = new HashSet<CodeIssueProvider> ();
			foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where (f => f.Result is InspectorResults)) {
				var analysisFix = analysisFix_;
				var ir = analysisFix.Result as InspectorResults;
				if (ir == null)
					continue;
			
				if (first) {
					menu.Add (new Gtk.SeparatorMenuItem ());
					first = false;
				}
				if (alreadyInserted.Contains (ir.Inspector))
					continue;
				alreadyInserted.Add (ir.Inspector);
				
				var label = GettextCatalog.GetString ("_Inspection options for \"{0}\"", ir.Inspector.Title);
				var menuItem = new Gtk.MenuItem (label);
				menuItem.Activated += analysisFix.ShowOptions;
				menuItem.Activated += delegate {
					menu.Destroy ();
				};
				menu.Add (menuItem);
				items++;
			}

			foreach (var fix_ in fixes.Where (f => f.BoundToIssue != null)) {
				var fix = fix_;
				foreach (var inspector_ in RefactoringService.GetInspectors (document.Editor.MimeType).Where (i => i.GetSeverity () != ICSharpCode.NRefactory.CSharp.Severity.None)) {
					var inspector = inspector_;

					if (inspector.IdString.IndexOf (fix.BoundToIssue.FullName, StringComparison.Ordinal) < 0)
						continue;
					if (first) {
						menu.Add (new Gtk.SeparatorMenuItem ());
						first = false;
					}
					if (alreadyInserted.Contains (inspector))
						continue;
					alreadyInserted.Add (inspector);
					
					var label = GettextCatalog.GetString ("_Inspection options for \"{0}\"", inspector.Title);
					var menuItem = new Gtk.MenuItem (label);
					menuItem.Activated += delegate {
						MessageService.RunCustomDialog (new CodeIssueOptionsDialog (inspector), MessageService.RootWindow);
						menu.Destroy ();
					};
					menu.Add (menuItem);
					break;
				}

				items++;
			}
		}
Ejemplo n.º 57
0
		void OnSelectIcon (object s, Gtk.ButtonPressEventArgs args)
		{
			Gtk.Menu menu = new Gtk.Menu ();
			
			Gtk.CheckMenuItem item = new Gtk.CheckMenuItem (Catalog.GetString ("Action"));
			item.DrawAsRadio = true;
			item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action);
			item.Activated += OnSetActionType;
			menu.Insert (item, -1);
			
			item = new Gtk.CheckMenuItem (Catalog.GetString ("Radio Action"));
			item.DrawAsRadio = true;
			item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio);
			item.Activated += OnSetRadioType;
			menu.Insert (item, -1);
			
			item = new Gtk.CheckMenuItem (Catalog.GetString ("Toggle Action"));
			item.DrawAsRadio = true;
			item.Active = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle);
			item.Activated += OnSetToggleType;
			menu.Insert (item, -1);
			
			menu.Insert (new Gtk.SeparatorMenuItem (), -1);
			
			Gtk.MenuItem itIcons = new Gtk.MenuItem (Catalog.GetString ("Select Icon"));
			menu.Insert (itIcons, -1);
			IconSelectorMenu menuIcons = new IconSelectorMenu (GetProject ());
			menuIcons.IconSelected += OnStockSelected;
			itIcons.Submenu = menuIcons;
			
			Gtk.MenuItem it = new Gtk.MenuItem (Catalog.GetString ("Clear Icon"));
			it.Sensitive = (node.Action.GtkAction.StockId != null);
			it.Activated += OnClearIcon;
			menu.Insert (it, -1);
			
			menu.ShowAll ();

			uint but = args != null ? args.Event.Button : 1;
			menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), but, Gtk.Global.CurrentEventTime);
			
			// Make sure we get the focus after closing the menu, so we can keep browsing buttons
			// using the keyboard.
			menu.Hidden += delegate (object sender, EventArgs a) {
				GrabFocus ();
			};
			
			if (args != null)
				args.RetVal = false;
		}
Ejemplo n.º 58
0
 public MenuItemBackend(Gtk.MenuItem item)
 {
     this.item = item;
     label = (Gtk.Label) item.Child;
     item.ShowAll ();
 }
Ejemplo n.º 59
0
	void PopupQuickFixMenu (Gdk.EventButton evt)
		{
			var menu = new Gtk.Menu ();

			Gtk.Menu fixMenu = menu;
			ResolveResult resolveResult;
			ICSharpCode.NRefactory.CSharp.AstNode node;
			int items = 0;
			if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) {
				var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (
					document,
					node,
					ref resolveResult
				);
	
				bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
				if (addUsing) {
					foreach (var t in possibleNamespaces.Where (tp => tp.Item2)) {
						string ns = t.Item1;
						var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true, node).Run ();
							menu.Destroy ();
						};
						menu.Add (menuItem);
						items++;
					}
				}
				
				bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
				if (resolveDirect) {
					foreach (var t in possibleNamespaces) {
						string ns = t.Item1;
						var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation)));
						menuItem.Activated += delegate {
							new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false, node).Run ();
							menu.Destroy ();
						};
						menu.Add (menuItem);
						items++;
					}
				}
				if (menu.Children.Any () && fixes.Any ()) {
					fixMenu = new Gtk.Menu ();
					var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes"));
					menuItem.Submenu = fixMenu;
					menu.Add (menuItem);
					items++;
				}
			}
			
			PopulateFixes (fixMenu, ref items);
			if (items == 0) {
				menu.Destroy ();
				return;
			}
			document.Editor.SuppressTooltips = true;
			document.Editor.Parent.HideTooltip ();
			menu.ShowAll ();
			menu.SelectFirst (true);
			menuPushed = true;
			menu.Hidden += delegate {
				document.Editor.SuppressTooltips = false;
			};
			menu.Destroyed += delegate {
				menuPushed = false;
				Hide ();
			};
			var container = document.Editor.Parent;
			var child = (TextEditor.EditorContainerChild)container [this];

			Gdk.Rectangle rect;
/*			if (child != null) {
				rect = new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0);
			} else {*/
				var p = container.LocationToPoint (loc);
				rect = new Gdk.Rectangle (p.X + container.Allocation.X , p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0);
			//}
			GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, rect);
		}
Ejemplo n.º 60
0
		public void PopulateFixes (Gtk.Menu menu)
		{
			int mnemonic = 1;
			foreach (var fix_ in fixes.OrderByDescending (i => GetUsage (i.IdString))) {
				var fix = fix_;
				var escapedLabel = fix.Title.Replace ("_", "__");
				var label = (mnemonic <= 10)
						? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
						: "  " + escapedLabel;
				var menuItem = new Gtk.MenuItem (label);
				menuItem.Activated += new ContextActionRunner (fix, document, loc).Run;
				menuItem.Activated += delegate {
					ConfirmUsage (fix.IdString);
					menu.Destroy ();
				};
				menu.Add (menuItem);
			}
			var first = true;
			var alreadyInserted = new HashSet<CodeIssueProvider> ();
			foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where (f => f.Result is InspectorResults)) {
				var analysisFix = analysisFix_;
				var ir = analysisFix.Result as InspectorResults;
				if (ir == null)
					continue;
			
				if (first) {
					menu.Add (new Gtk.SeparatorMenuItem ());
					first = false;
				}
				if (alreadyInserted.Contains (ir.Inspector))
					continue;
				alreadyInserted.Add (ir.Inspector);
			
				var label = GettextCatalog.GetString ("_Inspection options for \"{0}\"", ir.Inspector.Title);
				var menuItem = new Gtk.MenuItem (label);
				menuItem.Activated += analysisFix.ShowOptions;
				menuItem.Activated += delegate {
					menu.Destroy ();
				};
				menu.Add (menuItem);
			}

		}