f-spot r4543 - in trunk: . src src/Core src/Platform/Gnome src/Platform/Null src/Widgets



Author: sdelcroix
Date: Tue Oct 28 13:56:37 2008
New Revision: 4543
URL: http://svn.gnome.org/viewvc/f-spot?rev=4543&view=rev

Log:
2008-10-21  Stephane Delcroix  <sdelcroix novell com>

	* src/Makefile.am:
	* src/Platform/Gnome/PreferenceBackend.cs:
	* src/Platform/Null/PreferenceBackend.cs:
	* src/Preferences.cs: move the GConf bits in Platform

DateEdit

Added:
   trunk/src/Platform/Gnome/PreferenceBackend.cs
   trunk/src/Platform/Null/
   trunk/src/Platform/Null/PreferenceBackend.cs
      - copied, changed from r4542, /trunk/src/Core/IPreferenceBackend.cs
   trunk/src/Widgets/FDateEdit.cs
   trunk/src/Widgets/FDateEditDialog.cs
Removed:
   trunk/src/Core/IPreferenceBackend.cs
   trunk/src/GConfPreferenceBackend.cs
   trunk/src/NullPreferenceBackend.cs
   trunk/src/Platform/Gnome/GnomeThumbnailFactory.cs
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/Preferences.cs

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Tue Oct 28 13:56:37 2008
@@ -30,7 +30,6 @@
 	$(srcdir)/Core/IBrowsableItem.cs	\
 	$(srcdir)/Core/IBrowsableItemChanges.cs	\
 	$(srcdir)/Core/IBrowsableCollection.cs	\
-	$(srcdir)/Core/IPreferenceBackend.cs	\
 	$(srcdir)/Core/PhotoChanges.cs		\
 	$(srcdir)/Core/PhotosChanges.cs		\
 	$(srcdir)/Core/Roll.cs
@@ -76,9 +75,13 @@
 	$(srcdir)/Widgets/SaneTreeView.cs	\
 	$(srcdir)/Widgets/ScrolledView.cs
 
-PLATFORM_CSDISTFILES =					\
+GNOME_PLATFORM_CSDISTFILES =				\
+	$(srcdir)/Platform/Gnome/PreferenceBackend.cs	\
 	$(srcdir)/Platform/Gnome/ThumbnailFactory.cs
 
+NULL_PLATFORM_CSDISTFILES =				\
+	$(srcdir)/Platform/Null/PreferenceBackend.cs
+
 F_SPOT_CSDISTFILES =				\
 	$(srcdir)/AsyncPixbufLoader.cs		\
 	$(srcdir)/BlockProcessor.cs		\
@@ -142,7 +145,6 @@
 	$(srcdir)/FotkiRemote.cs		\
 	$(srcdir)/FormClient.cs			\
 	$(srcdir)/FullScreenView.cs		\
-	$(srcdir)/GConfPreferenceBackend.cs	\
 	$(srcdir)/GdkGlx.cs			\
 	$(srcdir)/GlTransition.cs		\
 	$(srcdir)/GroupAdaptor.cs		\
@@ -183,7 +185,6 @@
 	$(srcdir)/MemorySurface.cs		\
 	$(srcdir)/MetaStore.cs			\
 	$(srcdir)/MetadataStore.cs		\
-	$(srcdir)/NullPreferenceBackend.cs	\
 	$(srcdir)/Operation.cs			\
 	$(srcdir)/PhotoEventArgs.cs		\
 	$(srcdir)/PhotoImageView.cs		\
@@ -314,9 +315,10 @@
 	-r:FSpot.Core.dll			\
 	-r:FSpot.Utils.dll
 
-PLATFORM_ASSEMBLIES =				\
+GNOME_PLATFORM_ASSEMBLIES =			\
 	-pkg:gnome-sharp-2.0			\
 	-pkg:gtk-sharp-2.0			\
+	-pkg:gconf-sharp-2.0			\
 	-r:FSpot.Utils.dll
 
 F_SPOT_ASSEMBLIES = 				\
@@ -391,7 +393,9 @@
 
 WIDGETS_CSFILES = $(WIDGETS_CSDISTFILES)
 
-PLATFORM_CSFILES = $(PLATFORM_CSDISTFILES)
+GNOME_PLATFORM_CSFILES = $(GNOME_PLATFORM_CSDISTFILES)
+
+NULL_PLATFORM_CSFILES = $(NULL_PLATFROM_CSDISTFILES)
 
 F_SPOT_CSFILES = $(F_SPOT_CSDISTFILES)	\
 	AssemblyInfo.cs
@@ -420,6 +424,9 @@
 	@echo -e "\n*** Compiling $@"
 	$(CSC_LIB) -out:$@ $(EXTRAFLAGS) $(WIDGETS_CSFILES) $(WIDGETS_ASSEMBLIES)
 
+PLATFORM_CSFILES = $(GNOME_PLATFORM_CSFILES)
+PLATFORM_ASSEMBLIES = $(GNOME_PLATFORM_ASSEMBLIES)
+
 FSpot.Platform.dll: $(PLATFORM_CSFILES) FSpot.Utils.dll
 	@echo -e "\n*** Compiling $@"
 	$(CSC_LIB) -out:$@ $(EXTRAFLAGS) $(PLATFORM_CSFILES) $(PLATFORM_ASSEMBLIES)
@@ -437,6 +444,8 @@
 	$(QUERY_CSDISTFILES)			\
 	$(JOBSCHEDULER_CSDISTFILES)		\
 	$(WIDGETS_CSDISTFILES)			\
+	$(GNOME_PLATFORM_CSDISTFILES)		\
+	$(NULL_PLATFORM_CSDISTFILES)		\
 	$(F_SPOT_CSDISTFILES)			\
 	$(F_SPOT_DISTRESOURCES)			\
 	f-spot.exe.config.in			\
@@ -461,9 +470,10 @@
 	FSpot.JobScheduler.dll.mdb		\
 	FSpot.Widgets.dll			\
 	FSpot.Widgets.dll.mdb			\
+	FSpot.Platform.dll			\
+	FSpot.Platform.dll.mdb			\
 	Cms.dll.config
 
-
 DISTCLEANFILES = 				\
 	Makefile
 

Added: trunk/src/Platform/Gnome/PreferenceBackend.cs
==============================================================================
--- (empty file)
+++ trunk/src/Platform/Gnome/PreferenceBackend.cs	Tue Oct 28 13:56:37 2008
@@ -0,0 +1,95 @@
+/*
+ * FSpot.Platform.Gnome.PreferenceBackend.cs
+ *
+ * Author(s):
+ *	Stephane Delcroix  <stephane delcroix org>
+ *
+ * This is free software. See COPYING for details.
+ */
+#if !NOGCONF
+
+using System;
+using System.Runtime.Serialization;
+
+
+namespace FSpot
+{
+	public class NotifyEventArgs : System.EventArgs
+	{
+		string key;
+		public string Key {
+			get { return key; }
+		}
+
+		object val;
+		public object Value {
+			get { return val; }
+		}
+
+		public NotifyEventArgs (string key, object val)
+		{
+			this.key = key;
+			this.val = val;
+		}
+	}
+
+	public class NoSuchKeyException : Exception
+	{
+		public NoSuchKeyException () : base ()
+		{
+		}
+
+		public NoSuchKeyException (string key) : base (key)
+		{
+		}
+
+		public NoSuchKeyException (string key, Exception e) : base (key, e)
+		{
+		}
+
+		protected NoSuchKeyException (SerializationInfo info, StreamingContext context) : base (info, context)
+		{
+		}
+	}
+
+	public delegate void NotifyChangedHandler (object sender, NotifyEventArgs args);
+}
+
+namespace FSpot.Platform
+{
+	public class PreferenceBackend
+	{
+		private static GConf.Client client;
+		private GConf.Client Client {
+			get {
+				if (client == null)
+					client = new GConf.Client ();
+				return client;
+			}
+		}
+
+		public PreferenceBackend ()
+		{
+		}
+
+		public object Get (string key)
+		{
+			try {
+				return Client.Get (key);
+			} catch (GConf.NoSuchKeyException) {
+				throw new NoSuchKeyException (key);
+			}
+		}
+
+		public void Set (string key, object o)
+		{
+			Client.Set (key, o);
+		}
+
+		public void AddNotify (string key, NotifyChangedHandler handler)
+		{
+			Client.AddNotify (key, delegate (object sender, GConf.NotifyEventArgs args) {handler (sender, new NotifyEventArgs (args.Key, args.Value));});
+		}
+	}
+}
+#endif

Copied: trunk/src/Platform/Null/PreferenceBackend.cs (from r4542, /trunk/src/Core/IPreferenceBackend.cs)
==============================================================================
--- /trunk/src/Core/IPreferenceBackend.cs	(original)
+++ trunk/src/Platform/Null/PreferenceBackend.cs	Tue Oct 28 13:56:37 2008
@@ -1,5 +1,5 @@
 /*
- * FSpot.IPreferenceBackend.cs
+ * FSpot.NullPreferenceBackend.cs
  *
  * Author(s):
  *	Stephane Delcroix  <stephane delcroix org>
@@ -7,9 +7,6 @@
  * This is free software. See COPYING for details.
  */
 
-using System;
-using System.Runtime.Serialization;
-
 namespace FSpot
 {
 	public class NotifyEventArgs : System.EventArgs
@@ -51,11 +48,23 @@
 	}
 
 	public delegate void NotifyChangedHandler (object sender, NotifyEventArgs args);
+}
 
-	public interface IPreferenceBackend
+namespace FSpot.Platform
+{
+	public class PreferenceBackend : IPreferenceBackend
 	{
-		object Get (string key);
-		void Set (string key, object value);	
-		void AddNotify (string key, NotifyChangedHandler handler);
+		public object Get (string key)
+		{
+			throw new NoSuchKeyException (key);
+		}
+
+		public void Set (string key, object o)
+		{
+		}
+
+		public void AddNotify (string key, NotifyChangedHandler handler)
+		{
+		}
 	}
 }

Modified: trunk/src/Preferences.cs
==============================================================================
--- trunk/src/Preferences.cs	(original)
+++ trunk/src/Preferences.cs	Tue Oct 28 13:56:37 2008
@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using Mono.Unix;
+using FSpot.Platform;
 
 namespace FSpot
 {
@@ -86,22 +87,12 @@
 		public const string GSD_THUMBS_MAX_SIZE = "/desktop/gnome/thumbnail_cache/maximum_size";
 
 
-		private static IPreferenceBackend backend;
+		private static PreferenceBackend backend;
 		private static NotifyChangedHandler changed_handler;
-		private static IPreferenceBackend Backend {
+		private static PreferenceBackend Backend {
 			get {
 				if (backend == null) {
-#if !NOGCONF
-					try {
-						backend = new GConfPreferenceBackend ();
-					} catch (Exception ex) {
-						Console.WriteLine ("Couldn't load Gconf. Check that gconf-daemon is running.{0}{1}",
-							Environment.NewLine, ex);
-						backend = new NullPreferenceBackend ();
-					}
-#else
-					backend = new NullPreferenceBackend ();
-#endif
+					backend = new PreferenceBackend ();
 					changed_handler = new NotifyChangedHandler (OnSettingChanged);
 					backend.AddNotify ("/apps/f-spot", changed_handler);
 					backend.AddNotify ("/apps/gnome-screensaver/themes", changed_handler);

Added: trunk/src/Widgets/FDateEdit.cs
==============================================================================
--- (empty file)
+++ trunk/src/Widgets/FDateEdit.cs	Tue Oct 28 13:56:37 2008
@@ -0,0 +1,43 @@
+/*
+ * FSpot.Widgets.DateEdit.cs
+ *
+ * Author(s):
+ *	Stephane Delcroix  <stephane delcroix org>
+ *
+ * Copyright (c) 2008 Novell, Inc.
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using Gtk;
+
+namespace FSpot.Widgets
+{
+	public class DateEdit : Bin
+	{
+		public event EventHandler DateChanged;
+		public event EventHandler TimeChanged;
+
+		public bool ShowTime {get; set;}
+		public bool ShowOffset {get; set;}
+		public DateTimeOffset DateTimeOffset {get; set;}
+
+		ComboBox combo;
+
+		public DateEdit () : DateEdit (DateTime.Now)
+		{
+		}
+
+		public DateEdit (DateTime datetime) : DateEdit (new DateTimeOffset (datetime))
+		{
+		}
+
+		public DateEdit (DateTimeOffset datetimeoffset)
+		{
+			DateTimeOffset = datetimeoffset;
+			combo = new ComboBox ();
+			Add (combo);
+		}
+	}
+}

Added: trunk/src/Widgets/FDateEditDialog.cs
==============================================================================
--- (empty file)
+++ trunk/src/Widgets/FDateEditDialog.cs	Tue Oct 28 13:56:37 2008
@@ -0,0 +1,148 @@
+/*
+ * FSpot.Widgets.DateEditDialog.cs
+ *
+ * Author(s):
+ *	Stephane Delcroix  <stephane delcroix org>
+ *
+ * Copyright (c) 2008 Novell, Inc.
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using Gtk;
+
+namespace FSpot.Widgets
+{
+	internal class DateEditDialog : VBox
+	{
+		public DateTimeOffset DateTimeOffset {get; set;}
+		public event EventHandler DateChanged;
+
+		Calendar calendar;
+		TreeStore time_store;
+		ComboBox time_combo;
+
+		public DateEditDialog (DateTimeOffset dto)
+		{
+			DateTimeOffset = dto;
+
+			calendar = new Calendar ();
+			calendar.Date = DateTimeOffset.Date;
+			calendar.DaySelected += HandleDateChanged;
+			calendar.Show ();
+			Add (calendar);
+
+			HBox timebox = new HBox ();
+
+			Entry timeentry = new Entry ();
+			timeentry.Show ();
+			timebox.Add (timeentry);
+
+			Gtk.CellRendererText timecell = new Gtk.CellRendererText ();
+			time_combo = new Gtk.ComboBox ();
+			time_store = new Gtk.TreeStore (typeof (string), typeof (int), typeof (int));
+			time_combo.Model = time_store;
+			time_combo.PackStart (timecell, true);
+			time_combo.SetCellDataFunc (timecell, new CellLayoutDataFunc (TimeCellFunc));
+			time_combo.Realized += FillTimeCombo;
+			time_combo.Changed += HandleTimeComboChanged;
+			time_combo.Show ();
+			timebox.Add (time_combo);
+
+			timebox.Show ();
+			Add (timebox);
+		}
+
+		void TimeCellFunc (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
+		{
+			string name = (string)tree_model.GetValue (iter, 0);
+			(cell as CellRendererText).Text = name;
+		}
+
+		void FillTimeCombo (object o, EventArgs e)
+		{
+			FillTimeCombo ();
+		}
+
+		void FillTimeCombo ()
+		{
+			int lower_hour = 0;
+			int upper_hour = 23;
+			int time_increment = 10;
+
+			if (lower_hour > upper_hour)
+				return;
+
+			time_combo.Changed -= HandleTimeComboChanged;
+
+			int localhour = System.DateTime.Now.Hour;
+
+			TreeIter iter;
+			for (int i=lower_hour; i<=upper_hour; i++)
+			{
+				iter = time_store.AppendValues (TimeLabel (i, 0, true), i, 0);
+				for (int j = time_increment; j < 60; j += time_increment) {
+					time_store.AppendValues (iter, TimeLabel (i, j, true), i, j);
+				}
+				if (i == localhour)
+					time_combo.Active = i - lower_hour;
+
+			}
+			if (localhour < lower_hour)
+				time_combo.Active = 0;
+			if (localhour > upper_hour)
+				time_combo.Active = upper_hour - lower_hour;
+
+			time_combo.Changed += HandleTimeComboChanged;
+
+			//Update ();
+		}
+
+		void HandleTimeComboChanged (object o, EventArgs e)
+		{
+			TreeIter iter;
+			if (time_combo.GetActiveIter (out iter)) {
+//				datetime.Hour = (int) time_store.GetValue (iter, 1);
+//				datetime.Minute = (int) time_store.GetValue (iter, 2);
+			}
+		}
+
+
+		void HandleDateChanged (object o, EventArgs args)
+		{
+			Console.WriteLine ("DateChanged: {0}", calendar.Date);
+			if (DateChanged != null)
+				DateChanged (o, args);
+		}
+
+		private static string TimeLabel (int h, int m, bool two4hr)
+		{
+			if (two4hr) {
+				return String.Format ("{0}{1}{2}",
+							h % 24,
+							System.Globalization.DateTimeFormatInfo.CurrentInfo.TimeSeparator,
+							m.ToString ("00"));
+			} else {
+				return String.Format ("{0}{1}{2} {3}",
+							(h + 11) % 12 + 1,
+							System.Globalization.DateTimeFormatInfo.CurrentInfo.TimeSeparator,
+							m.ToString ("00"),
+							(12 <= h && h < 24) ?
+								System.Globalization.DateTimeFormatInfo.CurrentInfo.PMDesignator :
+								System.Globalization.DateTimeFormatInfo.CurrentInfo.AMDesignator);
+			}
+		}
+
+
+		static void Main ()
+		{
+			Application.Init ();
+			Window w = new Window ("test");
+			w.Add (new DateEditDialog (DateTimeOffset.Now));
+			w.ShowAll ();
+			Application.Run ();
+		}
+	}
+
+}



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