Esempio n. 1
0
		void MakeRecentTree ()
		{
		    targets =
			new Gtk.TargetEntry [] {
				new Gtk.TargetEntry ("STRING",
				Gtk.TargetFlags.App,
				(uint) Target.Text),
				new Gtk.TargetEntry ("text/plain",
				Gtk.TargetFlags.App,
				(uint) Target.Text),
				new Gtk.TargetEntry ("text/uri-list",
				Gtk.TargetFlags.App,
				(uint) Target.Uri),
				new Gtk.TargetEntry ("text/path-list",
				Gtk.TargetFlags.App,
				(uint) Target.Path),
			};

			tree = new RecentTreeView ();
			tree.HeadersVisible = true;
			tree.RulesHint = true;
			tree.RowActivated += OnRowActivated;
			tree.Selection.Mode = Gtk.SelectionMode.Multiple;
			tree.Selection.Changed += OnSelectionChanged;
			tree.ButtonPressEvent += OnTreeViewButtonPressed;
			tree.KeyPressEvent += OnTreeViewKeyPressed;
			tree.MotionNotifyEvent += OnTreeViewMotionNotify;
			tree.ButtonReleaseEvent += OnTreeViewButtonReleased;
			tree.DragDataGet += OnTreeViewDragDataGet;

			tree.EnableModelDragSource (Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
						    targets,
						    Gdk.DragAction.Move);

			Gtk.CellRenderer renderer;

			Gtk.TreeViewColumn title = new Gtk.TreeViewColumn ();
			title.Title = Catalog.GetString ("Note");
			title.MinWidth = 150; // Fix for bgo 575337 - "Matches" column causes notes name not to be shown. jjennings jul 13, 2011
			title.Sizing = Gtk.TreeViewColumnSizing.Autosize;
			title.Expand = true;
			title.Resizable = true;

			renderer = new Gtk.CellRendererPixbuf ();
			title.PackStart (renderer, false);
			title.AddAttribute (renderer, "pixbuf", 0 /* icon */);

			renderer = new Gtk.CellRendererText ();
			(renderer as Gtk.CellRendererText).Ellipsize =
				Pango.EllipsizeMode.End;
			title.PackStart (renderer, true);
			title.AddAttribute (renderer, "text", 1 /* title */);
			title.SortColumnId = 1; /* title */
			title.SortIndicator = false;
			title.Reorderable = false;
			title.SortOrder = Gtk.SortType.Ascending;

			tree.AppendColumn (title);

			Gtk.TreeViewColumn change = new Gtk.TreeViewColumn ();
			change.Title = Catalog.GetString ("Last Changed");
			change.Sizing = Gtk.TreeViewColumnSizing.Autosize;
			change.Resizable = false;

			renderer = new Gtk.CellRendererText ();
			renderer.Data ["xalign"] = 1.0;
			change.PackStart (renderer, false);
			change.AddAttribute (renderer, "text", 2 /* change date */);
			change.SortColumnId = 2; /* change date */
			change.SortIndicator = false;
			change.Reorderable = false;
			change.SortOrder = Gtk.SortType.Descending;

			tree.AppendColumn (change);
		}