Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/gtk/options/passwords_page_gtk.cc

Issue 3149033: Linux: set the size of the "show password" button in the password manager after realizing it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/options/passwords_page_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/options/passwords_page_gtk.h" 5 #include "chrome/browser/gtk/options/passwords_page_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/gtk_util.h" 9 #include "app/gtk_util.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_REMOVE_BUTTON).c_str()); 45 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_REMOVE_BUTTON).c_str());
46 gtk_widget_set_sensitive(remove_button_, FALSE); 46 gtk_widget_set_sensitive(remove_button_, FALSE);
47 g_signal_connect(remove_button_, "clicked", 47 g_signal_connect(remove_button_, "clicked",
48 G_CALLBACK(OnRemoveButtonClickedThunk), this); 48 G_CALLBACK(OnRemoveButtonClickedThunk), this);
49 remove_all_button_ = gtk_button_new_with_label(l10n_util::GetStringUTF8( 49 remove_all_button_ = gtk_button_new_with_label(l10n_util::GetStringUTF8(
50 IDS_PASSWORDS_PAGE_VIEW_REMOVE_ALL_BUTTON).c_str()); 50 IDS_PASSWORDS_PAGE_VIEW_REMOVE_ALL_BUTTON).c_str());
51 gtk_widget_set_sensitive(remove_all_button_, FALSE); 51 gtk_widget_set_sensitive(remove_all_button_, FALSE);
52 g_signal_connect(remove_all_button_, "clicked", 52 g_signal_connect(remove_all_button_, "clicked",
53 G_CALLBACK(OnRemoveAllButtonClickedThunk), this); 53 G_CALLBACK(OnRemoveAllButtonClickedThunk), this);
54 54
55 // We start with the "hide password" text but change it in the realize event.
55 show_password_button_ = gtk_button_new_with_label( 56 show_password_button_ = gtk_button_new_with_label(
56 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON).c_str()); 57 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON).c_str());
57 GtkRequisition hide_size, show_size;
58 // Get the size request of the button with the "hide password" text.
59 gtk_widget_size_request(show_password_button_, &hide_size);
60 gtk_button_set_label(GTK_BUTTON(show_password_button_),
61 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str());
62 // Get the size request of the button with the "show password" text.
63 gtk_widget_size_request(show_password_button_, &show_size);
64 // Determine the maximum width and height.
65 if (hide_size.width > show_size.width)
66 show_size.width = hide_size.width;
67 if (hide_size.height > show_size.height)
68 show_size.height = hide_size.height;
69 // Force the button to be large enough for both labels.
70 gtk_widget_set_size_request(show_password_button_, show_size.width,
71 show_size.height);
72 gtk_widget_set_sensitive(show_password_button_, FALSE); 58 gtk_widget_set_sensitive(show_password_button_, FALSE);
73 g_signal_connect(show_password_button_, "clicked", 59 g_signal_connect(show_password_button_, "clicked",
74 G_CALLBACK(OnShowPasswordButtonClickedThunk), this); 60 G_CALLBACK(OnShowPasswordButtonClickedThunk), this);
61 g_signal_connect(show_password_button_, "realize",
62 G_CALLBACK(OnShowPasswordButtonRealizedThunk), this);
75 63
76 password_ = gtk_label_new(""); 64 password_ = gtk_label_new("");
77 65
78 GtkWidget* buttons = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 66 GtkWidget* buttons = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
79 gtk_box_pack_start(GTK_BOX(buttons), remove_button_, FALSE, FALSE, 0); 67 gtk_box_pack_start(GTK_BOX(buttons), remove_button_, FALSE, FALSE, 0);
80 gtk_box_pack_start(GTK_BOX(buttons), remove_all_button_, FALSE, FALSE, 0); 68 gtk_box_pack_start(GTK_BOX(buttons), remove_all_button_, FALSE, FALSE, 0);
81 gtk_box_pack_start(GTK_BOX(buttons), show_password_button_, FALSE, FALSE, 0); 69 gtk_box_pack_start(GTK_BOX(buttons), show_password_button_, FALSE, FALSE, 0);
82 gtk_box_pack_start(GTK_BOX(buttons), password_, FALSE, FALSE, 0); 70 gtk_box_pack_start(GTK_BOX(buttons), password_, FALSE, FALSE, 0);
83 71
84 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); 72 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 GTK_TREE_MODEL(password_list_sort_), &iter); 246 GTK_TREE_MODEL(password_list_sort_), &iter);
259 gint index = gtk_tree::GetTreeSortChildRowNumForPath( 247 gint index = gtk_tree::GetTreeSortChildRowNumForPath(
260 password_list_sort_, path); 248 password_list_sort_, path);
261 gtk_tree_path_free(path); 249 gtk_tree_path_free(path);
262 std::string pass = UTF16ToUTF8(password_list_[index]->password_value); 250 std::string pass = UTF16ToUTF8(password_list_[index]->password_value);
263 gtk_label_set_text(GTK_LABEL(password_), pass.c_str()); 251 gtk_label_set_text(GTK_LABEL(password_), pass.c_str());
264 gtk_button_set_label(GTK_BUTTON(show_password_button_), 252 gtk_button_set_label(GTK_BUTTON(show_password_button_),
265 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON).c_str()); 253 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON).c_str());
266 } 254 }
267 255
256 void PasswordsPageGtk::OnShowPasswordButtonRealized(GtkWidget* widget) {
257 // We have just realized the "show password" button, so we can now accurately
258 // find out how big it needs to be in order to accomodate both the "show" and
259 // "hide" labels. (This requires font information to work correctly.) The
260 // button starts with the "hide" label so we only have to change it once.
261 GtkRequisition hide_size, show_size;
262 // Get the size request of the button with the "hide password" text.
263 gtk_widget_size_request(show_password_button_, &hide_size);
264 gtk_button_set_label(GTK_BUTTON(show_password_button_),
265 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str());
266 // Get the size request of the button with the "show password" text.
267 gtk_widget_size_request(show_password_button_, &show_size);
268 // Determine the maximum width and height.
269 if (hide_size.width > show_size.width)
270 show_size.width = hide_size.width;
271 if (hide_size.height > show_size.height)
272 show_size.height = hide_size.height;
273 // Force the button to be large enough for both labels.
274 gtk_widget_set_size_request(show_password_button_, show_size.width,
275 show_size.height);
276 }
277
268 void PasswordsPageGtk::OnPasswordSelectionChanged(GtkTreeSelection* selection) { 278 void PasswordsPageGtk::OnPasswordSelectionChanged(GtkTreeSelection* selection) {
269 // No matter how the selection changed, we want to hide the old password. 279 // No matter how the selection changed, we want to hide the old password.
270 gtk_label_set_text(GTK_LABEL(password_), ""); 280 gtk_label_set_text(GTK_LABEL(password_), "");
271 gtk_button_set_label(GTK_BUTTON(show_password_button_), 281 gtk_button_set_label(GTK_BUTTON(show_password_button_),
272 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str()); 282 l10n_util::GetStringUTF8(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON).c_str());
273 password_showing_ = false; 283 password_showing_ = false;
274 284
275 GtkTreeIter iter; 285 GtkTreeIter iter;
276 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) { 286 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) {
277 gtk_widget_set_sensitive(show_password_button_, FALSE); 287 gtk_widget_set_sensitive(show_password_button_, FALSE);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 PasswordStore* store = page_->GetPasswordStore(); 319 PasswordStore* store = page_->GetPasswordStore();
310 pending_login_query_ = store->GetAutofillableLogins(this); 320 pending_login_query_ = store->GetAutofillableLogins(this);
311 } 321 }
312 322
313 void PasswordsPageGtk::PasswordListPopulater::OnPasswordStoreRequestDone( 323 void PasswordsPageGtk::PasswordListPopulater::OnPasswordStoreRequestDone(
314 int handle, const std::vector<webkit_glue::PasswordForm*>& result) { 324 int handle, const std::vector<webkit_glue::PasswordForm*>& result) {
315 DCHECK_EQ(pending_login_query_, handle); 325 DCHECK_EQ(pending_login_query_, handle);
316 pending_login_query_ = 0; 326 pending_login_query_ = 0;
317 page_->SetPasswordList(result); 327 page_->SetPasswordList(result);
318 } 328 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/options/passwords_page_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698