| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 const std::string user_data_dir = | 299 const std::string user_data_dir = |
| 300 command_line.GetSwitchValueNative(switches::kUserDataDir); | 300 command_line.GetSwitchValueNative(switches::kUserDataDir); |
| 301 gtk_window_util::SetWindowCustomClass(window_, | 301 gtk_window_util::SetWindowCustomClass(window_, |
| 302 std::string(gdk_get_program_class()) + " (" + user_data_dir + ")"); | 302 std::string(gdk_get_program_class()) + " (" + user_data_dir + ")"); |
| 303 } | 303 } |
| 304 | 304 |
| 305 // For popups, we initialize widgets then set the window geometry, because | 305 // For popups, we initialize widgets then set the window geometry, because |
| 306 // popups need the widgets inited before they can set the window size | 306 // popups need the widgets inited before they can set the window size |
| 307 // properly. For other windows, we set the geometry first to prevent resize | 307 // properly. For other windows, we set the geometry first to prevent resize |
| 308 // flicker. | 308 // flicker. |
| 309 if (browser_->is_type_popup() || browser_->is_type_panel()) { | 309 if (browser_->is_type_popup()) { |
| 310 gtk_window_set_role(window_, "pop-up"); | 310 gtk_window_set_role(window_, "pop-up"); |
| 311 InitWidgets(); | 311 InitWidgets(); |
| 312 SetGeometryHints(); | 312 SetGeometryHints(); |
| 313 } else { | 313 } else { |
| 314 gtk_window_set_role(window_, "browser"); | 314 gtk_window_set_role(window_, "browser"); |
| 315 SetGeometryHints(); | 315 SetGeometryHints(); |
| 316 InitWidgets(); | 316 InitWidgets(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 ConnectAccelerators(); | 319 ConnectAccelerators(); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 } | 939 } |
| 940 | 940 |
| 941 bool BrowserWindowGtk::IsToolbarVisible() const { | 941 bool BrowserWindowGtk::IsToolbarVisible() const { |
| 942 return IsToolbarSupported(); | 942 return IsToolbarSupported(); |
| 943 } | 943 } |
| 944 | 944 |
| 945 gfx::Rect BrowserWindowGtk::GetRootWindowResizerRect() const { | 945 gfx::Rect BrowserWindowGtk::GetRootWindowResizerRect() const { |
| 946 return gfx::Rect(); | 946 return gfx::Rect(); |
| 947 } | 947 } |
| 948 | 948 |
| 949 bool BrowserWindowGtk::IsPanel() const { | |
| 950 return false; | |
| 951 } | |
| 952 | |
| 953 void BrowserWindowGtk::ConfirmAddSearchProvider(TemplateURL* template_url, | 949 void BrowserWindowGtk::ConfirmAddSearchProvider(TemplateURL* template_url, |
| 954 Profile* profile) { | 950 Profile* profile) { |
| 955 new EditSearchEngineDialog(window_, template_url, NULL, profile); | 951 new EditSearchEngineDialog(window_, template_url, NULL, profile); |
| 956 } | 952 } |
| 957 | 953 |
| 958 void BrowserWindowGtk::ToggleBookmarkBar() { | 954 void BrowserWindowGtk::ToggleBookmarkBar() { |
| 959 chrome::ToggleBookmarkBarWhenVisible(browser_->profile()); | 955 chrome::ToggleBookmarkBarWhenVisible(browser_->profile()); |
| 960 } | 956 } |
| 961 | 957 |
| 962 void BrowserWindowGtk::ShowUpdateChromeDialog() { | 958 void BrowserWindowGtk::ShowUpdateChromeDialog() { |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 // Linux, instead letting the window manager choose a position. | 1521 // Linux, instead letting the window manager choose a position. |
| 1526 // | 1522 // |
| 1527 // However, in cases like dropping a tab where the bounds are | 1523 // However, in cases like dropping a tab where the bounds are |
| 1528 // specifically set, we do want to position explicitly. We also | 1524 // specifically set, we do want to position explicitly. We also |
| 1529 // force the position as part of session restore, as applications | 1525 // force the position as part of session restore, as applications |
| 1530 // that restore other, similar state (for instance GIMP, audacity, | 1526 // that restore other, similar state (for instance GIMP, audacity, |
| 1531 // pidgin, dia, and gkrellm) do tend to restore their positions. | 1527 // pidgin, dia, and gkrellm) do tend to restore their positions. |
| 1532 // | 1528 // |
| 1533 // For popup windows, we assume that if x == y == 0, the opening page | 1529 // For popup windows, we assume that if x == y == 0, the opening page |
| 1534 // did not specify a position. Let the WM position the popup instead. | 1530 // did not specify a position. Let the WM position the popup instead. |
| 1535 bool is_popup_or_panel = browser_->is_type_popup() || | 1531 bool is_popup = browser_->is_type_popup(); |
| 1536 browser_->is_type_panel(); | 1532 bool popup_without_position = is_popup && |
| 1537 bool popup_without_position = is_popup_or_panel && | |
| 1538 bounds.x() == 0 && bounds.y() == 0; | 1533 bounds.x() == 0 && bounds.y() == 0; |
| 1539 bool move = browser_->bounds_overridden() && !popup_without_position; | 1534 bool move = browser_->bounds_overridden() && !popup_without_position; |
| 1540 SetBoundsImpl(bounds, !is_popup_or_panel, move); | 1535 SetBoundsImpl(bounds, !is_popup, move); |
| 1541 } | 1536 } |
| 1542 | 1537 |
| 1543 void BrowserWindowGtk::ConnectHandlersToSignals() { | 1538 void BrowserWindowGtk::ConnectHandlersToSignals() { |
| 1544 g_signal_connect(window_, "delete-event", | 1539 g_signal_connect(window_, "delete-event", |
| 1545 G_CALLBACK(OnMainWindowDeleteEventThunk), this); | 1540 G_CALLBACK(OnMainWindowDeleteEventThunk), this); |
| 1546 g_signal_connect(window_, "destroy", | 1541 g_signal_connect(window_, "destroy", |
| 1547 G_CALLBACK(OnMainWindowDestroyThunk), this); | 1542 G_CALLBACK(OnMainWindowDestroyThunk), this); |
| 1548 g_signal_connect(window_, "configure-event", | 1543 g_signal_connect(window_, "configure-event", |
| 1549 G_CALLBACK(OnConfigureThunk), this); | 1544 G_CALLBACK(OnConfigureThunk), this); |
| 1550 g_signal_connect(window_, "window-state-event", | 1545 g_signal_connect(window_, "window-state-event", |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 wm_type == ui::WM_OPENBOX || | 2386 wm_type == ui::WM_OPENBOX || |
| 2392 wm_type == ui::WM_XFWM4); | 2387 wm_type == ui::WM_XFWM4); |
| 2393 } | 2388 } |
| 2394 | 2389 |
| 2395 // static | 2390 // static |
| 2396 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2391 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2397 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2392 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2398 browser_window_gtk->Init(); | 2393 browser_window_gtk->Init(); |
| 2399 return browser_window_gtk; | 2394 return browser_window_gtk; |
| 2400 } | 2395 } |
| OLD | NEW |