[f-spot: 3/5] WIP: sde 1 - glade 0



commit 79af5f462c557e6f0f4099af7065fc76de145645
Author: Stephane Delcroix <stephane delcroix org>
Date:   Thu Apr 30 16:48:57 2009 +0200

    WIP: sde 1 - glade 0
---
 src/MainWindow.cs                   |    8 ++-
 src/UI.Dialog/DateRangeDialog.cs    |  116 ++++++++++++++++++++---------------
 src/UI.Dialog/ui/DateRangeDialog.ui |   57 ++++++++++-------
 3 files changed, 105 insertions(+), 76 deletions(-)

diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index cdeae9f..56993f7 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -2649,8 +2649,12 @@ public class MainWindow {
 	}
 
 	void HandleSetDateRange (object sender, EventArgs args) {
-		DateCommands.Set set_command = new DateCommands.Set (query, main_window);
-		set_command.Execute ();
+		var date_range_dialog = new DateRangeDialog (query, main_window);
+		if ((ResponseType)date_range_dialog.Run () == ResponseType.Ok)
+			Console.WriteLine ("DO SOMETHING");
+		date_range_dialog.Destroy ();
+//		DateCommands.Set set_command = new DateCommands.Set (query, main_window);
+//		set_command.Execute ();
 		//update the TimeLine
 		if (group_selector.Adaptor is TimeAdaptor && query.Range != null) 
 			group_selector.SetLimitsToDates(query.Range.Start, query.Range.End);
diff --git a/src/UI.Dialog/DateRangeDialog.cs b/src/UI.Dialog/DateRangeDialog.cs
index 5fcfce3..0b80887 100644
--- a/src/UI.Dialog/DateRangeDialog.cs
+++ b/src/UI.Dialog/DateRangeDialog.cs
@@ -1,9 +1,10 @@
 /*
- * DateCommand.cs
+ * FSpot.UI.Dialog.DateRangeDialog.cs
  *
  * Author(s):
  * 	Larry Ewing <lewing novell com>
  * 	Bengt Thuree
+ *	Stephane Delcroix  <stephane delcroix org>
  *
  * This is free software. See COPYING for details.
  *
@@ -14,17 +15,19 @@ using System;
 using Mono.Unix;
 using FSpot;
 using FSpot.Query;
-using FSpot.UI.Dialog;
 
-public class DateCommands {
-	public class Set : GladeDialog {
+namespace FSpot.UI.Dialog
+{
+	public class DateRangeDialog : BuilderDialog {
 		FSpot.PhotoQuery query;
 		Gtk.Window parent_window;
 
-		[Glade.Widget] private Button ok_button;
-		[Glade.Widget] private Gnome.DateEdit start_dateedit;
-		[Glade.Widget] private Gnome.DateEdit end_dateedit;
-		[Glade.Widget] private ComboBox period_combobox;
+		[Builder.Object] Button ok_button;
+		[Builder.Object] Gnome.DateEdit start_dateedit;
+		[Builder.Object] Gnome.DateEdit end_dateedit;
+		[Builder.Object] ComboBox period_combobox;
+
+		TreeStore rangestore;
 
 		static string [] ranges = {
 			"today",
@@ -43,6 +46,58 @@ public class DateCommands {
 			"customizedrange"
 		};
 
+		public DateRangeDialog (FSpot.PhotoQuery query, Gtk.Window parent_window) : base ("DateRangeDialog.ui", "date_range_dialog")
+		{
+			this.query = query;
+			this.parent_window = parent_window;
+			TransientFor = parent_window;
+			DefaultResponse = ResponseType.Ok;
+			var cell_renderer = new CellRendererText ();
+
+			// Build the combo box with years and month names
+			period_combobox.Model = rangestore = new TreeStore (typeof (string));
+			period_combobox.PackStart (cell_renderer, true);
+
+			period_combobox.SetCellDataFunc (cell_renderer, new CellLayoutDataFunc (RangeCellFunc));
+
+			foreach (string range in ranges)
+				rangestore.AppendValues (GetString(range));
+
+//			start_dateedit.DateChanged += HandleDateEditChanged;
+//			((Gtk.Entry) start_dateedit.Children [0] as Gtk.Entry).Changed += HandleDateEditChanged;
+//			end_dateedit.DateChanged += HandleDateEditChanged;
+//			((Gtk.Entry) end_dateedit.Children [0] as Gtk.Entry).Changed += HandleDateEditChanged;
+//			
+           	 	period_combobox.Active = System.Array.IndexOf(ranges, "last7days"); // Default to Last 7 days
+			period_combobox.Changed += HandlePeriodComboboxChanged;
+//
+//			if (query.Range != null) {
+//				start_dateedit.Time = query.Range.Start;
+//				end_dateedit.Time = query.Range.End;
+//			}
+//
+//			ResponseType response = (ResponseType) this.Dialog.Run ();
+//
+//			bool success = false;
+//
+//			if (response == ResponseType.Ok) {
+//				query.Range = QueryRange (period_combobox.Active);
+//				success = true;
+//			}
+//			
+//			this.Dialog.Destroy ();
+//			return success;
+		}
+
+		void RangeCellFunc (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
+		{
+			string name = (string)tree_model.GetValue (iter, 0);
+			(cell as CellRendererText).Text = name;
+		}
+
+
+
+
 		private static string GetString(int index)
 		{
 			return GetString (ranges [index]);
@@ -93,6 +148,9 @@ public class DateCommands {
 
 		private DateRange QueryRange (int index)
 		{
+			Console.WriteLine ("QueryRange");
+			Console.WriteLine ("index " + index);
+			Console.WriteLine ("ranges " + ranges);
 			return QueryRange ( ranges [index]);
 		}
 
@@ -204,47 +262,5 @@ public class DateCommands {
 			end_dateedit.DateChanged += HandleDateEditChanged;
 			((Gtk.Entry) end_dateedit.Children [0] as Gtk.Entry).Changed += HandleDateEditChanged;
 		}
-
-		public Set (FSpot.PhotoQuery query, Gtk.Window parent_window)
-		{
-			this.query = query;
-			this.parent_window = parent_window;
-		}
-
-		public bool Execute ()
-		{
-			this.CreateDialog ("date_range_dialog");
-
-			// Build the combo box with years and month names
-			foreach (string range in ranges)
-				period_combobox.AppendText (GetString(range));
-
-			start_dateedit.DateChanged += HandleDateEditChanged;
-			((Gtk.Entry) start_dateedit.Children [0] as Gtk.Entry).Changed += HandleDateEditChanged;
-			end_dateedit.DateChanged += HandleDateEditChanged;
-			((Gtk.Entry) end_dateedit.Children [0] as Gtk.Entry).Changed += HandleDateEditChanged;
-			
-			period_combobox.Changed += HandlePeriodComboboxChanged;
-           	 	period_combobox.Active = System.Array.IndexOf(ranges, "last7days"); // Default to Last 7 days
-
-			if (query.Range != null) {
-				start_dateedit.Time = query.Range.Start;
-				end_dateedit.Time = query.Range.End;
-			}
-
-			Dialog.TransientFor = parent_window;
-			Dialog.DefaultResponse = ResponseType.Ok;
-			ResponseType response = (ResponseType) this.Dialog.Run ();
-
-			bool success = false;
-
-			if (response == ResponseType.Ok) {
-				query.Range = QueryRange (period_combobox.Active);
-				success = true;
-			}
-			
-			this.Dialog.Destroy ();
-			return success;
-		}
 	}
 }
diff --git a/src/UI.Dialog/ui/DateRangeDialog.ui b/src/UI.Dialog/ui/DateRangeDialog.ui
index bb2353d..440f6fd 100644
--- a/src/UI.Dialog/ui/DateRangeDialog.ui
+++ b/src/UI.Dialog/ui/DateRangeDialog.ui
@@ -1,11 +1,13 @@
 <?xml version="1.0"?>
-<!--*- mode: xml -*-->
 <interface>
+  <requires lib="gtk+" version="2.14"/>
+  <!-- interface-requires gnome 0.0 -->
+  <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkDialog" id="date_range_dialog">
     <property name="visible">True</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes">Set date range</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox7">
@@ -21,7 +23,7 @@
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="label_xalign">0</property>
-                <property name="shadow_type">GTK_SHADOW_NONE</property>
+                <property name="shadow_type">none</property>
                 <child>
                   <object class="GtkAlignment" id="alignment3">
                     <property name="visible">True</property>
@@ -46,6 +48,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -60,16 +63,16 @@
               </packing>
             </child>
             <child>
-              <object class="GtkFrame" id="frame2">
+              <object class="GtkFrame" id="frame3">
                 <property name="visible">True</property>
                 <property name="label_xalign">0</property>
-                <property name="shadow_type">GTK_SHADOW_NONE</property>
+                <property name="shadow_type">none</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment4">
+                  <object class="GtkAlignment" id="alignment5">
                     <property name="visible">True</property>
                     <property name="left_padding">12</property>
                     <child>
-                      <object class="GnomeDateEdit" id="end_dateedit">
+                      <object class="GnomeDateEdit" id="start_dateedit">
                         <property name="visible">True</property>
                         <property name="dateedit_flags">GNOME_DATE_EDIT_24_HR</property>
                       </object>
@@ -77,30 +80,31 @@
                   </object>
                 </child>
                 <child type="label">
-                  <object class="GtkLabel" id="label18">
+                  <object class="GtkLabel" id="label19">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;b&gt;End Date&lt;/b&gt;</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Start Date&lt;/b&gt;</property>
                     <property name="use_markup">True</property>
+                    <property name="wrap_mode">word-char</property>
                   </object>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">3</property>
+                <property name="position">2</property>
               </packing>
             </child>
             <child>
-              <object class="GtkFrame" id="frame3">
+              <object class="GtkFrame" id="frame2">
                 <property name="visible">True</property>
                 <property name="label_xalign">0</property>
-                <property name="shadow_type">GTK_SHADOW_NONE</property>
+                <property name="shadow_type">none</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment5">
+                  <object class="GtkAlignment" id="alignment4">
                     <property name="visible">True</property>
                     <property name="left_padding">12</property>
                     <child>
-                      <object class="GnomeDateEdit" id="start_dateedit">
+                      <object class="GnomeDateEdit" id="end_dateedit">
                         <property name="visible">True</property>
                         <property name="dateedit_flags">GNOME_DATE_EDIT_24_HR</property>
                       </object>
@@ -108,18 +112,17 @@
                   </object>
                 </child>
                 <child type="label">
-                  <object class="GtkLabel" id="label19">
+                  <object class="GtkLabel" id="label18">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Start Date&lt;/b&gt;</property>
+                    <property name="label" translatable="yes">&lt;b&gt;End Date&lt;/b&gt;</property>
                     <property name="use_markup">True</property>
-                    <property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
                   </object>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">2</property>
+                <property name="position">3</property>
               </packing>
             </child>
           </object>
@@ -131,24 +134,29 @@
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="dialog-action_area7">
             <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="cancelbutton3">
+                <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
-                <property name="tooltip-text" translatable="yes">Cancel, do not change the current timeline. </property>
-                <property name="label">gtk-cancel</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">Cancel, do not change the current timeline. </property>
                 <property name="use_stock">True</property>
               </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
             </child>
             <child>
               <object class="GtkButton" id="ok_button">
+                <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
-                <property name="tooltip-text" translatable="yes">Only photos taken within these dates will be displayed.</property>
-                <property name="label">gtk-ok</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">Only photos taken within these dates will be displayed.</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -158,7 +166,8 @@
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
       </object>



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