diff options
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/gtk/edit_search_engine_dialog.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_util.cc | 65 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_util.h | 14 | ||||
-rw-r--r-- | chrome/browser/gtk/import_dialog_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/gtk/keyword_editor_view.cc | 14 | ||||
-rw-r--r-- | chrome/browser/gtk/options/content_exception_editor.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/options/content_exceptions_window_gtk.cc | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/options/content_settings_window_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/options/cookies_view.cc | 10 | ||||
-rw-r--r-- | chrome/browser/gtk/options/fonts_languages_window_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/options/geolocation_content_exceptions_window.cc | 11 | ||||
-rw-r--r-- | chrome/browser/gtk/options/passwords_exceptions_window_gtk.cc | 13 | ||||
-rw-r--r-- | chrome/browser/gtk/options/url_picker_dialog_gtk.cc | 5 |
14 files changed, 130 insertions, 42 deletions
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); |