[ease] [general] Added images to progress dialogs



commit c2fbcacbca5d463dc9557154291f7b2dc8d8efba
Author: Nate Stedman <natesm gmail com>
Date:   Mon Aug 23 07:48:04 2010 -0400

    [general] Added images to progress dialogs

 data/ui/progress-dialog.ui          |    8 +++-----
 ease-core/ease-archiver.vala        |    4 +++-
 ease-core/ease-dialog-progress.vala |   29 ++++++++++++++++++++++++++++-
 ease/ease-import-dialog.vala        |    9 ++++++---
 4 files changed, 40 insertions(+), 10 deletions(-)
---
diff --git a/data/ui/progress-dialog.ui b/data/ui/progress-dialog.ui
index 8258b5c..31b8ffc 100644
--- a/data/ui/progress-dialog.ui
+++ b/data/ui/progress-dialog.ui
@@ -14,19 +14,17 @@
         <property name="visible">True</property>
         <property name="spacing">2</property>
         <child>
-          <object class="GtkVBox" id="vbox-top">
+          <object class="GtkHBox" id="hbox">
             <property name="visible">True</property>
             <property name="spacing">4</property>
             <child>
-              <placeholder/>
-            </child>
-            <child>
               <object class="GtkProgressBar" id="progress">
                 <property name="height_request">30</property>
                 <property name="visible">True</property>
               </object>
               <packing>
-                <property name="position">1</property>
+                <property name="pack_type">end</property>
+                <property name="position">0</property>
               </packing>
             </child>
           </object>
diff --git a/ease-core/ease-archiver.vala b/ease-core/ease-archiver.vala
index 2a97589..63eafc6 100644
--- a/ease-core/ease-archiver.vala
+++ b/ease-core/ease-archiver.vala
@@ -172,7 +172,9 @@ namespace Ease.Archiver
 		                        Gtk.Window? win) throws Error
 	{
 		// create a progress dialog
-		var dialog = new Dialog.Progress(title, false, 1, win);
+		var img = new Gtk.Image.from_stock("gtk-save",
+		                                   Gtk.IconSize.LARGE_TOOLBAR);
+		var dialog = new Dialog.Progress.with_image(title, false, 1, win, img);
 	
 		// archive away!
 		var arc = new Archiver(temp_path, filename, files, dialog);
diff --git a/ease-core/ease-dialog-progress.vala b/ease-core/ease-dialog-progress.vala
index fcb08c3..81f06a1 100644
--- a/ease-core/ease-dialog-progress.vala
+++ b/ease-core/ease-dialog-progress.vala
@@ -30,6 +30,7 @@ public class Ease.Dialog.Progress : GLib.Object
 	private Gtk.ProgressBar progress;
 	private double max_val;
 	private bool destroyed = false;
+	private Gtk.Builder builder;
 	
 	/**
 	 * Creates a progress dialog.
@@ -44,7 +45,7 @@ public class Ease.Dialog.Progress : GLib.Object
 	{
 		max_val = max;
 		
-		var builder = new Gtk.Builder();
+		builder = new Gtk.Builder();
 		try
 		{
 			builder.add_from_file(data_path(Path.build_filename(Temp.UI_DIR,
@@ -63,6 +64,32 @@ public class Ease.Dialog.Progress : GLib.Object
 	}
 	
 	/**
+	 * Creates a progress dialog with an image on the left side. Although
+	 * this is a dialog, Gtk.IconSize.LARGE_TOOLBAR should be used if the icon
+	 * is a stock item.
+	 *
+	 * @param title The title of the dialog.
+	 * @param cancellable If the dialog should display a cancel button.
+	 * @param max The maximum value of the dialog.
+	 * @param modal The window the dialog should be modal for, or null.
+	 * @param image The image widget.
+	 */
+	public Progress.with_image(string title, bool cancellable, double max,
+	                           Gtk.Window? modal, Gtk.Image image)
+	{
+		this(title, cancellable, max, modal);
+		
+		// create the image's container and add it
+		var hbox = builder.get_object("hbox") as Gtk.HBox;
+		var align = new Gtk.Alignment(0.5f, 0.5f, 0, 0);
+		align.set_padding(0, 0, 4, 4);
+		align.add(image);
+		align.show();
+		image.show();
+		hbox.pack_start(align, false, false, 0);
+	}
+	
+	/**
 	 * Shows the progress dialog.
 	 */
 	public void show()
diff --git a/ease/ease-import-dialog.vala b/ease/ease-import-dialog.vala
index e1420ae..e9e78dc 100644
--- a/ease/ease-import-dialog.vala
+++ b/ease/ease-import-dialog.vala
@@ -58,8 +58,11 @@ internal class Ease.ImportDialog : Gtk.Window
 		                                                  widget);
 		
 		widget.add_media.connect((media_list) => {
-			var progress = new Dialog.Progress(_("Downloading Media Files"),
-			                                   false, media_list.size, this); 
+			var img = new Gtk.Image.from_stock("gtk-go-down",
+			                                   Gtk.IconSize.LARGE_TOOLBAR);
+			var progress = new Dialog.Progress.with_image(
+				_("Downloading Media Files"), false,
+				media_list.size, this, img); 
 			progress.show();
 			total_images = media_list.size;
 			add_media_recursive(progress, media_list, Temp.request(), 0);
@@ -96,7 +99,7 @@ internal class Ease.ImportDialog : Gtk.Window
 			                Priority.DEFAULT, null,
 			                (current, total) => {
 				progress.add(((double)current - previous) / (double)total);
-				previous += current - previous;
+				previous = current;
 			},
 			                (sender, result) => {
 				add_image(copy.get_path());



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