| 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_window_gtk.h" | 5 #include "chrome/browser/gtk/browser_window_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 <string> | 10 #include <string> |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 cairo_destroy(cr); | 345 cairo_destroy(cr); |
| 346 | 346 |
| 347 return FALSE; | 347 return FALSE; |
| 348 } | 348 } |
| 349 | 349 |
| 350 } // namespace | 350 } // namespace |
| 351 | 351 |
| 352 // Callback from GTK when the user clicks the main menu button. | 352 // Callback from GTK when the user clicks the main menu button. |
| 353 static void OnMainMenuButtonClicked(GtkWidget* widget, | 353 static void OnMainMenuButtonClicked(GtkWidget* widget, |
| 354 BrowserWindowGtk* browser) { | 354 BrowserWindowGtk* browser) { |
| 355 MainMenu::Show(browser->browser()); | 355 chromeos::MainMenu::Show(browser->browser()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 #endif // OS_CHROMEOS | 358 #endif // OS_CHROMEOS |
| 359 | 359 |
| 360 int GetCommandId(guint accel_key, GdkModifierType modifier) { | 360 int GetCommandId(guint accel_key, GdkModifierType modifier) { |
| 361 // Bug 9806: If capslock is on, we will get a capital letter as accel_key. | 361 // Bug 9806: If capslock is on, we will get a capital letter as accel_key. |
| 362 accel_key = gdk_keyval_to_lower(accel_key); | 362 accel_key = gdk_keyval_to_lower(accel_key); |
| 363 // Filter modifier to only include accelerator modifiers. | 363 // Filter modifier to only include accelerator modifiers. |
| 364 modifier = static_cast<GdkModifierType>( | 364 modifier = static_cast<GdkModifierType>( |
| 365 modifier & gtk_accelerator_get_default_mod_mask()); | 365 modifier & gtk_accelerator_get_default_mod_mask()); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 // The Browser associated with this browser window must become the active | 796 // The Browser associated with this browser window must become the active |
| 797 // browser at the time Show() is called. This is the natural behaviour under | 797 // browser at the time Show() is called. This is the natural behaviour under |
| 798 // Windows, but gtk_widget_show won't show the widget (and therefore won't | 798 // Windows, but gtk_widget_show won't show the widget (and therefore won't |
| 799 // call OnFocusIn()) until we return to the runloop. Therefore any calls to | 799 // call OnFocusIn()) until we return to the runloop. Therefore any calls to |
| 800 // BrowserList::GetLastActive() (for example, in bookmark_util), will return | 800 // BrowserList::GetLastActive() (for example, in bookmark_util), will return |
| 801 // the previous browser instead if we don't explicitly set it here. | 801 // the previous browser instead if we don't explicitly set it here. |
| 802 BrowserList::SetLastActive(browser()); | 802 BrowserList::SetLastActive(browser()); |
| 803 | 803 |
| 804 #if defined(OS_CHROMEOS) | 804 #if defined(OS_CHROMEOS) |
| 805 if (browser_->type() == Browser::TYPE_POPUP) { | 805 if (browser_->type() == Browser::TYPE_POPUP) { |
| 806 panel_controller_ = new PanelController(this); | 806 panel_controller_ = new chromeos::PanelController(this); |
| 807 } else { | 807 } else { |
| 808 TabOverviewTypes::instance()->SetWindowType( | 808 TabOverviewTypes::instance()->SetWindowType( |
| 809 GTK_WIDGET(window_), | 809 GTK_WIDGET(window_), |
| 810 TabOverviewTypes::WINDOW_TYPE_CHROME_TOPLEVEL, | 810 TabOverviewTypes::WINDOW_TYPE_CHROME_TOPLEVEL, |
| 811 NULL); | 811 NULL); |
| 812 } | 812 } |
| 813 #endif | 813 #endif |
| 814 | 814 |
| 815 gtk_window_present(window_); | 815 gtk_window_present(window_); |
| 816 if (maximize_after_show_) { | 816 if (maximize_after_show_) { |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 main_menu_button_ = | 1636 main_menu_button_ = |
| 1637 new CustomDrawButton(IDR_MAIN_MENU_BUTTON, IDR_MAIN_MENU_BUTTON, | 1637 new CustomDrawButton(IDR_MAIN_MENU_BUTTON, IDR_MAIN_MENU_BUTTON, |
| 1638 IDR_MAIN_MENU_BUTTON, 0); | 1638 IDR_MAIN_MENU_BUTTON, 0); |
| 1639 gtk_widget_show(main_menu_button_->widget()); | 1639 gtk_widget_show(main_menu_button_->widget()); |
| 1640 g_signal_connect(G_OBJECT(main_menu_button_->widget()), "clicked", | 1640 g_signal_connect(G_OBJECT(main_menu_button_->widget()), "clicked", |
| 1641 G_CALLBACK(OnMainMenuButtonClicked), this); | 1641 G_CALLBACK(OnMainMenuButtonClicked), this); |
| 1642 GTK_WIDGET_UNSET_FLAGS(main_menu_button_->widget(), GTK_CAN_FOCUS); | 1642 GTK_WIDGET_UNSET_FLAGS(main_menu_button_->widget(), GTK_CAN_FOCUS); |
| 1643 gtk_box_pack_start(GTK_BOX(titlebar_hbox), main_menu_button_->widget(), | 1643 gtk_box_pack_start(GTK_BOX(titlebar_hbox), main_menu_button_->widget(), |
| 1644 FALSE, FALSE, 0); | 1644 FALSE, FALSE, 0); |
| 1645 | 1645 |
| 1646 MainMenu::ScheduleCreation(); | 1646 chromeos::MainMenu::ScheduleCreation(); |
| 1647 | 1647 |
| 1648 if (has_compact_nav_bar) { | 1648 if (has_compact_nav_bar) { |
| 1649 compact_navbar_hbox_ = gtk_hbox_new(FALSE, 0); | 1649 compact_navbar_hbox_ = gtk_hbox_new(FALSE, 0); |
| 1650 gtk_widget_show(compact_navbar_hbox_); | 1650 gtk_widget_show(compact_navbar_hbox_); |
| 1651 gtk_box_pack_start(GTK_BOX(titlebar_hbox), compact_navbar_hbox_, | 1651 gtk_box_pack_start(GTK_BOX(titlebar_hbox), compact_navbar_hbox_, |
| 1652 FALSE, FALSE, 0); | 1652 FALSE, FALSE, 0); |
| 1653 | 1653 |
| 1654 // Reset the compact nav bit now that we're creating the next toplevel | 1654 // Reset the compact nav bit now that we're creating the next toplevel |
| 1655 // window. Code below will use our local has_compact_nav_bar variable. | 1655 // window. Code below will use our local has_compact_nav_bar variable. |
| 1656 next_window_should_use_compact_nav_ = false; | 1656 next_window_should_use_compact_nav_ = false; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1772 // call realize (requiring a window) in the Init function. | 1772 // call realize (requiring a window) in the Init function. |
| 1773 views::WidgetGtk* clb_widget = | 1773 views::WidgetGtk* clb_widget = |
| 1774 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); | 1774 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); |
| 1775 clb_widget->set_delete_on_destroy(true); | 1775 clb_widget->set_delete_on_destroy(true); |
| 1776 // Must initialize with a NULL parent since the widget will assume the | 1776 // Must initialize with a NULL parent since the widget will assume the |
| 1777 // parent is also a WidgetGtk. Then we can parent the native widget | 1777 // parent is also a WidgetGtk. Then we can parent the native widget |
| 1778 // afterwards. | 1778 // afterwards. |
| 1779 clb_widget->Init(NULL, gfx::Rect(0, 0, 100, 30)); | 1779 clb_widget->Init(NULL, gfx::Rect(0, 0, 100, 30)); |
| 1780 gtk_widget_reparent(clb_widget->GetNativeView(), compact_navbar_hbox_); | 1780 gtk_widget_reparent(clb_widget->GetNativeView(), compact_navbar_hbox_); |
| 1781 | 1781 |
| 1782 compact_navigation_bar_ = new CompactNavigationBar(browser_.get()); | 1782 compact_navigation_bar_ = |
| 1783 new chromeos::CompactNavigationBar(browser_.get()); |
| 1783 | 1784 |
| 1784 clb_widget->SetContentsView(compact_navigation_bar_); | 1785 clb_widget->SetContentsView(compact_navigation_bar_); |
| 1785 compact_navigation_bar_->Init(); | 1786 compact_navigation_bar_->Init(); |
| 1786 | 1787 |
| 1787 // Must be after Init. | 1788 // Must be after Init. |
| 1788 gtk_widget_set_size_request(clb_widget->GetNativeView(), | 1789 gtk_widget_set_size_request(clb_widget->GetNativeView(), |
| 1789 compact_navigation_bar_->GetPreferredSize().width(), 20); | 1790 compact_navigation_bar_->GetPreferredSize().width(), 20); |
| 1790 clb_widget->Show(); | 1791 clb_widget->Show(); |
| 1791 } | 1792 } |
| 1792 | 1793 |
| 1793 // Create the status area. | 1794 // Create the status area. |
| 1794 views::WidgetGtk* status_widget = | 1795 views::WidgetGtk* status_widget = |
| 1795 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); | 1796 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); |
| 1796 status_widget->set_delete_on_destroy(true); | 1797 status_widget->set_delete_on_destroy(true); |
| 1797 status_widget->Init(NULL, gfx::Rect(0, 0, 100, 30)); | 1798 status_widget->Init(NULL, gfx::Rect(0, 0, 100, 30)); |
| 1798 gtk_widget_reparent(status_widget->GetNativeView(), status_container); | 1799 gtk_widget_reparent(status_widget->GetNativeView(), status_container); |
| 1799 status_area_ = new StatusAreaView(browser(), GetNativeHandle()); | 1800 status_area_ = new chromeos::StatusAreaView(browser(), GetNativeHandle()); |
| 1800 status_widget->SetContentsView(status_area_); | 1801 status_widget->SetContentsView(status_area_); |
| 1801 status_area_->Init(); | 1802 status_area_->Init(); |
| 1802 | 1803 |
| 1803 // Must be after Init. | 1804 // Must be after Init. |
| 1804 gfx::Size status_area_size = status_area_->GetPreferredSize(); | 1805 gfx::Size status_area_size = status_area_->GetPreferredSize(); |
| 1805 gtk_widget_set_size_request(status_widget->GetNativeView(), | 1806 gtk_widget_set_size_request(status_widget->GetNativeView(), |
| 1806 status_area_size.width(), | 1807 status_area_size.width(), |
| 1807 status_area_size.height()); | 1808 status_area_size.height()); |
| 1808 status_widget->Show(); | 1809 status_widget->Show(); |
| 1809 } | 1810 } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 // are taken from the WMs' source code. | 2303 // are taken from the WMs' source code. |
| 2303 return (wm_name == "Blackbox" || | 2304 return (wm_name == "Blackbox" || |
| 2304 wm_name == "compiz" || | 2305 wm_name == "compiz" || |
| 2305 wm_name == "e16" || // Enlightenment DR16 | 2306 wm_name == "e16" || // Enlightenment DR16 |
| 2306 wm_name == "KWin" || | 2307 wm_name == "KWin" || |
| 2307 wm_name == "Metacity" || | 2308 wm_name == "Metacity" || |
| 2308 wm_name == "Mutter" || | 2309 wm_name == "Mutter" || |
| 2309 wm_name == "Openbox" || | 2310 wm_name == "Openbox" || |
| 2310 wm_name == "Xfwm4"); | 2311 wm_name == "Xfwm4"); |
| 2311 } | 2312 } |
| OLD | NEW |