diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 18:56:27 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 18:56:27 +0000 |
commit | ef921826834b693e83ebe3a4ae6984b9b39b723b (patch) | |
tree | cdd47055756ceadb597d06d0a18b5e56a37d9a99 /chrome/browser/autocomplete | |
parent | b2b26af9cd8e5d436fdf27d2f266ad3c23f7a192 (diff) | |
download | chromium_src-ef921826834b693e83ebe3a4ae6984b9b39b723b.zip chromium_src-ef921826834b693e83ebe3a4ae6984b9b39b723b.tar.gz chromium_src-ef921826834b693e83ebe3a4ae6984b9b39b723b.tar.bz2 |
Override GtkTextView's size request width in the Linux Omnibox.
GtkTextView requests enough space to fit all of the text. It turns out if you
weren't doing something to restrict the window size (like using a tiling
manager) long text in the edit would push the window to fit the text.
Review URL: http://codereview.chromium.org/93127
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14449 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 13 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.h | 8 |
2 files changed, 21 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index 5310667..6e8efed 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -123,6 +123,12 @@ void AutocompleteEditViewGtk::Init() { // signal, but it is very convenient and clean for catching up/down. g_signal_connect(text_view_, "move-cursor", G_CALLBACK(&HandleViewMoveCursorThunk), this); + // Override the size request. We want to keep the original height request + // from the widget, since that's font dependent. We want to ignore the width + // so we don't force a minimum width based on the text length. + g_signal_connect(text_view_, "size-request", + G_CALLBACK(&HandleViewSizeRequestThunk), this); + } void AutocompleteEditViewGtk::SetFocus() { @@ -455,6 +461,13 @@ void AutocompleteEditViewGtk::HandleViewMoveCursor( // Propagate into GtkTextView. } +gboolean AutocompleteEditViewGtk::HandleViewSizeRequest(GtkRequisition* req) { + // Don't force a minimum width, but use the font-relative height. + GTK_WIDGET_GET_CLASS(text_view_)->size_request(text_view_, req); + req->width = 1; + return TRUE; // We already called the default handler. +} + AutocompleteEditViewGtk::CharRange AutocompleteEditViewGtk::GetSelection() { // You can not just use get_selection_bounds here, since the order will be // ascending, and you don't know where the user's start and end of the diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h index 7eef26b..7ee00dd 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h @@ -162,6 +162,14 @@ class AutocompleteEditViewGtk : public AutocompleteEditView { gint count, gboolean extendion_selection); + static gboolean HandleViewSizeRequestThunk(GtkWidget* view, + GtkRequisition* req, + gpointer self) { + return reinterpret_cast<AutocompleteEditViewGtk*>(self)-> + HandleViewSizeRequest(req); + } + gboolean HandleViewSizeRequest(GtkRequisition* req); + // Get the character indices of the current selection. This honors // direction, cp_max is the insertion point, and cp_min is the bound. CharRange GetSelection(); |