| OLD | NEW |
| 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/browser_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 g_object_unref(accel_group_); | 89 g_object_unref(accel_group_); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void BrowserToolbarGtk::Init(Profile* profile, | 92 void BrowserToolbarGtk::Init(Profile* profile, |
| 93 GtkWindow* top_level_window) { | 93 GtkWindow* top_level_window) { |
| 94 // Make sure to tell the location bar the profile before calling its Init. | 94 // Make sure to tell the location bar the profile before calling its Init. |
| 95 SetProfile(profile); | 95 SetProfile(profile); |
| 96 | 96 |
| 97 show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); | 97 show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); |
| 98 | 98 |
| 99 event_box_ = gtk_event_box_new(); |
| 100 |
| 99 toolbar_ = gtk_hbox_new(FALSE, kToolbarWidgetSpacing); | 101 toolbar_ = gtk_hbox_new(FALSE, kToolbarWidgetSpacing); |
| 102 gtk_container_add(GTK_CONTAINER(event_box_), toolbar_); |
| 100 gtk_container_set_border_width(GTK_CONTAINER(toolbar_), 4); | 103 gtk_container_set_border_width(GTK_CONTAINER(toolbar_), 4); |
| 101 // Demand we're always at least kToolbarHeight tall. | 104 // Demand we're always at least kToolbarHeight tall. |
| 102 // -1 for width means "let GTK do its normal sizing". | 105 // -1 for width means "let GTK do its normal sizing". |
| 103 gtk_widget_set_size_request(toolbar_, -1, kToolbarHeight); | 106 gtk_widget_set_size_request(toolbar_, -1, kToolbarHeight); |
| 104 g_signal_connect(toolbar_, "expose-event", | 107 g_signal_connect(toolbar_, "expose-event", |
| 105 G_CALLBACK(&OnToolbarExpose), this); | 108 G_CALLBACK(&OnToolbarExpose), this); |
| 106 | 109 |
| 107 // A GtkAccelGroup is not InitiallyUnowned, meaning we get a real reference | 110 // A GtkAccelGroup is not InitiallyUnowned, meaning we get a real reference |
| 108 // count starting at one. We don't want the lifetime to be managed by the | 111 // count starting at one. We don't want the lifetime to be managed by the |
| 109 // top level window, since the lifetime should be tied to the C++ object. | 112 // top level window, since the lifetime should be tied to the C++ object. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 G_CALLBACK(OnPageAppMenuMouseMotion), this); | 172 G_CALLBACK(OnPageAppMenuMouseMotion), this); |
| 170 g_signal_connect(app_menu_->widget(), "move-current", | 173 g_signal_connect(app_menu_->widget(), "move-current", |
| 171 G_CALLBACK(OnPageAppMenuMoveCurrent), this); | 174 G_CALLBACK(OnPageAppMenuMoveCurrent), this); |
| 172 gtk_box_pack_start(GTK_BOX(menus_hbox_), chrome_menu, FALSE, FALSE, 0); | 175 gtk_box_pack_start(GTK_BOX(menus_hbox_), chrome_menu, FALSE, FALSE, 0); |
| 173 | 176 |
| 174 gtk_box_pack_start(GTK_BOX(toolbar_), menus_hbox_, FALSE, FALSE, 0); | 177 gtk_box_pack_start(GTK_BOX(toolbar_), menus_hbox_, FALSE, FALSE, 0); |
| 175 | 178 |
| 176 // Force all the CustomDrawButtons to load the correct rendering style. | 179 // Force all the CustomDrawButtons to load the correct rendering style. |
| 177 UserChangedTheme(); | 180 UserChangedTheme(); |
| 178 | 181 |
| 179 gtk_widget_show_all(toolbar_); | 182 gtk_widget_show_all(event_box_); |
| 180 | 183 |
| 181 if (show_home_button_.GetValue()) { | 184 if (show_home_button_.GetValue()) { |
| 182 gtk_widget_show(home_->widget()); | 185 gtk_widget_show(home_->widget()); |
| 183 } else { | 186 } else { |
| 184 gtk_widget_hide(home_->widget()); | 187 gtk_widget_hide(home_->widget()); |
| 185 } | 188 } |
| 186 } | 189 } |
| 187 | 190 |
| 188 void BrowserToolbarGtk::AddToolbarToBox(GtkWidget* box) { | 191 void BrowserToolbarGtk::AddToolbarToBox(GtkWidget* box) { |
| 189 gtk_box_pack_start(GTK_BOX(box), toolbar_, FALSE, FALSE, 0); | 192 gtk_box_pack_start(GTK_BOX(box), event_box_, FALSE, FALSE, 0); |
| 190 } | 193 } |
| 191 | 194 |
| 192 void BrowserToolbarGtk::Show() { | 195 void BrowserToolbarGtk::Show() { |
| 193 gtk_widget_show(toolbar_); | 196 gtk_widget_show(toolbar_); |
| 194 } | 197 } |
| 195 | 198 |
| 196 void BrowserToolbarGtk::Hide() { | 199 void BrowserToolbarGtk::Hide() { |
| 197 gtk_widget_hide(toolbar_); | 200 gtk_widget_hide(toolbar_); |
| 198 } | 201 } |
| 199 | 202 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 break; | 526 break; |
| 524 } | 527 } |
| 525 } | 528 } |
| 526 | 529 |
| 527 void BrowserToolbarGtk::InitNineBox() { | 530 void BrowserToolbarGtk::InitNineBox() { |
| 528 // TODO(estade): use |profile_|? | 531 // TODO(estade): use |profile_|? |
| 529 background_ninebox_.reset(new NineBox( | 532 background_ninebox_.reset(new NineBox( |
| 530 browser_->profile()->GetThemeProvider(), | 533 browser_->profile()->GetThemeProvider(), |
| 531 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0)); | 534 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0)); |
| 532 } | 535 } |
| OLD | NEW |