diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-09 00:52:19 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-09 00:52:19 +0000 |
commit | 3a991672550ca9b6f4046ab1232caf8d48d14b23 (patch) | |
tree | d4e92a6c4dfaea27ff8c962daf4fa210bc40c148 /chrome | |
parent | 635437c0531761ca0cf7a9de06ba1c4b3bbb9c44 (diff) | |
download | chromium_src-3a991672550ca9b6f4046ab1232caf8d48d14b23.zip chromium_src-3a991672550ca9b6f4046ab1232caf8d48d14b23.tar.gz chromium_src-3a991672550ca9b6f4046ab1232caf8d48d14b23.tar.bz2 |
linux: set a minimum size for dialogs based on locale resources
GTK dialogs size to their contents, but sometimes the title is the
longest string available.
BUG=28024
Review URL: http://codereview.chromium.org/534006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/resources/locale_settings.grd | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/import_dialog_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/views/create_application_shortcut_view.cc | 1 | ||||
-rw-r--r-- | chrome/common/gtk_util.cc | 13 | ||||
-rw-r--r-- | chrome/common/gtk_util.h | 7 |
7 files changed, 41 insertions, 7 deletions
diff --git a/chrome/app/resources/locale_settings.grd b/chrome/app/resources/locale_settings.grd index a122250..0bbc205 100644 --- a/chrome/app/resources/locale_settings.grd +++ b/chrome/app/resources/locale_settings.grd @@ -663,6 +663,11 @@ <message name="IDS_DOWNLOAD_IN_PROGRESS_MINIMUM_HEIGHT_LINES" use_name_for_id="true"> 4 </message> + + <!-- The width for the "create application shortcuts" dialog in characters. --> + <message name="IDS_CREATE_SHORTCUTS_DIALOG_WIDTH_CHARS" use_name_for_id="true"> + 55 + </message> </messages> </release> </grit> diff --git a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc index 07b911d..b85d86b 100644 --- a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc +++ b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc @@ -12,6 +12,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "grit/generated_resources.h" +#include "grit/locale_settings.h" // static void ClearBrowsingDataDialogGtk::Show(GtkWindow* parent, Profile* profile) { @@ -29,6 +30,10 @@ ClearBrowsingDataDialogGtk::ClearBrowsingDataDialogGtk(GtkWindow* parent, GTK_STOCK_CLOSE, GTK_RESPONSE_REJECT, NULL); + gtk_widget_realize(dialog); + gtk_util::SetWindowWidthFromResources(GTK_WINDOW(dialog), + IDS_CLEARDATA_DIALOG_WIDTH_CHARS, + /* resizable */ false); gtk_util::AddButtonToDialog(dialog, l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_COMMIT).c_str(), GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); @@ -127,7 +132,6 @@ ClearBrowsingDataDialogGtk::ClearBrowsingDataDialogGtk(GtkWindow* parent, g_signal_connect(dialog, "response", G_CALLBACK(HandleOnResponseDialog), this); - gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_widget_show_all(dialog); } diff --git a/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc index 56a5908..61105d3 100644 --- a/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc +++ b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc @@ -8,6 +8,7 @@ #include "chrome/browser/shell_integration.h" #include "chrome/common/gtk_util.h" #include "grit/generated_resources.h" +#include "grit/locale_settings.h" // static void CreateApplicationShortcutsDialogGtk::Show(GtkWindow* parent, @@ -33,6 +34,10 @@ CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk( GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); + gtk_widget_realize(dialog); + gtk_util::SetWindowWidthFromResources(GTK_WINDOW(dialog), + IDS_CREATE_SHORTCUTS_DIALOG_WIDTH_CHARS, + /* resizable */ false); gtk_util::AddButtonToDialog(dialog, l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_COMMIT).c_str(), GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); @@ -63,7 +68,6 @@ CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk( g_signal_connect(dialog, "response", G_CALLBACK(HandleOnResponseDialog), this); - gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_widget_show_all(dialog); } diff --git a/chrome/browser/gtk/import_dialog_gtk.cc b/chrome/browser/gtk/import_dialog_gtk.cc index 9acd79e..443d453 100644 --- a/chrome/browser/gtk/import_dialog_gtk.cc +++ b/chrome/browser/gtk/import_dialog_gtk.cc @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "chrome/common/gtk_util.h" #include "grit/generated_resources.h" +#include "grit/locale_settings.h" // static void ImportDialogGtk::Show(GtkWindow* parent, Profile* profile) { @@ -35,6 +36,10 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); + gtk_widget_realize(dialog_); + gtk_util::SetWindowWidthFromResources(GTK_WINDOW(dialog_), + IDS_IMPORT_DIALOG_WIDTH_CHARS, + /* resizable */ false); importer_host_->set_parent_window(GTK_WINDOW(dialog_)); // Add import button separately as we might need to disable it, if @@ -45,10 +50,6 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) GTK_WIDGET_SET_FLAGS(import_button, GTK_CAN_DEFAULT); gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); - // 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; gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); @@ -114,7 +115,6 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) g_signal_connect(dialog_, "response", G_CALLBACK(HandleOnResponseDialog), this); - gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE); gtk_widget_show_all(dialog_); } diff --git a/chrome/browser/views/create_application_shortcut_view.cc b/chrome/browser/views/create_application_shortcut_view.cc index 37d4b81..63d55c9 100644 --- a/chrome/browser/views/create_application_shortcut_view.cc +++ b/chrome/browser/views/create_application_shortcut_view.cc @@ -312,6 +312,7 @@ void CreateApplicationShortcutView::Init() { } gfx::Size CreateApplicationShortcutView::GetPreferredSize() { + // TODO(evanm): should this use IDS_CREATE_SHORTCUTS_DIALOG_WIDTH_CHARS? static const int kDialogWidth = 360; int height = GetLayoutManager()->GetPreferredHeightForWidth(this, kDialogWidth); diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index 75a5acf..f63fd69 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -219,6 +219,19 @@ void GetWidgetSizeFromCharacters(GtkWidget* widget, double width_chars, g_object_unref(context); } +void SetWindowWidthFromResources(GtkWindow* window, int resource_id, + bool resizable) { + int width; + gtk_util::GetWidgetSizeFromResources(GTK_WIDGET(window), resource_id, 0, + &width, NULL); + if (resizable) { + gtk_window_set_default_size(window, width, -1); + } else { + gtk_widget_set_size_request(GTK_WIDGET(window), width, -1); + } + gtk_window_set_resizable(window, resizable ? TRUE : FALSE); +} + void RemoveAllChildren(GtkWidget* container) { gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); } diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h index f92c3ad..1e7c636 100644 --- a/chrome/common/gtk_util.h +++ b/chrome/common/gtk_util.h @@ -81,6 +81,13 @@ void GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, void GetWidgetSizeFromCharacters(GtkWidget* widget, double width_chars, double height_lines, int* width, int* height); +// As above, but a convenience method for configuring dialog width. +// |resizable| also controls whether the dialog will be resizable +// (this info is also necessary for getting the width-setting code +// right). +void SetWindowWidthFromResources(GtkWindow* window, int resource_id, + bool resizable); + // Remove all children from this container. void RemoveAllChildren(GtkWidget* container); |