summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/browser_toolbar_view_gtk.cc35
-rw-r--r--chrome/browser/gtk/browser_toolbar_view_gtk.h11
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc2
3 files changed, 40 insertions, 8 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_view_gtk.cc b/chrome/browser/gtk/browser_toolbar_view_gtk.cc
index 28a40dc..b2ba34b 100644
--- a/chrome/browser/gtk/browser_toolbar_view_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_view_gtk.cc
@@ -130,6 +130,7 @@ gboolean BrowserToolbarGtk::CustomDrawButton::OnExpose(
BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser)
: toolbar_(NULL),
+ entry_(NULL),
model_(browser->toolbar_model()),
browser_(browser),
profile_(NULL) {
@@ -176,9 +177,11 @@ void BrowserToolbarGtk::Init(Profile* profile) {
star_.reset(BuildToolbarButton(IDR_STAR, IDR_STAR_P, IDR_STAR_H, IDR_STAR_D,
l10n_util::GetString(IDS_TOOLTIP_STAR), false));
- GtkWidget* entry = gtk_entry_new();
- gtk_widget_set_size_request(entry, 0, 27);
- gtk_box_pack_start(GTK_BOX(toolbar_), entry, TRUE, TRUE, 0);
+ entry_ = gtk_entry_new();
+ gtk_widget_set_size_request(entry_, 0, 27);
+ g_signal_connect(G_OBJECT(entry_), "activate",
+ G_CALLBACK(OnEntryActivate), this);
+ gtk_box_pack_start(GTK_BOX(toolbar_), entry_, TRUE, TRUE, 0);
go_.reset(BuildToolbarButton(IDR_GO, IDR_GO_P, IDR_GO_H, 0, L"", false));
@@ -251,6 +254,13 @@ void BrowserToolbarGtk::SetProfile(Profile* profile) {
// location_bar_->SetProfile(profile);
}
+void BrowserToolbarGtk::UpdateTabContents(TabContents* contents,
+ bool should_restore_state) {
+ // Extract the UTF-8 representation of the URL.
+ gtk_entry_set_text(GTK_ENTRY(entry_),
+ contents->GetURL().possibly_invalid_spec().c_str());
+}
+
// TODO(port): This needs to deal with our styled pixmaps.
BrowserToolbarGtk::CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
int normal_id, int active_id, int highlight_id, int depressed_id,
@@ -258,10 +268,10 @@ BrowserToolbarGtk::CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
CustomDrawButton* button = new CustomDrawButton(normal_id, active_id,
highlight_id, depressed_id);
- // TODO(erg): Mismatch between wstring and string.
- // gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tooltips_),
- // GTK_WIDGET(back_),
- // localized_tooltip, localized_tooltip);
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tooltips_),
+ GTK_WIDGET(button->widget()),
+ WideToUTF8(localized_tooltip).c_str(),
+ WideToUTF8(localized_tooltip).c_str());
if (menu_button) {
g_signal_connect(G_OBJECT(button->widget()), "button_press_event",
G_CALLBACK(OnMenuButtonPressEvent), this);
@@ -275,6 +285,17 @@ BrowserToolbarGtk::CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
}
/* static */
+void BrowserToolbarGtk::OnEntryActivate(GtkEntry *entry,
+ BrowserToolbarGtk* toolbar) {
+ GURL dest(std::string(gtk_entry_get_text(entry)));
+ toolbar->browser_->OpenURLFromTab(NULL, dest, GURL(),
+ CURRENT_TAB,
+ PageTransition::TYPED);
+ toolbar->browser_->GetSelectedTabContents()->
+ OpenURL(dest, GURL(), CURRENT_TAB, PageTransition::TYPED);
+}
+
+/* static */
void BrowserToolbarGtk::OnButtonClick(GtkWidget* button,
BrowserToolbarGtk* toolbar) {
int tag = -1;
diff --git a/chrome/browser/gtk/browser_toolbar_view_gtk.h b/chrome/browser/gtk/browser_toolbar_view_gtk.h
index e958f6a..e98097a 100644
--- a/chrome/browser/gtk/browser_toolbar_view_gtk.h
+++ b/chrome/browser/gtk/browser_toolbar_view_gtk.h
@@ -15,6 +15,7 @@
class Browser;
class Profile;
+class TabContents;
class ToolbarModel;
// View class that displays the GTK version of the toolbar and routes gtk
@@ -44,6 +45,9 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
void SetProfile(Profile* profile);
+ // Message that we should react to a state change.
+ void UpdateTabContents(TabContents* contents, bool should_restore_state);
+
private:
class CustomDrawButton; // Defined in the .cc file.
@@ -55,6 +59,10 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
const std::wstring& localized_tooltip,
bool menu_button);
+ // Gtk callback for the "activate" signal on the |entry_| widget. Responds to
+ // enter.
+ static void OnEntryActivate(GtkEntry *entry, BrowserToolbarGtk* toolbar);
+
// Gtk callback for the "clicked" signal.
static void OnButtonClick(GtkWidget* button, BrowserToolbarGtk* toolbar);
@@ -76,6 +84,9 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
// Tooltip container for all GTK widgets in this class.
GtkTooltips* toolbar_tooltips_;
+ // Our temporary URL bar (until we get the omnibox up).
+ GtkWidget* entry_;
+
// All the buttons in the toolbar.
scoped_ptr<CustomDrawButton> back_, forward_;
scoped_ptr<CustomDrawButton> reload_, home_;
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 6b739dc..6250b77 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -241,7 +241,7 @@ void BrowserWindowGtk::UpdateStopGoState(bool is_loading) {
void BrowserWindowGtk::UpdateToolbar(TabContents* contents,
bool should_restore_state) {
- NOTIMPLEMENTED();
+ toolbar_->UpdateTabContents(contents, should_restore_state);
}
void BrowserWindowGtk::FocusToolbar() {