~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.WelcomePage/WelcomePageRecentProjectsList.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
namespace MonoDevelop.Ide.WelcomePage
36
36
{
37
 
        class WelcomePageRecentProjectsList : VBox
 
37
        public class WelcomePageRecentProjectsList : WelcomePageSection
38
38
        {
39
39
                bool destroyed;
40
40
                EventHandler recentChangesHandler;
41
 
                
 
41
                VBox box;
42
42
                int itemCount = 10;
 
43
                Gdk.Pixbuf openProjectIcon;
 
44
                Gdk.Pixbuf newProjectIcon;
43
45
                
44
 
                public WelcomePageRecentProjectsList (XElement el)
 
46
                public WelcomePageRecentProjectsList (string title = null, int count = 10): base (title)
45
47
                {
46
 
                        var countAtt = el.Attribute ("count");
47
 
                        if (countAtt != null)
48
 
                                itemCount = (int) countAtt;
 
48
                        openProjectIcon = Gdk.Pixbuf.LoadFromResource ("open_solution.png");
 
49
                        newProjectIcon = Gdk.Pixbuf.LoadFromResource ("new_solution.png");
 
50
 
 
51
                        box = new VBox ();
 
52
 
 
53
                        itemCount = count;
49
54
                        
50
55
                        recentChangesHandler = DispatchService.GuiDispatch (new EventHandler (RecentFilesChanged));
51
56
                        DesktopService.RecentFiles.Changed += recentChangesHandler;
52
57
                        RecentFilesChanged (null, null);
 
58
 
 
59
                        SetContent (box);
 
60
                        TitleAlignment.BottomPadding = Styles.WelcomeScreen.Pad.Solutions.LargeTitleMarginBottom;
 
61
                        ContentAlignment.LeftPadding = 0;
 
62
                        ContentAlignment.RightPadding = 0;
53
63
                }
54
64
                
55
 
                public override void Destroy ()
 
65
                protected override void OnDestroyed ()
56
66
                {
57
67
                        destroyed = true;
58
 
                        base.Destroy ();
 
68
                        base.OnDestroyed ();
59
69
                        DesktopService.RecentFiles.Changed -= recentChangesHandler;
60
70
                }
61
71
 
65
75
                        if (destroyed)
66
76
                                return;
67
77
                        
68
 
                        foreach (var c in Children) {
69
 
                                this.Remove (c);
 
78
                        foreach (var c in box.Children) {
 
79
                                box.Remove (c);
70
80
                                c.Destroy ();
71
81
                        }
 
82
 
 
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);
 
89
 
 
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);
 
95
 
 
96
                        box.PackStart (hbox, false, false, 0);
72
97
                        
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);
83
111
                                //};
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);
 
117
                                };
88
118
                        }
89
119
                        
 
120
 
 
121
 
90
122
                        this.ShowAll ();
91
123
                }
92
124