コード例 #1
0
ファイル: NoteBuffer.cs プロジェクト: MatteoNardi/Tomboy
		public NoteBuffer (Gtk.TextTagTable tags, Note note)
: base (tags)
		{
			RegisterSerializeFormat ("text/html", (Gtk.TextBufferSerializeFunc) Delegate.CreateDelegate (typeof(Gtk.TextBufferSerializeFunc), this, "SerializeToHtml"));

			active_tags = new List<Gtk.TextTag> ();
			undo_manager = new UndoManager (this);

			InsertText += TextInsertedEvent;
			DeleteRange += RangeDeletedEvent;
			MarkSet += MarkSetEvent;

			TagApplied += OnTagApplied;

			tags.TagChanged += OnTagChanged;

			widgetQueue = new Queue <WidgetInsertData> ();
			widgetQueueTimeout = 0;

			this.note = note;
		}
コード例 #2
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));
			};
		}