Exemplo n.º 1
0
        public static void PopupMenu(Gtk.Menu menu, Gdk.EventButton ev, Gtk.MenuPositionFunc mpf)
        {
            menu.Deactivated += DeactivateMenu;
            try {
                menu.Popup(null,
                           null,
                           mpf,
                           (ev == null) ? 0 : ev.Button,
                           (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
            } catch {
                Logger.Debug("Menu popup failed with custom MenuPositionFunc; trying again without");
                menu.Popup(null,
                           null,
                           null,
                           (ev == null) ? 0 : ev.Button,
                           (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
            }

            // Highlight the parent
            if (menu.AttachWidget != null)
            {
                menu.AttachWidget.State = Gtk.StateType.Selected;
            }

#if WIN32
            BringToForeground();
#endif
        }
Exemplo n.º 2
0
        public void Activate(Gdk.EventButton eb, Literal literal, Gtk.Menu popupMenu, bool isPopup)
        {
            /*MenuItem attach_item = new MenuItem (Catalog.GetString ("Find With"));
             * TagMenu attach_menu = new TagMenu (attach_item, App.Instance.Database.Tags);
             * attach_menu.TagSelected += literal.HandleAttachTagCommand;
             * attach_item.ShowAll ();
             * popup_menu.Append (attach_item);*/

            if (literal.IsNegated)
            {
                GtkUtil.MakeMenuItem(popupMenu, Strings.IncludePhotosTaggedTagName(literal.Tag.Name),
                                     new EventHandler(literal.HandleToggleNegatedCommand), true);
            }
            else
            {
                GtkUtil.MakeMenuItem(popupMenu, Strings.ExcludePhotosTaggedTagName(literal.Tag.Name),
                                     new EventHandler(literal.HandleToggleNegatedCommand), true);
            }

            GtkUtil.MakeMenuItem(popupMenu, Strings.RemoveFromSearch, "gtk-remove", new EventHandler(literal.HandleRemoveCommand), true);

            if (isPopup)
            {
                if (eb != null)
                {
                    popupMenu.Popup(null, null, null, eb.Button, eb.Time);
                }
                else
                {
                    popupMenu.Popup(null, null, null, 0, Gtk.Global.CurrentEventTime);
                }
            }
        }
Exemplo n.º 3
0
        void HandleClicked(object sender, Gtk.ButtonPressEventArgs e)
        {
            if (e.Event.Button != 1)
            {
                return;
            }

            Gtk.Menu menu = CreateMenu();

            if (menu != null)
            {
                isOpen = true;

                //make sure the button looks depressed
                Gtk.ReliefStyle oldRelief = Widget.Relief;
                Widget.Relief = Gtk.ReliefStyle.Normal;

                //clean up after the menu's done
                menu.Hidden += delegate {
                    Widget.Relief = oldRelief;
                    isOpen        = false;
                    ((Gtk.Widget)Widget).State = Gtk.StateType.Normal;

                    //FIXME: for some reason the menu's children don't get activated if we destroy
                    //directly here, so use a timeout to delay it
                    GLib.Timeout.Add(100, delegate {
                        //menu.Destroy ();
                        return(false);
                    });
                };
                menu.Popup(null, null, PositionFunc, 1, Gtk.Global.CurrentEventTime);
            }
        }
        protected virtual void ShowDropDown()
        {
            if (HasChildren)
            {
                PopupMenu         = new Gtk.Menu();
                PopupMenu.Hidden += (s, o) =>
                                    HideDropDown();
                PopupMenu.SelectionDone += (s, e) => {
                    var i = 0;
                };
                Populate(PopupMenu);
                PopupMenu.ShowAll();

                PopupMenu.Popup(null, null, delegate(Gtk.Menu menu, out int x, out int y, out bool push_in) {
                    var all = ContentWidget.Allocation;
                    var loc = GtkBackendHelper.ConvertToScreenCoordinates(ContentWidget, new Xwt.Point(0, all.Height));
                    x       = (int)loc.X;
                    y       = (int)loc.Y;
                    push_in = true;
                }, 0,
                                Gtk.Global.CurrentEventTime);

                PopupMenu.WidthRequest = this.Widget.Allocation.Width;
            }
        }
Exemplo n.º 5
0
        void OnPopupMenu(object sender, Gtk.PopupMenuArgs e)
        {
            try {
                var mainWindowType = pluginHost.MainWindow.GetType();
                var cxtTrayField   = mainWindowType.GetField("m_ctxTray",
                                                             BindingFlags.Instance | BindingFlags.NonPublic);
                var ctxTray = cxtTrayField.GetValue(pluginHost.MainWindow);

                // Synthesize menu open events. These are expected by KeePass and
                // other plugins

                var onOpening = ctxTray.GetType().GetMethod("OnOpening",
                                                            BindingFlags.Instance | BindingFlags.NonPublic);
                DBusBackgroundWorker.InvokeWinformsThread(() =>
                                                          onOpening.Invoke(ctxTray, new[] { new CancelEventArgs() }));

                statusIconMenu.Popup(null, null, null, (uint)e.Args[0], (uint)e.Args[1]);

                var onOpened = ctxTray.GetType().GetMethod("OnOpened",
                                                           BindingFlags.Instance | BindingFlags.NonPublic);
                DBusBackgroundWorker.InvokeWinformsThread(() =>
                                                          onOpened.Invoke(ctxTray, new[] { new CancelEventArgs() }));
            } catch (Exception ex) {
                Debug.Fail(ex.ToString());
            }
        }
Exemplo n.º 6
0
        void IMenuItemContainer.ShowContextMenu(ActionItem aitem)
        {
            ActionMenuItem menuItem = aitem as ActionMenuItem;

            Gtk.Menu     m    = new Gtk.Menu();
            Gtk.MenuItem item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Cut(menuItem);
            };
            item.Visible = false;               // No copy & paste for now
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Copy(menuItem);
            };
            item.Visible = false;               // No copy & paste for now
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Paste(menuItem);
            };
            item.Visible = false;               // No copy & paste for now
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Delete(menuItem);
            };
            m.ShowAll();
            m.Popup();
        }
Exemplo n.º 7
0
        protected override void OnClicked()
        {
            base.OnClicked();

            if (creator != null)
            {
                Gtk.Menu menu = creator(this);

                if (menu != null)
                {
                    isOpen = true;

                    //make sure the button looks depressed
                    Gtk.ReliefStyle oldRelief = this.Relief;
                    this.Relief = Gtk.ReliefStyle.Normal;

                    //clean up after the menu's done
                    menu.Hidden += delegate {
                        this.Relief = oldRelief;
                        isOpen      = false;
                        this.State  = Gtk.StateType.Normal;

                        //FIXME: for some reason the menu's children don't get activated if we destroy
                        //directly here, so use a timeout to delay it
                        GLib.Timeout.Add(100, delegate {
                            //menu.Destroy ();
                            return(false);
                        });
                    };
                    menu.Popup(null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime);
                }
            }
        }
Exemplo n.º 8
0
 private void IconClicked(object source, Gtk.ButtonPressEventArgs args)
 {
     //ProjectWindow pw = new ProjectWindow();
     //pw.Show();
     menu.ShowAll();
     menu.Popup(null, null, null, IntPtr.Zero, args.Event.Button, args.Event.Time);
 }
Exemplo n.º 9
0
 void OnIconMarginButtonPress(object s, MarginMouseEventArgs args)
 {
     if (args.Button == 3)
     {
         editor.Caret.Line   = args.LineNumber;
         editor.Caret.Column = 1;
         Gtk.Menu popupMenu = (Gtk.Menu)MainClass.MainWindow.ActionUiManager.GetWidget("/iconMarginPopup");
         if (popupMenu != null)
         {
             popupMenu.ShowAll();
             popupMenu.Popup();
         }
     }
     else if (args.Button == 1)
     {
         if (!string.IsNullOrEmpty(FileName))
         {
             if (args.LineSegment != null)
             {
                 //DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber + 1);
                 //AddBreakpoints(args.LineSegment);
             }
         }
     }
 }
Exemplo n.º 10
0
        void ShowMenu()
        {
            Gtk.Menu menu = CreateMenu();

            if (menu != null)
            {
                isOpen = true;

                //make sure the button looks depressed
                Gtk.ReliefStyle oldRelief = Widget.Relief;
                Widget.Relief = Gtk.ReliefStyle.Normal;
                Widget.SetStateActive();

                //clean up after the menu's done
                menu.Hidden += delegate {
                    Widget.Relief = oldRelief;
                    isOpen        = false;
                    Widget.SetStateNormal();

                    //FIXME: for some reason the menu's children don't get activated if we destroy
                    //directly here, so use a timeout to delay it
                    GLib.Timeout.Add(100, delegate {
                        //menu.Destroy ();
                        return(false);
                    });
                };
                menu.Popup(null, null, PositionFunc, 1, Gtk.Global.CurrentEventTime);
            }
        }
        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();
        }
Exemplo n.º 12
0
        protected virtual void OnPersonTreeViewKeyPressEvent(object sender, Gtk.KeyPressEventArgs e)
        {
            Trace.Call(sender, e);

            if ((e.Event.State & Gdk.ModifierType.Mod1Mask) != 0 ||
                (e.Event.State & Gdk.ModifierType.ControlMask) != 0 ||
                (e.Event.State & Gdk.ModifierType.ShiftMask) != 0)
            {
                // alt, ctrl or shift pushed, returning
                return;
            }

            if (e.Event.Key == Gdk.Key.Menu &&
                _PersonTreeView.Selection.CountSelectedRows() > 0)
            {
                _PersonMenu.Popup(null, null, null, 0, e.Event.Time);
            }
        }
Exemplo n.º 13
0
 // Place the menu underneath an arbitrary parent widget.  The
 // parent widget must be set using menu.AttachToWidget before
 // calling this
 public static void PopupMenu(Gtk.Menu menu, Gdk.EventButton ev)
 {
     menu.Deactivated += new EventHandler(DeactivateMenu);
     menu.Popup(null,
                null,
                new Gtk.MenuPositionFunc(GetMenuPosition),
                (ev == null) ? 0 : ev.Button,
                (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
 }
        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;
            }
        }
Exemplo n.º 15
0
 protected override void OnPanelClick(Gdk.EventButton e, Placement placement)
 {
     if (e.Button == 3)
     {
         CommandEntrySet opset = new CommandEntrySet();
         opset.AddItem(CommandSystemCommands.ToolbarList);
         Gtk.Menu menu = manager.CreateMenu(opset);
         menu.Popup(null, null, null, 0, e.Time);
     }
     base.OnPanelClick(e, placement);
 }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
            }
        }
Exemplo n.º 18
0
        protected virtual void OnTabButtonPress(object sender, Gtk.ButtonPressEventArgs e)
        {
            Trace.Call(sender, e);

            try {
                if (e.Event.Button == 3)
                {
                    _TabMenu.Popup(null, null, null, e.Event.Button, e.Event.Time);
                }
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Exemplo n.º 19
0
        private bool DoPopupMenu(Gdk.EventButton evnt)
        {
            Gtk.Menu menu = new Gtk.Menu();

            PopulatePopup(this, menu);

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

            menu.AttachToWidget(this, null);

            if (evnt != null)
            {
                menu.Popup(null, null, null, evnt.Button, evnt.Time);
            }
            else
            {
                menu.Popup();
            }

            return(true);
        }
Exemplo n.º 20
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();
            };
        }
Exemplo n.º 21
0
        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");

            editLabel.Activated += delegate(object sender, EventArgs e)
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };

            m_contextMenu.Add(editLabel);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 22
0
        private void ShowPopup()
        {
            Gtk.Menu menu = new Gtk.Menu();

            Gtk.MenuItem deleteFile = new Gtk.MenuItem(GettextCatalog.GetString("Delete file"));
            deleteFile.Activated += new EventHandler(OnDeleteFiles);

            Gtk.MenuItem renameFile = new Gtk.MenuItem(GettextCatalog.GetString("Rename file"));
            renameFile.Activated += new EventHandler(OnRenameFile);
            renameFile.Sensitive  = false;

            menu.Append(deleteFile);
            menu.Append(renameFile);

            menu.Popup(null, null, null, 3, Gtk.Global.CurrentEventTime);
            menu.ShowAll();
        }
        protected override bool OnPopupMenu()
        {
            Gtk.Menu mnu = new Gtk.Menu();

            Gtk.ImageMenuItem play = new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay, null);
            play.Activated += delegate(object sender, EventArgs a) {
                _view.PlayAlbum((CS_AlbumInfo)this.Model[Selection.FirstIndex]);
            };

            Gtk.ImageMenuItem edit = new Gtk.ImageMenuItem(Gtk.Stock.Edit, null);
            edit.Activated += delegate(object sender, EventArgs a) {
                _view.EditSheet(((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet());
            };

            Gtk.ImageMenuItem show_file = new Gtk.ImageMenuItem("Show in filesystem");
            show_file.Image      = new Gtk.Image(Gtk.Stock.Directory, Gtk.IconSize.Menu);
            show_file.Activated += delegate(object sender, EventArgs a) {
                _view.OpenContainingFolder((CS_AlbumInfo)this.Model[Selection.FirstIndex]);
            };

            mnu.Append(play);
            mnu.Append(new Gtk.SeparatorMenuItem());
            mnu.Append(edit);
            mnu.Append(show_file);

            CueSheet s = ((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet();

            if (Mp3Split.DllPresent())
            {
                if (Mp3Split.IsSupported(s.musicFileName()))
                {
                    Gtk.ImageMenuItem split = new Gtk.ImageMenuItem("Split & Write to location");
                    split.Image      = new Gtk.Image(Gtk.Stock.Convert, Gtk.IconSize.Menu);
                    split.Activated += delegate(object sender, EventArgs a) {
                        _view.MusicFileToDevice(((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet());
                    };
                    mnu.Append(split);
                }
            }

            mnu.ShowAll();
            mnu.Popup();

            return(false);
        }
Exemplo n.º 24
0
        /*
         *      int j = 1;
         *      for (int i = 1; i <= insertObject.Document.LineCount; i++) {
         *              LineSegment ls = insertObject.Document.GetLine(i);
         *              if (ls != null) {
         *
         *                      if (j == 1) {
         *                              ErrorMarker er = new ErrorMarker(ls);
         *                              er.AddToLine(insertObject.Document);
         *                              j++;
         *                      } else if (j == 2) {
         *                              TextMarker bm = new BreakpointTextMarker(insertObject, false);
         *                              //DebugTextMarker tm = new DebugTextMarker((insertObject as TextEditor));
         *
         *                              insertObject.Document.AddMarker(ls, bm);
         *                              insertObject.QueueDraw();
         *                              j++;
         *                      } else {
         *                              if (ls.IsBookmarked != true) {
         *                                      //int lineNumber = insertObject.Document.OffsetToLineNumber (ls.Offset);
         *                                      ls.IsBookmarked = true;
         *                                      insertObject.Document.RequestUpdate(new LineUpdate(i));
         *                                      insertObject.Document.CommitDocumentUpdate();
         *                              }
         *                              j = 1;
         *                      }
         *              }
         *      }*/

        void OnTextMarginButtonPress(object s, MarginMouseEventArgs args)
        {
            if (args.Button == 3)
            {
                Selection sel = editor.MainSelection;

                editor.Caret.Line = args.LineNumber;
                DocumentLocation dl = editor.VisualToDocumentLocation(args.X, args.Y);
                editor.Caret.Location = dl;

                if ((sel != null) && (args.LineNumber >= sel.MinLine && args.LineNumber <= sel.MaxLine))
                {
                    editor.MainSelection = sel;
                }

                if (args.LineSegment != null)
                {
                    Gtk.Menu popupMenu = (Gtk.Menu)MainClass.MainWindow.ActionUiManager.GetWidget("/textMarginPopup");
                    if (popupMenu != null)
                    {
                        Gtk.Action act = MainClass.MainWindow.ActionUiManager.FindActionByName("gotodefinition");

                        if (act != null)
                        {
                            act.Visible = false;

                            string caretWord = editor.GetCarretWord();
                            //Console.WriteLine("caretWord ->"+caretWord );
                            if (!String.IsNullOrEmpty(caretWord))
                            {
                                int indx = MainClass.CompletedCache.ListDataTypes.FindIndex(x => x.DisplayText == caretWord);
                                if (indx > -1)
                                {
                                    act.Visible = true;
                                }
                            }
                            //act.Visible = false;
                            //act.Sensitive = false;
                        }
                        //popupMenu.ShowAll();
                        popupMenu.Popup();
                    }
                }
            }
        }
Exemplo n.º 25
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);
			}
		}
Exemplo n.º 26
0
 protected void OnRight(object sender, Gtk.ButtonPressEventArgs e)
 {
     if (e.Event.Button == 3)            // Botón derecho.
     {
         Gtk.TreePath RowPath;
         if (Exercises.GetPathAtPos(Convert.ToInt32(e.Event.X),
                                    Convert.ToInt32(e.Event.Y),
                                    out RowPath))
         {
             int          ActiveRow      = RowPath.Indices[0];
             Gtk.Menu     m              = new Gtk.Menu();
             Gtk.MenuItem DeleteExercise = new Gtk.MenuItem("Delete exercise");
             DeleteExercise.ButtonPressEvent += (o, a) => OnDelete(ActiveRow);
             m.Add(DeleteExercise);
             m.ShowAll();
             m.Popup();
         }
     }
 }
Exemplo n.º 27
0
        // HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59

        /*
         * private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
         * {
         *  m_contextMenu = new Gtk.Menu();
         *  Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");
         *
         *  editLabel.Activated += delegate(object sender, EventArgs e)
         *  {
         *      SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
         *      mainTool.DelegateTool = textTool;
         *      textTool.StartEditing();
         *  };
         *
         *  m_contextMenu.Add(editLabel);
         *  m_contextMenu.ShowAll();
         *
         *  m_contextMenu.Popup();
         * }
         */

        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");
            Gtk.MenuItem copy      = new Gtk.MenuItem("Copy");
            Gtk.MenuItem cut       = new Gtk.MenuItem("Cut");
            // Gtk.MenuItem paste = new Gtk.MenuItem("Paste");

            editLabel.Activated += delegate(object sender, EventArgs e)
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };

            copy.Activated += delegate(object sender, EventArgs e)
            {
                Clipboard.Copy(ExperimentNode.Owner as BaseExperiment);
            };

            cut.Activated += delegate(object sender, EventArgs e)
            {
                Clipboard.Cut(ExperimentNode.Owner as BaseExperiment);
            };

            /*
             * paste.Activated += delegate(object sender, EventArgs e)
             * {
             *  Clipboard.Paste(ExperimentNode.Owner as BaseExperiment);
             *  ExperimentCanvasPad ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, this);
             *  ecp.DisplayAddedSubgraph(ExperimentNode.Owner as BaseExperiment);
             * };
             */

            m_contextMenu.Add(editLabel);
            m_contextMenu.Add(copy);
            m_contextMenu.Add(cut);
            // m_contextMenu.Add(paste);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 28
0
        void OnSelectIcon(object sender, Gtk.ButtonPressEventArgs e)
        {
            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();
            menu.Popup(null, null, new Gtk.MenuPositionFunc(OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime);
            e.RetVal = false;
        }
        protected override bool OnPopupMenu()
        {
            Gtk.Menu mnu = new Gtk.Menu();

            Gtk.ImageMenuItem play = new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay, null);
            play.Activated += delegate(object sender, EventArgs a) {
                _view.PlayPlayList((CS_PlayList)this.Model[Selection.FirstIndex]);
            };

            //Gtk.ImageMenuItem edit=new Gtk.ImageMenuItem(Gtk.Stock.Edit,null);
            //edit.Activated+=delegate(object sender,EventArgs a) {
            //	_view.EditPlayList(((CS_PlayList) this.Model[Selection.FirstIndex]).getSheet ());
            //};

            mnu.Append(play);
            mnu.Append(new Gtk.SeparatorMenuItem());
            //mnu.Append (edit);
            mnu.ShowAll();
            mnu.Popup();

            return(false);
        }
Exemplo n.º 30
0
        protected override void OnPressed()
        {
            base.OnPressed();
            Gtk.Menu menu = new Gtk.Menu();
            foreach (ComboItemSet iset in items)
            {
                if (iset.Count == 0)
                {
                    continue;
                }

                if (menu.Children.Length > 0)
                {
                    Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem();
                    sep.Show();
                    menu.Insert(sep, -1);
                }

                Gtk.RadioMenuItem grp = new Gtk.RadioMenuItem("");
                foreach (ComboItem ci in iset)
                {
                    Gtk.RadioMenuItem mi = new Gtk.RadioMenuItem(grp, ci.Label.Replace("_", "__"));
                    if (ci.Item == iset.CurrentItem || ci.Item.Equals(iset.CurrentItem))
                    {
                        mi.Active = true;
                    }

                    ComboItemSet isetLocal = iset;
                    ComboItem    ciLocal   = ci;
                    mi.Activated += delegate
                    {
                        SelectItem(isetLocal, ciLocal);
                    };
                    mi.ShowAll();
                    menu.Insert(mi, -1);
                }
            }
            menu.Popup(null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime);
        }
Exemplo n.º 31
0
        private void OnStatusIconPopupMenu(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

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

            Gtk.ImageMenuItem preferencesItem = new Gtk.ImageMenuItem(
                Gtk.Stock.Preferences, null
                );
            preferencesItem.Activated += delegate {
                try {
                    var builder = new Gtk.Builder(null, "PreferencesDialog2.ui", null);
                    var widget  = (Gtk.Widget)builder.GetObject("PreferencesDialog");
                    var dialog  = new PreferencesDialog(f_MainWindow, builder, widget.Handle);
                    dialog.Show();
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            };
            menu.Add(preferencesItem);

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

            Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem(
                Gtk.Stock.Quit, null
                );
            quitItem.Activated += delegate {
                try {
                    Frontend.Quit();
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            };
            menu.Add(quitItem);

            menu.ShowAll();
            menu.Popup();
        }
Exemplo n.º 32
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;
		}
        protected override bool OnPopupMenu()
        {
            Gtk.Menu mnu=new Gtk.Menu();

            Gtk.ImageMenuItem play=new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay,null);
            play.Activated+=delegate(object sender,EventArgs a) {
                _view.PlayAlbum((CS_AlbumInfo) this.Model[Selection.FirstIndex]);
            };

            Gtk.ImageMenuItem edit=new Gtk.ImageMenuItem(Gtk.Stock.Edit,null);
            edit.Activated+=delegate(object sender,EventArgs a) {
                _view.EditSheet(((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ());
            };

            Gtk.ImageMenuItem show_file=new Gtk.ImageMenuItem("Show in filesystem");
            show_file.Image=new Gtk.Image(Gtk.Stock.Directory,Gtk.IconSize.Menu);
            show_file.Activated+=delegate(object sender, EventArgs a) {
                _view.OpenContainingFolder((CS_AlbumInfo) this.Model[Selection.FirstIndex]);
            };

            mnu.Append (play);
            mnu.Append (new Gtk.SeparatorMenuItem());
            mnu.Append (edit);
            mnu.Append (show_file);

            CueSheet s=((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ();
            if (Mp3Split.DllPresent()) {
                if (Mp3Split.IsSupported(s.musicFileName ())) {
                    Gtk.ImageMenuItem split=new Gtk.ImageMenuItem("Split & Write to location");
                    split.Image=new Gtk.Image(Gtk.Stock.Convert,Gtk.IconSize.Menu);
                    split.Activated+=delegate(object sender,EventArgs a) {
                        _view.MusicFileToDevice(((CS_AlbumInfo) this.Model[Selection.FirstIndex]).getSheet ());
                    };
                    mnu.Append (split);
                }
            }

            mnu.ShowAll ();
            mnu.Popup();

            return false;
        }
Exemplo n.º 34
0
        public void ShowContextMenu(ActionItem aitem)
        {
            ActionMenuItem menuItem = (ActionMenuItem) aitem;

            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);
            };

            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.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                menuItem.Copy ();
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Paste (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                menuItem.Delete ();
            };
            m.ShowAll ();
            m.Popup ();
        }
Exemplo n.º 35
0
        void IMenuItemContainer.ShowContextMenu(ActionItem aitem)
        {
            ActionMenuItem menuItem = aitem as ActionMenuItem;

            Gtk.Menu m = new Gtk.Menu ();
            Gtk.MenuItem item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Cut (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Copy (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Paste (menuItem);
            };
            item.Visible = false;	// No copy & paste for now
            item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null);
            m.Add (item);
            item.Activated += delegate (object s, EventArgs a) {
                Delete (menuItem);
            };
            m.ShowAll ();
            m.Popup ();
        }
Exemplo n.º 36
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);
		}
Exemplo n.º 37
0
		void nsIContextMenuListener2.OnShowContextMenu(uint aContextFlags, nsIContextMenuInfo info)
		{
			// if we don't have a target node, we can't do anything by default.  this happens in XUL forms (i.e. about:config)
			if (info.GetTargetNodeAttribute() == null)
				return;
			
			ContextMenu menu = new ContextMenu();
			
			// no default items are added when the context menu is disabled
			if (!this.NoDefaultContextMenu)
			{
				List<MenuItem> optionals = new List<MenuItem>();
				
				if (this.CanUndo || this.CanRedo)
				{
					optionals.Add(new MenuItem("Undo", delegate { Undo(); }));
					optionals.Add(new MenuItem("Redo", delegate { Redo(); }));
					
					optionals[0].Enabled = this.CanUndo;
					optionals[1].Enabled = this.CanRedo;
				}
				else
				{
					optionals.Add(new MenuItem("Back", delegate { GoBack(); }));
					optionals.Add(new MenuItem("Forward", delegate { GoForward(); }));
					
					optionals[0].Enabled = this.CanGoBack;
					optionals[1].Enabled = this.CanGoForward;
				}
				
				optionals.Add(new MenuItem("-"));
				
				if (this.CanCopyImageContents)
					optionals.Add(new MenuItem("Copy Image Contents", delegate { CopyImageContents(); }));
				
				if (this.CanCopyImageLocation)
					optionals.Add(new MenuItem("Copy Image Location", delegate { CopyImageLocation(); }));
				
				if (this.CanCopyLinkLocation)
					optionals.Add(new MenuItem("Copy Link Location", delegate { CopyLinkLocation(); }));
				
				if (this.CanCopySelection)
					optionals.Add(new MenuItem("Copy Selection", delegate { CopySelection(); }));
				
				MenuItem mnuSelectAll = new MenuItem("Select All");
				mnuSelectAll.Click += delegate { SelectAll(); };

				GeckoDomDocument doc = GeckoDomDocument.CreateDomDocumentWraper(info.GetTargetNodeAttribute().GetOwnerDocumentAttribute());

				string viewSourceUrl = (doc == null) ? null : Convert.ToString(doc.Uri);
				
				MenuItem mnuViewSource = new MenuItem("View Source");
				mnuViewSource.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuViewSource.Click += delegate { ViewSource(viewSourceUrl); };

				MenuItem mnuOpenInSystemBrowser = new MenuItem("View In System Browser");//nice for debugging with firefox/firebug
				mnuOpenInSystemBrowser.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuOpenInSystemBrowser.Click += delegate { ViewInSystemBrowser(viewSourceUrl); };


				string properties = (doc != null && doc.Uri == Document.Uri) ? "Page Properties" : "IFRAME Properties";
				
				MenuItem mnuProperties = new MenuItem(properties);
				mnuProperties.Enabled = doc != null;
				mnuProperties.Click += delegate { ShowPageProperties(doc); };
				
				menu.MenuItems.AddRange(optionals.ToArray());
				menu.MenuItems.Add(mnuSelectAll);
				menu.MenuItems.Add("-");
				menu.MenuItems.Add(mnuViewSource);
				menu.MenuItems.Add(mnuOpenInSystemBrowser);
				menu.MenuItems.Add(mnuProperties);
			}

			// get image urls
			Uri backgroundImageSrc = null, imageSrc = null;
			nsIURI src;
			try
			{
				src = info.GetBackgroundImageSrcAttribute();
				backgroundImageSrc = src.ToUri();
				Marshal.ReleaseComObject( src );
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}

			try
			{
				src = info.GetImageSrcAttribute();
				if ( src != null )
				{
					imageSrc = src.ToUri();
					Marshal.ReleaseComObject( src );
				}
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}
			
			// get associated link.  note that this needs to be done manually because GetAssociatedLink returns a non-zero
			// result when no associated link is available, so an exception would be thrown by nsString.Get()
			string associatedLink = null;
			try
			{
				using (nsAString str = new nsAString())
				{
					info.GetAssociatedLinkAttribute(str);
					associatedLink = str.ToString();
				}
			}
			catch (COMException comException) { }			
			
			GeckoContextMenuEventArgs e = new GeckoContextMenuEventArgs(
				PointToClient(MousePosition), menu, associatedLink, backgroundImageSrc, imageSrc,
				GeckoNode.Create(Xpcom.QueryInterface<nsIDOMNode>(info.GetTargetNodeAttribute()))
				);
			
			OnShowContextMenu(e);
			
			if (e.ContextMenu != null && e.ContextMenu.MenuItems.Count > 0)
			{
#if GTK
				// When using GTK we can't use SWF to display the context menu: SWF displays
				// the context menu and then tries to track the mouse so that it knows when to
				// close the context menu. However, GTK intercepts the mouse click before SWF gets
				// it, so the menu never closes. Instead we display a GTK menu and translate
				// the SWF menu items into Gtk.MenuItems.
				// TODO: currently this code only handles text menu items. Would be nice to also
				// translate images etc.
				var popupMenu = new Gtk.Menu();

				foreach (MenuItem swfMenuItem in e.ContextMenu.MenuItems)
				{
					var gtkMenuItem = new Gtk.MenuItem(swfMenuItem.Text);
					gtkMenuItem.Sensitive = swfMenuItem.Enabled;
					MenuItem origMenuItem = swfMenuItem;
					gtkMenuItem.Activated += (sender, ev) => origMenuItem.PerformClick();
					popupMenu.Append(gtkMenuItem);
				}
				popupMenu.ShowAll();
				popupMenu.Popup();
#else
				e.ContextMenu.Show(this, e.Location);
#endif
			}
		}
Exemplo n.º 38
0
        private static void OnStatusIconPopupMenu(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

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

            Gtk.ImageMenuItem preferencesItem = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, null);
            preferencesItem.Activated += delegate {
                try {
                    PreferencesDialog dialog = new PreferencesDialog(_MainWindow);
                    dialog.CurrentPage = PreferencesDialog.Page.Interface;
                    dialog.CurrentInterfacePage = PreferencesDialog.InterfacePage.Notification;
                } catch (Exception ex) {
                    ShowException(ex);
                }
            };
            menu.Add(preferencesItem);

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

            Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem(Gtk.Stock.Quit, null);
            quitItem.Activated += delegate {
                try {
                    Quit();
                } catch (Exception ex) {
                    ShowException(ex);
                }
            };
            menu.Add(quitItem);

            menu.ShowAll();
            menu.Popup();
        }
Exemplo n.º 39
0
		private void ArrowButton_Click(object sender, EventArgs e)
		{
			Gtk.Menu menu = new Gtk.Menu();
			
			foreach (string childId in _dummyFam.Children)
			{
				GedcomIndividualRecord child = (GedcomIndividualRecord)_database[childId];
				
				string name = child.GetName().Name;
				
				Gtk.ImageMenuItem menuItem = new Gtk.ImageMenuItem(name);
				menuItem.Image = new Gtk.Image(Gtk.Stock.JumpTo, Gtk.IconSize.Menu);
				menuItem.ShowAll();
				
				menu.Append(menuItem);
								
				menuItem.Activated += ChildMenu_Activated;
			}
			
			menu.Popup();
		}
Exemplo n.º 40
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;
            };
        }
        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };
    
            m_contextMenu.Add(editLabel);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 42
0
		void OnSelectIcon (object sender, Gtk.ButtonPressEventArgs e)
		{
			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 ();
			menu.Popup (null, null, new Gtk.MenuPositionFunc (OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime);
			e.RetVal = false;
		}
Exemplo n.º 43
0
        // HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59
        /*
        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };
    
            m_contextMenu.Add(editLabel);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
        */

        private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev)
        {
            m_contextMenu = new Gtk.Menu();
            Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label");
            Gtk.MenuItem copy = new Gtk.MenuItem("Copy");
            Gtk.MenuItem cut = new Gtk.MenuItem("Cut");
            // Gtk.MenuItem paste = new Gtk.MenuItem("Paste");

            editLabel.Activated += delegate(object sender, EventArgs e) 
            {
                SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev);
                mainTool.DelegateTool = textTool;
                textTool.StartEditing();
            };

            copy.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Copy(ExperimentNode.Owner as BaseExperiment);
            };

            cut.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Cut(ExperimentNode.Owner as BaseExperiment);
            };

            /*
            paste.Activated += delegate(object sender, EventArgs e) 
            {
                Clipboard.Paste(ExperimentNode.Owner as BaseExperiment);
                ExperimentCanvasPad ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, this);
                ecp.DisplayAddedSubgraph(ExperimentNode.Owner as BaseExperiment); 
            };
            */

            m_contextMenu.Add(editLabel);
            m_contextMenu.Add(copy);
            m_contextMenu.Add(cut);
            // m_contextMenu.Add(paste);
            m_contextMenu.ShowAll();

            m_contextMenu.Popup();
        }
Exemplo n.º 44
0
        private void ShowPopup()
        {
            Gtk.Menu menu = new Gtk.Menu ();

            Gtk.MenuItem deleteFile = new Gtk.MenuItem (GettextCatalog.GetString ("Delete file"));
            deleteFile.Activated += new EventHandler (OnDeleteFiles);

            Gtk.MenuItem renameFile = new Gtk.MenuItem (GettextCatalog.GetString ("Rename file"));
            renameFile.Activated += new EventHandler (OnRenameFile);
            renameFile.Sensitive = false;

            menu.Append (deleteFile);
            menu.Append (renameFile);

            menu.Popup (null, null, null, 3, Gtk.Global.CurrentEventTime);
            menu.ShowAll ();
        }
Exemplo n.º 45
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 ();
			};
		}