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_titlebar.h" | 5 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 titlebar_left_buttons_hbox_(NULL), | 212 titlebar_left_buttons_hbox_(NULL), |
| 213 titlebar_right_buttons_hbox_(NULL), | 213 titlebar_right_buttons_hbox_(NULL), |
| 214 titlebar_left_spy_frame_(NULL), | 214 titlebar_left_spy_frame_(NULL), |
| 215 titlebar_right_spy_frame_(NULL), | 215 titlebar_right_spy_frame_(NULL), |
| 216 top_padding_left_(NULL), | 216 top_padding_left_(NULL), |
| 217 top_padding_right_(NULL), | 217 top_padding_right_(NULL), |
| 218 app_mode_favicon_(NULL), | 218 app_mode_favicon_(NULL), |
| 219 app_mode_title_(NULL), | 219 app_mode_title_(NULL), |
| 220 using_custom_frame_(false), | 220 using_custom_frame_(false), |
| 221 window_has_focus_(false), | 221 window_has_focus_(false), |
| 222 window_has_mouse_(false), | |
| 222 theme_service_(NULL) { | 223 theme_service_(NULL) { |
| 223 Init(); | 224 Init(); |
| 224 } | 225 } |
| 225 | 226 |
| 226 void BrowserTitlebar::Init() { | 227 void BrowserTitlebar::Init() { |
| 227 // The widget hierarchy is shown below. | 228 // The widget hierarchy is shown below. |
| 228 // | 229 // |
| 229 // +- EventBox (container_) ------------------------------------------------+ | 230 // +- EventBox (container_) ------------------------------------------------+ |
| 230 // +- HBox (container_hbox_) -----------------------------------------------+ | 231 // +- HBox (container_hbox_) -----------------------------------------------+ |
| 231 // |+ VBox ---++- Algn. -++- Alignment --------------++- Algn. -++ VBox ---+| | 232 // |+ VBox ---++- Algn. -++- Alignment --------------++- Algn. -++ VBox ---+| |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 container_ = gtk_event_box_new(); | 278 container_ = gtk_event_box_new(); |
| 278 gtk_widget_set_name(container_, "chrome-browser-titlebar"); | 279 gtk_widget_set_name(container_, "chrome-browser-titlebar"); |
| 279 gtk_event_box_set_visible_window(GTK_EVENT_BOX(container_), FALSE); | 280 gtk_event_box_set_visible_window(GTK_EVENT_BOX(container_), FALSE); |
| 280 gtk_container_add(GTK_CONTAINER(container_), container_hbox_); | 281 gtk_container_add(GTK_CONTAINER(container_), container_hbox_); |
| 281 | 282 |
| 282 g_signal_connect(container_, "scroll-event", G_CALLBACK(OnScrollThunk), this); | 283 g_signal_connect(container_, "scroll-event", G_CALLBACK(OnScrollThunk), this); |
| 283 | 284 |
| 284 g_signal_connect(window_, "window-state-event", | 285 g_signal_connect(window_, "window-state-event", |
| 285 G_CALLBACK(OnWindowStateChangedThunk), this); | 286 G_CALLBACK(OnWindowStateChangedThunk), this); |
| 286 | 287 |
| 288 if (IsTypePanel()) { | |
| 289 g_signal_connect(window_, "enter-notify-event", | |
| 290 G_CALLBACK(OnEnterNotifyThunk), this); | |
| 291 g_signal_connect(window_, "leave-notify-event", | |
| 292 G_CALLBACK(OnLeaveNotifyThunk), this); | |
| 293 } | |
| 294 | |
| 287 // Allocate the two button boxes on the left and right parts of the bar, | 295 // Allocate the two button boxes on the left and right parts of the bar, |
| 288 // spyguy frames in case of incognito mode, and profile button boxes. | 296 // spyguy frames in case of incognito mode, and profile button boxes. |
| 289 titlebar_left_buttons_vbox_ = gtk_vbox_new(FALSE, 0); | 297 titlebar_left_buttons_vbox_ = gtk_vbox_new(FALSE, 0); |
| 290 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_buttons_vbox_, | 298 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_buttons_vbox_, |
| 291 FALSE, FALSE, 0); | 299 FALSE, FALSE, 0); |
| 292 if (browser_window_->browser()->profile()->IsOffTheRecord() && | 300 if (browser_window_->browser()->profile()->IsOffTheRecord() && |
| 293 browser_window_->browser()->is_type_tabbed()) { | 301 browser_window_->browser()->is_type_tabbed()) { |
| 294 titlebar_left_spy_frame_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 302 titlebar_left_spy_frame_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| 295 gtk_widget_set_no_show_all(titlebar_left_spy_frame_, TRUE); | 303 gtk_widget_set_no_show_all(titlebar_left_spy_frame_, TRUE); |
| 296 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_left_spy_frame_), 0, | 304 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_left_spy_frame_), 0, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 FALSE, 0); | 377 FALSE, 0); |
| 370 // We use the app logo as a placeholder image so the title doesn't jump | 378 // We use the app logo as a placeholder image so the title doesn't jump |
| 371 // around. | 379 // around. |
| 372 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 380 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 373 app_mode_favicon_ = gtk_image_new_from_pixbuf( | 381 app_mode_favicon_ = gtk_image_new_from_pixbuf( |
| 374 rb.GetRTLEnabledPixbufNamed(IDR_PRODUCT_LOGO_16)); | 382 rb.GetRTLEnabledPixbufNamed(IDR_PRODUCT_LOGO_16)); |
| 375 g_object_set_data(G_OBJECT(app_mode_favicon_), "left-align-popup", | 383 g_object_set_data(G_OBJECT(app_mode_favicon_), "left-align-popup", |
| 376 reinterpret_cast<void*>(true)); | 384 reinterpret_cast<void*>(true)); |
| 377 gtk_container_add(GTK_CONTAINER(favicon_event_box), app_mode_favicon_); | 385 gtk_container_add(GTK_CONTAINER(favicon_event_box), app_mode_favicon_); |
| 378 | 386 |
| 387 if (IsTypePanel()) { | |
| 388 panel_wrench_button_.reset( | |
| 389 BuildTitlebarButton(IDR_BALLOON_WRENCH, IDR_BALLOON_WRENCH_P, | |
| 390 IDR_BALLOON_WRENCH_H, app_mode_hbox, FALSE, | |
| 391 IDS_NEW_TAB_APP_SETTINGS)); | |
| 392 gtk_widget_set_no_show_all(panel_wrench_button_->widget(), TRUE); | |
| 393 } | |
| 394 | |
| 379 app_mode_title_ = gtk_label_new(NULL); | 395 app_mode_title_ = gtk_label_new(NULL); |
| 380 gtk_label_set_ellipsize(GTK_LABEL(app_mode_title_), PANGO_ELLIPSIZE_END); | 396 gtk_label_set_ellipsize(GTK_LABEL(app_mode_title_), PANGO_ELLIPSIZE_END); |
| 381 gtk_misc_set_alignment(GTK_MISC(app_mode_title_), 0.0, 0.5); | 397 gtk_misc_set_alignment(GTK_MISC(app_mode_title_), 0.0, 0.5); |
| 382 gtk_box_pack_start(GTK_BOX(app_mode_hbox), app_mode_title_, TRUE, TRUE, | 398 gtk_box_pack_start(GTK_BOX(app_mode_hbox), app_mode_title_, TRUE, TRUE, |
| 383 0); | 399 0); |
| 384 | 400 |
| 385 // Register with the theme provider to set the |app_mode_title_| label | 401 // Register with the theme provider to set the |app_mode_title_| label |
| 386 // color. | 402 // color. |
| 387 theme_service_ = GtkThemeService::GetFrom( | 403 theme_service_ = GtkThemeService::GetFrom( |
| 388 browser_window_->browser()->profile()); | 404 browser_window_->browser()->profile()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 StringTokenizer tokenizer(button_string, ":,"); | 437 StringTokenizer tokenizer(button_string, ":,"); |
| 422 tokenizer.set_options(StringTokenizer::RETURN_DELIMS); | 438 tokenizer.set_options(StringTokenizer::RETURN_DELIMS); |
| 423 int left_count = 0; | 439 int left_count = 0; |
| 424 int right_count = 0; | 440 int right_count = 0; |
| 425 while (tokenizer.GetNext()) { | 441 while (tokenizer.GetNext()) { |
| 426 if (tokenizer.token_is_delim()) { | 442 if (tokenizer.token_is_delim()) { |
| 427 if (*tokenizer.token_begin() == ':') | 443 if (*tokenizer.token_begin() == ':') |
| 428 left_side = false; | 444 left_side = false; |
| 429 } else { | 445 } else { |
| 430 base::StringPiece token = tokenizer.token_piece(); | 446 base::StringPiece token = tokenizer.token_piece(); |
| 431 if (token == "minimize") { | 447 if (token == "minimize" && !IsTypePanel()) { |
| 432 (left_side ? left_count : right_count)++; | 448 (left_side ? left_count : right_count)++; |
| 433 GtkWidget* parent_box = GetButtonHBox(left_side); | 449 GtkWidget* parent_box = GetButtonHBox(left_side); |
| 434 minimize_button_.reset( | 450 minimize_button_.reset( |
| 435 BuildTitlebarButton(IDR_MINIMIZE, IDR_MINIMIZE_P, | 451 BuildTitlebarButton(IDR_MINIMIZE, IDR_MINIMIZE_P, |
| 436 IDR_MINIMIZE_H, parent_box, | 452 IDR_MINIMIZE_H, parent_box, true, |
| 437 IDS_XPFRAME_MINIMIZE_TOOLTIP)); | 453 IDS_XPFRAME_MINIMIZE_TOOLTIP)); |
| 438 | 454 |
| 439 gtk_widget_size_request(minimize_button_->widget(), | 455 gtk_widget_size_request(minimize_button_->widget(), |
| 440 &minimize_button_req_); | 456 &minimize_button_req_); |
| 441 } else if (token == "maximize") { | 457 } else if (token == "maximize" && !IsTypePanel()) { |
| 442 (left_side ? left_count : right_count)++; | 458 (left_side ? left_count : right_count)++; |
| 443 GtkWidget* parent_box = GetButtonHBox(left_side); | 459 GtkWidget* parent_box = GetButtonHBox(left_side); |
| 444 restore_button_.reset( | 460 restore_button_.reset( |
| 445 BuildTitlebarButton(IDR_RESTORE, IDR_RESTORE_P, | 461 BuildTitlebarButton(IDR_RESTORE, IDR_RESTORE_P, |
| 446 IDR_RESTORE_H, parent_box, | 462 IDR_RESTORE_H, parent_box, true, |
| 447 IDS_XPFRAME_RESTORE_TOOLTIP)); | 463 IDS_XPFRAME_RESTORE_TOOLTIP)); |
| 448 maximize_button_.reset( | 464 maximize_button_.reset( |
| 449 BuildTitlebarButton(IDR_MAXIMIZE, IDR_MAXIMIZE_P, | 465 BuildTitlebarButton(IDR_MAXIMIZE, IDR_MAXIMIZE_P, |
| 450 IDR_MAXIMIZE_H, parent_box, | 466 IDR_MAXIMIZE_H, parent_box, true, |
| 451 IDS_XPFRAME_MAXIMIZE_TOOLTIP)); | 467 IDS_XPFRAME_MAXIMIZE_TOOLTIP)); |
| 452 | 468 |
| 453 gtk_util::SetButtonClickableByMouseButtons(maximize_button_->widget(), | 469 gtk_util::SetButtonClickableByMouseButtons(maximize_button_->widget(), |
| 454 true, true, true); | 470 true, true, true); |
| 455 gtk_widget_size_request(restore_button_->widget(), | 471 gtk_widget_size_request(restore_button_->widget(), |
| 456 &restore_button_req_); | 472 &restore_button_req_); |
| 457 } else if (token == "close") { | 473 } else if (token == "close") { |
| 458 (left_side ? left_count : right_count)++; | 474 (left_side ? left_count : right_count)++; |
| 459 GtkWidget* parent_box = GetButtonHBox(left_side); | 475 GtkWidget* parent_box = GetButtonHBox(left_side); |
| 460 close_button_.reset( | 476 close_button_.reset( |
| 461 BuildTitlebarButton(IDR_CLOSE, IDR_CLOSE_P, | 477 BuildTitlebarButton(IDR_CLOSE, IDR_CLOSE_P, |
| 462 IDR_CLOSE_H, parent_box, | 478 IDR_CLOSE_H, parent_box, true, |
| 463 IDS_XPFRAME_CLOSE_TOOLTIP)); | 479 IDS_XPFRAME_CLOSE_TOOLTIP)); |
| 464 close_button_->set_flipped(left_side); | 480 close_button_->set_flipped(left_side); |
| 465 | 481 |
| 466 gtk_widget_size_request(close_button_->widget(), &close_button_req_); | 482 gtk_widget_size_request(close_button_->widget(), &close_button_req_); |
| 467 } | 483 } |
| 468 // Ignore any other values like "pin" since we don't have images for | 484 // Ignore any other values like "pin" since we don't have images for |
| 469 // those. | 485 // those. |
| 470 } | 486 } |
| 471 } | 487 } |
| 472 | 488 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 top_padding_left_ = top_padding; | 541 top_padding_left_ = top_padding; |
| 526 } else { | 542 } else { |
| 527 titlebar_right_buttons_hbox_ = buttons_hbox; | 543 titlebar_right_buttons_hbox_ = buttons_hbox; |
| 528 top_padding_right_ = top_padding; | 544 top_padding_right_ = top_padding; |
| 529 } | 545 } |
| 530 | 546 |
| 531 return buttons_hbox; | 547 return buttons_hbox; |
| 532 } | 548 } |
| 533 | 549 |
| 534 CustomDrawButton* BrowserTitlebar::BuildTitlebarButton(int image, | 550 CustomDrawButton* BrowserTitlebar::BuildTitlebarButton(int image, |
| 535 int image_pressed, int image_hot, GtkWidget* box, int tooltip) { | 551 int image_pressed, int image_hot, GtkWidget* box, bool start, |
| 552 int tooltip) { | |
| 536 CustomDrawButton* button = new CustomDrawButton(image, image_pressed, | 553 CustomDrawButton* button = new CustomDrawButton(image, image_pressed, |
| 537 image_hot, 0); | 554 image_hot, 0); |
| 538 gtk_widget_add_events(GTK_WIDGET(button->widget()), GDK_POINTER_MOTION_MASK); | 555 gtk_widget_add_events(GTK_WIDGET(button->widget()), GDK_POINTER_MOTION_MASK); |
| 539 g_signal_connect(button->widget(), "clicked", | 556 g_signal_connect(button->widget(), "clicked", |
| 540 G_CALLBACK(OnButtonClickedThunk), this); | 557 G_CALLBACK(OnButtonClickedThunk), this); |
| 541 g_signal_connect(button->widget(), "motion-notify-event", | 558 g_signal_connect(button->widget(), "motion-notify-event", |
| 542 G_CALLBACK(OnMouseMoveEvent), browser_window_); | 559 G_CALLBACK(OnMouseMoveEvent), browser_window_); |
| 543 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip); | 560 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip); |
| 544 gtk_widget_set_tooltip_text(button->widget(), | 561 gtk_widget_set_tooltip_text(button->widget(), |
| 545 localized_tooltip.c_str()); | 562 localized_tooltip.c_str()); |
| 546 gtk_box_pack_start(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); | 563 if (start) |
| 564 gtk_box_pack_start(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); | |
| 565 else | |
| 566 gtk_box_pack_end(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); | |
| 547 return button; | 567 return button; |
| 548 } | 568 } |
| 549 | 569 |
| 550 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { | 570 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { |
| 551 using_custom_frame_ = use_custom_frame; | 571 using_custom_frame_ = use_custom_frame; |
| 552 if (!use_custom_frame || | 572 if (!use_custom_frame || |
| 553 (browser_window_->IsMaximized() && unity::IsRunning())) { | 573 (browser_window_->IsMaximized() && unity::IsRunning())) { |
| 554 if (titlebar_left_buttons_vbox_) | 574 if (titlebar_left_buttons_vbox_) |
| 555 gtk_widget_hide(titlebar_left_buttons_vbox_); | 575 gtk_widget_hide(titlebar_left_buttons_vbox_); |
| 556 if (titlebar_right_buttons_vbox_) | 576 if (titlebar_right_buttons_vbox_) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 568 void BrowserTitlebar::UpdateTitleAndIcon() { | 588 void BrowserTitlebar::UpdateTitleAndIcon() { |
| 569 if (!app_mode_title_) | 589 if (!app_mode_title_) |
| 570 return; | 590 return; |
| 571 | 591 |
| 572 // Get the page title and elide it to the available space. | 592 // Get the page title and elide it to the available space. |
| 573 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); | 593 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); |
| 574 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); | 594 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); |
| 575 | 595 |
| 576 // Note: we want to exclude the application popup window. | 596 // Note: we want to exclude the application popup window. |
| 577 if (browser_window_->browser()->is_app() && | 597 if (browser_window_->browser()->is_app() && |
| 578 !browser_window_->browser()->is_type_popup()) { | 598 browser_window_->browser()->is_type_tabbed()) { |
| 579 // Update the system app icon. We don't need to update the icon in the top | 599 // Update the system app icon. We don't need to update the icon in the top |
| 580 // left of the custom frame, that will get updated when the throbber is | 600 // left of the custom frame, that will get updated when the throbber is |
| 581 // updated. | 601 // updated. |
| 582 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); | 602 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); |
| 583 if (icon.empty()) { | 603 if (icon.empty()) { |
| 584 gtk_util::SetWindowIcon(window_); | 604 gtk_util::SetWindowIcon(window_); |
| 585 } else { | 605 } else { |
| 586 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); | 606 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); |
| 587 gtk_window_set_icon(window_, icon_pixbuf); | 607 gtk_window_set_icon(window_, icon_pixbuf); |
| 588 g_object_unref(icon_pixbuf); | 608 g_object_unref(icon_pixbuf); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 if (event->direction == GDK_SCROLL_LEFT || | 815 if (event->direction == GDK_SCROLL_LEFT || |
| 796 event->direction == GDK_SCROLL_UP) { | 816 event->direction == GDK_SCROLL_UP) { |
| 797 if (index != 0) | 817 if (index != 0) |
| 798 tabstrip_model->SelectPreviousTab(); | 818 tabstrip_model->SelectPreviousTab(); |
| 799 } else if (index + 1 < tabstrip_model->count()) { | 819 } else if (index + 1 < tabstrip_model->count()) { |
| 800 tabstrip_model->SelectNextTab(); | 820 tabstrip_model->SelectNextTab(); |
| 801 } | 821 } |
| 802 return TRUE; | 822 return TRUE; |
| 803 } | 823 } |
| 804 | 824 |
| 825 gboolean BrowserTitlebar::OnEnterNotify(GtkWidget* widget, | |
| 826 GdkEventCrossing* event) { | |
| 827 // Ignore if entered from a child widget. | |
| 828 if (event->detail == GDK_NOTIFY_INFERIOR) | |
| 829 return FALSE; | |
| 830 | |
| 831 if (window_ && panel_wrench_button_.get()) | |
| 832 gtk_widget_show(panel_wrench_button_->widget()); | |
| 833 | |
| 834 window_has_mouse_ = TRUE; | |
| 835 return FALSE; | |
| 836 } | |
| 837 | |
| 838 gboolean BrowserTitlebar::OnLeaveNotify(GtkWidget* widget, | |
| 839 GdkEventCrossing* event) { | |
| 840 // Ignore if left towards a child widget. | |
| 841 if (event->detail == GDK_NOTIFY_INFERIOR) | |
| 842 return FALSE; | |
| 843 | |
| 844 if (window_ && panel_wrench_button_.get() && !window_has_focus_) | |
| 845 gtk_widget_hide(panel_wrench_button_->widget()); | |
| 846 | |
| 847 window_has_mouse_ = FALSE; | |
| 848 return FALSE; | |
| 849 } | |
| 850 | |
| 805 // static | 851 // static |
| 806 void BrowserTitlebar::OnButtonClicked(GtkWidget* button) { | 852 void BrowserTitlebar::OnButtonClicked(GtkWidget* button) { |
| 807 if (close_button_.get() && close_button_->widget() == button) { | 853 if (close_button_.get() && close_button_->widget() == button) { |
| 808 browser_window_->Close(); | 854 browser_window_->Close(); |
| 809 } else if (restore_button_.get() && restore_button_->widget() == button) { | 855 } else if (restore_button_.get() && restore_button_->widget() == button) { |
| 810 browser_window_->UnMaximize(); | 856 browser_window_->UnMaximize(); |
| 811 } else if (maximize_button_.get() && maximize_button_->widget() == button) { | 857 } else if (maximize_button_.get() && maximize_button_->widget() == button) { |
| 812 MaximizeButtonClicked(); | 858 MaximizeButtonClicked(); |
| 813 } else if (minimize_button_.get() && minimize_button_->widget() == button) { | 859 } else if (minimize_button_.get() && minimize_button_->widget() == button) { |
| 814 gtk_window_iconify(window_); | 860 gtk_window_iconify(window_); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 905 } | 951 } |
| 906 } | 952 } |
| 907 | 953 |
| 908 void BrowserTitlebar::ActiveWindowChanged(GdkWindow* active_window) { | 954 void BrowserTitlebar::ActiveWindowChanged(GdkWindow* active_window) { |
| 909 // Can be called during shutdown; BrowserWindowGtk will set our |window_| | 955 // Can be called during shutdown; BrowserWindowGtk will set our |window_| |
| 910 // to NULL during that time. | 956 // to NULL during that time. |
| 911 if (!window_) | 957 if (!window_) |
| 912 return; | 958 return; |
| 913 | 959 |
| 914 window_has_focus_ = GTK_WIDGET(window_)->window == active_window; | 960 window_has_focus_ = GTK_WIDGET(window_)->window == active_window; |
| 961 if (IsTypePanel()) { | |
| 962 if (window_has_focus_ || window_has_mouse_) | |
| 963 gtk_widget_show(panel_wrench_button_->widget()); | |
| 964 else | |
| 965 gtk_widget_hide(panel_wrench_button_->widget()); | |
| 966 } | |
| 915 UpdateTextColor(); | 967 UpdateTextColor(); |
| 916 } | 968 } |
| 917 | 969 |
| 970 bool BrowserTitlebar::IsTypePanel() { | |
| 971 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels) && | |
|
jennb
2011/06/23 23:09:43
browser.cc converts type to POPUP if --enable-pane
prasadt
2011/06/24 00:01:11
Chatted offline.
Looks like we convert TYPE_PANEL
| |
| 972 browser_window_->browser()->is_type_panel(); | |
| 973 } | |
| 974 | |
| 918 /////////////////////////////////////////////////////////////////////////////// | 975 /////////////////////////////////////////////////////////////////////////////// |
| 919 // BrowserTitlebar::Throbber implementation | 976 // BrowserTitlebar::Throbber implementation |
| 920 // TODO(tc): Handle anti-clockwise spinning when waiting for a connection. | 977 // TODO(tc): Handle anti-clockwise spinning when waiting for a connection. |
| 921 | 978 |
| 922 // We don't bother to clean up these or the pixbufs they contain when we exit. | 979 // We don't bother to clean up these or the pixbufs they contain when we exit. |
| 923 static std::vector<GdkPixbuf*>* g_throbber_frames = NULL; | 980 static std::vector<GdkPixbuf*>* g_throbber_frames = NULL; |
| 924 static std::vector<GdkPixbuf*>* g_throbber_waiting_frames = NULL; | 981 static std::vector<GdkPixbuf*>* g_throbber_waiting_frames = NULL; |
| 925 | 982 |
| 926 // Load |resource_id| from the ResourceBundle and split it into a series of | 983 // Load |resource_id| from the ResourceBundle and split it into a series of |
| 927 // square GdkPixbufs that get stored in |frames|. | 984 // square GdkPixbufs that get stored in |frames|. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 ui::SimpleMenuModel::Delegate* delegate) | 1032 ui::SimpleMenuModel::Delegate* delegate) |
| 976 : SimpleMenuModel(delegate) { | 1033 : SimpleMenuModel(delegate) { |
| 977 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); | 1034 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); |
| 978 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); | 1035 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); |
| 979 AddSeparator(); | 1036 AddSeparator(); |
| 980 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | 1037 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); |
| 981 AddSeparator(); | 1038 AddSeparator(); |
| 982 AddCheckItemWithStringId(kShowWindowDecorationsCommand, | 1039 AddCheckItemWithStringId(kShowWindowDecorationsCommand, |
| 983 IDS_SHOW_WINDOW_DECORATIONS_MENU); | 1040 IDS_SHOW_WINDOW_DECORATIONS_MENU); |
| 984 } | 1041 } |
| OLD | NEW |