diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 20:53:13 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 20:53:13 +0000 |
commit | f7f72659b51abad657a600e9198a388c17128517 (patch) | |
tree | 25b524b99b426c6a9971df2799b373060f3c6ad1 /chrome | |
parent | f845e14d13d8561c38ff37da4f69a6e3352ca1f8 (diff) | |
download | chromium_src-f7f72659b51abad657a600e9198a388c17128517.zip chromium_src-f7f72659b51abad657a600e9198a388c17128517.tar.gz chromium_src-f7f72659b51abad657a600e9198a388c17128517.tar.bz2 |
Host native gtk dialog in a Chrome window.
- Add a NativeDialogWindow as container for native dialog contents;
- Host native option dialogs in NativeDialogWindow;
BUG=<http://crosbug.com/1885>
TEST=Verify sub dialogs from options dialog have a frame and no longer full screen.
Review URL: http://codereview.chromium.org/1702018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46391 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
18 files changed, 342 insertions, 51 deletions
diff --git a/chrome/browser/autofill/autofill_dialog_gtk.cc b/chrome/browser/autofill/autofill_dialog_gtk.cc index 0f7a40a..2369fbd 100644 --- a/chrome/browser/autofill/autofill_dialog_gtk.cc +++ b/chrome/browser/autofill/autofill_dialog_gtk.cc @@ -383,12 +383,6 @@ AutoFillDialog::AutoFillDialog(Profile* profile, GTK_RESPONSE_OK, NULL); - gtk_widget_realize(dialog_); - gtk_util::SetWindowSizeFromResources(GTK_WINDOW(dialog_), - IDS_AUTOFILL_DIALOG_WIDTH_CHARS, - IDS_AUTOFILL_DIALOG_HEIGHT_LINES, - true); - // Allow browser windows to go in front of the AutoFill dialog in Metacity. gtk_window_set_type_hint(GTK_WINDOW(dialog_), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), @@ -451,12 +445,14 @@ AutoFillDialog::AutoFillDialog(Profile* profile, gtk_button_box_set_child_secondary( GTK_BUTTON_BOX(GTK_DIALOG(dialog_)->action_area), link, TRUE); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_AUTOFILL_DIALOG_WIDTH_CHARS, + IDS_AUTOFILL_DIALOG_HEIGHT_LINES, + true); } void AutoFillDialog::Show() { - gtk_window_present_with_time(GTK_WINDOW(dialog_), - gtk_get_current_event_time()); + gtk_util::PresentWindow(dialog_, gtk_get_current_event_time()); } // static diff --git a/chrome/browser/chromeos/native_dialog_window.cc b/chrome/browser/chromeos/native_dialog_window.cc new file mode 100644 index 0000000..69abbeb --- /dev/null +++ b/chrome/browser/chromeos/native_dialog_window.cc @@ -0,0 +1,178 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/native_dialog_window.h" + +#include "app/gtk_signal.h" +#include "base/logging.h" +#include "base/utf_string_conversions.h" +#include "views/controls/native/native_view_host.h" +#include "views/window/dialog_delegate.h" +#include "views/window/window.h" + +namespace { + +const int kDialogPadding = 3; + +const char kNativeDialogHostWindow[] = "_chromeos_native_dialog_host_window_"; + +} // namespace + +namespace chromeos { + +class NativeDialogHost : public views::View, + public views::DialogDelegate { + public: + explicit NativeDialogHost(gfx::NativeView native_dialog, + const gfx::Size& size, + bool resizeable); + ~NativeDialogHost(); + + // views::DialogDelegate implementation: + virtual bool CanResize() const { return resizeable_; } + virtual int GetDialogButtons() const { return 0; } + virtual std::wstring GetWindowTitle() const { return title_; } + virtual views::View* GetContentsView() { return this; } + + protected: + CHROMEGTK_CALLBACK_0(NativeDialogHost, void, OnDialogDestroy); + + // views::View implementation: + virtual gfx::Size GetPreferredSize(); + virtual void Layout(); + virtual void ViewHierarchyChanged(bool is_add, + views::View* parent, + views::View* child); + private: + // Init and attach to native dialog. + void Init(); + + // The GtkDialog whose vbox will be displayed in this view. + gfx::NativeView dialog_; + + // NativeViewHost for the dialog's contents. + views::NativeViewHost* contents_view_; + + std::wstring title_; + gfx::Size size_; + bool resizeable_; + + int destroy_signal_id_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(NativeDialogHost); +}; + +/////////////////////////////////////////////////////////////////////////////// +// NativeDialogHost, public: + +NativeDialogHost::NativeDialogHost(gfx::NativeView native_dialog, + const gfx::Size& size, + bool resizeable) + : dialog_(native_dialog), + contents_view_(NULL), + size_(size), + resizeable_(resizeable), + destroy_signal_id_(0) { + const char* title = gtk_window_get_title(GTK_WINDOW(dialog_)); + if (title) + UTF8ToWide(title, strlen(title), &title_); + + destroy_signal_id_ = g_signal_connect(dialog_, "destroy", + G_CALLBACK(OnDialogDestroyThunk), this); +} + +NativeDialogHost::~NativeDialogHost() { + if (dialog_) { + // Disconnect the "destroy" signal because we are about to destroy + // the dialog ourselves and no longer interested in it. + g_signal_handler_disconnect(G_OBJECT(dialog_), destroy_signal_id_); + gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_CLOSE); + } +} + +void NativeDialogHost::OnDialogDestroy(GtkWidget* widget) { + dialog_ = NULL; + destroy_signal_id_ = 0; + window()->Close(); +} + +/////////////////////////////////////////////////////////////////////////////// +// NativeDialogHost, views::View overrides: + +gfx::Size NativeDialogHost::GetPreferredSize() { + return size_; +} + +void NativeDialogHost::Layout() { + contents_view_->SetBounds(0, 0, width(), height()); +} + +void NativeDialogHost::ViewHierarchyChanged(bool is_add, + views::View* parent, + views::View* child) { + if (is_add && child == this) + Init(); +} + +/////////////////////////////////////////////////////////////////////////////// +// NativeDialogHost, private: +void NativeDialogHost::Init() { + if (contents_view_) + return; + + // Create a GtkAlignment as dialog contents container. + GtkWidget* contents = gtk_alignment_new(0.5, 0.5, 1.0, 1.0); + gtk_alignment_set_padding(GTK_ALIGNMENT(contents), + kDialogPadding, kDialogPadding, + kDialogPadding, kDialogPadding); + + // Move dialog contents into our container. + GtkWidget* dialog_contents = GTK_DIALOG(dialog_)->vbox; + g_object_ref(dialog_contents); + gtk_container_remove(GTK_CONTAINER(dialog_), dialog_contents); + gtk_container_add(GTK_CONTAINER(contents), dialog_contents); + g_object_unref(dialog_contents); + gtk_widget_hide(dialog_); + + g_object_set_data(G_OBJECT(dialog_), kNativeDialogHostWindow, + reinterpret_cast<gpointer>(window()->GetNativeWindow())); + + gtk_widget_show_all(contents); + + contents_view_ = new views::NativeViewHost(); + AddChildView(contents_view_); + contents_view_->Attach(contents); + + // Use gtk's default size if size is not speicified. + if (size_.IsEmpty()) { + // Use given width or height if given. + if (size_.width() || size_.height()) { + int width = size_.width() == 0 ? -1 : size_.width(); + int height = size_.height() == 0 ? -1 : size_.height(); + gtk_widget_set_size_request(contents, width, height); + } + + GtkRequisition requsition = { 0 }; + gtk_widget_size_request(contents, &requsition); + size_.set_width(requsition.width); + size_.set_height(requsition.height); + } +} + +void ShowNativeDialog(gfx::NativeWindow parent, + gfx::NativeView native_dialog, + const gfx::Size& dialog_size, + bool resizeable) { + NativeDialogHost* native_dialog_host = + new NativeDialogHost(native_dialog, dialog_size, resizeable); + views::Window::CreateChromeWindow(parent, gfx::Rect(), native_dialog_host); + native_dialog_host->window()->Show(); +} + +gfx::NativeWindow GetNativeDialogWindow(gfx::NativeView native_dialog) { + return reinterpret_cast<gfx::NativeWindow>( + g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHostWindow)); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/native_dialog_window.h b/chrome/browser/chromeos/native_dialog_window.h new file mode 100644 index 0000000..2dd14c4 --- /dev/null +++ b/chrome/browser/chromeos/native_dialog_window.h @@ -0,0 +1,27 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_NATIVE_DIALOG_WINDOW_H_ +#define CHROME_BROWSER_CHROMEOS_NATIVE_DIALOG_WINDOW_H_ + +#include "gfx/native_widget_types.h" + +namespace gfx { +class Size; +} // namespace gfx + +namespace chromeos { + +// Shows a native dialog in views::Window. +void ShowNativeDialog(gfx::NativeWindow parent, + gfx::NativeView native_dialog, + const gfx::Size& size, + bool resizeable); + +// Gets the container window of the given |native_dialog|. +gfx::NativeWindow GetNativeDialogWindow(gfx::NativeView native_dialog); + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_NATIVE_DIALOG_WINDOW_H_ diff --git a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc index 88c8348..6a94eb8 100644 --- a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc +++ b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc @@ -51,11 +51,6 @@ ClearBrowsingDataDialogGtk::ClearBrowsingDataDialogGtk(GtkWindow* parent, accessible_widget_helper_.reset(new AccessibleWidgetHelper(dialog_, profile)); accessible_widget_helper_->SendOpenWindowNotification(dialog_name); - gtk_widget_realize(dialog_); - gtk_util::SetWindowSizeFromResources(GTK_WINDOW(dialog_), - IDS_CLEARDATA_DIALOG_WIDTH_CHARS, - -1, // height - false); // resizable gtk_util::AddButtonToDialog(dialog_, l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_COMMIT).c_str(), GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); @@ -182,7 +177,10 @@ ClearBrowsingDataDialogGtk::ClearBrowsingDataDialogGtk(GtkWindow* parent, UpdateDialogButtons(); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_CLEARDATA_DIALOG_WIDTH_CHARS, + -1, + false); } ClearBrowsingDataDialogGtk::~ClearBrowsingDataDialogGtk() { diff --git a/chrome/browser/gtk/edit_search_engine_dialog.cc b/chrome/browser/gtk/edit_search_engine_dialog.cc index 0359595..aa64b73 100644 --- a/chrome/browser/gtk/edit_search_engine_dialog.cc +++ b/chrome/browser/gtk/edit_search_engine_dialog.cc @@ -196,7 +196,7 @@ void EditSearchEngineDialog::Init(GtkWindow* parent_window, Profile* profile) { EnableControls(); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialog(dialog_); g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroyThunk), this); diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc index 2658d60..cab430c 100644 --- a/chrome/browser/gtk/gtk_util.cc +++ b/chrome/browser/gtk/gtk_util.cc @@ -28,6 +28,12 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/native_dialog_window.h" +#include "chrome/browser/chromeos/options/options_window_view.h" +#include "views/window/window.h" +#endif // defined(OS_CHROMEOS) + namespace { const char kBoldLabelMarkup[] = "<span weight='bold'>%s</span>"; @@ -908,4 +914,63 @@ bool AddWindowAlphaChannel(GtkWidget* window) { return rgba; } +#if defined(OS_CHROMEOS) + +void ShowDialog(GtkWidget* dialog) { + chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(), + dialog, gfx::Size(), false); +} + +void ShowDialogWithLocalizedSize(GtkWidget* dialog, + int width_id, + int height_id, + bool resizeable) { + int width = (width_id == -1) ? 0 : + views::Window::GetLocalizedContentsWidth(width_id); + int height = (height_id == -1) ? 0 : + views::Window::GetLocalizedContentsHeight(height_id); + + chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(), + dialog, + gfx::Size(width, height), + resizeable); +} + +void PresentWindow(GtkWidget* window, int timestamp) { + GtkWindow* host_window = chromeos::GetNativeDialogWindow(window); + if (!host_window) + host_window = GTK_WINDOW(window); + if (timestamp) + gtk_window_present_with_time(host_window, timestamp); + else + gtk_window_present(host_window); +} + +#else + +void ShowDialog(GtkWidget* dialog) { + gtk_widget_show_all(dialog); +} + +void ShowDialogWithLocalizedSize(GtkWidget* dialog, + int width_id, + int height_id, + bool resizeable) { + gtk_widget_realize(dialog); + SetWindowSizeFromResources(GTK_WINDOW(dialog), + width_id, + height_id, + resizeable); + gtk_widget_show_all(dialog); +} + +void PresentWindow(GtkWidget* window, int timestamp) { + if (timestamp) + gtk_window_present_with_time(GTK_WINDOW(window), timestamp); + else + gtk_window_present(GTK_WINDOW(window)); +} + +#endif + } // namespace gtk_util diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h index e469a19..b121e03 100644 --- a/chrome/browser/gtk/gtk_util.h +++ b/chrome/browser/gtk/gtk_util.h @@ -280,6 +280,20 @@ bool URLFromPrimarySelection(Profile* profile, GURL* url); // Set the colormap of the given window to rgba to allow transparency. bool AddWindowAlphaChannel(GtkWidget* window); +// Wrappers to show a GtkDialog. On Linux, it merely calls gtk_widget_show_all. +// On ChromeOs, it calls ShowNativeDialog which hosts the its vbox +// in a view based Window. +void ShowDialog(GtkWidget* dialog); +void ShowDialogWithLocalizedSize(GtkWidget* dialog, + int width_id, + int height_id, + bool resizeable); + +// Wrapper to present a window. On Linux, it just calls gtk_window_present or +// gtk_window_present_with_time for non-zero timestamp. For ChromeOS, it first +// finds the host window of the dialog contents and then present it. +void PresentWindow(GtkWidget* window, int timestamp); + } // namespace gtk_util #endif // CHROME_BROWSER_GTK_GTK_UTIL_H_ diff --git a/chrome/browser/gtk/import_dialog_gtk.cc b/chrome/browser/gtk/import_dialog_gtk.cc index 7017c6c..5af8aec 100644 --- a/chrome/browser/gtk/import_dialog_gtk.cc +++ b/chrome/browser/gtk/import_dialog_gtk.cc @@ -62,11 +62,6 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile, dialog_, profile)); accessible_widget_helper_->SendOpenWindowNotification(dialog_name); - gtk_widget_realize(dialog_); - gtk_util::SetWindowSizeFromResources(GTK_WINDOW(dialog_), - IDS_IMPORT_DIALOG_WIDTH_CHARS, - -1, // height - false); // resizable importer_host_->set_parent_window(GTK_WINDOW(dialog_)); // Add import button separately as we might need to disable it, if @@ -157,7 +152,10 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile, UpdateDialogButtons(); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_IMPORT_DIALOG_WIDTH_CHARS, + -1, // height + false); // resizable } ImportDialogGtk::~ImportDialogGtk() { diff --git a/chrome/browser/gtk/keyword_editor_view.cc b/chrome/browser/gtk/keyword_editor_view.cc index d715db9..fc597de 100644 --- a/chrome/browser/gtk/keyword_editor_view.cc +++ b/chrome/browser/gtk/keyword_editor_view.cc @@ -46,10 +46,13 @@ void KeywordEditorView::Show(Profile* profile) { // If there's already an existing editor window, activate it. if (instance_) { - gtk_window_present(GTK_WINDOW(instance_->dialog_)); + gtk_util::PresentWindow(instance_->dialog_, 0); } else { instance_ = new KeywordEditorView(profile); - gtk_widget_show_all(instance_->dialog_); + gtk_util::ShowDialogWithLocalizedSize(instance_->dialog_, + IDS_SEARCHENGINES_DIALOG_WIDTH_CHARS, + IDS_SEARCHENGINES_DIALOG_HEIGHT_LINES, + true); } } @@ -198,13 +201,6 @@ void KeywordEditorView::Init() { EnableControls(); - // Set the size of the dialog. - gtk_widget_realize(dialog_); - gtk_util::SetWindowSizeFromResources(GTK_WINDOW(dialog_), - IDS_SEARCHENGINES_DIALOG_WIDTH_CHARS, - IDS_SEARCHENGINES_DIALOG_HEIGHT_LINES, - true); - g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), this); g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroy), this); } diff --git a/chrome/browser/gtk/options/content_exception_editor.cc b/chrome/browser/gtk/options/content_exception_editor.cc index 264282f..ea12db9 100644 --- a/chrome/browser/gtk/options/content_exception_editor.cc +++ b/chrome/browser/gtk/options/content_exception_editor.cc @@ -72,7 +72,7 @@ ContentExceptionEditor::ContentExceptionEditor( // Prime the state of the buttons. OnEntryChanged(entry_); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialog(dialog_); g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroyThunk), this); diff --git a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc index e1e3e8b..04929c5 100644 --- a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc +++ b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc @@ -35,6 +35,8 @@ void ContentExceptionsWindowGtk::ShowExceptionsWindow( if (!instances[type]) { // Create the options window. instances[type] = new ContentExceptionsWindowGtk(parent, map, type); + } else { + gtk_util::PresentWindow(instances[type]->dialog_, 0); } } @@ -142,7 +144,10 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk( UpdateButtonState(); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_CONTENT_EXCEPTION_DIALOG_WIDTH_CHARS, + -1, + true); g_signal_connect(dialog_, "response", G_CALLBACK(gtk_widget_destroy), NULL); g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroyThunk), this); diff --git a/chrome/browser/gtk/options/content_settings_window_gtk.cc b/chrome/browser/gtk/options/content_settings_window_gtk.cc index 3ad2a15..a9421d4 100644 --- a/chrome/browser/gtk/options/content_settings_window_gtk.cc +++ b/chrome/browser/gtk/options/content_settings_window_gtk.cc @@ -129,7 +129,7 @@ ContentSettingsWindowGtk::ContentSettingsWindowGtk(GtkWindow* parent, // Need to show the notebook before connecting switch-page signal, otherwise // we'll immediately get a signal switching to page 0 and overwrite our // last_selected_page_ value. - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, -1, -1, true); g_signal_connect(notebook_, "switch-page", G_CALLBACK(OnSwitchPageThunk), this); @@ -148,8 +148,7 @@ void ContentSettingsWindowGtk::ShowContentSettingsTab( ContentSettingsType page) { // Bring options window to front if it already existed and isn't already // in front - gtk_window_present_with_time(GTK_WINDOW(dialog_), - gtk_get_current_event_time()); + gtk_util::PresentWindow(dialog_, gtk_get_current_event_time()); if (page == CONTENT_SETTINGS_TYPE_DEFAULT) { // Remember the last visited page from local state. diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc index 1d67b5a..155e775 100644 --- a/chrome/browser/gtk/options/cookies_view.cc +++ b/chrome/browser/gtk/options/cookies_view.cc @@ -15,6 +15,7 @@ #include "chrome/browser/gtk/gtk_util.h" #include "gfx/gtk_util.h" #include "grit/generated_resources.h" +#include "grit/locale_settings.h" namespace { @@ -55,7 +56,7 @@ void CookiesView::Show( // If there's already an existing editor window, activate it. if (instance_) { - gtk_window_present(GTK_WINDOW(instance_->dialog_)); + gtk_util::PresentWindow(instance_->dialog_, 0); } else { instance_ = new CookiesView(parent, profile, @@ -78,7 +79,12 @@ CookiesView::CookiesView( filter_update_factory_(this), destroy_dialog_in_destructor_(false) { Init(parent); - gtk_widget_show_all(dialog_); + + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_COOKIES_DIALOG_WIDTH_CHARS, + -1, + true); + gtk_chrome_cookie_view_clear(GTK_CHROME_COOKIE_VIEW(cookie_display_)); } diff --git a/chrome/browser/gtk/options/fonts_languages_window_gtk.cc b/chrome/browser/gtk/options/fonts_languages_window_gtk.cc index 3b3b750..d51c10e 100644 --- a/chrome/browser/gtk/options/fonts_languages_window_gtk.cc +++ b/chrome/browser/gtk/options/fonts_languages_window_gtk.cc @@ -97,7 +97,7 @@ FontsLanguagesWindowGtk::FontsLanguagesWindowGtk(Profile* profile) IDS_FONT_LANGUAGE_SETTING_LANGUAGES_TAB_TITLE).c_str())); // Show the notebook. - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, -1, -1, false); // We only have one button and don't do any special handling, so just hook it // directly to gtk_widget_destroy. @@ -117,7 +117,7 @@ void FontsLanguagesWindowGtk::ShowTabPage(gfx::NativeWindow window, // Bring options window to front if it already existed and isn't already // in front. - gtk_window_present(GTK_WINDOW(dialog_)); + gtk_util::PresentWindow(dialog_, 0); // If the page is out of bounds, reset to the first tab. if (page < 0 || page >= gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_))) diff --git a/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc b/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc index 0274faf..84c4b57 100644 --- a/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc +++ b/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc @@ -11,6 +11,7 @@ #include "chrome/browser/gtk/gtk_util.h" #include "gfx/gtk_util.h" #include "grit/generated_resources.h" +#include "grit/locale_settings.h" namespace { @@ -24,8 +25,11 @@ void GeolocationContentExceptionsWindow::ShowExceptionsWindow( GtkWindow* parent, GeolocationContentSettingsMap* map) { DCHECK(map); - if (!instance) + if (!instance) { instance = new GeolocationContentExceptionsWindow(parent, map); + } else { + gtk_util::PresentWindow(instance->dialog_, 0); + } } GeolocationContentExceptionsWindow::GeolocationContentExceptionsWindow( @@ -111,7 +115,10 @@ GeolocationContentExceptionsWindow::GeolocationContentExceptionsWindow( UpdateButtonState(); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_GEOLOCATION_EXCEPTION_DIALOG_WIDTH_CHARS, + IDS_GEOLOCATION_EXCEPTION_DIALOG_HEIGHT_LINES, + true); g_signal_connect(dialog_, "response", G_CALLBACK(gtk_widget_destroy), NULL); g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroyThunk), this); diff --git a/chrome/browser/gtk/options/passwords_exceptions_window_gtk.cc b/chrome/browser/gtk/options/passwords_exceptions_window_gtk.cc index 1abcf72..33fa5b3 100644 --- a/chrome/browser/gtk/options/passwords_exceptions_window_gtk.cc +++ b/chrome/browser/gtk/options/passwords_exceptions_window_gtk.cc @@ -102,19 +102,16 @@ PasswordsExceptionsWindowGtk::PasswordsExceptionsWindowGtk(Profile* profile) gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); - gtk_widget_realize(dialog_); - gtk_util::SetWindowSizeFromResources(GTK_WINDOW(dialog_), - IDS_PASSWORDS_DIALOG_WIDTH_CHARS, - IDS_PASSWORDS_DIALOG_HEIGHT_LINES, - true); - // We only have one button and don't do any special handling, so just hook it // directly to gtk_widget_destroy. g_signal_connect(dialog_, "response", G_CALLBACK(gtk_widget_destroy), NULL); g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroy), this); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_PASSWORDS_DIALOG_WIDTH_CHARS, + IDS_PASSWORDS_DIALOG_HEIGHT_LINES, + true); } PasswordsExceptionsWindowGtk::~PasswordsExceptionsWindowGtk() { @@ -123,7 +120,7 @@ PasswordsExceptionsWindowGtk::~PasswordsExceptionsWindowGtk() { void PasswordsExceptionsWindowGtk::Show() { // Bring options window to front if it already existed and isn't already // in front - gtk_window_present(GTK_WINDOW(dialog_)); + gtk_util::PresentWindow(dialog_, 0); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc index b5e5a5b..11a50ea 100644 --- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc +++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc @@ -166,7 +166,10 @@ UrlPickerDialogGtk::UrlPickerDialogGtk(UrlPickerCallback* callback, &width, NULL); gtk_tree_view_column_set_fixed_width(column, width); - gtk_widget_show_all(dialog_); + gtk_util::ShowDialogWithLocalizedSize(dialog_, + IDS_URLPICKER_DIALOG_WIDTH_CHARS, + IDS_URLPICKER_DIALOG_HEIGHT_LINES, + false); g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroyThunk), this); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d8e42d8..b1a32ad 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -429,6 +429,8 @@ 'browser/chromeos/login/wizard_screen.h', 'browser/chromeos/low_battery_observer.cc', 'browser/chromeos/low_battery_observer.h', + 'browser/chromeos/native_dialog_window.cc', + 'browser/chromeos/native_dialog_window.h', 'browser/chromeos/network_list.cc', 'browser/chromeos/network_list.h', 'browser/chromeos/options/internet_page_view.cc', |