From 9a4e7e93c9499382d556c5e6e6eca0e5c1c0e80b Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 11 Jan 2015 00:49:56 +0100 Subject: [PATCH] MonoDevelop Addins: hello world, disable if no active project --- .../MonoDevelop.HelloWorld/Commands.cs | 15 +++++- .../MonoDevelop.HelloWorld/ShowFilesDialog.cs | 10 ---- .../MonoDevelop.HelloWorld.ShowFilesDialog.cs | 57 ++++++++++++--------- .../MonoDevelop.HelloWorld/gtk-gui/gui.stetic | 58 ++++++++++++++-------- 4 files changed, 85 insertions(+), 55 deletions(-) diff --git a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/Commands.cs b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/Commands.cs index 9df0db6..9985036 100644 --- a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/Commands.cs +++ b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/Commands.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using MonoDevelop.Components.Commands; using MonoDevelop.Ide; using MonoDevelop.Projects; @@ -23,6 +22,18 @@ namespace MonoDevelop.HelloWorld MessageService.ShowCustomDialog (dlg); } } + + protected override void Update (CommandInfo info) + { + var proj = IdeApp.Workspace.GetAllProjects ().FirstOrDefault (); + if (proj != null) { + info.Enabled = true; + info.Visible = true; + } else { + info.Enabled = false; + info.Visible = true; + } + } } } diff --git a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/ShowFilesDialog.cs b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/ShowFilesDialog.cs index eff622e..5c109a1 100644 --- a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/ShowFilesDialog.cs +++ b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/ShowFilesDialog.cs @@ -12,16 +12,6 @@ namespace MonoDevelop.HelloWorld { this.project = project; this.Build (); - - var fileNames = new StringBuilder (); - fileNames.Append ("Project name: " + project.Name); - fileNames.Append (Environment.NewLine); - foreach (var file in project.Files) - { - fileNames.Append(file.Name); - fileNames.Append (Environment.NewLine); - } - this.ShowFilesTextView.Buffer.Text = fileNames.ToString (); } protected void OnButtonShowFilesClickEvent (object sender, EventArgs e) diff --git a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/MonoDevelop.HelloWorld.ShowFilesDialog.cs b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/MonoDevelop.HelloWorld.ShowFilesDialog.cs index 97a0bbb..74e9e59 100644 --- a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/MonoDevelop.HelloWorld.ShowFilesDialog.cs +++ b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/MonoDevelop.HelloWorld.ShowFilesDialog.cs @@ -14,6 +14,8 @@ namespace MonoDevelop.HelloWorld private global::Gtk.TextView ShowFilesTextView; + private global::Gtk.HBox hbox2; + private global::Gtk.Button ShowFilesButton; private global::Gtk.Button buttonCancel; @@ -59,25 +61,35 @@ namespace MonoDevelop.HelloWorld this.vbox2.Add (this.GtkScrolledWindow1); global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.GtkScrolledWindow1])); w5.Position = 1; - w1.Add (this.vbox2); - global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2])); - w6.Position = 0; - // Internal child MonoDevelop.HelloWorld.ShowFilesDialog.ActionArea - global::Gtk.HButtonBox w7 = this.ActionArea; - w7.Name = "dialog1_ActionArea"; - w7.Spacing = 10; - w7.BorderWidth = ((uint)(5)); - w7.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); - // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + // Container child vbox2.Gtk.Box+BoxChild + this.hbox2 = new global::Gtk.HBox (); + this.hbox2.Name = "hbox2"; + this.hbox2.Spacing = 6; + // Container child hbox2.Gtk.Box+BoxChild this.ShowFilesButton = new global::Gtk.Button (); this.ShowFilesButton.CanFocus = true; this.ShowFilesButton.Name = "ShowFilesButton"; this.ShowFilesButton.UseUnderline = true; this.ShowFilesButton.Label = global::Mono.Unix.Catalog.GetString ("ShowFiles"); - this.AddActionWidget (this.ShowFilesButton, 0); - global::Gtk.ButtonBox.ButtonBoxChild w8 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w7 [this.ShowFilesButton])); - w8.Expand = false; - w8.Fill = false; + this.hbox2.Add (this.ShowFilesButton); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.ShowFilesButton])); + w6.Position = 1; + w6.Expand = false; + w6.Fill = false; + this.vbox2.Add (this.hbox2); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox2])); + w7.Position = 2; + w7.Expand = false; + w7.Fill = false; + w1.Add (this.vbox2); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2])); + w8.Position = 0; + // Internal child MonoDevelop.HelloWorld.ShowFilesDialog.ActionArea + global::Gtk.HButtonBox w9 = this.ActionArea; + w9.Name = "dialog1_ActionArea"; + w9.Spacing = 10; + w9.BorderWidth = ((uint)(5)); + w9.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild this.buttonCancel = new global::Gtk.Button (); this.buttonCancel.CanDefault = true; @@ -87,10 +99,9 @@ namespace MonoDevelop.HelloWorld this.buttonCancel.UseUnderline = true; this.buttonCancel.Label = "gtk-cancel"; this.AddActionWidget (this.buttonCancel, -6); - global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w7 [this.buttonCancel])); - w9.Position = 1; - w9.Expand = false; - w9.Fill = false; + global::Gtk.ButtonBox.ButtonBoxChild w10 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w9 [this.buttonCancel])); + w10.Expand = false; + w10.Fill = false; // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild this.buttonOk = new global::Gtk.Button (); this.buttonOk.CanDefault = true; @@ -100,14 +111,14 @@ namespace MonoDevelop.HelloWorld this.buttonOk.UseUnderline = true; this.buttonOk.Label = "gtk-ok"; this.AddActionWidget (this.buttonOk, -5); - global::Gtk.ButtonBox.ButtonBoxChild w10 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w7 [this.buttonOk])); - w10.Position = 2; - w10.Expand = false; - w10.Fill = false; + global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w9 [this.buttonOk])); + w11.Position = 1; + w11.Expand = false; + w11.Fill = false; if ((this.Child != null)) { this.Child.ShowAll (); } - this.DefaultWidth = 400; + this.DefaultWidth = 521; this.DefaultHeight = 300; this.Show (); this.ShowFilesButton.Clicked += new global::System.EventHandler (this.OnButtonShowFilesClickEvent); diff --git a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/gui.stetic b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/gui.stetic index 39656b9..c6394a9 100644 --- a/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/gui.stetic +++ b/MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/gui.stetic @@ -8,10 +8,10 @@ - + CenterOnParent - 3 + 2 False @@ -57,6 +57,40 @@ True + + + + 6 + + + + + + + True + TextOnly + ShowFiles + True + + + + 1 + True + False + False + + + + + + + + 2 + True + False + False + + 0 @@ -70,24 +104,9 @@ 10 5 - 3 + 2 End - - - True - TextOnly - ShowFiles - True - 0 - - - - False - False - - - True @@ -99,7 +118,6 @@ gtk-cancel - 1 False False @@ -116,7 +134,7 @@ gtk-ok - 2 + 1 False False -- 2.1.4