summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/gtk/options/passwords_page_gtk.cc40
-rw-r--r--chrome/browser/gtk/options/passwords_page_gtk.h1
2 files changed, 26 insertions, 15 deletions
diff --git a/chrome/browser/gtk/options/passwords_page_gtk.cc b/chrome/browser/gtk/options/passwords_page_gtk.cc
index 1d2d79f..96829f1 100644
--- a/chrome/browser/gtk/options/passwords_page_gtk.cc
+++ b/chrome/browser/gtk/options/passwords_page_gtk.cc
@@ -52,26 +52,14 @@ PasswordsPageGtk::PasswordsPageGtk(Profile* profile)
g_signal_connect(remove_all_button_, "clicked",
G_CALLBACK(OnRemoveAllButtonClickedThunk), this);
+ // We start with the "hide password" text but change it in the realize event.
show_password_button_ = gtk_button_new_with_label(
l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON).c_str());
- GtkRequisition hide_size, show_size;
- // Get the size request of the button with the "hide password" text.
- gtk_widget_size_request(show_password_button_, &hide_size);
- gtk_button_set_label(GTK_BUTTON(show_password_button_),
- l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str());
- // Get the size request of the button with the "show password" text.
- gtk_widget_size_request(show_password_button_, &show_size);
- // Determine the maximum width and height.
- if (hide_size.width > show_size.width)
- show_size.width = hide_size.width;
- if (hide_size.height > show_size.height)
- show_size.height = hide_size.height;
- // Force the button to be large enough for both labels.
- gtk_widget_set_size_request(show_password_button_, show_size.width,
- show_size.height);
gtk_widget_set_sensitive(show_password_button_, FALSE);
g_signal_connect(show_password_button_, "clicked",
G_CALLBACK(OnShowPasswordButtonClickedThunk), this);
+ g_signal_connect(show_password_button_, "realize",
+ G_CALLBACK(OnShowPasswordButtonRealizedThunk), this);
password_ = gtk_label_new("");
@@ -265,6 +253,28 @@ void PasswordsPageGtk::OnShowPasswordButtonClicked(GtkWidget* widget) {
l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON).c_str());
}
+void PasswordsPageGtk::OnShowPasswordButtonRealized(GtkWidget* widget) {
+ // We have just realized the "show password" button, so we can now accurately
+ // find out how big it needs to be in order to accomodate both the "show" and
+ // "hide" labels. (This requires font information to work correctly.) The
+ // button starts with the "hide" label so we only have to change it once.
+ GtkRequisition hide_size, show_size;
+ // Get the size request of the button with the "hide password" text.
+ gtk_widget_size_request(show_password_button_, &hide_size);
+ gtk_button_set_label(GTK_BUTTON(show_password_button_),
+ l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str());
+ // Get the size request of the button with the "show password" text.
+ gtk_widget_size_request(show_password_button_, &show_size);
+ // Determine the maximum width and height.
+ if (hide_size.width > show_size.width)
+ show_size.width = hide_size.width;
+ if (hide_size.height > show_size.height)
+ show_size.height = hide_size.height;
+ // Force the button to be large enough for both labels.
+ gtk_widget_set_size_request(show_password_button_, show_size.width,
+ show_size.height);
+}
+
void PasswordsPageGtk::OnPasswordSelectionChanged(GtkTreeSelection* selection) {
// No matter how the selection changed, we want to hide the old password.
gtk_label_set_text(GTK_LABEL(password_), "");
diff --git a/chrome/browser/gtk/options/passwords_page_gtk.h b/chrome/browser/gtk/options/passwords_page_gtk.h
index 229c55d..3b7dc25 100644
--- a/chrome/browser/gtk/options/passwords_page_gtk.h
+++ b/chrome/browser/gtk/options/passwords_page_gtk.h
@@ -36,6 +36,7 @@ class PasswordsPageGtk {
CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnRemoveAllButtonClicked);
CHROMEGTK_CALLBACK_1(PasswordsPageGtk, void, OnRemoveAllConfirmResponse, int);
CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnShowPasswordButtonClicked);
+ CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnShowPasswordButtonRealized);
CHROMEG_CALLBACK_0(PasswordsPageGtk, void, OnPasswordSelectionChanged,
GtkTreeSelection*);