[banshee] [Lastfm] Use a GTK LinkButton for the badge and signup buttons



commit 113f206b276503eb397dea0de7ed4175b1aebf53
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Fri Jun 26 19:00:10 2009 +0200

    [Lastfm] Use a GTK LinkButton for the badge and signup buttons
    
    The Lastfm.LinkButton is removed, and the GTK LinkButton is used
    instead, for the badge and signup button in the account configuration
    dialog. This also fixes BGO#586978.

 src/Libraries/Lastfm.Gui/Lastfm.Gui.csproj         |    1 -
 .../Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs      |    3 +-
 src/Libraries/Lastfm.Gui/Lastfm.Gui/Badge.cs       |   30 +------
 src/Libraries/Lastfm.Gui/Lastfm.Gui/LinkButton.cs  |   81 --------------------
 src/Libraries/Lastfm.Gui/Makefile.am               |    3 +-
 src/Libraries/Lastfm/Lastfm/Account.cs             |   12 +++-
 6 files changed, 17 insertions(+), 113 deletions(-)
---
diff --git a/src/Libraries/Lastfm.Gui/Lastfm.Gui.csproj b/src/Libraries/Lastfm.Gui/Lastfm.Gui.csproj
index 6ce399b..8866c70 100644
--- a/src/Libraries/Lastfm.Gui/Lastfm.Gui.csproj
+++ b/src/Libraries/Lastfm.Gui/Lastfm.Gui.csproj
@@ -50,7 +50,6 @@
     <Compile Include="Lastfm.Gui\AccountLoginDialog.cs" />
     <Compile Include="Lastfm.Gui\AccountLoginForm.cs" />
     <Compile Include="Lastfm.Gui\Badge.cs" />
-    <Compile Include="Lastfm.Gui\LinkButton.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
diff --git a/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs b/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs
index 1946aa2..00c04cc 100644
--- a/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs
+++ b/src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs
@@ -110,8 +110,7 @@ namespace Lastfm.Gui
             }
             
             Resize (3, 2);
-            signup_button = new LinkButton (Catalog.GetString ("Sign up for Last.fm"));
-            signup_button.Clicked += delegate { account.SignUp (); };
+            signup_button = new LinkButton (account.SignUpUrl, Catalog.GetString ("Sign up for Last.fm"));
             signup_button.Show ();
             Attach (signup_button, 1, 2, 2, 3, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
         }
diff --git a/src/Libraries/Lastfm.Gui/Lastfm.Gui/Badge.cs b/src/Libraries/Lastfm.Gui/Lastfm.Gui/Badge.cs
index d29a2f5..3245ee0 100644
--- a/src/Libraries/Lastfm.Gui/Lastfm.Gui/Badge.cs
+++ b/src/Libraries/Lastfm.Gui/Lastfm.Gui/Badge.cs
@@ -34,31 +34,26 @@ using Lastfm;
 
 namespace Lastfm.Gui
 {
-    public class Badge : Gtk.EventBox
+    public class Badge : Gtk.LinkButton
     {
-        private static Gdk.Cursor hand_cursor = new Gdk.Cursor (Gdk.CursorType.Hand1);
         private static Gdk.Pixbuf pixbuf = Gdk.Pixbuf.LoadFromResource ("badge.png");
         private static Gdk.Pixbuf pixbuf_hover = Gdk.Pixbuf.LoadFromResource ("badge-hover.png");
         
-        private Account account;
         private Image image;
         private bool link = true;
         
-        public Badge (Account account) : base ()
+        public Badge (Account account) : base (account.HomePageUrl)
         {
-            this.account = account;
             image = new Image ();
             image.Pixbuf = pixbuf;
             image.Xalign = 0.0f;
-            image.Show ();
-            Add (image);
+            Image = image;
         }
                 
         protected override bool OnEnterNotifyEvent (Gdk.EventCrossing evnt)
         {
             if (link) {
-                GdkWindow.Cursor = hand_cursor;
-                image.Pixbuf = pixbuf_hover;
+                (Image as Image).Pixbuf = pixbuf_hover;
             }
             
             return base.OnEnterNotifyEvent (evnt);
@@ -66,26 +61,11 @@ namespace Lastfm.Gui
 
         protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing evnt)
         {
-            image.Pixbuf = pixbuf;
-            GdkWindow.Cursor = null;
+            (Image as Image).Pixbuf = pixbuf;
             
             return base.OnLeaveNotifyEvent (evnt);
         }
         
-        protected override bool OnButtonReleaseEvent (Gdk.EventButton evnt)
-        {
-            if (evnt.Button == 1) {
-                account.VisitHomePage ();
-            }
-            
-            return base.OnButtonReleaseEvent (evnt);
-        }
-        
-        public bool Link {
-            get { return link; }
-            set { link = value; }
-        }
-        
         public static Gdk.Pixbuf Pixbuf {
             get { return pixbuf; }
         }
diff --git a/src/Libraries/Lastfm.Gui/Makefile.am b/src/Libraries/Lastfm.Gui/Makefile.am
index 7abccd7..fe3a3be 100644
--- a/src/Libraries/Lastfm.Gui/Makefile.am
+++ b/src/Libraries/Lastfm.Gui/Makefile.am
@@ -5,8 +5,7 @@ LINK = $(REF_LASTFM_GUI)
 SOURCES =  \
 	Lastfm.Gui/AccountLoginDialog.cs \
 	Lastfm.Gui/AccountLoginForm.cs \
-	Lastfm.Gui/Badge.cs \
-	Lastfm.Gui/LinkButton.cs
+	Lastfm.Gui/Badge.cs
 
 RESOURCES =  \
 	Resources/badge.png \
diff --git a/src/Libraries/Lastfm/Lastfm/Account.cs b/src/Libraries/Lastfm/Lastfm/Account.cs
index b5aba1c..de82369 100644
--- a/src/Libraries/Lastfm/Lastfm/Account.cs
+++ b/src/Libraries/Lastfm/Lastfm/Account.cs
@@ -72,9 +72,13 @@ namespace Lastfm
             set { scrobble_url = value; }
         }
 
+        public string SignUpUrl {
+            get { return "http://www.last.fm/join";; }
+        }
+
         public void SignUp ()
         {
-            Browser.Open ("http://www.last.fm/join";);
+            Browser.Open (SignUpUrl);
         }
         
         public void VisitUserProfile (string username)
@@ -82,9 +86,13 @@ namespace Lastfm
             Browser.Open (String.Format ("http://last.fm/user/{0}";, username));
         }
         
+        public string HomePageUrl {
+            get { return "http://www.last.fm/";; }
+        }
+        
         public void VisitHomePage ()
         {
-            Browser.Open ("http://last.fm/";);
+            Browser.Open (HomePageUrl);
         }
         
         public virtual void Save ()



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