Ejemplo n.º 1
0
        void RecentFilesChanged(object sender, EventArgs e)
        {
            //this can get called by async dispatch after the widget is destroyed
            if (destroyed)
            {
                return;
            }

            foreach (var c in box.Children)
            {
                box.Remove(c);
                c.Destroy();
            }

            Gtk.HBox hbox = new HBox();
            var      btn  = new WelcomePageListButton(GettextCatalog.GetString("New..."), null, newProjectIcon, "monodevelop://MonoDevelop.Ide.Commands.FileCommands.NewProject");

            btn.WidthRequest    = (int)(Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Width / 2.3);
            btn.BorderPadding   = 6;
            btn.LeftTextPadding = 24;
            hbox.PackStart(btn, false, false, 0);

            btn = new WelcomePageListButton(GettextCatalog.GetString("Open..."), null, openProjectIcon, "monodevelop://MonoDevelop.Ide.Commands.FileCommands.OpenFile");
            btn.WidthRequest    = (int)(Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Width / 2.3);
            btn.BorderPadding   = 6;
            btn.LeftTextPadding = 24;
            hbox.PackStart(btn, false, false, 0);

            box.PackStart(hbox, false, false, 0);

            //TODO: pinned files
            foreach (var recent in DesktopService.RecentFiles.GetProjects().Take(itemCount))
            {
                var filename = recent.FileName;
                if (!System.IO.File.Exists(filename))
                {
                    continue;
                }

                var accessed = recent.TimeStamp;
                var pixbuf   = ImageService.GetIcon(GetIcon(filename), IconSize.Dnd);
                var button   = new WelcomePageListButton(recent.DisplayName, System.IO.Path.GetDirectoryName(filename), pixbuf, "project://" + filename);
                button.BorderPadding = 2;
                button.AllowPinning  = true;
                button.Pinned        = recent.IsFavorite;
                //FIXME: update times as needed. currently QueryTooltip causes crashes on Windows
                //button.QueryTooltip += delegate (object o, QueryTooltipArgs args) {
                //	args.Tooltip.Text = filename + "\n" + TimeSinceEdited (accessed);
                //	args.RetVal = true;
                //};
                //button.HasTooltip = true;
                button.TooltipText = filename + "\n" + TimeSinceEdited(accessed);
                box.PackStart(button, false, false, 0);
                var pinClickHandler = new PinClickHandler(filename);
                pinClickHandler.Register(button);
            }

            this.ShowAll();
        }
 public void Dispose()
 {
     if (button == null)
     {
         return;
     }
     button.PinClicked -= Button_PinClicked;
     button.Destroyed  -= Button_Destroyed;
     button             = null;
 }
		void RecentFilesChanged (object sender, EventArgs e)
		{
			//this can get called by async dispatch after the widget is destroyed
			if (destroyed)
				return;
			
			foreach (var c in box.Children) {
				box.Remove (c);
				c.Destroy ();
			}

			Gtk.HBox hbox = new HBox ();
			var btn = new WelcomePageListButton (GettextCatalog.GetString ("New..."), null, newProjectIcon, "monodevelop://MonoDevelop.Ide.Commands.FileCommands.NewProject");
			btn.WidthRequest = (int) (Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Width / 2.3);
			btn.BorderPadding = 6;
			btn.LeftTextPadding = 24;
			hbox.PackStart (btn, false, false, 0);

			btn = new WelcomePageListButton (GettextCatalog.GetString ("Open..."), null, openProjectIcon, "monodevelop://MonoDevelop.Ide.Commands.FileCommands.OpenFile");
			btn.WidthRequest = (int) (Styles.WelcomeScreen.Pad.Solutions.SolutionTile.Width / 2.3);
			btn.BorderPadding = 6;
			btn.LeftTextPadding = 24;
			hbox.PackStart (btn, false, false, 0);

			box.PackStart (hbox, false, false, 0);
			
			//TODO: pinned files
			foreach (var recent in DesktopService.RecentFiles.GetProjects ().Take (itemCount)) {
				var filename = recent.FileName;
				if (!System.IO.File.Exists (filename))
					continue;

				var accessed = recent.TimeStamp;
				var pixbuf = ImageService.GetPixbuf (GetIcon (filename), IconSize.Dnd);
				var button = new WelcomePageListButton (recent.DisplayName, System.IO.Path.GetDirectoryName (filename), pixbuf, "project://" + filename);
				button.BorderPadding = 2;
				button.AllowPinning = true;
				button.Pinned = recent.IsFavorite;
				//FIXME: update times as needed. currently QueryTooltip causes crashes on Windows
				//button.QueryTooltip += delegate (object o, QueryTooltipArgs args) {
				//	args.Tooltip.Text = filename + "\n" + TimeSinceEdited (accessed);
				//	args.RetVal = true;
				//};
				//button.HasTooltip = true;
				button.TooltipText = filename + "\n" + TimeSinceEdited (accessed);
				box.PackStart (button, false, false, 0);
				button.PinClicked += delegate {
					DesktopService.RecentFiles.SetFavoriteFile (filename, button.Pinned);
				};
			}
			


			this.ShowAll ();
		}
 internal void Register(WelcomePageListButton button)
 {
     this.button        = button;
     button.PinClicked += Button_PinClicked;
     button.Destroyed  += Button_Destroyed;
 }
			internal void Register (WelcomePageListButton button)
			{
				this.button = button;
				button.PinClicked += Button_PinClicked;
				button.Destroyed += Button_Destroyed;
			}
			public void Dispose ()
			{
				if (button == null)
					return;
				button.PinClicked -= Button_PinClicked;
				button.Destroyed -= Button_Destroyed;
				button = null;
			}