diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 17:50:34 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 17:50:34 +0000 |
commit | 08fb74a9f12f59c531cc5d7acdb0afea183dba12 (patch) | |
tree | 78eb1b586a658ac8433c2972a518748ad9ce47dc /chrome/browser/gtk | |
parent | 4a3cb4ea699653a8e516b00c057a4f7df20f2343 (diff) | |
download | chromium_src-08fb74a9f12f59c531cc5d7acdb0afea183dba12.zip chromium_src-08fb74a9f12f59c531cc5d7acdb0afea183dba12.tar.gz chromium_src-08fb74a9f12f59c531cc5d7acdb0afea183dba12.tar.bz2 |
Improve the look of the Linux omnibox.
- Paint a border around the input widget, which makes it fit better into the
toolbar. A bordered widget is also very nice to have for debugging, so I
abstracted a small helper for making a bordered bin.
- Improve the results popup by painting with some Pango attributes. Sort of
looks awful over NX, but I'm hoping it looks better on a real session.
BUG=8236
Review URL: http://codereview.chromium.org/46035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.cc | 43 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.h | 12 |
2 files changed, 39 insertions, 16 deletions
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index f927092..4f6d623 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -7,6 +7,7 @@ #include <string> #include "base/basictypes.h" +#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/string_util.h" #include "chrome/app/chrome_dll_resource.h" @@ -18,9 +19,22 @@ #include "skia/include/SkBitmap.h" #include "webkit/glue/window_open_disposition.h" +namespace { + +// We are positioned with a little bit of extra space that we don't use now. +const int kTopPadding = 1; +const int kBottomPadding = 2; + +// TODO(deanm): Eventually this should be painted with the background png +// image, but for now we get pretty close by just drawing a solid border. +const GdkColor kBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4); + +} // namespace + LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater, ToolbarModel* toolbar_model) - : vbox_(NULL), + : outer_bin_(NULL), + inner_vbox_(NULL), profile_(NULL), command_updater_(command_updater), toolbar_model_(toolbar_model), @@ -29,9 +43,7 @@ LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater, } LocationBarViewGtk::~LocationBarViewGtk() { - // TODO(deanm): Should I destroy the widgets here, or leave it up to the - // embedder? When the embedder destroys their widget, if we're a child, we - // will also get destroyed, so the ownership is kinda unclear. + gtk_widget_destroy(outer_bin_); } void LocationBarViewGtk::Init() { @@ -41,17 +53,24 @@ void LocationBarViewGtk::Init() { command_updater_)); location_entry_->Init(); - vbox_ = gtk_vbox_new(false, 0); + inner_vbox_ = gtk_vbox_new(false, 0); + + // TODO(deanm): We use a bunch of widgets to get things to layout with a + // border, etc. This should eventually be custom paint using the correct + // background image, etc. + gtk_box_pack_start(GTK_BOX(inner_vbox_), location_entry_->widget(), + TRUE, TRUE, 0); - // Get the location bar to fit nicely in the toolbar, kinda ugly. - static const int kTopPadding = 2; - static const int kBottomPadding = 3; - GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); - gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), + // Use an alignment to position our bordered location entry exactly. + outer_bin_ = gtk_alignment_new(0, 0, 1, 1); + gtk_alignment_set_padding(GTK_ALIGNMENT(outer_bin_), kTopPadding, kBottomPadding, 0, 0); - gtk_container_add(GTK_CONTAINER(alignment), location_entry_->widget()); + gtk_container_add( + GTK_CONTAINER(outer_bin_), + gfx::CreateGtkBorderBin(inner_vbox_, &kBorderColor, 1, 1, 0, 0)); - gtk_box_pack_start(GTK_BOX(vbox_), alignment, TRUE, TRUE, 0); + // Sink the ref so that we own the widget, and will destroy on destruction. + g_object_ref_sink(outer_bin_); } void LocationBarViewGtk::SetProfile(Profile* profile) { diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index 448bd5b..a970e34 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -33,9 +33,8 @@ class LocationBarViewGtk : public AutocompleteEditController, void SetProfile(Profile* profile); - // Return the native vbox widget. You must call Init() first, or the result - // will be NULL. This is the widget that an embedder should host. - GtkWidget* widget() { return vbox_; } + // Returns the widget the caller should host. You must call Init() first. + GtkWidget* widget() { return outer_bin_; } // Updates the location bar. We also reset the bar's permanent text and // security style, and, if |tab_for_state_restoring| is non-NULL, also @@ -64,7 +63,12 @@ class LocationBarViewGtk : public AutocompleteEditController, virtual void SaveStateToContents(TabContents* contents); private: - GtkWidget* vbox_; + // The outermost widget we want to be hosted. + GtkWidget* outer_bin_; + + // This is the widget you probably care about, our inner vbox (inside the + // the border) which holds the elements inside the location bar. + GtkWidget* inner_vbox_; scoped_ptr<AutocompleteEditViewGtk> location_entry_; |