banshee r3390 - in trunk/banshee: . build build/m4/shamrock src/Core/Banshee.Widgets src/Core/Banshee.Widgets/Banshee.Widgets tests



Author: abock
Date: Thu Mar  6 22:13:41 2008
New Revision: 3390
URL: http://svn.gnome.org/viewvc/banshee?rev=3390&view=rev

Log:
2008-03-06  Aaron Bockover  <abock gnome org>

    * src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs:
    Render the buffering progress bar using the GTK styles, take care of
    the pango layout manually instead of using a GtkLabel to be able
    to render the text in two colors, depending on the progress bar

    * build/build.rules.mk: Do not pass -warnaserror if mono is older than
    1.2.4 since there appear to be some fake warnings raised with the older
    gmcs compiler

    * build/m4/shamrock/mono.m4: Added a method to detect the mono version but
    not bail if it wasn't met, and set a result

    * configure.ac: Check for at least mono 1.2.4 and export the result



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/build/build.rules.mk
   trunk/banshee/build/m4/shamrock/mono.m4
   trunk/banshee/configure.ac
   trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets.mdp
   trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
   trunk/banshee/tests/Makefile.am

Modified: trunk/banshee/build/build.rules.mk
==============================================================================
--- trunk/banshee/build/build.rules.mk	(original)
+++ trunk/banshee/build/build.rules.mk	Thu Mar  6 22:13:41 2008
@@ -33,7 +33,7 @@
 	test "x$$colors" = "xyes" && \
 		echo -e "\033[1mCompiling $(notdir $@)...\033[0m" || \
 		echo "Compiling $(notdir $@)...";
-	@test "x$(top_srcdir)" = "x$(top_builddir)" && warn="-warnaserror"; $(BUILD) -target:$(TARGET) -out:$@ $$warn $(LINK) $(RESOURCES_BUILD) $(SOURCES_BUILD)
+	@test "x$(HAVE_MONO_1_2_6)" = "xyes" && warn="-warnaserror"; $(BUILD) -target:$(TARGET) -out:$@ $$warn $(LINK) $(RESOURCES_BUILD) $(SOURCES_BUILD)
 	@if [ -e $(notdir $  config) ]; then \
 		cp $(notdir $  config) $(top_builddir)/bin; \
 	fi;

Modified: trunk/banshee/build/m4/shamrock/mono.m4
==============================================================================
--- trunk/banshee/build/m4/shamrock/mono.m4	(original)
+++ trunk/banshee/build/m4/shamrock/mono.m4	Thu Mar  6 22:13:41 2008
@@ -18,6 +18,13 @@
 	PKG_CHECK_MODULES(MONO_MODULE, mono >= $1)
 ])
 
+AC_DEFUN([SHAMROCK_CHECK_MONO_MODULE_NOBAIL],
+[
+	PKG_CHECK_MODULES(MONO_MODULE, mono >= $1, 
+		HAVE_MONO_MODULE=yes, HAVE_MONO_MODULE=no)
+	AC_SUBST(HAVE_MONO_MODULE)
+])
+
 AC_DEFUN([_SHAMROCK_CHECK_MONO_GAC_ASSEMBLIES],
 [
 	for asm in $(echo "$*" | cut -d, -f2- | sed 's/\,/ /g')

Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac	(original)
+++ trunk/banshee/configure.ac	Thu Mar  6 22:13:41 2008
@@ -37,6 +37,7 @@
 ])
 
 dnl Mono and gmcs
+SHAMROCK_CHECK_MONO_MODULE_NOBAIL(1.2.4)
 SHAMROCK_CHECK_MONO_MODULE(1.1.10)
 SHAMROCK_FIND_MONO_2_0_COMPILER
 SHAMROCK_FIND_MONO_RUNTIME
@@ -50,6 +51,9 @@
 	ICSharpCode.SharpZipLib
 ])
 
+HAVE_MONO_1_2_6=$HAVE_MONO_MODULE
+AC_SUBST(HAVE_MONO_1_2_6)
+
 dnl NDesk DBus libraries
 BANSHEE_CHECK_NDESK_DBUS
 
@@ -164,6 +168,7 @@
     C Compiler:        ${CC}
     Mono C# Compiler:  ${MCS}
     Mono Runtime:      ${MONO}
+    Mono >= 1.2.6:     ${HAVE_MONO_1_2_6}
 "
 #    Digital Audio Players (DAP):
 #      iPod:            ${enable_ipodsharp}

Modified: trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets.mdp	Thu Mar  6 22:13:41 2008
@@ -51,6 +51,7 @@
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
   </References>
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="Makefile.am">
     <BuildFilesVar Sync="True" Name="SOURCES" />

Modified: trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs	Thu Mar  6 22:13:41 2008
@@ -1,30 +1,30 @@
-/***************************************************************************
- *  StreamPositionLabel.cs
- *
- *  Copyright (C) 2006 Novell, Inc.
- *  Written by Aaron Bockover <aaron abock org>
- ****************************************************************************/
-
-/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
- *
- *  Permission is hereby granted, free of charge, to any person obtaining a
- *  copy of this software and associated documentation files (the "Software"),  
- *  to deal in the Software without restriction, including without limitation  
- *  the rights to use, copy, modify, merge, publish, distribute, sublicense,  
- *  and/or sell copies of the Software, and to permit persons to whom the  
- *  Software is furnished to do so, subject to the following conditions:
- *
- *  The above copyright notice and this permission notice shall be included in 
- *  all copies or substantial portions of the Software.
- *
- *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
- *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
- *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
- *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
- *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
- *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
- *  DEALINGS IN THE SOFTWARE.
- */
+//
+// StreamPositionLabel.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2006-2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 
 using System;
 using Mono.Unix;
@@ -34,98 +34,131 @@
 {
     public class StreamPositionLabel : Alignment
     {
-        private Gdk.GC bar_gc;
         private double buffering_progress;
         private bool is_buffering;
         private bool is_contacting;
         private SeekSlider seekRange;
-        private Label label;
         private string format_string = "<small>{0}</small>";
+        private Pango.Layout layout;
         
-        public StreamPositionLabel(SeekSlider seekRange) : base(0.0f, 0.0f, 1.0f, 1.0f)
+        public StreamPositionLabel (SeekSlider seekRange) : base (0.0f, 0.0f, 1.0f, 1.0f)
         {
             AppPaintable = true;
             
-            label = new Label();
-            label.Show();
-            Add(label);
-            
             this.seekRange = seekRange;
             this.seekRange.ValueChanged += OnSliderUpdated;
             this.seekRange.DurationChanged += OnSliderUpdated;
+
+            BuildLayouts ();
+            UpdateLabel ();
+        }
+        
+        private void BuildLayouts ()
+        {
+            layout = new Pango.Layout (PangoContext);
+            layout.FontDescription = PangoContext.FontDescription.Copy ();
+            layout.Ellipsize = Pango.EllipsizeMode.None;
+            
+            layout.SetMarkup (String.Format (format_string, "W"));
             
-            UpdateLabel();
+            int width, height;
+            layout.GetPixelSize (out width, out height);
+            HeightRequest = height;
         }
         
-        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
+        protected override bool OnExposeEvent (Gdk.EventExpose evnt)
         {
-            if(bar_gc == null) {
-                bar_gc = new Gdk.GC(GdkWindow);
-                Gdk.Color color = DrawingUtilities.ColorBlend(Style.Background(StateType.Normal), 
-                    Style.Foreground(StateType.Normal), 0.2);
-                bar_gc.Background = color;
-                bar_gc.Foreground = color;
+            int bar_width = (int)((double)Allocation.Width * buffering_progress);
+            bool render_bar = false;
+            
+            if (bar_width > 0 && is_buffering) {
+                bar_width -= 2 * Style.XThickness;
+                render_bar = true;
+                
+                Gtk.Style.PaintBox (Style, GdkWindow, StateType.Normal, ShadowType.In, evnt.Area, this, null, 
+                    Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
+                
+                if (bar_width > 0) {
+                    Gtk.Style.PaintBox (Style, GdkWindow, StateType.Selected, ShadowType.EtchedOut, 
+                        evnt.Area, this, "bar", 
+                        Allocation.X + Style.XThickness, Allocation.Y + Style.YThickness, 
+                        bar_width, Allocation.Height - 2 * Style.YThickness);
+                }
             }
             
-            int bar_width = (int)((double)Allocation.Width * buffering_progress);
-            if(bar_width > 0 && is_buffering) {
-                GdkWindow.DrawRectangle(bar_gc, true, Allocation.X, Allocation.Y, bar_width, Allocation.Height);
+            int width, height;
+            layout.GetPixelSize (out width, out height);
+            
+            int x = Allocation.X + ((Allocation.Width - width) / 2);
+            int y = Allocation.Y + ((Allocation.Height - HeightRequest) / 2);
+            Gdk.Rectangle rect = evnt.Area;
+            
+            if (render_bar) {
+                width = bar_width + Style.XThickness;
+                rect = new Gdk.Rectangle (evnt.Area.X, evnt.Area.Y, width, evnt.Area.Height);
+                Gtk.Style.PaintLayout (Style, GdkWindow, StateType.Selected, true, rect, this, null, x, y, layout);
+                
+                rect.X += rect.Width;
+                rect.Width = evnt.Area.Width - rect.Width;
             }
             
-            return base.OnExposeEvent(evnt);
+            Gtk.Style.PaintLayout (Style, GdkWindow, StateType.Normal, true, rect, this, null, x, y, layout);
+            
+            return true;
         }
         
-        private void UpdateLabel()
+        private void UpdateLabel ()
         {
-            if(is_buffering) {
+            if (is_buffering) {
                 double progress = buffering_progress * 100.0;
-                UpdateLabel(Catalog.GetString("Buffering") + ": " + progress.ToString("0.0") + "%");
-            } else if(is_contacting) {
-                UpdateLabel(Catalog.GetString("Contacting..."));
-            } else if(seekRange.Value == 0 && seekRange.Duration == 0) {
-                UpdateLabel(Catalog.GetString("Idle"));
-            } else if(seekRange.Value == seekRange.Duration) {
-                UpdateLabel(FormatDuration((long)seekRange.Value));
+                UpdateLabel (Catalog.GetString("Buffering") + ": " + progress.ToString ("0.0") + "%");
+            } else if (is_contacting) {
+                UpdateLabel (Catalog.GetString ("Contacting..."));
+            } else if (seekRange.Value == 0 && seekRange.Duration == 0) {
+                UpdateLabel (Catalog.GetString ("Idle"));
+            } else if (seekRange.Value == seekRange.Duration) {
+                UpdateLabel (FormatDuration ((long)seekRange.Value));
             } else {
-                UpdateLabel(String.Format(Catalog.GetString("{0} of {1}"),
-                    FormatDuration((long)seekRange.Value), FormatDuration((long)seekRange.Adjustment.Upper)));
+                UpdateLabel (String.Format (Catalog.GetString ("{0} of {1}"),
+                    FormatDuration ((long)seekRange.Value), FormatDuration ((long)seekRange.Adjustment.Upper)));
             }
         }
         
-        private void UpdateLabel(string text)
+        private void UpdateLabel (string text)
         {
-            label.Markup = String.Format(format_string, GLib.Markup.EscapeText(text));
+            layout.SetMarkup (String.Format (format_string, GLib.Markup.EscapeText (text)));
+            QueueDraw ();
         }
         
-        private static string FormatDuration(long time)
+        private static string FormatDuration (long time)
         {
             time /= 1000;
             return (time > 3600 ? 
-                    String.Format("{0}:{1:00}:{2:00}", time / 3600, (time / 60) % 60, time % 60) :
-                    String.Format("{0}:{1:00}", time / 60, time % 60));
+                    String.Format ("{0}:{1:00}:{2:00}", time / 3600, (time / 60) % 60, time % 60) :
+                    String.Format ("{0}:{1:00}", time / 60, time % 60));
         }
         
-        private void OnSliderUpdated(object o, EventArgs args)
+        private void OnSliderUpdated (object o, EventArgs args)
         {
-            UpdateLabel();
+            UpdateLabel ();
         }
         
         public double BufferingProgress {
             get { return buffering_progress; }
             set {
-                buffering_progress = Math.Max(0.0, Math.Min(1.0, value));
-                UpdateLabel();
-                QueueDraw();
+                buffering_progress = Math.Max (0.0, Math.Min (1.0, value));
+                UpdateLabel ();
+                QueueDraw ();
             }
         }
         
         public bool IsBuffering {
             get { return is_buffering; }
             set { 
-                if(is_buffering != value) {
+                if (is_buffering != value) {
                     is_buffering = value;
-                    UpdateLabel();
-                    QueueDraw();
+                    UpdateLabel ();
+                    QueueDraw ();
                 }
             }
         }
@@ -133,10 +166,10 @@
         public bool IsContacting {
             get { return is_contacting; }
             set { 
-                if(is_contacting != value) {
+                if (is_contacting != value) {
                     is_contacting = value;
-                    UpdateLabel();
-                    QueueDraw();
+                    UpdateLabel ();
+                    QueueDraw ();
                 }
             }
         }
@@ -144,7 +177,7 @@
         public string FormatString {
             set { 
                 format_string = value;
-                UpdateLabel();
+                UpdateLabel ();
             }
         }
     }

Modified: trunk/banshee/tests/Makefile.am
==============================================================================
--- trunk/banshee/tests/Makefile.am	(original)
+++ trunk/banshee/tests/Makefile.am	Thu Mar  6 22:13:41 2008
@@ -5,7 +5,7 @@
 
 ASSEMBLY_NAME = banshee-tests
 ASSEMBLY = $(ASSEMBLY_NAME).dll
-ASSEMBLY_CSFILES = \
+ASSEMBLY_CSFILES =  \
 	$(srcdir)/Hyena/CryptoUtilTests.cs \
 	$(srcdir)/Hyena/RangeCollectionTests.cs \
 	$(srcdir)/Hyena/StringUtilTests.cs



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