Last.FM account dialog: Save+Close on Enter

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Last.FM account dialog: Save+Close on Enter

Peter de Kraker-2
Hi,

It was bothering me for a long time that the Last.FM account dialog,
where you enter your username and password, didn't responded to pressing
Enter. Since I am starting with C# I thought of it as a nice challenge
to try to fix it myself and this is the (probably crappy but working)
result. I hope it is not a problem if I as a newbie  post it here for
some feedback.

Index: src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs
===================================================================
--- src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs    (revision
4052)
+++ src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs    (working
copy)
@@ -64,6 +64,13 @@
           
             password_entry = new Entry ();
             password_entry.Visibility = false;
+
+            //When the user presses enter in the password field: save,
and then destroy the AcountLoginDialog
+            password_entry.Activated += delegate {
+                    this.Save ();
+                    this.Parent.Parent.Parent.Parent.Destroy
();                  
+                    };
+          
             password_entry.Show ();
           
             Attach (username_label, 0, 1, 0, 1, AttachOptions.Fill,


* I would guess that the Parent.[..].Parent stuff is not the best way to
close the Dialog, but I couldn't think of another way since the form is
a sub(x4)child of the AccountLoginDialog. Is there a better way?

* What is the use for the addCloseButton option in AccountLoginDialog? I
understand what it does, but not why it is optional.  I couldn't find a
reference to it that used it (everything calls with bool true), but if
it is really in use or important, I guess that my code should be moved
to a method, that gets called in the  "if (addCloseButton)" section.


Another thing: it took me quite some time to partly understand the code
of Lastfm.Gui, and I would really like to know why almost all the code
of the whole of Banshee is uncommented. Am I missing something or am I
supposed to understand banshee only by code? I have not really seen code
of other O/S projects but I thought it was common practice to document
code properly?

Anyway, looking forward to 1.0 and a lot of succes to the real devs !

Peter de Kraker





Index: src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs
===================================================================
--- src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs (revision 4052)
+++ src/Libraries/Lastfm.Gui/Lastfm.Gui/AccountLoginForm.cs (working copy)
@@ -64,6 +64,13 @@
             
             password_entry = new Entry ();
             password_entry.Visibility = false;
+
+            //When the user presses enter in the password field: save, and then destroy the AcountLoginDialog
+            password_entry.Activated += delegate {
+                    this.Save ();
+                    this.Parent.Parent.Parent.Parent.Destroy ();                    
+                    };
+            
             password_entry.Show ();
             
             Attach (username_label, 0, 1, 0, 1, AttachOptions.Fill,

_______________________________________________
Banshee-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/banshee-list
Reply | Threaded
Open this post in threaded view
|

Re: Last.FM account dialog: Save+Close on Enter

Bertrand Lorentz
Administrator
On Sat, 2008-05-31 at 23:18 +0200, Peter de Kraker wrote:

> Another thing: it took me quite some time to partly understand the code
> of Lastfm.Gui, and I would really like to know why almost all the code
> of the whole of Banshee is uncommented. Am I missing something or am I
> supposed to understand banshee only by code? I have not really seen code
> of other O/S projects but I thought it was common practice to document
> code properly?

I think the idea here is to keep the code clean and have the source
documentation (class descriptions, etc.) in separate XML files. They can
be packaged and used in monodoc.

Those files are in the docs/ directory, but they seem to be empty stubs.

Cheers,

--
Bertrand Lorentz <[hidden email]>
> http://flickr.com/photos/bl8/ <

_______________________________________________
Banshee-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/banshee-list

signature.asc (204 bytes) Download Attachment