f-spot r3869 - in trunk: . src src/Core src/UI.Dialog



Author: sdelcroix
Date: Tue May  6 07:02:47 2008
New Revision: 3869
URL: http://svn.gnome.org/viewvc/f-spot?rev=3869&view=rev

Log:
2008-05-06  Stephane Delcroix  <sdelcroix novell com>

	* src/f-spot.glade:
	* src/UI.Dialog/PreferenceDialog.cs: allow choosing themes from a list.


Modified:
   trunk/ChangeLog
   trunk/src/Core/Global.cs
   trunk/src/UI.Dialog/PreferenceDialog.cs
   trunk/src/f-spot.glade

Modified: trunk/src/Core/Global.cs
==============================================================================
--- trunk/src/Core/Global.cs	(original)
+++ trunk/src/Core/Global.cs	Tue May  6 07:02:47 2008
@@ -8,9 +8,7 @@
 namespace FSpot {
 	public class Global {
 		public static string HomeDirectory {
-			get {
-				return System.IO.Path.Combine (System.Environment.GetEnvironmentVariable ("HOME"), System.String.Empty);	
-			}
+			get { return System.IO.Path.Combine (System.Environment.GetEnvironmentVariable ("HOME"), System.String.Empty); }
 		}
 		
 		private static string base_dir = System.IO.Path.Combine (HomeDirectory,  System.IO.Path.Combine (".gnome2", "f-spot"));

Modified: trunk/src/UI.Dialog/PreferenceDialog.cs
==============================================================================
--- trunk/src/UI.Dialog/PreferenceDialog.cs	(original)
+++ trunk/src/UI.Dialog/PreferenceDialog.cs	Tue May  6 07:02:47 2008
@@ -9,6 +9,8 @@
  */
 
 using System;
+using System.IO;
+using System.Collections.Generic;
 using Gtk;
 
 namespace FSpot.UI.Dialog {
@@ -47,9 +49,10 @@
 		[Glade.Widget] private CheckButton dbus_check;
 		[Glade.Widget] private RadioButton themenone_radio;
 		[Glade.Widget] private RadioButton themecustom_radio;
-		[Glade.Widget] private ComboBox themelist_combo;
 		[Glade.Widget] private Label themelist_label;
 		[Glade.Widget] private FileChooserButton theme_filechooser;
+		[Glade.Widget] private Table theme_table;
+		private ComboBox themelist_combo;
 
 
 
@@ -57,6 +60,7 @@
 		int screensaver_tag;
 		private const string SaverCommand = "screensavers-f-spot-screensaver";
 		private const string SaverMode = "single";
+		Dictionary<string, string> theme_list;
 
 		public PreferenceDialog () : base ("main_preferences")
 		{
@@ -105,12 +109,27 @@
 			screensaverall_radio.Toggled += ToggleTagRadio;
 
 			themenone_radio.Toggled += ToggleThemeRadio;
+			themelist_combo = ComboBox.NewText ();
+			theme_list = new Dictionary<string, string> ();
+			string gtkrc = Path.Combine ("gtk-2.0", "gtkrc");
+			string [] search = {"/usr/share/themes", Path.Combine (Global.HomeDirectory, ".themes")};
+			foreach (string path in search)
+				if (Directory.Exists (path)) 
+					foreach (string dir in Directory.GetDirectories (path))
+						if (File.Exists (Path.Combine (dir, gtkrc)))
+							theme_list.Add (Path.GetFileName (dir), Path.Combine (dir, gtkrc));
+			
+			foreach (string theme in theme_list.Keys)
+				themelist_combo.AppendText (System.IO.Path.GetFileName (theme));
+			
+			theme_table.Attach (themelist_combo, 2, 3, 0, 1);
+			themelist_combo.Changed += HandleThemeComboChanged;
+			themelist_combo.Show ();
 			themelist_combo.Sensitive = theme_filechooser.Sensitive = themecustom_radio.Active; 
 			if (System.IO.File.Exists (Preferences.Get (Preferences.GTK_RC) as string))
 				theme_filechooser.SetFilename (Preferences.Get (Preferences.GTK_RC) as string);
 			theme_filechooser.SelectionChanged += HandleThemeFileActivated;
 			themecustom_radio.Active = (Preferences.Get (Preferences.GTK_RC) as string != String.Empty);	
-			themelist_label.Visible = themelist_combo.Visible = false;
 
 			Preferences.SettingChanged += OnPreferencesChanged;
 			this.Dialog.Destroyed += HandleDestroyed;
@@ -162,6 +181,15 @@
 			}
 		}
 
+		void HandleThemeComboChanged (object o, EventArgs e)
+		{
+			if (o == null)
+				return;
+			TreeIter iter;
+			if ((o as ComboBox).GetActiveIter (out iter))
+				Preferences.Set (Preferences.GTK_RC, theme_list [((o as ComboBox).Model.GetValue (iter, 0)) as string]);
+		}
+
 		void HandleThemeFileActivated (object o, EventArgs e)
 		{
 			if (theme_filechooser.Filename != null && theme_filechooser.Filename != Preferences.Get (Preferences.GTK_RC))
@@ -235,7 +263,8 @@
 			case Preferences.GTK_RC:
 				themenone_radio.Active = (val as string == String.Empty);
 				themecustom_radio.Active = (val as string != String.Empty);
-				theme_filechooser.SetFilename (val as string);
+				if (theme_filechooser.Sensitive)
+					theme_filechooser.SetFilename (val as string);
 				break;
 			}
 		}

Modified: trunk/src/f-spot.glade
==============================================================================
--- trunk/src/f-spot.glade	(original)
+++ trunk/src/f-spot.glade	Tue May  6 07:02:47 2008
@@ -6640,7 +6640,7 @@
                           </widget>
                         </child>
                         <child>
-                          <widget class="GtkTable" id="table3">
+                          <widget class="GtkTable" id="theme_table">
                             <property name="visible">True</property>
                             <property name="n_rows">2</property>
                             <property name="n_columns">3</property>
@@ -6663,11 +6663,13 @@
                               <widget class="GtkLabel" id="label21">
                                 <property name="visible">True</property>
                                 <property name="xalign">1</property>
-                                <property name="label" translatable="yes"> From gtkrc File :</property>
+                                <property name="label" translatable="yes"> From gtkrc File : </property>
                               </widget>
                               <packing>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
@@ -6675,13 +6677,11 @@
                               <widget class="GtkLabel" id="themelist_label">
                                 <property name="visible">True</property>
                                 <property name="xalign">1</property>
-                                <property name="label" translatable="yes"> From List :</property>
+                                <property name="label" translatable="yes"> From List : </property>
                               </widget>
                               <packing>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
@@ -6693,19 +6693,9 @@
                               <packing>
                                 <property name="left_attach">2</property>
                                 <property name="right_attach">3</property>
-                                <property name="x_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkComboBox" id="themelist_combo">
-                                <property name="visible">True</property>
-                              </widget>
-                              <packing>
-                                <property name="left_attach">2</property>
-                                <property name="right_attach">3</property>
                                 <property name="top_attach">1</property>
                                 <property name="bottom_attach">2</property>
-                                <property name="x_options"></property>
+                                <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
                           </widget>



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