35
35
namespace MonoDevelop.Ide.WelcomePage
37
class WelcomePageRecentProjectsList : VBox
37
public class WelcomePageRecentProjectsList : WelcomePageSection
40
40
EventHandler recentChangesHandler;
42
42
int itemCount = 10;
43
Gdk.Pixbuf openProjectIcon;
44
Gdk.Pixbuf newProjectIcon;
44
public WelcomePageRecentProjectsList (XElement el)
46
public WelcomePageRecentProjectsList (string title = null, int count = 10): base (title)
46
var countAtt = el.Attribute ("count");
48
itemCount = (int) countAtt;
48
openProjectIcon = Gdk.Pixbuf.LoadFromResource ("open_solution.png");
49
newProjectIcon = Gdk.Pixbuf.LoadFromResource ("new_solution.png");
50
55
recentChangesHandler = DispatchService.GuiDispatch (new EventHandler (RecentFilesChanged));
51
56
DesktopService.RecentFiles.Changed += recentChangesHandler;
52
57
RecentFilesChanged (null, null);
60
TitleAlignment.BottomPadding = Styles.WelcomeScreen.Pad.Solutions.LargeTitleMarginBottom;
61
ContentAlignment.LeftPadding = 0;
62
ContentAlignment.RightPadding = 0;
55
public override void Destroy ()
65
protected override void OnDestroyed ()
59
69
DesktopService.RecentFiles.Changed -= recentChangesHandler;
68
foreach (var c in Children) {
78
foreach (var c in box.Children) {
83
Gtk.HBox hbox = new HBox ();
84
var btn = new WelcomePageListButton (GettextCatalog.GetString ("New..."), null, newProjectIcon, "monodevelop://MonoDevelop.Ide.Commands.FileCommands.NewProject");
85
btn.WidthRequest = (int) (Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Width / 2.3);
86
btn.BorderPadding = 6;
87
btn.LeftTextPadding = 24;
88
hbox.PackStart (btn, false, false, 0);
90
btn = new WelcomePageListButton (GettextCatalog.GetString ("Open..."), null, openProjectIcon, "monodevelop://MonoDevelop.Ide.Commands.FileCommands.OpenFile");
91
btn.WidthRequest = (int) (Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Width / 2.3);
92
btn.BorderPadding = 6;
93
btn.LeftTextPadding = 24;
94
hbox.PackStart (btn, false, false, 0);
96
box.PackStart (hbox, false, false, 0);
73
98
//TODO: pinned files
74
99
foreach (var recent in DesktopService.RecentFiles.GetProjects ().Take (itemCount)) {
75
100
var filename = recent.FileName;
76
101
var accessed = recent.TimeStamp;
77
var button = new WelcomePageLinkButton (recent.DisplayName, "project://" + filename);
78
button.Ellipsize = Pango.EllipsizeMode.Middle;
102
var pixbuf = ImageService.GetPixbuf (GetIcon (filename), IconSize.Dnd);
103
var button = new WelcomePageListButton (recent.DisplayName, System.IO.Path.GetDirectoryName (filename), pixbuf, "project://" + filename);
104
button.BorderPadding = 2;
105
button.AllowPinning = true;
106
button.Pinned = recent.IsFavorite;
79
107
//FIXME: update times as needed. currently QueryTooltip causes crashes on Windows
80
108
//button.QueryTooltip += delegate (object o, QueryTooltipArgs args) {
81
109
// args.Tooltip.Text = filename + "\n" + TimeSinceEdited (accessed);
84
112
//button.HasTooltip = true;
85
113
button.TooltipText = filename + "\n" + TimeSinceEdited (accessed);
86
button.Icon = GetIcon (filename);
87
this.PackStart (button, false, false, 0);
114
box.PackStart (button, false, false, 0);
115
button.PinClicked += delegate {
116
DesktopService.RecentFiles.SetFavoriteFile (filename, button.Pinned);