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 | |
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
-rw-r--r-- | chrome/browser/browser_main.cc | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/about_chrome_dialog.cc | 16 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_editor_gtk.cc | 85 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_editor_gtk.h | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/hung_renderer_dialog_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/gtk/import_dialog_gtk.cc | 43 | ||||
-rw-r--r-- | chrome/browser/gtk/options/options_window_gtk.cc | 1 | ||||
-rw-r--r-- | chrome/common/gtk_util.cc | 28 | ||||
-rw-r--r-- | chrome/common/gtk_util.h | 3 |
9 files changed, 121 insertions, 75 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index c357c6e..aedc95d 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -104,6 +104,10 @@ #endif // defined(OS_WIN) +#if defined(TOOLKIT_GTK) +#include "chrome/common/gtk_util.h" +#endif + namespace Platform { void WillInitializeMainMessageLoop(const CommandLine & command_line); @@ -553,6 +557,9 @@ int BrowserMain(const MainFunctionParams& parameters) { // the installation event. RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run); #endif +#if defined(TOOLKIT_GTK) + gtk_util::InitRCStyles(); +#endif // Config the network module so it has access to resources. net::NetModule::SetResourceProvider(NetResourceProvider); diff --git a/chrome/browser/gtk/about_chrome_dialog.cc b/chrome/browser/gtk/about_chrome_dialog.cc index 390b618..00cdd1c 100644 --- a/chrome/browser/gtk/about_chrome_dialog.cc +++ b/chrome/browser/gtk/about_chrome_dialog.cc @@ -96,6 +96,11 @@ void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) { GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); + // Pick up the style set in gtk_util.cc:InitRCStyles(). + // The layout of this dialog is special because the logo should be flush + // with the edges of the window. + gtk_widget_set_name(dialog, "about-dialog"); + gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; @@ -135,10 +140,15 @@ void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) { gtk_container_add(GTK_CONTAINER(ebox), hbox); gtk_box_pack_start(GTK_BOX(content_area), ebox, TRUE, TRUE, 0); + // We use a separate box for the licensing etc. text. See the comment near + // the top of this function about using a special layout for this dialog. + GtkWidget* vbox = gtk_vbox_new(FALSE, 6); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); + GtkWidget* copyright_label = MakeMarkupLabel( "<span size=\"smaller\">%s</span>", l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)); - gtk_box_pack_start(GTK_BOX(content_area), copyright_label, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(vbox), copyright_label, TRUE, TRUE, 5); // TODO(erg): Figure out how to really insert links. We could just depend on // (or include the source of) libsexy's SexyUrlLabel gtk widget... @@ -155,13 +165,15 @@ void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) { gtk_label_set_line_wrap(GTK_LABEL(license_label), TRUE); gtk_misc_set_alignment(GTK_MISC(license_label), 0, 0); - gtk_box_pack_start(GTK_BOX(content_area), license_label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), license_label, TRUE, TRUE, 0); // Hack around Gtk's not-so-good label wrapping, as described here: // http://blog.16software.com/dynamic-label-wrapping-in-gtk g_signal_connect(G_OBJECT(license_label), "size-allocate", G_CALLBACK(FixLabelWrappingCallback), NULL); + gtk_box_pack_start(GTK_BOX(content_area), vbox, TRUE, TRUE, 0); + g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), NULL); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_widget_show_all(dialog); 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); } } diff --git a/chrome/browser/gtk/bookmark_editor_gtk.h b/chrome/browser/gtk/bookmark_editor_gtk.h index b6669a0..4149a05 100644 --- a/chrome/browser/gtk/bookmark_editor_gtk.h +++ b/chrome/browser/gtk/bookmark_editor_gtk.h @@ -103,9 +103,6 @@ class BookmarkEditorGtk : public BookmarkEditor, GtkWidget* dialog_; GtkWidget* name_entry_; GtkWidget* url_entry_; - GtkWidget* close_button_; - GtkWidget* ok_button_; - GtkWidget* new_folder_button_; GtkWidget* tree_view_; // Helper object that manages the currently selected item in |tree_view_|. diff --git a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc index 2ca6699..0f16cf0 100644 --- a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc +++ b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc @@ -93,20 +93,20 @@ void HungRendererDialogGtk::Init() { // | kill button wait button| // ·-----------------------------------· GtkWidget* contents_vbox = dialog_->vbox; - gtk_container_set_border_width(GTK_CONTAINER(contents_vbox), 12); + gtk_box_set_spacing(GTK_BOX(contents_vbox), 18); - GtkWidget* hbox = gtk_hbox_new(false, 12); + GtkWidget* hbox = gtk_hbox_new(FALSE, 12); gtk_box_pack_start(GTK_BOX(contents_vbox), hbox, TRUE, TRUE, 0); // Wrap the icon in a vbox so it stays top aligned. - GtkWidget* icon_vbox = gtk_vbox_new(false, 0); + GtkWidget* icon_vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), icon_vbox, FALSE, FALSE, 0); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); GdkPixbuf* icon_pixbuf = rb.GetPixbufNamed(IDR_FROZEN_TAB_ICON); GtkWidget* icon = gtk_image_new_from_pixbuf(icon_pixbuf); gtk_box_pack_start(GTK_BOX(icon_vbox), icon, FALSE, FALSE, 0); - GtkWidget* vbox = gtk_vbox_new(false, 6); + GtkWidget* vbox = gtk_vbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); GtkWidget* text = gtk_label_new( @@ -117,6 +117,8 @@ void HungRendererDialogGtk::Init() { GtkWidget* scroll_list = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_list), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll_list), + GTK_SHADOW_ETCHED_IN); gtk_box_pack_start(GTK_BOX(vbox), scroll_list, TRUE, TRUE, 0); // The list of hung tabs is GtkTreeView with a GtkListStore as the model. diff --git a/chrome/browser/gtk/import_dialog_gtk.cc b/chrome/browser/gtk/import_dialog_gtk.cc index c0b9cbd1..1aa5b30 100644 --- a/chrome/browser/gtk/import_dialog_gtk.cc +++ b/chrome/browser/gtk/import_dialog_gtk.cc @@ -23,27 +23,23 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) : l10n_util::GetStringUTF8(IDS_IMPORT_SETTINGS_TITLE).c_str(), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, l10n_util::GetStringUTF8(IDS_IMPORT_COMMIT).c_str(), GTK_RESPONSE_ACCEPT, - l10n_util::GetStringUTF8(IDS_CANCEL).c_str(), - GTK_RESPONSE_REJECT, NULL); - //TODO(rahulk): find how to set size properly so that the dialog box width is - // atleast enough to display full title. + // TODO(rahulk): find how to set size properly so that the dialog + // box width is at least enough to display full title. gtk_widget_set_size_request(dialog, 300, -1); GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; - GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0); - gtk_box_pack_start(GTK_BOX(content_area), alignment, TRUE, TRUE, 0); - - GtkWidget* vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(alignment), vbox); + gtk_box_set_spacing(GTK_BOX(content_area), 18); - GtkWidget* combo_hbox = gtk_hbox_new(FALSE, 5); + GtkWidget* combo_hbox = gtk_hbox_new(FALSE, 12); GtkWidget* from = gtk_label_new( l10n_util::GetStringUTF8(IDS_IMPORT_FROM_LABEL).c_str()); - gtk_box_pack_start(GTK_BOX(combo_hbox), from, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(combo_hbox), from, FALSE, FALSE, 0); combo_ = gtk_combo_box_new_text(); int profiles_count = importer_host_->GetAvailableProfileCount(); @@ -53,34 +49,33 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) : WideToUTF8(profile).c_str()); } gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0); - gtk_box_pack_start(GTK_BOX(combo_hbox), combo_, TRUE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(vbox), combo_hbox, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(combo_hbox), combo_, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(content_area), combo_hbox, FALSE, FALSE, 0); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 6); GtkWidget* description = gtk_label_new( l10n_util::GetStringUTF8(IDS_IMPORT_ITEMS_LABEL).c_str()); - gtk_box_pack_start(GTK_BOX(vbox), description, TRUE, TRUE, 5); - - GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); - gtk_alignment_set_padding(GTK_ALIGNMENT(text_alignment), 0, 0, 25, 0); - GtkWidget* text_vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(text_alignment), text_vbox); - gtk_box_pack_start(GTK_BOX(vbox), text_alignment, TRUE, TRUE, 0); + gtk_misc_set_alignment(GTK_MISC(description), 0, 0); + gtk_box_pack_start(GTK_BOX(vbox), description, FALSE, FALSE, 0); bookmarks_ = gtk_check_button_new_with_label( l10n_util::GetStringUTF8(IDS_IMPORT_FAVORITES_CHKBOX).c_str()); - gtk_box_pack_start(GTK_BOX(text_vbox), bookmarks_, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(vbox), bookmarks_, FALSE, FALSE, 0); search_engines_ = gtk_check_button_new_with_label( l10n_util::GetStringUTF8(IDS_IMPORT_SEARCH_ENGINES_CHKBOX).c_str()); - gtk_box_pack_start(GTK_BOX(text_vbox), search_engines_, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(vbox), search_engines_, FALSE, FALSE, 0); passwords_ = gtk_check_button_new_with_label( l10n_util::GetStringUTF8(IDS_IMPORT_PASSWORDS_CHKBOX).c_str()); - gtk_box_pack_start(GTK_BOX(text_vbox), passwords_, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(vbox), passwords_, FALSE, FALSE, 0); history_ = gtk_check_button_new_with_label( l10n_util::GetStringUTF8(IDS_IMPORT_HISTORY_CHKBOX).c_str()); - gtk_box_pack_start(GTK_BOX(text_vbox), history_, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(vbox), history_, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0); g_signal_connect(dialog, "response", G_CALLBACK(HandleOnResponseDialog), this); diff --git a/chrome/browser/gtk/options/options_window_gtk.cc b/chrome/browser/gtk/options/options_window_gtk.cc index 4319335..19ec9c7 100644 --- a/chrome/browser/gtk/options/options_window_gtk.cc +++ b/chrome/browser/gtk/options/options_window_gtk.cc @@ -80,6 +80,7 @@ OptionsWindowGtk::OptionsWindowGtk(Profile* profile) GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), 18); notebook_ = gtk_notebook_new(); diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index ef5d689..280a7ea 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -81,4 +81,32 @@ gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) { widget->allocation.width, widget->allocation.height); } +void InitRCStyles() { + static const char kRCText[] = + // Make our dialogs styled like the GNOME HIG. + // TODO(evanm): content-area-spacing doesn't seem to work -- maybe it + // was introduced in a later version of GTK? + "style \"gnome-dialog\" {\n" + " xthickness = 12\n" + " GtkDialog::action-area-border = 0\n" + " GtkDialog::button-spacing = 6\n" + " GtkDialog::content-area-spacing = 18\n" + " GtkDialog::content-area-border = 12\n" + "}\n" + // Note we set it at the "application" priority, so users can override. + "widget \"GtkDialog\" style : application \"gnome-dialog\"\n" + + // Make our about dialog special. + "style \"about-dialog\" {\n" + " GtkDialog::action-area-border = 12\n" + " GtkDialog::button-spacing = 6\n" + " GtkDialog::content-area-spacing = 18\n" + " GtkDialog::content-area-border = 0\n" + "}\n" + // Note we set it at the "application" priority, so users can override. + "widget \"about-dialog\" style : application \"about-dialog\"\n"; + + gtk_rc_parse_string(kRCText); +} + } // namespace gtk_util diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h index ab9a29d..8a9b3f0 100644 --- a/chrome/common/gtk_util.h +++ b/chrome/common/gtk_util.h @@ -38,6 +38,9 @@ gfx::Point GetWidgetScreenPosition(GtkWidget* widget); // Returns the bounds of the specified widget in screen coordinates. gfx::Rect GetWidgetScreenBounds(GtkWidget* widget); +// Initialize some GTK settings so that our dialogs are consistent. +void InitRCStyles(); + } // namespace gtk_util #endif // CHROME_COMMON_GTK_UTIL_H_ |