[mistelix] Fixes #582185 and disables OK button



commit 514a0cb939fdbb2d1f45f7e7307cae31de7009cf
Author: Jordi Mas and David Hernandez <dhernandez gmail com>
Date:   Tue May 12 00:27:28 2009 +0200

    Fixes #582185 and disables OK button
---
 src/dialogs/NewProjectDialog.cs |   51 ++++++++++++++++++++++++++++
 src/mistelix.glade              |   70 +++++++++++++++++++++++----------------
 2 files changed, 92 insertions(+), 29 deletions(-)

diff --git a/src/dialogs/NewProjectDialog.cs b/src/dialogs/NewProjectDialog.cs
index d1eb2a9..8fabf71 100644
--- a/src/dialogs/NewProjectDialog.cs
+++ b/src/dialogs/NewProjectDialog.cs
@@ -47,6 +47,7 @@ namespace Mistelix.Dialogs
 		[Glade.Widget] Gtk.Box videoformat_vbox;
 		[Glade.Widget] Gtk.Box aspectratio_vbox;
 		[Glade.Widget] Gtk.ComboBox resolution_combobox;
+		[Glade.Widget] Gtk.Button ok_button;
 
 		Gtk.RadioButton pal_radio;
 		Gtk.RadioButton ntsc_radio;
@@ -126,6 +127,8 @@ namespace Mistelix.Dialogs
 
 		void OnChangedProjectName (object sender, EventArgs args)
 		{
+			SensitiveOkButton ();
+
 			if (changed)
 				return;
 
@@ -136,6 +139,19 @@ namespace Mistelix.Dialogs
 		void OnChangedOutputDir (object sender, EventArgs args)
 		{
 			changed = true;
+			SensitiveOkButton ();
+		}
+
+		void SensitiveOkButton ()
+		{
+			bool active;
+	
+			if (output_dir.Text == string.Empty || name.Text == string.Empty)
+				active = false;
+			else
+				active = true;
+
+			ok_button.Sensitive = active;
 		}
 
 		string OutputDirFromName ()
@@ -147,6 +163,33 @@ namespace Mistelix.Dialogs
 		{
 			TreeIter iter;
 
+			// if directory doesn't exist ask the user to create it
+			if (!Directory.Exists (output_dir.Text)) {
+				MessageDialog md = new MessageDialog (Dialog, DialogFlags.DestroyWithParent,
+					MessageType.Question, ButtonsType.YesNo, 
+					Catalog.GetString ("The output directory provided does not exist. Do you want to create it?"));
+
+				ResponseType result = (ResponseType)md.Run ();
+				md.Destroy ();
+
+				if (result == ResponseType.Yes) {
+					try {
+						Directory.CreateDirectory (output_dir.Text);
+					}
+					catch (Exception e) {
+						MessageDialog mderror = new MessageDialog (Dialog, DialogFlags.DestroyWithParent,
+							MessageType.Error, ButtonsType.Ok, 
+							Catalog.GetString ("Unable to create directory."));
+
+						mderror.Run ();
+						mderror.Destroy ();
+						return;
+					}
+				} else {
+					return;
+				}
+			}
+
 			project = new Project ();
 			project.Details.OutputDir = output_dir.Text;
 			project.Details.Name = name.Text;
@@ -172,6 +215,14 @@ namespace Mistelix.Dialogs
 				project.Details.AspectRatio = AspectRatio.FourByThree;
 			else
 				project.Details.AspectRatio = AspectRatio.SixteenByNine;
+	
+			Dialog.Respond (ResponseType.Ok);
+		}
+
+
+		void OnCancel (object sender, EventArgs args)
+		{
+			Dialog.Respond (ResponseType.Cancel);
 		}
 
 		void OnBrowse (object o, EventArgs args)
diff --git a/src/mistelix.glade b/src/mistelix.glade
index 2c672f3..ea5f791 100644
--- a/src/mistelix.glade
+++ b/src/mistelix.glade
@@ -1167,7 +1167,7 @@
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="focus_on_map">True</property>
   <property name="urgency_hint">False</property>
-  <property name="has_separator">True</property>
+  <property name="has_separator">False</property>
 
   <child internal-child="vbox">
     <widget class="GtkVBox" id="dialog-vbox2">
@@ -1176,36 +1176,9 @@
       <property name="spacing">0</property>
 
       <child internal-child="action_area">
-	<widget class="GtkHButtonBox" id="dialog-action_area1">
+	<widget class="GtkHButtonBox" id="hbuttonbox6">
 	  <property name="visible">True</property>
 	  <property name="layout_style">GTK_BUTTONBOX_END</property>
-
-	  <child>
-	    <widget class="GtkButton" id="cancelbutton1">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-cancel</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-6</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="okbutton1">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-ok</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-5</property>
-	      <signal name="clicked" handler="OnOK" last_modification_time="Tue, 11 Nov 2008 18:26:14 GMT"/>
-	    </widget>
-	  </child>
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
@@ -1665,6 +1638,45 @@
 	      <property name="fill">True</property>
 	    </packing>
 	  </child>
+
+	  <child>
+	    <widget class="GtkHButtonBox" id="hbuttonbox7">
+	      <property name="visible">True</property>
+	      <property name="layout_style">GTK_BUTTONBOX_END</property>
+	      <property name="spacing">6</property>
+
+	      <child>
+		<widget class="GtkButton" id="button4">
+		  <property name="visible">True</property>
+		  <property name="can_default">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="label">gtk-cancel</property>
+		  <property name="use_stock">True</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+		  <signal name="clicked" handler="OnCancel" last_modification_time="Fri, 31 Oct 2008 17:29:41 GMT"/>
+		</widget>
+	      </child>
+
+	      <child>
+		<widget class="GtkButton" id="ok_button">
+		  <property name="visible">True</property>
+		  <property name="can_default">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="label">gtk-ok</property>
+		  <property name="use_stock">True</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+		  <signal name="clicked" handler="OnOK" last_modification_time="Fri, 31 Oct 2008 17:29:41 GMT"/>
+		</widget>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">3</property>
+	      <property name="expand">True</property>
+	      <property name="fill">True</property>
+	    </packing>
+	  </child>
 	</widget>
 	<packing>
 	  <property name="padding">0</property>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]