private void PopulateGoogleOptionMenu (GoogleAccountManager manager, GoogleAccount changed_account)
		{
			Gtk.Menu menu = new Gtk.Menu ();
			this.account = changed_account;
			int pos = -1;

			accounts = manager.GetAccounts ();
			if (accounts == null || accounts.Count == 0) {
				Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("(No Gallery)"));
				menu.Append (item);
				gallery_optionmenu.Sensitive = false;
				edit_button.Sensitive = false;
			} else {
				int i = 0;
				foreach (GoogleAccount account in accounts) {
					if (account == changed_account)
						pos = i;

					Gtk.MenuItem item = new Gtk.MenuItem (account.Username);
					menu.Append (item);
					i++;
				}
				gallery_optionmenu.Sensitive = true;
				edit_button.Sensitive = true;
			}

			menu.ShowAll ();
			gallery_optionmenu.Menu = menu;
			gallery_optionmenu.SetHistory ((uint)pos);
		}
        public static GoogleAccountManager GetInstance()
        {
            if (instance == null) {
                instance = new GoogleAccountManager ();
            }

            return instance;
        }
Esempio n. 3
0
        private void PopulateGoogleOptionMenu(GoogleAccountManager manager, GoogleAccount changed_account)
        {
            this.account = changed_account;
            int pos = -1;

            accounts = manager.GetAccounts ();
            if (accounts == null || accounts.Count == 0) {

                if (accounts == null)
                    Log.Debug ("accounts == null");
                else
                    Log.Debug ("accounts != null");

                Log.DebugFormat ("accounts.Count = {0}", accounts.Count);

                gallery_optionmenu.AppendText (Catalog.GetString ("(No Gallery)"));
                gallery_optionmenu.Sensitive = false;
                edit_button.Sensitive = false;

                pos = 0;
            } else {
                int i = 0;
                pos = 0;
                foreach (GoogleAccount account in accounts) {
                    if (account == changed_account)
                        pos = i;

                    gallery_optionmenu.AppendText (account.Username);
                    i++;
                }
                gallery_optionmenu.Sensitive = true;
                edit_button.Sensitive = true;
            }

            Log.DebugFormat ("Setting gallery_optionmenu.Active = {0}", pos);
            gallery_optionmenu.Active = pos;
        }