diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:20:33 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:20:33 +0000 |
commit | dd092159f3252df0afc3863ed052a417d1590d81 (patch) | |
tree | 7dec4d705b0b797887a00221b7736c0cba433ab3 /chrome/browser/gtk/bookmark_editor_gtk.cc | |
parent | 2237ce6abe23d4e4610af5a492eb60016fb85171 (diff) | |
download | chromium_src-dd092159f3252df0afc3863ed052a417d1590d81.zip chromium_src-dd092159f3252df0afc3863ed052a417d1590d81.tar.gz chromium_src-dd092159f3252df0afc3863ed052a417d1590d81.tar.bz2 |
linux: unify all the dialog layout code for visual consistency.
We follow the GNOME HIG where possible, which mostly means the
pixel spacing of the borders and buttons in dialogs.
BUG=12056
Review URL: http://codereview.chromium.org/113539
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/bookmark_editor_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/bookmark_editor_gtk.cc | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/chrome/browser/gtk/bookmark_editor_gtk.cc b/chrome/browser/gtk/bookmark_editor_gtk.cc index 32af739..f4da66e 100644 --- a/chrome/browser/gtk/bookmark_editor_gtk.cc +++ b/chrome/browser/gtk/bookmark_editor_gtk.cc @@ -26,7 +26,7 @@ namespace { // Background color of text field when URL is invalid. const GdkColor kErrorColor = GDK_COLOR_RGB(0xFF, 0xBC, 0xBC); -// Preferred width of the tree. +// Preferred initial dimensions, in pixels, of the folder tree. static const int kTreeWidth = 300; static const int kTreeHeight = 150; @@ -76,38 +76,31 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) { DCHECK(bb_model_); bb_model_->AddObserver(this); - // TODO(erg): Redo this entire class as a normal GtkWindow with it's modality - // manually set to TRUE because using the stock GtkDialog class gives me - // almost no control over the buttons on the bottom. dialog_ = gtk_dialog_new_with_buttons( l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_TITLE).c_str(), parent_window, GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); + gtk_dialog_set_has_separator(GTK_DIALOG(dialog_), FALSE); if (show_tree_) { - // We want the New Folder button to not automatically dismiss the dialog so - // we have to do that manually. gtk_dialog_add_button() always makes the - // button dismiss the dialog box. This isn't 100% accurate to what I want; - // see above about redoing this as a GtkWindow. GtkWidget* action_area = GTK_DIALOG(dialog_)->action_area; - new_folder_button_ = gtk_button_new_with_label("New Folder"); - g_signal_connect(new_folder_button_, "clicked", + GtkWidget* new_folder_button = gtk_button_new_with_label( + l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON).c_str()); + g_signal_connect(new_folder_button, "clicked", G_CALLBACK(OnNewFolderClicked), this); - gtk_box_pack_start(GTK_BOX(action_area), new_folder_button_, - FALSE, FALSE, 0); + gtk_container_add(GTK_CONTAINER(action_area), new_folder_button); + gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(action_area), + new_folder_button, TRUE); } - close_button_ = gtk_dialog_add_button(GTK_DIALOG(dialog_), - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT); - ok_button_ = gtk_dialog_add_button(GTK_DIALOG(dialog_), - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); // The GTK dialog content area layout (overview) // - // +- GtkVBox |content_area| --------------------------------------+ + // +- GtkVBox |vbox| ----------------------------------------------+ // |+- GtkTable |table| ------------------------------------------+| // ||+- GtkLabel ------+ +- GtkEntry |name_entry_| --------------+|| // ||| | | ||| @@ -128,48 +121,49 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) { // |+-------------------------------------------------------------+| // +---------------------------------------------------------------+ GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox; - gtk_container_set_border_width(GTK_CONTAINER(content_area), 12); + gtk_box_set_spacing(GTK_BOX(content_area), 18); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 12); + GtkWidget* table = gtk_table_new(2, 2, FALSE); + gtk_table_set_col_spacing(GTK_TABLE(table), 0, 12); + gtk_table_set_row_spacings(GTK_TABLE(table), 6); GtkWidget* label = gtk_label_new( l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NAME_LABEL).c_str()); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(label), 0, 1, 0, 1, - (GtkAttachOptions)(GTK_SHRINK), - (GtkAttachOptions)(GTK_SHRINK), - 12, 0); + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(GTK_FILL), + 0, 0); name_entry_ = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(name_entry_), node_ ? WideToUTF8(node_->GetTitle()).c_str() : ""); g_signal_connect(G_OBJECT(name_entry_), "changed", G_CALLBACK(OnEntryChanged), this); - g_object_set(G_OBJECT(name_entry_), "activates-default", TRUE, NULL); - gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(name_entry_), - 1, 2, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_FILL), - 0, 0); + gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); + gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(name_entry_), + 1, 2, 0, 1); label = gtk_label_new( l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_URL_LABEL).c_str()); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(label), 0, 1, 1, 2, - (GtkAttachOptions)(GTK_SHRINK), - (GtkAttachOptions)(GTK_SHRINK), - 12, 0); + (GtkAttachOptions)(GTK_FILL), + (GtkAttachOptions)(GTK_FILL), + 0, 0); url_entry_ = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(url_entry_), node_ ? node_->GetURL().spec().c_str() : ""); g_signal_connect(G_OBJECT(url_entry_), "changed", G_CALLBACK(OnEntryChanged), this); - g_object_set(G_OBJECT(url_entry_), "activates-default", TRUE, NULL); - gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(url_entry_), - 1, 2, 1, 2, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_FILL), - 0, 0); + gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); + gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(url_entry_), + 1, 2, 1, 2); - gtk_box_pack_start(GTK_BOX(content_area), table, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); if (show_tree_) { GtkTreeIter selected_iter; @@ -199,12 +193,17 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) { GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), - GTK_POLICY_NEVER, + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll_window), + GTK_SHADOW_ETCHED_IN); gtk_container_add(GTK_CONTAINER(scroll_window), tree_view_); - gtk_box_pack_start(GTK_BOX(content_area), scroll_window, TRUE, TRUE, 12); + + gtk_box_pack_start(GTK_BOX(vbox), scroll_window, TRUE, TRUE, 0); } + gtk_box_pack_start(GTK_BOX(content_area), vbox, TRUE, TRUE, 0); + g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), this); g_signal_connect(dialog_, "delete-event", @@ -365,10 +364,12 @@ void BookmarkEditorGtk::OnEntryChanged(GtkEditable* entry, const GURL url(dialog->GetInputURL()); if (!url.is_valid()) { gtk_widget_modify_base(dialog->url_entry_, GTK_STATE_NORMAL, &kErrorColor); - gtk_widget_set_sensitive(GTK_WIDGET(dialog->ok_button_), false); + gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->dialog_), + GTK_RESPONSE_ACCEPT, FALSE); } else { gtk_widget_modify_base(dialog->url_entry_, GTK_STATE_NORMAL, NULL); - gtk_widget_set_sensitive(GTK_WIDGET(dialog->ok_button_), true); + gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->dialog_), + GTK_RESPONSE_ACCEPT, TRUE); } } |