Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/browser/gtk/browser_window_gtk.cc

Issue 165272: Add a first attempt at a compact location bar and a status bar. The status ba... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | chrome/browser/gtk/tabs/tab_strip_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "chrome/browser/tab_contents/tab_contents_view.h" 59 #include "chrome/browser/tab_contents/tab_contents_view.h"
60 #include "chrome/browser/window_sizer.h" 60 #include "chrome/browser/window_sizer.h"
61 #include "chrome/common/gtk_util.h" 61 #include "chrome/common/gtk_util.h"
62 #include "chrome/common/notification_service.h" 62 #include "chrome/common/notification_service.h"
63 #include "chrome/common/pref_names.h" 63 #include "chrome/common/pref_names.h"
64 #include "chrome/common/pref_service.h" 64 #include "chrome/common/pref_service.h"
65 #include "grit/app_resources.h" 65 #include "grit/app_resources.h"
66 #include "grit/theme_resources.h" 66 #include "grit/theme_resources.h"
67 67
68 #if defined(OS_CHROMEOS) 68 #if defined(OS_CHROMEOS)
69 #include "chrome/browser/views/compact_navigation_bar.h"
70 #include "chrome/browser/views/frame/status_area_view.h"
69 #include "chrome/browser/views/panel_controller.h" 71 #include "chrome/browser/views/panel_controller.h"
70 #include "chrome/browser/views/tabs/tab_overview_types.h" 72 #include "chrome/browser/views/tabs/tab_overview_types.h"
73 #include "views/widget/widget_gtk.h"
74
75 #define COMPACT_NAV_BAR
71 #endif 76 #endif
72 77
73 namespace { 78 namespace {
74 79
75 // The number of milliseconds between loading animation frames. 80 // The number of milliseconds between loading animation frames.
76 const int kLoadingAnimationFrameTimeMs = 30; 81 const int kLoadingAnimationFrameTimeMs = 30;
77 82
78 // Default offset of the contents splitter in pixels. 83 // Default offset of the contents splitter in pixels.
79 const int kDefaultContentsSplitOffset = 400; 84 const int kDefaultContentsSplitOffset = 400;
80 85
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 385
381 } // namespace 386 } // namespace
382 387
383 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; 388 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_;
384 389
385 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) 390 BrowserWindowGtk::BrowserWindowGtk(Browser* browser)
386 : browser_(browser), 391 : browser_(browser),
387 #if defined(OS_CHROMEOS) 392 #if defined(OS_CHROMEOS)
388 drag_active_(false), 393 drag_active_(false),
389 panel_controller_(NULL), 394 panel_controller_(NULL),
395 compact_navigation_bar_(NULL),
396 status_area_(NULL),
390 #endif 397 #endif
391 frame_cursor_(NULL), 398 frame_cursor_(NULL),
392 is_active_(true), 399 is_active_(true),
393 last_click_time_(0), 400 last_click_time_(0),
394 maximize_after_show_(false) { 401 maximize_after_show_(false) {
395 use_custom_frame_.Init(prefs::kUseCustomChromeFrame, 402 use_custom_frame_.Init(prefs::kUseCustomChromeFrame,
396 browser_->profile()->GetPrefs(), this); 403 browser_->profile()->GetPrefs(), this);
397 404
398 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); 405 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
399 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this); 406 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this);
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 gtk_widget_set_redraw_on_allocate(window_container_, TRUE); 1297 gtk_widget_set_redraw_on_allocate(window_container_, TRUE);
1291 g_signal_connect(G_OBJECT(window_container_), "expose-event", 1298 g_signal_connect(G_OBJECT(window_container_), "expose-event",
1292 G_CALLBACK(&OnCustomFrameExpose), this); 1299 G_CALLBACK(&OnCustomFrameExpose), this);
1293 gtk_container_add(GTK_CONTAINER(window_container_), window_vbox); 1300 gtk_container_add(GTK_CONTAINER(window_container_), window_vbox);
1294 1301
1295 tabstrip_.reset(new TabStripGtk(browser_->tabstrip_model())); 1302 tabstrip_.reset(new TabStripGtk(browser_->tabstrip_model()));
1296 tabstrip_->Init(); 1303 tabstrip_->Init();
1297 1304
1298 // Build the titlebar (tabstrip + header space + min/max/close buttons). 1305 // Build the titlebar (tabstrip + header space + min/max/close buttons).
1299 titlebar_.reset(new BrowserTitlebar(this, window_)); 1306 titlebar_.reset(new BrowserTitlebar(this, window_));
1307
1308 #if defined(OS_CHROMEOS) && defined(COMPACT_NAV_BAR)
1309 // Make a box that we'll later insert the compact navigation bar into. The
1310 // tabstrip must go into an hbox with our box so that they can get arranged
1311 // horizontally.
1312 GtkWidget* titlebar_hbox = gtk_hbox_new(FALSE, 0);
1313 GtkWidget* navbar_hbox = gtk_hbox_new(FALSE, 0);
1314 GtkWidget* status_hbox = gtk_hbox_new(FALSE, 0);
1315 gtk_widget_show(navbar_hbox);
1316 gtk_widget_show(titlebar_hbox);
1317 gtk_widget_show(status_hbox);
1318 gtk_box_pack_start(GTK_BOX(titlebar_hbox), navbar_hbox, FALSE, FALSE, 0);
1319 gtk_box_pack_start(GTK_BOX(titlebar_hbox), titlebar_->widget(), TRUE, TRUE,
1320 0);
1321 gtk_box_pack_start(GTK_BOX(titlebar_hbox), status_hbox, FALSE, FALSE, 0);
1322
1323 gtk_box_pack_start(GTK_BOX(window_vbox), titlebar_hbox, FALSE, FALSE, 0);
1324
1325 #else
1326 // Insert the tabstrip into the window.
1300 gtk_box_pack_start(GTK_BOX(window_vbox), titlebar_->widget(), FALSE, FALSE, 1327 gtk_box_pack_start(GTK_BOX(window_vbox), titlebar_->widget(), FALSE, FALSE,
1301 0); 1328 0);
1329 #endif // OS_CHROMEOS
1302 1330
1303 // The content_vbox_ surrounds the "content": toolbar+bookmarks bar+page. 1331 // The content_vbox_ surrounds the "content": toolbar+bookmarks bar+page.
1304 content_vbox_ = gtk_vbox_new(FALSE, 0); 1332 content_vbox_ = gtk_vbox_new(FALSE, 0);
1305 gtk_widget_show(content_vbox_); 1333 gtk_widget_show(content_vbox_);
1306 1334
1307 toolbar_.reset(new BrowserToolbarGtk(browser_.get(), this)); 1335 toolbar_.reset(new BrowserToolbarGtk(browser_.get(), this));
1308 toolbar_->Init(browser_->profile(), window_); 1336 toolbar_->Init(browser_->profile(), window_);
1309 toolbar_->AddToolbarToBox(content_vbox_); 1337 toolbar_->AddToolbarToBox(content_vbox_);
1338 #if defined(OS_CHROMEOS) && defined(COMPACT_NAV_BAR)
1339 gtk_widget_hide(toolbar_->widget());
1340 #endif
1310 1341
1311 bookmark_bar_.reset(new BookmarkBarGtk(browser_->profile(), browser_.get(), 1342 bookmark_bar_.reset(new BookmarkBarGtk(browser_->profile(), browser_.get(),
1312 this)); 1343 this));
1313 bookmark_bar_->AddBookmarkbarToBox(content_vbox_); 1344 bookmark_bar_->AddBookmarkbarToBox(content_vbox_);
1314 1345
1315 if (IsExtensionShelfSupported()) { 1346 if (IsExtensionShelfSupported()) {
1316 extension_shelf_.reset(new ExtensionShelfGtk(browser()->profile(), 1347 extension_shelf_.reset(new ExtensionShelfGtk(browser()->profile(),
1317 browser_.get())); 1348 browser_.get()));
1318 extension_shelf_->AddShelfToBox(content_vbox_); 1349 extension_shelf_->AddShelfToBox(content_vbox_);
1319 MaybeShowExtensionShelf(); 1350 MaybeShowExtensionShelf();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 UpdateCustomFrame(); 1400 UpdateCustomFrame();
1370 1401
1371 GtkWidget* event_box = gtk_event_box_new(); 1402 GtkWidget* event_box = gtk_event_box_new();
1372 gtk_container_add(GTK_CONTAINER(event_box), render_area_vbox_); 1403 gtk_container_add(GTK_CONTAINER(event_box), render_area_vbox_);
1373 gtk_widget_show(event_box); 1404 gtk_widget_show(event_box);
1374 gtk_container_add(GTK_CONTAINER(content_vbox_), event_box); 1405 gtk_container_add(GTK_CONTAINER(content_vbox_), event_box);
1375 gtk_container_add(GTK_CONTAINER(window_vbox), content_vbox_); 1406 gtk_container_add(GTK_CONTAINER(window_vbox), content_vbox_);
1376 gtk_container_add(GTK_CONTAINER(window_), window_container_); 1407 gtk_container_add(GTK_CONTAINER(window_), window_container_);
1377 gtk_widget_show(window_container_); 1408 gtk_widget_show(window_container_);
1378 browser_->tabstrip_model()->AddObserver(this); 1409 browser_->tabstrip_model()->AddObserver(this);
1410
1411 #if defined(OS_CHROMEOS) && defined(COMPACT_NAV_BAR)
1412 // Create the compact navigation bar. This must be done after adding
1413 // everything to the window since it's done in Views, which expects to call
1414 // realize (requiring a window) in the Init function.
1415 views::WidgetGtk* clb_widget =
1416 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD);
1417 clb_widget->set_delete_on_destroy(true);
1418 // Must initialize with a NULL parent since the widget will assume the parent
1419 // is also a WidgetGtk. Then we can parent the native widget afterwards.
1420 clb_widget->Init(NULL, gfx::Rect(0, 0, 100, 30));
1421 gtk_widget_reparent(clb_widget->GetNativeView(), navbar_hbox);
1422
1423 compact_navigation_bar_ = new CompactNavigationBar(browser_.get());
1424
1425 clb_widget->SetContentsView(compact_navigation_bar_);
1426 compact_navigation_bar_->Init();
1427
1428 // Create the status area.
1429 views::WidgetGtk* status_widget =
1430 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD);
1431 status_widget->set_delete_on_destroy(true);
1432 status_widget->Init(NULL, gfx::Rect(0, 0, 100, 30));
1433 gtk_widget_reparent(status_widget->GetNativeView(), status_hbox);
1434 status_area_ = new StatusAreaView(browser());
1435 status_widget->SetContentsView(status_area_);
1436 status_area_->Init();
1437
1438 // Must be after Init.
1439 gtk_widget_set_size_request(clb_widget->GetNativeView(),
1440 compact_navigation_bar_->GetPreferredSize().width(), 20);
1441 gfx::Size status_area_size = status_area_->GetPreferredSize();
1442 gtk_widget_set_size_request(status_widget->GetNativeView(),
1443 status_area_size.width(),
1444 status_area_size.height());
1445 clb_widget->Show();
1446 status_widget->Show();
1447 #endif // OS_CHROMEOS
1379 } 1448 }
1380 1449
1381 void BrowserWindowGtk::SetBackgroundColor() { 1450 void BrowserWindowGtk::SetBackgroundColor() {
1382 Profile* profile = browser()->profile(); 1451 Profile* profile = browser()->profile();
1383 ThemeProvider* theme_provider = profile->GetThemeProvider(); 1452 ThemeProvider* theme_provider = profile->GetThemeProvider();
1384 int frame_color_id; 1453 int frame_color_id;
1385 if (IsActive()) { 1454 if (IsActive()) {
1386 frame_color_id = browser()->profile()->IsOffTheRecord() 1455 frame_color_id = browser()->profile()->IsOffTheRecord()
1387 ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO 1456 ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO
1388 : BrowserThemeProvider::COLOR_FRAME; 1457 : BrowserThemeProvider::COLOR_FRAME;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 // are taken from the WMs' source code. 1887 // are taken from the WMs' source code.
1819 return (wm_name == "Blackbox" || 1888 return (wm_name == "Blackbox" ||
1820 wm_name == "compiz" || 1889 wm_name == "compiz" ||
1821 wm_name == "e16" || // Enlightenment DR16 1890 wm_name == "e16" || // Enlightenment DR16
1822 wm_name == "Fluxbox" || 1891 wm_name == "Fluxbox" ||
1823 wm_name == "KWin" || 1892 wm_name == "KWin" ||
1824 wm_name == "Metacity" || 1893 wm_name == "Metacity" ||
1825 wm_name == "Openbox" || 1894 wm_name == "Openbox" ||
1826 wm_name == "Xfwm4"); 1895 wm_name == "Xfwm4");
1827 } 1896 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | chrome/browser/gtk/tabs/tab_strip_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698