public WelcomePageWidget(WelcomePageView parentView) : base()
        {
            this.Build();
            this.parentView = parentView;

            linkHoverLeaveEventHandler = new Gtk.LeaveNotifyEventHandler(handleHoverLeave);
            linkHoverEnterEventHandler = new Gtk.EnterNotifyEventHandler(handleHoverEnter);
            linkClickedEventHandler    = new EventHandler(HandleLink);

            string logoPath = AddinManager.CurrentAddin.GetFilePath("md-logo.png");

            logoPixbuf = new Gdk.Pixbuf(logoPath);
            string bgPath = AddinManager.CurrentAddin.GetFilePath("md-bg.png");

            bgPixbuf = new Gdk.Pixbuf(bgPath);

            alignment1.SetPadding(logoHeight + spacing, 0, spacing, 0);
            ModifyBg(StateType.Normal, Style.White);

            BuildFromXml();
            LoadRecent();

            IdeApp.Workbench.GuiLocked   += OnLock;
            IdeApp.Workbench.GuiUnlocked += OnUnlock;
        }
 protected override void OnDestroyed()
 {
     base.OnDestroyed();
     parentView = null;
     IdeApp.Workbench.GuiLocked   -= OnLock;
     IdeApp.Workbench.GuiUnlocked -= OnUnlock;
 }
		public WelcomePageWidget (WelcomePageView parentView) : base ()
		{
			this.Build ();
			this.parentView = parentView;
			
			linkHoverLeaveEventHandler = new Gtk.LeaveNotifyEventHandler (handleHoverLeave);
			linkHoverEnterEventHandler = new Gtk.EnterNotifyEventHandler (handleHoverEnter);
			linkClickedEventHandler = new EventHandler (HandleLink);

			using (var stream = BrandingService.OpenStream ("WelcomePage_Logo.png"))
				logoPixbuf = new Gdk.Pixbuf (stream);
			using (var stream = BrandingService.OpenStream ("WelcomePage_TopBorderRepeat.png"))
				bgPixbuf = new Gdk.Pixbuf (stream);
			
			alignment1.SetPadding (WelcomePageView.LogoHeight + WelcomePageView.Spacing, 0, WelcomePageView.Spacing, 0);
			Gdk.Color color;
			if (!Gdk.Color.Parse (WelcomePageView.BackgroundColor, ref color))
				color = Style.White;
			ModifyBg (StateType.Normal, color);
			
			BuildFromXml ();
			LoadRecent ();

			IdeApp.Workbench.GuiLocked += OnLock;
			IdeApp.Workbench.GuiUnlocked += OnUnlock;
		}
		public WelcomePageWidget (WelcomePageView parentView) : base ()
		{
			this.Build ();
			this.parentView = parentView;
			
			linkHoverLeaveEventHandler = new Gtk.LeaveNotifyEventHandler (handleHoverLeave);
			linkHoverEnterEventHandler = new Gtk.EnterNotifyEventHandler (handleHoverEnter);
			linkClickedEventHandler = new EventHandler (HandleLink);

			string logoPath = AddinManager.CurrentAddin.GetFilePath ("md-logo.png");
			logoPixbuf = new Gdk.Pixbuf (logoPath);
			string bgPath = AddinManager.CurrentAddin.GetFilePath ("md-bg.png");
			bgPixbuf = new Gdk.Pixbuf (bgPath);
			
			alignment1.SetPadding (logoHeight + spacing, 0, spacing, 0);
			ModifyBg (StateType.Normal, Style.White);
			
			BuildFromXml ();
			LoadRecent ();

			IdeApp.Workbench.GuiLocked += OnLock;
			IdeApp.Workbench.GuiUnlocked += OnUnlock;
		}
		protected override void OnDestroyed ()
		{
			base.OnDestroyed ();
			parentView = null;
			IdeApp.Workbench.GuiLocked -= OnLock;
			IdeApp.Workbench.GuiUnlocked -= OnUnlock;
		}
        public void LoadRecent()
        {
            //this can get called by async dispatch after the widget is destroyed
            if (parentView == null)
            {
                return;
            }

            Widget[] oldChildren = (Widget[])recentFilesTable.Children.Clone();
            foreach (Widget w in oldChildren)
            {
                Gtk.Table.TableChild tc = (Gtk.Table.TableChild)recentFilesTable [w];
                if (tc.TopAttach >= 2)
                {
                    recentFilesTable.Remove(w);
                }
            }

            if (parentView.RecentProjectsCount <= 0)
            {
                return;
            }

            uint i = 2;

            foreach (RecentItem ri in parentView.RecentProjects)
            {
                //getting the icon requires probing the file, so handle IO errors
                string icon;
                try {
                    if (!System.IO.File.Exists(ri.LocalPath))
                    {
                        continue;
                    }

/* delay project service creation.
 *                                      icon = IdeApp.Services.ProjectService.FileFormats.GetFileFormats
 *                                                      (ri.LocalPath, typeof(Solution)).Length > 0
 *                                                              ? "md-solution"
 *                                                              : "md-workspace";*/

                    icon = System.IO.Path.GetExtension(ri.LocalPath) != ".mdw"
                                                                ? "md-solution"
                                                                : "md-workspace";
                }
                catch (IOException ex) {
                    LoggingService.LogWarning("Error building recent solutions list", ex);
                    continue;
                }

                LinkButton button = new LinkButton();
                Label      label  = new Label();
                recentFilesTable.Attach(button, 0, 1, i, i + 1);
                recentFilesTable.Attach(label, 1, 2, i, i + 1);
                button.Clicked          += linkClickedEventHandler;
                button.EnterNotifyEvent += linkHoverEnterEventHandler;
                button.LeaveNotifyEvent += linkHoverLeaveEventHandler;
                label.Justify            = Justification.Right;
                label.Xalign             = 1;
                button.Xalign            = 0;

                string name = (ri.Private != null && ri.Private.Length > 0) ?
                              ri.Private :
                              System.IO.Path.GetFileNameWithoutExtension(ri.LocalPath);
                button.Label        = string.Format(textFormat, name);
                button.HoverMessage = ri.LocalPath;
                button.LinkUrl      = "project://" + ri.LocalPath;
                button.Icon         = icon;
                label.Markup        = string.Format(textFormat, WelcomePageView.TimeSinceEdited(ri.Timestamp));

                i++;

                button.InnerLabel.MaxWidthChars = 22;
                button.InnerLabel.Ellipsize     = Pango.EllipsizeMode.End;
            }
            recentFilesTable.RowSpacing = 0;
            recentFilesTable.ShowAll();
        }