Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1246 // TODO(estade): after we manage browser activation, add a check to make sure | 1246 // TODO(estade): after we manage browser activation, add a check to make sure |
| 1247 // we are the active browser before calling RestoreFocus(). | 1247 // we are the active browser before calling RestoreFocus(). |
| 1248 if (!browser_->tabstrip_model()->closing_all()) { | 1248 if (!browser_->tabstrip_model()->closing_all()) { |
| 1249 new_contents->view()->RestoreFocus(); | 1249 new_contents->view()->RestoreFocus(); |
| 1250 if (new_contents->find_tab_helper()->find_ui_active()) | 1250 if (new_contents->find_tab_helper()->find_ui_active()) |
| 1251 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); | 1251 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 // Update all the UI bits. | 1254 // Update all the UI bits. |
| 1255 UpdateTitleBar(); | 1255 UpdateTitleBar(); |
| 1256 UpdateToolbar(new_contents, true); | |
| 1257 MaybeShowBookmarkBar(false); | 1256 MaybeShowBookmarkBar(false); |
| 1257 // It's the Browser object's responsibility to update our toolbar; this | |
|
Evan Stade
2011/11/12 00:06:26
I don't think this comment is strictly necessary a
| |
| 1258 // already happened before this Observer method was called. | |
| 1258 } | 1259 } |
| 1259 | 1260 |
| 1260 void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 1261 void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
| 1261 // Do nothing if we're in the process of closing the browser window. | 1262 // Do nothing if we're in the process of closing the browser window. |
| 1262 if (!window_) | 1263 if (!window_) |
| 1263 return; | 1264 return; |
| 1264 | 1265 |
| 1265 bool is_active = (GTK_WIDGET(window_)->window == active_window); | 1266 bool is_active = (GTK_WIDGET(window_)->window == active_window); |
| 1266 bool changed = (is_active != is_active_); | 1267 bool changed = (is_active != is_active_); |
| 1267 | 1268 |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2346 GdkScreen* screen = gtk_window_get_screen(window_); | 2347 GdkScreen* screen = gtk_window_get_screen(window_); |
| 2347 gint monitor_num = gdk_screen_get_monitor_at_window(screen, | 2348 gint monitor_num = gdk_screen_get_monitor_at_window(screen, |
| 2348 GTK_WIDGET(window_)->window); | 2349 GTK_WIDGET(window_)->window); |
| 2349 | 2350 |
| 2350 GdkRectangle monitor_size; | 2351 GdkRectangle monitor_size; |
| 2351 gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor_size); | 2352 gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor_size); |
| 2352 return bounds_.size() == gfx::Size(monitor_size.width, monitor_size.height); | 2353 return bounds_.size() == gfx::Size(monitor_size.width, monitor_size.height); |
| 2353 } | 2354 } |
| 2354 | 2355 |
| 2355 void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) { | 2356 void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) { |
| 2356 GtkWidget* parent = gtk_widget_get_parent(bookmark_bar_->widget()); | 2357 GtkWidget* target_parent = NULL; |
| 2357 if (parent) | |
| 2358 gtk_container_remove(GTK_CONTAINER(parent), bookmark_bar_->widget()); | |
| 2359 | |
| 2360 if (!is_floating) { | 2358 if (!is_floating) { |
| 2361 // Place the bookmark bar at the end of |window_vbox_|; this happens after | 2359 // Place the bookmark bar at the end of |window_vbox_|; this happens after |
| 2362 // we have placed the render area at the end of |window_vbox_| so we will | 2360 // we have placed the render area at the end of |window_vbox_| so we will |
| 2363 // be above the render area. | 2361 // be above the render area. |
| 2364 gtk_box_pack_end(GTK_BOX(window_vbox_), bookmark_bar_->widget(), | 2362 target_parent = window_vbox_; |
| 2365 FALSE, FALSE, 0); | |
| 2366 } else { | 2363 } else { |
| 2367 // Place the bookmark bar at the end of the render area; this happens after | 2364 // Place the bookmark bar at the end of the render area; this happens after |
| 2368 // the tab contents container has been placed there so we will be | 2365 // the tab contents container has been placed there so we will be |
| 2369 // above the webpage (in terms of y). | 2366 // above the webpage (in terms of y). |
| 2370 gtk_box_pack_end(GTK_BOX(render_area_vbox_), bookmark_bar_->widget(), | 2367 target_parent = render_area_vbox_; |
| 2368 } | |
| 2369 | |
| 2370 GtkWidget* parent = gtk_widget_get_parent(bookmark_bar_->widget()); | |
| 2371 if (parent != target_parent) { | |
| 2372 if (parent) | |
| 2373 gtk_container_remove(GTK_CONTAINER(parent), bookmark_bar_->widget()); | |
| 2374 | |
| 2375 gtk_box_pack_end(GTK_BOX(target_parent), bookmark_bar_->widget(), | |
| 2371 FALSE, FALSE, 0); | 2376 FALSE, FALSE, 0); |
| 2372 } | 2377 } |
| 2373 } | 2378 } |
| 2374 | 2379 |
| 2375 void BrowserWindowGtk::ShowSettingsMenu(GtkWidget* widget, | 2380 void BrowserWindowGtk::ShowSettingsMenu(GtkWidget* widget, |
| 2376 GdkEventButton* event) { | 2381 GdkEventButton* event) { |
| 2377 // Nothing to do. Panel window will override this. | 2382 // Nothing to do. Panel window will override this. |
| 2378 } | 2383 } |
| 2379 | 2384 |
| 2380 BrowserWindowGtk::TitleDecoration BrowserWindowGtk::GetWindowTitle( | 2385 BrowserWindowGtk::TitleDecoration BrowserWindowGtk::GetWindowTitle( |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2403 wm_type == ui::WM_OPENBOX || | 2408 wm_type == ui::WM_OPENBOX || |
| 2404 wm_type == ui::WM_XFWM4); | 2409 wm_type == ui::WM_XFWM4); |
| 2405 } | 2410 } |
| 2406 | 2411 |
| 2407 // static | 2412 // static |
| 2408 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2413 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2409 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2414 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2410 browser_window_gtk->Init(); | 2415 browser_window_gtk->Init(); |
| 2411 return browser_window_gtk; | 2416 return browser_window_gtk; |
| 2412 } | 2417 } |
| OLD | NEW |