[f-spot] CDExport: move to GtkBuilder



commit b0686f0f0da54e030fcbfd3ebe15ec430e7c0126
Author: Lorenzo Milesi <maxxer yetopen it>
Date:   Tue Jul 14 00:00:30 2009 +0200

    CDExport: move to GtkBuilder
    
    * Reduced window height, to fit netbooks (<600px)
    * Export button translatable

 extensions/Exporters/CDExport/CDExport.addin.xml   |    2 +-
 extensions/Exporters/CDExport/CDExport.cs          |  159 ++++++++++++--------
 .../CDExport/{CDExport.glade => CDExport.ui}       |  115 +++++++--------
 extensions/Exporters/CDExport/Makefile.am          |   17 +-
 4 files changed, 158 insertions(+), 135 deletions(-)
---
diff --git a/extensions/Exporters/CDExport/CDExport.addin.xml b/extensions/Exporters/CDExport/CDExport.addin.xml
index 39abe87..c27b4aa 100644
--- a/extensions/Exporters/CDExport/CDExport.addin.xml
+++ b/extensions/Exporters/CDExport/CDExport.addin.xml
@@ -1,5 +1,5 @@
 <Addin namespace="FSpot"
-	version="0.6.0.1"
+	version="0.6.0.2"
 	name="CD Export"
 	description="This extension allows you to burn your photos to CD."
 	author="F-Spot team"
diff --git a/extensions/Exporters/CDExport/CDExport.cs b/extensions/Exporters/CDExport/CDExport.cs
index cb54416..e9520e0 100644
--- a/extensions/Exporters/CDExport/CDExport.cs
+++ b/extensions/Exporters/CDExport/CDExport.cs
@@ -1,49 +1,56 @@
+/*
+ * CDExport.cs
+ *
+ * Authors:
+ *   Larry Ewing <lewing novell com>
+ *   Lorenzo Milesi <maxxer yetopen it>
+ *
+ * Copyright (c) 2007-2009 Novell, Inc.
+ *
+ * This is free software. See COPYING for details.
+ */
+
 using System;
 using System.IO;
+using System.Reflection;
 using System.Runtime.InteropServices;
+
 using Mono.Unix;
+
 using FSpot;
 using FSpot.Filters;
 using FSpot.Widgets;
 using FSpot.Utils;
 using FSpot.UI.Dialog;
+
 using GLib;
+using Gtk;
+using GtkBeans;
 
 namespace FSpotCDExport {
-	public class CDExport : FSpot.Extensions.IExporter {
+	class CDExportDialog : BuilderDialog {
 		IBrowsableCollection selection;
-
-		[Glade.Widget] Gtk.Dialog dialog;
-		[Glade.Widget] Gtk.ScrolledWindow thumb_scrolledwindow;
-		[Glade.Widget] Gtk.CheckButton remove_check;
-		[Glade.Widget] Gtk.CheckButton rotate_check;
-		[Glade.Widget] Gtk.Label size_label;
-		[Glade.Widget] Gtk.Frame previous_frame;
-
 		Gtk.Window listwindow;
-		System.Uri dest = new System.Uri ("burn:///");
+		System.Uri dest;
 
-		int photo_index;
-		bool clean;
-		bool rotate;
+		[GtkBeans.Builder.Object] ScrolledWindow thumb_scrolledwindow;
+		[GtkBeans.Builder.Object] CheckButton remove_check;
+		[GtkBeans.Builder.Object] CheckButton rotate_check;
+		[GtkBeans.Builder.Object] Label size_label;
+		[GtkBeans.Builder.Object] Frame previous_frame;
 
-		ThreadProgressDialog progress_dialog;
-		System.Threading.Thread command_thread;
-
-		private Glade.XML xml;
-		private string dialog_name = "cd_export_dialog";
+		public bool Clean {
+			get { return remove_check.Active; }
+		}
 
-		public CDExport ()
-		{
+		public bool Rotate {
+			get { return rotate_check.Active; }
 		}
 
-		public void Run (IBrowsableCollection selection)
+		public CDExportDialog (IBrowsableCollection selection, System.Uri dest) : base (Assembly.GetExecutingAssembly (), "CDExport.ui", "cd_export_dialog")
 		{
-
-			xml = new Glade.XML (null, "CDExport.glade", dialog_name, "f-spot");
-			xml.Autoconnect (this);
-
 			this.selection = selection;
+			this.dest = dest;
 
 			// Calculate the total size
 			long total_size = 0;
@@ -58,22 +65,29 @@ namespace FSpotCDExport {
 				}
 			}
 
-			IconView view = new IconView (selection);
+			FSpot.Widgets.IconView view = new FSpot.Widgets.IconView (selection);
 			view.DisplayDates = false;
 			view.DisplayTags = false;
+			view.DisplayRatings = false;
 
-			Dialog.Modal = false;
-			Dialog.TransientFor = null;
+			this.Modal = false;
+			this.TransientFor = null;
 
 			size_label.Text = Format.SizeForDisplay (total_size);
 
 			thumb_scrolledwindow.Add (view);
-			Dialog.ShowAll ();
+			this.ShowAll ();
 
 			previous_frame.Visible = IsEmpty (dest);
 			//LoadHistory ();
 
-			Dialog.Response += HandleResponse;
+		}
+
+		bool IsEmpty (System.Uri path)
+		{
+			foreach (GLib.FileInfo fi in FileFactory.NewForUri (path).EnumerateChildren ("*", FileQueryInfoFlags.None, null))
+				return true;
+			return false;
 		}
 
 		void HandleBrowseExisting (object sender, System.EventArgs args)
@@ -103,6 +117,55 @@ namespace FSpotCDExport {
 					ListAll (t, new System.Uri (path, info.Name + "/"));
 			}
 		}
+		
+		~CDExportDialog ()
+		{
+			if (listwindow != null)
+				listwindow.Destroy ();
+		}
+
+	}
+
+
+	public class CDExport : FSpot.Extensions.IExporter {
+		IBrowsableCollection selection;
+
+		System.Uri dest = new System.Uri ("burn:///");
+
+		int photo_index;
+		bool clean;
+		bool rotate;
+
+		CDExportDialog dialog;
+		ThreadProgressDialog progress_dialog;
+		System.Threading.Thread command_thread;
+
+		public CDExport ()
+		{
+		}
+
+		public void Run (IBrowsableCollection selection)
+		{
+			this.selection = selection;
+			dialog = new CDExportDialog (selection, dest);
+			//LoadHistory ();
+
+                        if (dialog.Run () != (int)ResponseType.Ok) {
+                                dialog.Destroy ();
+                                return;
+                        }
+
+			clean = dialog.Clean;
+			rotate = dialog.Rotate;
+
+			command_thread = new System.Threading.Thread (new System.Threading.ThreadStart (Transfer));
+			command_thread.Name = Catalog.GetString ("Transferring Pictures");
+
+			progress_dialog = new ThreadProgressDialog (command_thread, selection.Count);
+			progress_dialog.Start ();
+
+			dialog.Destroy ();
+		}
 
 		[DllImport ("libc")]
 		extern static int system (string program);
@@ -134,13 +197,6 @@ namespace FSpotCDExport {
 			}
 		}
 
-		bool IsEmpty (System.Uri path)
-		{
-			foreach (GLib.FileInfo fi in FileFactory.NewForUri (path).EnumerateChildren ("*", FileQueryInfoFlags.None, null))
-				return true;
-			return false;
-		}
-
 		public void Transfer () {
 			try {
 				bool result = true;
@@ -189,6 +245,7 @@ namespace FSpotCDExport {
 				}
 
 			} catch (System.Exception e) {
+				FSpot.Utils.Log.DebugException (e);
 				progress_dialog.Message = e.ToString ();
 				progress_dialog.ProgressText = Catalog.GetString ("Error Transferring");
 				return;
@@ -229,33 +286,5 @@ namespace FSpotCDExport {
 			fcb.Password = passwd;
 		}
 
-		private void HandleResponse (object sender, Gtk.ResponseArgs args)
-		{
-			if (listwindow != null)
-				listwindow.Destroy ();
-			if (args.ResponseId != Gtk.ResponseType.Ok) {
-				Dialog.Destroy ();
-				return;
-			}
-
-			clean = remove_check.Active;
-			rotate = rotate_check.Active;
-			Dialog.Destroy ();
-
-			command_thread = new System.Threading.Thread (new System.Threading.ThreadStart (Transfer));
-			command_thread.Name = Catalog.GetString ("Transferring Pictures");
-
-			progress_dialog = new ThreadProgressDialog (command_thread, selection.Count);
-			progress_dialog.Start ();
-		}
-
-		private Gtk.Dialog Dialog {
-			get {
-				if (dialog == null)
-					dialog = (Gtk.Dialog) xml.GetWidget (dialog_name);
-
-				return dialog;
-			}
-		}
 	}
 }
diff --git a/extensions/Exporters/CDExport/CDExport.glade b/extensions/Exporters/CDExport/CDExport.ui
similarity index 74%
rename from extensions/Exporters/CDExport/CDExport.glade
rename to extensions/Exporters/CDExport/CDExport.ui
index 4143599..d1f018b 100644
--- a/extensions/Exporters/CDExport/CDExport.glade
+++ b/extensions/Exporters/CDExport/CDExport.ui
@@ -1,34 +1,33 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<?xml version="1.0"?>
 <!--*- mode: xml -*-->
-<glade-interface>
-  <widget class="GtkDialog" id="cd_export_dialog">
+<interface>
+  <object class="GtkDialog" id="cd_export_dialog">
     <property name="visible">True</property>
     <property name="title" translatable="yes">Create CD</property>
     <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
-      <widget class="GtkVBox" id="dialog-vbox13">
+      <object class="GtkVBox" id="dialog-vbox13">
         <property name="visible">True</property>
         <child>
-          <widget class="GtkVBox" id="vbox42">
+          <object class="GtkVBox" id="vbox42">
             <property name="visible">True</property>
             <child>
-              <widget class="GtkFrame" id="frame33">
+              <object class="GtkFrame" id="frame33">
                 <property name="visible">True</property>
                 <property name="shadow_type">GTK_SHADOW_NONE</property>
                 <child>
-                  <widget class="GtkAlignment" id="alignment37">
+                  <object class="GtkAlignment" id="alignment37">
                     <property name="visible">True</property>
                     <property name="left_padding">12</property>
                     <child>
-                      <widget class="GtkVBox" id="vbox43">
+                      <object class="GtkVBox" id="vbox43">
                         <property name="visible">True</property>
                         <property name="spacing">6</property>
                         <child>
-                          <widget class="GtkScrolledWindow" id="thumb_scrolledwindow">
+                          <object class="GtkScrolledWindow" id="thumb_scrolledwindow">
                             <property name="width_request">512</property>
-                            <property name="height_request">512</property>
+                            <property name="height_request">350</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
@@ -36,41 +35,40 @@
                             <child>
                               <placeholder/>
                             </child>
-                          </widget>
+                          </object>
                         </child>
                         <child>
-                          <widget class="GtkFrame" id="previous_frame">
+                          <object class="GtkFrame" id="previous_frame">
                             <property name="visible">True</property>
                             <property name="shadow_type">GTK_SHADOW_NONE</property>
                             <child>
-                              <widget class="GtkAlignment" id="alignment1">
+                              <object class="GtkAlignment" id="alignment1">
                                 <property name="visible">True</property>
                                 <property name="left_padding">12</property>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox1">
+                                  <object class="GtkHBox" id="hbox1">
                                     <property name="visible">True</property>
                                     <property name="spacing">12</property>
                                     <child>
-                                      <widget class="GtkCheckButton" id="remove_check">
+                                      <object class="GtkCheckButton" id="remove_check">
                                         <property name="can_focus">True</property>
                                         <property name="label" translatable="yes">_Write only these photos to CD</property>
                                         <property name="use_underline">True</property>
                                         <property name="draw_indicator">True</property>
-                                      </widget>
+                                      </object>
                                       <packing>
                                         <property name="expand">False</property>
                                         <property name="fill">False</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkButton" id="browse_button">
+                                      <object class="GtkButton" id="browse_button">
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
                                         <property name="label" translatable="yes">_Browse Previously Scheduled Files</property>
                                         <property name="use_underline">True</property>
-					<signal name="clicked" handler="HandleBrowseExisting"/>
-				        <property name="response_id">0</property>
-                                      </widget>
+                                        <signal handler="HandleBrowseExisting" name="clicked"/>
+                                      </object>
                                       <packing>
                                         <property name="expand">False</property>
                                         <property name="fill">False</property>
@@ -80,33 +78,30 @@
                                     <child>
                                       <placeholder/>
                                     </child>
-                                  </widget>
+                                  </object>
                                 </child>
-                              </widget>
+                              </object>
                             </child>
-                            <child>
-                              <widget class="GtkLabel" id="label1">
+                            <child type="label">
+                              <object class="GtkLabel" id="label1">
                                 <property name="visible">True</property>
                                 <property name="label" translatable="yes">&lt;b&gt;&lt;i&gt;There is some previously scheduled items to write&lt;/i&gt;&lt;/b&gt;</property>
                                 <property name="use_markup">True</property>
-                              </widget>
-                              <packing>
-                                <property name="type">label_item</property>
-                              </packing>
+                              </object>
                             </child>
-                          </widget>
+                          </object>
                           <packing>
                             <property name="position">1</property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkCheckButton" id="rotate_check">
+                          <object class="GtkCheckButton" id="rotate_check">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="label" translatable="yes">Autorotate</property>
                             <property name="use_underline">True</property>
                             <property name="draw_indicator">True</property>
-                          </widget>
+                          </object>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
@@ -114,23 +109,23 @@
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkHBox" id="hbox85">
+                          <object class="GtkHBox" id="hbox85">
                             <property name="visible">True</property>
                             <child>
-                              <widget class="GtkLabel" id="label210">
+                              <object class="GtkLabel" id="label210">
                                 <property name="visible">True</property>
                                 <property name="label" translatable="yes">Size of the exported selection:</property>
-                              </widget>
+                              </object>
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkLabel" id="size_label">
+                              <object class="GtkLabel" id="size_label">
                                 <property name="visible">True</property>
                                 <property name="label" translatable="yes">Size</property>
-                              </widget>
+                              </object>
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
@@ -140,66 +135,66 @@
                             <child>
                               <placeholder/>
                             </child>
-                          </widget>
+                          </object>
                           <packing>
                             <property name="position">3</property>
                           </packing>
                         </child>
-                      </widget>
+                      </object>
                     </child>
-                  </widget>
+                  </object>
                 </child>
-                <child>
-                  <widget class="GtkLabel" id="label98">
+                <child type="label">
+                  <object class="GtkLabel" id="label98">
                     <property name="visible">True</property>
                     <property name="label" translatable="yes">&lt;b&gt;Photos to Burn&lt;/b&gt;</property>
                     <property name="use_markup">True</property>
-                  </widget>
-                  <packing>
-                    <property name="type">label_item</property>
-                  </packing>
+                  </object>
                 </child>
-              </widget>
+              </object>
             </child>
-          </widget>
+          </object>
           <packing>
             <property name="position">1</property>
           </packing>
         </child>
         <child internal-child="action_area">
-          <widget class="GtkHButtonBox" id="dialog-action_area13">
+          <object class="GtkHButtonBox" id="dialog-action_area13">
             <property name="visible">True</property>
             <property name="layout_style">GTK_BUTTONBOX_END</property>
             <child>
-              <widget class="GtkButton" id="cancelbutton6">
+              <object class="GtkButton" id="cancelbutton6">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="label">gtk-cancel</property>
                 <property name="use_stock">True</property>
-                <property name="response_id">-6</property>
-              </widget>
+              </object>
             </child>
             <child>
-              <widget class="GtkButton" id="export_button">
+              <object class="GtkButton" id="export_button">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
-                <property name="label">_Export</property>
+                <property name="label" translatable="yes">_Export</property>
                 <property name="use_underline">True</property>
-                <property name="response_id">-5</property>
-              </widget>
+              </object>
               <packing>
                 <property name="position">1</property>
               </packing>
             </child>
-          </widget>
+          </object>
           <packing>
             <property name="expand">False</property>
             <property name="pack_type">GTK_PACK_END</property>
           </packing>
         </child>
-      </widget>
+      </object>
     </child>
-  </widget>
-</glade-interface>
+    <action-widgets>
+      <action-widget response="0">browse_button</action-widget>
+      <action-widget response="-6">cancelbutton6</action-widget>
+      <action-widget response="-5">export_button</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/extensions/Exporters/CDExport/Makefile.am b/extensions/Exporters/CDExport/Makefile.am
index 53ce060..8f96fdd 100644
--- a/extensions/Exporters/CDExport/Makefile.am
+++ b/extensions/Exporters/CDExport/Makefile.am
@@ -7,34 +7,33 @@ PLUGIN_MANIFEST = $(PLUGIN_NAME).addin.xml
 PLUGIN_ASSEMBLY = $(PLUGIN_NAME).dll
 
 PLUGIN_SOURCES =			\
-	$(srcdir)/CDExport.cs
+	$(srcdir)/CDExport.cs		
 
 REFS =					\
-	-r:$(top_builddir)/src/f-spot.exe		\
+	-r:$(top_builddir)/src/f-spot.exe	\
 	-r:$(top_builddir)/src/FSpot.Core.dll	\
 	-r:$(top_builddir)/src/FSpot.Utils.dll	\
 	$(LINK_MONO_ADDINS)			\
 	$(LINK_SEMWEB)				\
 	$(LINK_GPHOTO2)				\
+	$(LINK_GTKSHARPBEANS)			\	
+	$(LINK_GIOSHARP)			\
 	-r:Mono.Posix
 
 PKGS =					\
 	-pkg:gnome-vfs-sharp-2.0	\
-	$(LINK_GTKSHARPBEANS)		\	
-	-pkg:gtk-sharp-2.0		\
-	$(LINK_GIOSHARP)		\
-	-pkg:glade-sharp-2.0
+	-pkg:gtk-sharp-2.0
 
 RESOURCES =				\
 	-resource:$(srcdir)/$(PLUGIN_MANIFEST)	\
-	-resource:$(srcdir)/$(PLUGIN_NAME).glade
+	-resource:$(srcdir)/$(PLUGIN_NAME).ui
 
 all: $(PLUGIN_ASSEMBLY)
 
 mpack: $(PLUGIN_ASSEMBLY)
 	mautil p $(PLUGIN_ASSEMBLY)
 
-$(PLUGIN_ASSEMBLY): $(PLUGIN_SOURCES) $(PLUGIN_MANIFEST) $(PLUGIN_NAME).glade
+$(PLUGIN_ASSEMBLY): $(PLUGIN_SOURCES) $(PLUGIN_MANIFEST) $(PLUGIN_NAME).ui
 	$(CSC_LIB) -out:$@ $(CSC_DEFINES) $(PLUGIN_SOURCES) $(REFS) $(PKGS) $(ASSEMBLIES) $(RESOURCES)
 
 plugindir = $(pkglibdir)/extensions
@@ -45,7 +44,7 @@ plugin_DATA =			\
 EXTRA_DIST = 			\
 	$(PLUGIN_SOURCES)	\
 	$(PLUGIN_MANIFEST)	\
-	$(PLUGIN_NAME).glade
+	$(PLUGIN_NAME).ui
 
 CLEANFILES =			\
 	$(PLUGIN_ASSEMBLY)	\



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