コード例 #1
0
ファイル: AppMenu.cs プロジェクト: dlbeer/olishell
        // Create "View" menu
        MenuItem CreateViewMenu(AccelGroup agr)
        {
            MenuItem view = new MenuItem("_View");
            Menu viewMenu = new Menu();
            view.Submenu = viewMenu;

            powerVisible = new CheckMenuItem("Show power _graph");
            powerVisible.Active = settings.PowerGraphVisible;
            powerVisible.Activated += OnShowPowerGraph;
            powerVisible.AddAccelerator("activate", agr,
            new AccelKey(Gdk.Key.F3, Gdk.ModifierType.None,
            AccelFlags.Visible));
            viewMenu.Append(powerVisible);

            viewMenu.Append(new SeparatorMenuItem());

            MenuItem zoomIn = new ImageMenuItem(Stock.ZoomIn, agr);
            zoomIn.Activated += (obj, evt) =>
            debugPane.PowerView.ZoomIn();
            zoomIn.AddAccelerator("activate", agr,
            new AccelKey(Gdk.Key.plus, Gdk.ModifierType.ControlMask,
            AccelFlags.Visible));
            viewMenu.Append(zoomIn);

            MenuItem zoomOut = new ImageMenuItem(Stock.ZoomOut, agr);
            zoomOut.Activated += (obj, evt) =>
            debugPane.PowerView.ZoomOut();
            zoomOut.AddAccelerator("activate", agr,
            new AccelKey(Gdk.Key.minus, Gdk.ModifierType.ControlMask,
            AccelFlags.Visible));
            viewMenu.Append(zoomOut);

            MenuItem zoomFit = new ImageMenuItem(Stock.ZoomFit, agr);
            zoomFit.Activated += (obj, evt) =>
            debugPane.PowerView.ZoomFit();
            zoomFit.AddAccelerator("activate", agr,
            new AccelKey(Gdk.Key.Key_0, Gdk.ModifierType.ControlMask,
            AccelFlags.Visible));
            viewMenu.Append(zoomFit);

            MenuItem zoomFull = new ImageMenuItem(Stock.Zoom100, agr);
            zoomFull.Activated += (obj, evt) =>
            debugPane.PowerView.ZoomFull();
            zoomFull.AddAccelerator("activate", agr,
            new AccelKey(Gdk.Key.Key_1, Gdk.ModifierType.ControlMask,
            AccelFlags.Visible));
            viewMenu.Append(zoomFull);

            return view;
        }
コード例 #2
0
ファイル: TestMenus.cs プロジェクト: saraa/fishtastic
        public static Gtk.Window Create()
        {
            window = new Window ("Menus");

            AccelGroup accel_group = new AccelGroup ();
            window.AddAccelGroup (accel_group);

            VBox box1 = new VBox (false, 0);
            window.Add (box1);

            MenuBar menubar = new MenuBar ();
            box1.PackStart (menubar, false, false, 0);

            Menu menu = Create_Menu (2, true);
            MenuItem menuitem = new MenuItem ("foo");
            menuitem.Submenu = menu;
            menubar.Append (menuitem);

            menuitem = new MenuItem ("bar");
            menuitem.Submenu = Create_Menu (3, true);
            menubar.Append (menuitem);

            Image image = new Image (Stock.Help, IconSize.Menu);

            menuitem = new ImageMenuItem ("Help");
            ((ImageMenuItem) menuitem).Image = image;
            menuitem.Submenu = Create_Menu (4, true);
            menuitem.RightJustified = true;
            menubar.Append (menuitem);

            menubar = new MenuBar ();
            box1.PackStart (menubar, false, true, 0);

            menu = Create_Menu (2, true);

            menuitem = new MenuItem ("Second menu bar");
            menuitem.Submenu = menu;
            menubar.Append (menuitem);

            VBox box2 = new VBox (false, 10);
            box2.BorderWidth = 10;
            box1.PackStart (box2, true, true, 0);

            menu = Create_Menu (1, false);
            menu.AccelGroup = accel_group;

            menu.Append (new SeparatorMenuItem ());

            menuitem = new CheckMenuItem ("Accelerate Me");
            menu.Append (menuitem);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFBE, 0, AccelFlags.Visible);

            menuitem = new CheckMenuItem ("Accelerator locked");
            menu.Append (menuitem);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible | AccelFlags.Locked);

            menuitem = new CheckMenuItem ("Accelerator Frozen");
            menu.Append (menuitem);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFC0, 0, AccelFlags.Visible);

            OptionMenu option_menu = new OptionMenu ();
            option_menu.Menu = menu;
            option_menu.SetHistory (3);
            box2.PackStart (option_menu, true, true, 0);

            box1.PackStart (new HSeparator (), false, false, 0);

            box2 = new VBox (false, 10);
            box2.BorderWidth = 10;
            box1.PackStart (box2, false, true, 0);

            Button close_button = new Button (Stock.Close);
            close_button.Clicked += new EventHandler (Close_Button);
            box2.PackStart (close_button, true, true, 0);

            close_button.CanDefault = true;
            close_button.GrabDefault ();

            window.ShowAll ();
            return window;
        }
コード例 #3
0
ファイル: NoteWindow.cs プロジェクト: oluc/tomboy
		// FIXME: Tags applied to a word should hold over the space
		// between the next word, as thats where you'll start typeing.
		// Tags are only active -after- a character with that tag.  This
		// is different from the way gtk-textbuffer applies tags.

		//
		// Text menu
		//
		// Menu for font style and size, and set the active radio
		// menuitem depending on the cursor poition.
		//

		public NoteTextMenu (Gtk.AccelGroup accel_group,
		                     NoteBuffer     buffer,
		                     UndoManager    undo_manager)
			: base ()
		{
			this.buffer = buffer;
			this.undo_manager = undo_manager;

			if (undo_manager != null) {
				undo = new Gtk.ImageMenuItem (Gtk.Stock.Undo, accel_group);
				undo.Activated += UndoClicked;
				undo.AddAccelerator ("activate",
				                     accel_group,
				                     (uint) Gdk.Key.z,
				                     Gdk.ModifierType.ControlMask,
				                     Gtk.AccelFlags.Visible);
				undo.Show ();
				Append (undo);

				redo = new Gtk.ImageMenuItem (Gtk.Stock.Redo, accel_group);
				redo.Activated += RedoClicked;
				redo.AddAccelerator ("activate",
				                     accel_group,
				                     (uint) Gdk.Key.z,
				                     (Gdk.ModifierType.ControlMask |
				                      Gdk.ModifierType.ShiftMask),
				                     Gtk.AccelFlags.Visible);
				redo.Show ();
				Append (redo);

				Gtk.SeparatorMenuItem undo_spacer = new Gtk.SeparatorMenuItem ();
				Append (undo_spacer);

				// Listen to events so we can sensitize and
				// enable keybinding
				undo_manager.UndoChanged += UndoChanged;
			}

			bold = new Gtk.CheckMenuItem ("<b>" +
			                              Catalog.GetString ("_Bold") +
			                              "</b>");
			MarkupLabel (bold);
			bold.Data ["Tag"] = "bold";
			bold.Activated += FontStyleClicked;
			bold.AddAccelerator ("activate",
			                     accel_group,
			                     (uint) Gdk.Key.b,
			                     Gdk.ModifierType.ControlMask,
			                     Gtk.AccelFlags.Visible);

			italic = new Gtk.CheckMenuItem ("<i>" +
			                                Catalog.GetString ("_Italic") +
			                                "</i>");
			MarkupLabel (italic);
			italic.Data ["Tag"] = "italic";
			italic.Activated += FontStyleClicked;
			italic.AddAccelerator ("activate",
			                       accel_group,
			                       (uint) Gdk.Key.i,
			                       Gdk.ModifierType.ControlMask,
			                       Gtk.AccelFlags.Visible);

			strikeout = new Gtk.CheckMenuItem ("<s>" +
			                                   Catalog.GetString ("_Strikeout") +
			                                   "</s>");
			MarkupLabel (strikeout);
			strikeout.Data ["Tag"] = "strikethrough";
			strikeout.Activated += FontStyleClicked;
			strikeout.AddAccelerator ("activate",
			                          accel_group,
			                          (uint) Gdk.Key.s,
			                          Gdk.ModifierType.ControlMask,
			                          Gtk.AccelFlags.Visible);

			highlight = new Gtk.CheckMenuItem ("<span background='yellow'>" +
			                                   Catalog.GetString ("_Highlight") +
			                                   "</span>");
			MarkupLabel (highlight);
			highlight.Data ["Tag"] = "highlight";
			highlight.Activated += FontStyleClicked;
			highlight.AddAccelerator ("activate",
			                          accel_group,
			                          (uint) Gdk.Key.h,
			                          Gdk.ModifierType.ControlMask,
			                          Gtk.AccelFlags.Visible);

			Gtk.SeparatorMenuItem spacer1 = new Gtk.SeparatorMenuItem ();

			Gtk.MenuItem font_size = new Gtk.MenuItem (Catalog.GetString ("Font Size"));
			font_size.Sensitive = false;

			normal = new Gtk.RadioMenuItem (Catalog.GetString ("_Normal"));
			MarkupLabel (normal);
			normal.Active = true;
			normal.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.Key_0,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			normal.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.KP_0,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			normal.Activated += FontSizeActivated;

			huge = new Gtk.RadioMenuItem (normal.Group,
			                              "<span size=\"x-large\">" +
			                              Catalog.GetString ("Hu_ge") +
			                              "</span>");
			MarkupLabel (huge);
			huge.Data ["Tag"] = "size:huge";
			huge.Activated += FontSizeActivated;

			large = new Gtk.RadioMenuItem (huge.Group,
			                               "<span size=\"large\">" +
			                               Catalog.GetString ("_Large") +
			                               "</span>");
			MarkupLabel (large);
			large.Data ["Tag"] = "size:large";
			large.Activated += FontSizeActivated;

			small = new Gtk.RadioMenuItem (large.Group,
			                               "<span size=\"small\">" +
			                               Catalog.GetString ("S_mall") +
			                               "</span>");
			MarkupLabel (small);
			small.Data ["Tag"] = "size:small";
			small.Activated += FontSizeActivated;

			hidden_no_size = new Gtk.RadioMenuItem (small.Group, string.Empty);
			hidden_no_size.Hide ();

			increase_font = new Gtk.MenuItem (Catalog.GetString ("Increase Font Size"));
			increase_font.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.plus,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			increase_font.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.KP_Add,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			increase_font.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.equal,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			increase_font.Activated += IncreaseFontClicked;

			decrease_font = new Gtk.MenuItem (Catalog.GetString ("Decrease Font Size"));
			decrease_font.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.minus,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			decrease_font.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.KP_Subtract,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			decrease_font.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.underscore,
						Gdk.ModifierType.ControlMask,
						Gtk.AccelFlags.Visible);
			decrease_font.Activated += DecreaseFontClicked;

			Gtk.SeparatorMenuItem spacer2 = new Gtk.SeparatorMenuItem ();

			bullets = new Gtk.CheckMenuItem (Catalog.GetString ("Bullets"));
			bullets.Activated += ToggleBulletsClicked;

			increase_indent = new Gtk.ImageMenuItem (Gtk.Stock.Indent, accel_group);
			increase_indent.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.Right,
						Gdk.ModifierType.Mod1Mask,
						Gtk.AccelFlags.Visible);
			increase_indent.Activated += IncreaseIndentClicked;
			increase_indent.Show ();

			decrease_indent = new Gtk.ImageMenuItem (Gtk.Stock.Unindent, accel_group);
			decrease_indent.AddAccelerator ("activate",
						accel_group,
						(uint) Gdk.Key.Left,
						Gdk.ModifierType.Mod1Mask,
						Gtk.AccelFlags.Visible);
			decrease_indent.Activated += DecreaseIndentClicked;
			decrease_indent.Show ();

			RefreshState ();

			Append (bold);
			Append (italic);
			Append (strikeout);
			Append (highlight);
			Append (spacer1);
			Append (font_size);
			Append (small);
			Append (normal);
			Append (large);
			Append (huge);
			Append (increase_font);
			Append (decrease_font);
			Append (spacer2);
			Append (bullets);
			Append (increase_indent);
			Append (decrease_indent);
			ShowAll ();

			theme_hack_menu = new Menu ();
			theme_hack_menu.Realize ();
			theme_hack_menu.StyleSet += delegate {
				ModifyBg (StateType.Normal, theme_hack_menu.Style.Background (StateType.Normal));
			};
		}