tasque r150 - in trunk: . src src/Backends/Rtm



Author: sharm
Date: Tue Oct 21 15:17:05 2008
New Revision: 150
URL: http://svn.gnome.org/viewvc/tasque?rev=150&view=rev

Log:
Fixes for bug #532766, courtesy of Guillaume Beland.

* tasque/src/NoteDialog.cs:
* tasque/src/Backends/Rtm/RtmPreferencesWidget.cs: Do not paint the
  background white.

* tasque/src/Utilities.cs: Add ColorGetHex method, stolen from Banshee,
  that takes a Gdk.Color and makes a hex string like "#FFFFFF".

* tasque/src/TaskGroup.cs: Green was a pretty header color, but let's
  use the "selected" state color from the GTK+ theme instead.

* tasque/src/TaskWindow.cs: Get the background color from the GTK+ theme
  instead of just using white.  Some whitespace fixes.

Modified:
   trunk/ChangeLog
   trunk/src/Backends/Rtm/RtmPreferencesWidget.cs
   trunk/src/NoteDialog.cs
   trunk/src/TaskGroup.cs
   trunk/src/TaskWindow.cs
   trunk/src/Utilities.cs

Modified: trunk/src/Backends/Rtm/RtmPreferencesWidget.cs
==============================================================================
--- trunk/src/Backends/Rtm/RtmPreferencesWidget.cs	(original)
+++ trunk/src/Backends/Rtm/RtmPreferencesWidget.cs	Tue Oct 21 15:17:05 2008
@@ -29,8 +29,6 @@
 			
 			// We're using an event box so we can paint the background white
 			BorderWidth = 0;
-			ModifyBg(StateType.Normal, new Gdk.Color(255,255,255));
-			ModifyBase(StateType.Normal, new Gdk.Color(255,255,255));
 
 			VBox mainVBox = new VBox(false, 0);
 			mainVBox.BorderWidth = 10;

Modified: trunk/src/NoteDialog.cs
==============================================================================
--- trunk/src/NoteDialog.cs	(original)
+++ trunk/src/NoteDialog.cs	Tue Oct 21 15:17:05 2008
@@ -37,10 +37,7 @@
 			
 			Gtk.EventBox innerEb = new Gtk.EventBox();
 			innerEb.BorderWidth = 0;
-			innerEb.ModifyBg (Gtk.StateType.Normal, 
-						new Gdk.Color(255,255,255));
-			innerEb.ModifyBase (Gtk.StateType.Normal, 
-						new Gdk.Color(255,255,255));
+
 
 			targetVBox = new Gtk.VBox();
 			targetVBox.BorderWidth = 5;

Modified: trunk/src/TaskGroup.cs
==============================================================================
--- trunk/src/TaskGroup.cs	(original)
+++ trunk/src/TaskGroup.cs	Tue Oct 21 15:17:05 2008
@@ -2,6 +2,8 @@
 // User: boyd at 7:50 PMÂ2/11/2008
 
 using System;
+using Gdk;
+using Gtk;
 
 namespace Tasque
 {
@@ -69,12 +71,13 @@
 			header.UseMarkup = true;
 			header.UseUnderline = false;
 			header.Markup =
-				string.Format ("<span size=\"x-large\" foreground=\"#9eb96e\" weight=\"bold\">{0}</span>",
-							   groupName);
+				string.Format ("<span size=\"x-large\" foreground=\"{0}\" weight=\"bold\">{1}</span>", 
+								GetHighlightColor (),
+								groupName);
 			header.Xalign = 0;
-			
+
 			header.Show ();
-			
+
 //			eb.Add(header);
 //			PackStart (eb, false, false, 0);
 			headerHBox.PackStart (header, false, false, 0);
@@ -444,6 +447,23 @@
 			
 			return null;
 		}
+		
+		/// <summary>
+		/// This returns the current highlight color from the GTK theme
+		/// </summary>
+		/// <returns>
+		/// An hexadecimal color string (ex #ffffff)
+		/// </returns>
+		private string GetHighlightColor ()
+		{
+			Gdk.Color fgColor;
+
+			using (Gtk.Style style = Gtk.Rc.GetStyle (this)) 
+				fgColor = style.Backgrounds [(int) StateType.Selected];
+
+			return Utilities.ColorGetHex (fgColor);
+		}
+		
 		#endregion // Private Methods
 		
 		#region Event Handlers

Modified: trunk/src/TaskWindow.cs
==============================================================================
--- trunk/src/TaskWindow.cs	(original)
+++ trunk/src/TaskWindow.cs	Tue Oct 21 15:17:05 2008
@@ -30,6 +30,7 @@
 
 using System;
 using System.Collections.Generic;
+using Gdk;
 using Gtk;
 using Mono.Unix;
 
@@ -58,7 +59,8 @@
 		private TaskGroup nextSevenDaysGroup;
 		private TaskGroup futureGroup;
 		private CompletedTaskGroup completedTaskGroup;
-		
+		private EventBox innerEb;
+
 		private List<TaskGroup> taskGroups;
 		
 		private Dictionary<ITask, NoteDialog> noteDialogs;
@@ -81,7 +83,7 @@
 			noteIcon = Utilities.GetIcon ("note", 16);
 		}
 		
-		public TaskWindow (IBackend aBackend) : base (WindowType.Toplevel)
+		public TaskWindow (IBackend aBackend) : base (Gtk.WindowType.Toplevel)
 		{
 			this.backend = aBackend;
 			taskGroups = new List<TaskGroup> ();
@@ -156,7 +158,7 @@
 			
 			// Use a small add icon so the button isn't mammoth-sized
 			HBox buttonHBox = new HBox (false, 6);
-			Image addImage = new Image (Gtk.Stock.Add, IconSize.Menu);
+			Gtk.Image addImage = new Gtk.Image (Gtk.Stock.Add, IconSize.Menu);
 			addImage.Show ();
 			buttonHBox.PackStart (addImage, false, false, 0);
 			Label l = new Label (Catalog.GetString ("_Add"));
@@ -166,7 +168,7 @@
 			addTaskButton = 
 				new MenuToolButton (buttonHBox, Catalog.GetString ("_Add Task"));
 			addTaskButton.UseUnderline = true;
-		    	// Disactivate the button until the backend is initialized
+			// Disactivate the button until the backend is initialized
 			addTaskButton.Sensitive = false;
 			Gtk.Menu addTaskMenu = new Gtk.Menu ();
 			addTaskButton.Menu = addTaskMenu;
@@ -175,15 +177,15 @@
 			topHBox.PackStart (addTaskButton, false, false, 0);
 			
 			globalKeys.AddAccelerator (OnGrabEntryFocus,
-			                           (uint) Gdk.Key.n,
-			                           Gdk.ModifierType.ControlMask,
-			                           Gtk.AccelFlags.Visible);
+						(uint) Gdk.Key.n,
+						Gdk.ModifierType.ControlMask,
+						Gtk.AccelFlags.Visible);
 			
 			globalKeys.AddAccelerator (delegate (object sender, EventArgs e) {
 				Application.Instance.Quit (); },
-			                           (uint) Gdk.Key.q,
-			                           Gdk.ModifierType.ControlMask,
-			                           Gtk.AccelFlags.Visible);
+						(uint) Gdk.Key.q,
+						Gdk.ModifierType.ControlMask,
+						Gtk.AccelFlags.Visible);
 			
 			topHBox.Show ();
 			mainVBox.PackStart (topHBox, false, false, 0);
@@ -197,17 +199,11 @@
 			scrolledWindow.Show ();
 			mainVBox.PackStart (scrolledWindow, true, true, 0);
 
-			EventBox innerEb = new EventBox();
+			innerEb = new EventBox();
 			innerEb.BorderWidth = 0;
-			innerEb.ModifyBg(	StateType.Normal, 
-						new Gdk.Color(255,255,255));
-			innerEb.ModifyBase(	StateType.Normal, 
-						new Gdk.Color(255,255,255));
-
-			targetVBox = new VBox();
-			targetVBox.BorderWidth = 5;
-			targetVBox.Show ();
-			innerEb.Add(targetVBox);
+			Gdk.Color backgroundColor = GetBackgroundColor ();
+			innerEb.ModifyBg (StateType.Normal, backgroundColor);
+			innerEb.ModifyBase (StateType.Normal, backgroundColor);
 
 			scrolledWindow.AddWithViewport(innerEb);
 			
@@ -238,8 +234,13 @@
 
 		void PopulateWindow()
 		{
+			if (targetVBox != null)
+				targetVBox.Destroy ();
 			
-
+			targetVBox = new VBox();
+			targetVBox.BorderWidth = 5;
+			targetVBox.Show ();
+			innerEb.Add(targetVBox);
 			// Add in the groups
 			
 			//
@@ -801,9 +802,31 @@
 			
 			return task;
 		}
+		
+		/// <summary>
+		/// This returns the current input widget color from the GTK theme
+		/// </summary>
+		/// <returns>
+		/// A Gdk.Color
+		/// </returns>
+		private Gdk.Color GetBackgroundColor ()
+		{
+			using (Gtk.Style style = Gtk.Rc.GetStyle (this)) 
+				return style.Base (StateType.Normal);
+		}
+		
 		#endregion // Private Methods
 
 		#region Event Handlers
+		protected override void OnStyleSet (Gtk.Style previous_style)
+		{
+			base.OnStyleSet (previous_style);
+			Gdk.Color backgroundColor = GetBackgroundColor ();
+			innerEb.ModifyBg (StateType.Normal, backgroundColor);
+			innerEb.ModifyBase (StateType.Normal, backgroundColor);
+			PopulateWindow ();
+		}
+		
 		private void OnRealized (object sender, EventArgs args)
 		{
 			addTaskEntry.GrabFocus ();
@@ -1042,19 +1065,19 @@
 					ImageMenuItem item;
 					
 					item = new ImageMenuItem (Catalog.GetString ("_Notes..."));
-					item.Image = new Image (noteIcon);
+					item.Image = new Gtk.Image (noteIcon);
 					item.Activated += OnShowTaskNotes;
 					popupMenu.Add (item);
 					
 					popupMenu.Add (new SeparatorMenuItem ());
 
 					item = new ImageMenuItem (Catalog.GetString ("_Delete task"));
-					item.Image = new Image(Gtk.Stock.Delete, IconSize.Menu);
+					item.Image = new Gtk.Image(Gtk.Stock.Delete, IconSize.Menu);
 					item.Activated += OnDeleteTask;
 					popupMenu.Add (item);
 
 					item = new ImageMenuItem(Catalog.GetString ("_Edit task"));
-					item.Image = new Image(Gtk.Stock.Edit, IconSize.Menu);
+					item.Image = new Gtk.Image(Gtk.Stock.Edit, IconSize.Menu);
 					item.Activated += OnEditTask;
 					popupMenu.Add (item);
 

Modified: trunk/src/Utilities.cs
==============================================================================
--- trunk/src/Utilities.cs	(original)
+++ trunk/src/Utilities.cs	Tue Oct 21 15:17:05 2008
@@ -36,7 +36,8 @@
 using System.IO;
 using System.Security.Cryptography;
 using Mono.Unix;
-
+using Gdk;
+using Gtk;
 
 namespace Tasque
 {
@@ -397,5 +398,19 @@
 			parsedDueDate = DateTime.MinValue;
 			return;
 		}
+
+		/// <summary>
+		/// This returns the hexadecimal value of an GDK color.
+		/// </summary>
+		/// <param name="color">
+		/// The color to convert to a hex string.
+		/// </param>
+		public static string ColorGetHex (Gdk.Color color)
+		{
+			return String.Format ("#{0:x2}{1:x2}{2:x2}",
+			                      (byte)(color.Red >> 8),
+			                      (byte)(color.Green >> 8),
+			                      (byte)(color.Blue >> 8));
+		}
 	}
 }



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