summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/location_bar_view_gtk.cc
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 17:50:34 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 17:50:34 +0000
commit08fb74a9f12f59c531cc5d7acdb0afea183dba12 (patch)
tree78eb1b586a658ac8433c2972a518748ad9ce47dc /chrome/browser/gtk/location_bar_view_gtk.cc
parent4a3cb4ea699653a8e516b00c057a4f7df20f2343 (diff)
downloadchromium_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/location_bar_view_gtk.cc')
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc43
1 files changed, 31 insertions, 12 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) {