MonoDevelop Addins: hello world, disable if no active project
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 10 Jan 2015 23:49:56 +0000 (00:49 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 10 Jan 2015 23:49:56 +0000 (00:49 +0100)
MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/Commands.cs
MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/ShowFilesDialog.cs
MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/MonoDevelop.HelloWorld.ShowFilesDialog.cs
MonoDevelop/addins/MonoDevelop.HelloWorld/MonoDevelop.HelloWorld/gtk-gui/gui.stetic

index 9df0db6..9985036 100644 (file)
@@ -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;
+                       }
+               }
        }
 }
 
index eff622e..5c109a1 100644 (file)
@@ -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)
index 97a0bbb..74e9e59 100644 (file)
@@ -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);
index 39656b9..c6394a9 100644 (file)
@@ -8,10 +8,10 @@
     <widget-library name="MonoDevelop.Ide, Version=2.6.0.0, Culture=neutral" />
     <widget-library name="../bin/Release/MonoDevelop.HelloWorld.dll" internal="true" />
   </import>
-  <widget class="Gtk.Dialog" id="MonoDevelop.HelloWorld.ShowFilesDialog" design-size="400 300">
+  <widget class="Gtk.Dialog" id="MonoDevelop.HelloWorld.ShowFilesDialog" design-size="521 300">
     <property name="MemberName" />
     <property name="WindowPosition">CenterOnParent</property>
-    <property name="Buttons">3</property>
+    <property name="Buttons">2</property>
     <property name="HelpButton">False</property>
     <child internal-child="VBox">
       <widget class="Gtk.VBox" id="dialog1_VBox">
                 <property name="AutoSize">True</property>
               </packing>
             </child>
+            <child>
+              <widget class="Gtk.HBox" id="hbox2">
+                <property name="MemberName" />
+                <property name="Spacing">6</property>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <widget class="Gtk.Button" id="ShowFilesButton">
+                    <property name="MemberName" />
+                    <property name="CanFocus">True</property>
+                    <property name="Type">TextOnly</property>
+                    <property name="Label" translatable="yes">ShowFiles</property>
+                    <property name="UseUnderline">True</property>
+                    <signal name="Clicked" handler="OnButtonShowFilesClickEvent" />
+                  </widget>
+                  <packing>
+                    <property name="Position">1</property>
+                    <property name="AutoSize">True</property>
+                    <property name="Expand">False</property>
+                    <property name="Fill">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+              </widget>
+              <packing>
+                <property name="Position">2</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
           </widget>
           <packing>
             <property name="Position">0</property>
         <property name="MemberName" />
         <property name="Spacing">10</property>
         <property name="BorderWidth">5</property>
-        <property name="Size">3</property>
+        <property name="Size">2</property>
         <property name="LayoutStyle">End</property>
         <child>
-          <widget class="Gtk.Button" id="ShowFilesButton">
-            <property name="MemberName" />
-            <property name="CanFocus">True</property>
-            <property name="Type">TextOnly</property>
-            <property name="Label" translatable="yes">ShowFiles</property>
-            <property name="UseUnderline">True</property>
-            <property name="ResponseId">0</property>
-            <signal name="Clicked" handler="OnButtonShowFilesClickEvent" />
-          </widget>
-          <packing>
-            <property name="Expand">False</property>
-            <property name="Fill">False</property>
-          </packing>
-        </child>
-        <child>
           <widget class="Gtk.Button" id="buttonCancel">
             <property name="MemberName" />
             <property name="CanDefault">True</property>
             <property name="label">gtk-cancel</property>
           </widget>
           <packing>
-            <property name="Position">1</property>
             <property name="Expand">False</property>
             <property name="Fill">False</property>
           </packing>
             <property name="label">gtk-ok</property>
           </widget>
           <packing>
-            <property name="Position">2</property>
+            <property name="Position">1</property>
             <property name="Expand">False</property>
             <property name="Fill">False</property>
           </packing>