Beispiel #1
0
        private void UpdateUI()
        {
            bool have_user        = Account.UserName != null;
            bool have_session_key = Account.SessionKey != null;

            if (have_session_key)
            {
                LastSessionKeySchema.Set(Account.SessionKey);
                LastIsSubscriberSchema.Set(Account.Subscriber);
            }

            if (have_user)
            {
                SetUserName(Account.UserName);
            }
            else
            {
                ClearChildSources();
            }

            if (Connection.Connected)
            {
                HideStatus();
            }
            else
            {
                SetStatus(RadioConnection.MessageFor(Connection.State), Connection.State != ConnectionState.Connecting, Connection.State);
            }

            OnUpdated();
        }
Beispiel #2
0
        private void OnPreferencesServiceInstallWidgetAdapters(object sender, EventArgs args)
        {
            if (pref_section == null)
            {
                return;
            }

            var user_entry = new Gtk.Entry(user_pref.Value ?? "");

            user_entry.Changed += (o, a) => { user_pref.Value = user_entry.Text; };

            var auth_button = new Gtk.Button(Authorized ? Catalog.GetString("Authorized!") : Catalog.GetString("Authorize..."));

            user_pref.ValueChanged += (s) => { auth_button.Sensitive = NeedAuth; };
            auth_button.Sensitive   = NeedAuth;
            auth_button.TooltipText = Catalog.GetString("Open Last.fm in a browser, giving you the option to authorize Banshee to work with your account");
            auth_button.Clicked    += delegate {
                account.SessionKey = null;
                account.RequestAuthorization();
            };

            var signup_button = new Gtk.LinkButton(account.SignUpUrl, Catalog.GetString("Sign up for Last.fm"));

            signup_button.Xalign = 0f;

            var refresh_button = new Gtk.Button(new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Button));

            user_pref.ValueChanged    += (s) => { refresh_button.Sensitive = NeedAuth; };
            refresh_button.Sensitive   = NeedAuth;
            refresh_button.TooltipText = Catalog.GetString("Check if Banshee has been authorized");
            refresh_button.Clicked    += delegate {
                if (String.IsNullOrEmpty(account.UserName) || account.SessionKey == null)
                {
                    account.UserName = LastUserSchema.Get();
                    account.FetchSessionKey();
                    account.Save();
                    LastSessionKeySchema.Set(account.SessionKey);
                }

                auth_button.Sensitive = refresh_button.Sensitive = NeedAuth;
                auth_button.Label     = Authorized
                    ? Catalog.GetString("Authorized!")
                    : Catalog.GetString("Authorize...");
            };

            var auth_box = new Gtk.HBox()
            {
                Spacing = 6
            };

            auth_box.PackStart(user_entry, true, true, 0);
            auth_box.PackStart(auth_button, false, false, 0);
            auth_box.PackStart(refresh_button, false, false, 0);
            auth_box.ShowAll();

            signup_button.Visible = String.IsNullOrEmpty(user_pref.Value);

            var button_box = new Gtk.HBox()
            {
                Spacing = 6
            };

            button_box.PackStart(new Badge(account)
            {
                Visible = true
            }, false, false, 0);
            button_box.PackStart(signup_button, true, true, 0);

            user_pref.DisplayWidget = auth_box;
            pref_section["lastfm-signup"].DisplayWidget = button_box;
        }