Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Side by Side Diff: chrome/browser/gtk/location_bar_view_gtk.cc

Issue 46035: Improve the look of the Linux omnibox. (Closed)
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/location_bar_view_gtk.h" 5 #include "chrome/browser/gtk/location_bar_view_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/gfx/gtk_util.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "chrome/app/chrome_dll_resource.h" 13 #include "chrome/app/chrome_dll_resource.h"
13 #include "chrome/browser/alternate_nav_url_fetcher.h" 14 #include "chrome/browser/alternate_nav_url_fetcher.h"
14 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" 15 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
15 #include "chrome/browser/command_updater.h" 16 #include "chrome/browser/command_updater.h"
16 #include "chrome/browser/tab_contents/tab_contents.h" 17 #include "chrome/browser/tab_contents/tab_contents.h"
17 #include "chrome/common/page_transition_types.h" 18 #include "chrome/common/page_transition_types.h"
18 #include "skia/include/SkBitmap.h" 19 #include "skia/include/SkBitmap.h"
19 #include "webkit/glue/window_open_disposition.h" 20 #include "webkit/glue/window_open_disposition.h"
20 21
22 namespace {
23
24 // We are positioned with a little bit of extra space that we don't use now.
25 const int kTopPadding = 1;
26 const int kBottomPadding = 2;
27
28 // TODO(deanm): Eventually this should be painted with the background png
29 // image, but for now we get pretty close by just drawing a solid border.
30 const GdkColor kBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4);
31
32 } // namespace
33
21 LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater, 34 LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater,
22 ToolbarModel* toolbar_model) 35 ToolbarModel* toolbar_model)
23 : vbox_(NULL), 36 : outer_bin_(NULL),
37 inner_vbox_(NULL),
24 profile_(NULL), 38 profile_(NULL),
25 command_updater_(command_updater), 39 command_updater_(command_updater),
26 toolbar_model_(toolbar_model), 40 toolbar_model_(toolbar_model),
27 disposition_(CURRENT_TAB), 41 disposition_(CURRENT_TAB),
28 transition_(PageTransition::TYPED) { 42 transition_(PageTransition::TYPED) {
29 } 43 }
30 44
31 LocationBarViewGtk::~LocationBarViewGtk() { 45 LocationBarViewGtk::~LocationBarViewGtk() {
32 // TODO(deanm): Should I destroy the widgets here, or leave it up to the 46 gtk_widget_destroy(outer_bin_);
33 // embedder? When the embedder destroys their widget, if we're a child, we
34 // will also get destroyed, so the ownership is kinda unclear.
35 } 47 }
36 48
37 void LocationBarViewGtk::Init() { 49 void LocationBarViewGtk::Init() {
38 location_entry_.reset(new AutocompleteEditViewGtk(this, 50 location_entry_.reset(new AutocompleteEditViewGtk(this,
39 toolbar_model_, 51 toolbar_model_,
40 profile_, 52 profile_,
41 command_updater_)); 53 command_updater_));
42 location_entry_->Init(); 54 location_entry_->Init();
43 55
44 vbox_ = gtk_vbox_new(false, 0); 56 inner_vbox_ = gtk_vbox_new(false, 0);
45 57
46 // Get the location bar to fit nicely in the toolbar, kinda ugly. 58 // TODO(deanm): We use a bunch of widgets to get things to layout with a
47 static const int kTopPadding = 2; 59 // border, etc. This should eventually be custom paint using the correct
48 static const int kBottomPadding = 3; 60 // background image, etc.
49 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 61 gtk_box_pack_start(GTK_BOX(inner_vbox_), location_entry_->widget(),
50 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 62 TRUE, TRUE, 0);
63
64 // Use an alignment to position our bordered location entry exactly.
65 outer_bin_ = gtk_alignment_new(0, 0, 1, 1);
66 gtk_alignment_set_padding(GTK_ALIGNMENT(outer_bin_),
51 kTopPadding, kBottomPadding, 0, 0); 67 kTopPadding, kBottomPadding, 0, 0);
52 gtk_container_add(GTK_CONTAINER(alignment), location_entry_->widget()); 68 gtk_container_add(
69 GTK_CONTAINER(outer_bin_),
70 gfx::CreateGtkBorderBin(inner_vbox_, &kBorderColor, 1, 1, 0, 0));
53 71
54 gtk_box_pack_start(GTK_BOX(vbox_), alignment, TRUE, TRUE, 0); 72 // Sink the ref so that we own the widget, and will destroy on destruction.
73 g_object_ref_sink(outer_bin_);
55 } 74 }
56 75
57 void LocationBarViewGtk::SetProfile(Profile* profile) { 76 void LocationBarViewGtk::SetProfile(Profile* profile) {
58 profile_ = profile; 77 profile_ = profile;
59 } 78 }
60 79
61 void LocationBarViewGtk::Update(const TabContents* contents) { 80 void LocationBarViewGtk::Update(const TabContents* contents) {
62 location_entry_->Update(contents); 81 location_entry_->Update(contents);
63 } 82 }
64 83
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 161 }
143 162
144 void LocationBarViewGtk::FocusSearch() { 163 void LocationBarViewGtk::FocusSearch() {
145 location_entry_->SetUserText(L"?"); 164 location_entry_->SetUserText(L"?");
146 location_entry_->SetFocus(); 165 location_entry_->SetFocus();
147 } 166 }
148 167
149 void LocationBarViewGtk::SaveStateToContents(TabContents* contents) { 168 void LocationBarViewGtk::SaveStateToContents(TabContents* contents) {
150 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
151 } 170 }
OLDNEW
« chrome/browser/gtk/location_bar_view_gtk.h ('K') | « chrome/browser/gtk/location_bar_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698