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

Side by Side Diff: chrome/browser/ui/gtk/browser_titlebar.cc

Issue 7206036: Titlebar modifications for panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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
OLDNEW
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
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
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 (is_type_panel()) {
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);
298
Evan Stade 2011/06/21 02:58:08 ?
prasadt 2011/06/21 18:21:06 Done. Removed empty line, left over from some cha
290 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_buttons_vbox_, 299 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_buttons_vbox_,
291 FALSE, FALSE, 0); 300 FALSE, FALSE, 0);
292 if (browser_window_->browser()->profile()->IsOffTheRecord() && 301 if (browser_window_->browser()->profile()->IsOffTheRecord() &&
293 browser_window_->browser()->is_type_tabbed()) { 302 browser_window_->browser()->is_type_tabbed()) {
294 titlebar_left_spy_frame_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 303 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); 304 gtk_widget_set_no_show_all(titlebar_left_spy_frame_, TRUE);
296 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_left_spy_frame_), 0, 305 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_left_spy_frame_), 0,
297 kOTRBottomSpacing, kOTRSideSpacing, kOTRSideSpacing); 306 kOTRBottomSpacing, kOTRSideSpacing, kOTRSideSpacing);
298 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_spy_frame_, 307 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_spy_frame_,
299 FALSE, FALSE, 0); 308 FALSE, FALSE, 0);
(...skipping 21 matching lines...) Expand all
321 if (browser_window_->browser()->profile()->IsOffTheRecord() && 330 if (browser_window_->browser()->profile()->IsOffTheRecord() &&
322 browser_window_->browser()->is_type_tabbed()) { 331 browser_window_->browser()->is_type_tabbed()) {
323 titlebar_right_spy_frame_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 332 titlebar_right_spy_frame_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
324 gtk_widget_set_no_show_all(titlebar_right_spy_frame_, TRUE); 333 gtk_widget_set_no_show_all(titlebar_right_spy_frame_, TRUE);
325 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_right_spy_frame_), 0, 334 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_right_spy_frame_), 0,
326 kOTRBottomSpacing, kOTRSideSpacing, kOTRSideSpacing); 335 kOTRBottomSpacing, kOTRSideSpacing, kOTRSideSpacing);
327 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_spy_frame_, 336 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_spy_frame_,
328 FALSE, FALSE, 0); 337 FALSE, FALSE, 0);
329 } 338 }
330 titlebar_right_buttons_vbox_ = gtk_vbox_new(FALSE, 0); 339 titlebar_right_buttons_vbox_ = gtk_vbox_new(FALSE, 0);
340
Evan Stade 2011/06/21 02:58:08 ?
prasadt 2011/06/21 18:21:06 Done.
331 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_, 341 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_,
332 FALSE, FALSE, 0); 342 FALSE, FALSE, 0);
333 343
334 #if defined(USE_GCONF) 344 #if defined(USE_GCONF)
335 // Either read the gconf database and register for updates (on GNOME), or use 345 // Either read the gconf database and register for updates (on GNOME), or use
336 // the default value (anywhere else). 346 // the default value (anywhere else).
337 GConfTitlebarListener::GetInstance()->SetTitlebarButtons(this); 347 GConfTitlebarListener::GetInstance()->SetTitlebarButtons(this);
338 #else 348 #else
339 BuildButtons(kDefaultButtonString); 349 BuildButtons(kDefaultButtonString);
340 #endif 350 #endif
(...skipping 28 matching lines...) Expand all
369 FALSE, 0); 379 FALSE, 0);
370 // We use the app logo as a placeholder image so the title doesn't jump 380 // We use the app logo as a placeholder image so the title doesn't jump
371 // around. 381 // around.
372 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 382 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
373 app_mode_favicon_ = gtk_image_new_from_pixbuf( 383 app_mode_favicon_ = gtk_image_new_from_pixbuf(
374 rb.GetRTLEnabledPixbufNamed(IDR_PRODUCT_LOGO_16)); 384 rb.GetRTLEnabledPixbufNamed(IDR_PRODUCT_LOGO_16));
375 g_object_set_data(G_OBJECT(app_mode_favicon_), "left-align-popup", 385 g_object_set_data(G_OBJECT(app_mode_favicon_), "left-align-popup",
376 reinterpret_cast<void*>(true)); 386 reinterpret_cast<void*>(true));
377 gtk_container_add(GTK_CONTAINER(favicon_event_box), app_mode_favicon_); 387 gtk_container_add(GTK_CONTAINER(favicon_event_box), app_mode_favicon_);
378 388
389 if (is_type_panel()) {
390 panel_wrench_button_.reset(
391 BuildTitlebarButton(IDR_BALLOON_WRENCH, IDR_BALLOON_WRENCH_P,
392 IDR_BALLOON_WRENCH_H, app_mode_hbox, FALSE,
393 IDS_NEW_TAB_APP_SETTINGS));
394 gtk_widget_set_no_show_all(panel_wrench_button_->widget(), TRUE);
395 }
396
379 app_mode_title_ = gtk_label_new(NULL); 397 app_mode_title_ = gtk_label_new(NULL);
380 gtk_label_set_ellipsize(GTK_LABEL(app_mode_title_), PANGO_ELLIPSIZE_END); 398 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); 399 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, 400 gtk_box_pack_start(GTK_BOX(app_mode_hbox), app_mode_title_, TRUE, TRUE,
383 0); 401 0);
384 402
385 // Register with the theme provider to set the |app_mode_title_| label 403 // Register with the theme provider to set the |app_mode_title_| label
386 // color. 404 // color.
387 theme_service_ = GtkThemeService::GetFrom( 405 theme_service_ = GtkThemeService::GetFrom(
388 browser_window_->browser()->profile()); 406 browser_window_->browser()->profile());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 tokenizer.set_options(StringTokenizer::RETURN_DELIMS); 440 tokenizer.set_options(StringTokenizer::RETURN_DELIMS);
423 int left_count = 0; 441 int left_count = 0;
424 int right_count = 0; 442 int right_count = 0;
425 while (tokenizer.GetNext()) { 443 while (tokenizer.GetNext()) {
426 if (tokenizer.token_is_delim()) { 444 if (tokenizer.token_is_delim()) {
427 if (*tokenizer.token_begin() == ':') 445 if (*tokenizer.token_begin() == ':')
428 left_side = false; 446 left_side = false;
429 } else { 447 } else {
430 base::StringPiece token = tokenizer.token_piece(); 448 base::StringPiece token = tokenizer.token_piece();
431 if (token == "minimize") { 449 if (token == "minimize") {
432 (left_side ? left_count : right_count)++; 450 if (!is_type_panel()) {
Evan Stade 2011/06/21 02:58:08 move into if statement above
prasadt 2011/06/21 18:21:06 Done.
433 GtkWidget* parent_box = GetButtonHBox(left_side); 451 (left_side ? left_count : right_count)++;
434 minimize_button_.reset( 452 GtkWidget* parent_box = GetButtonHBox(left_side);
435 BuildTitlebarButton(IDR_MINIMIZE, IDR_MINIMIZE_P, 453 minimize_button_.reset(
436 IDR_MINIMIZE_H, parent_box, 454 BuildTitlebarButton(IDR_MINIMIZE, IDR_MINIMIZE_P,
437 IDS_XPFRAME_MINIMIZE_TOOLTIP)); 455 IDR_MINIMIZE_H, parent_box, true,
456 IDS_XPFRAME_MINIMIZE_TOOLTIP));
438 457
439 gtk_widget_size_request(minimize_button_->widget(), 458 gtk_widget_size_request(minimize_button_->widget(),
440 &minimize_button_req_); 459 &minimize_button_req_);
460 }
441 } else if (token == "maximize") { 461 } else if (token == "maximize") {
442 (left_side ? left_count : right_count)++; 462 if (!is_type_panel()) {
Evan Stade 2011/06/21 02:58:08 move into if statement above
prasadt 2011/06/21 18:21:06 Done.
443 GtkWidget* parent_box = GetButtonHBox(left_side); 463 (left_side ? left_count : right_count)++;
444 restore_button_.reset( 464 GtkWidget* parent_box = GetButtonHBox(left_side);
445 BuildTitlebarButton(IDR_RESTORE, IDR_RESTORE_P, 465 restore_button_.reset(
446 IDR_RESTORE_H, parent_box, 466 BuildTitlebarButton(IDR_RESTORE, IDR_RESTORE_P,
447 IDS_XPFRAME_RESTORE_TOOLTIP)); 467 IDR_RESTORE_H, parent_box, true,
448 maximize_button_.reset( 468 IDS_XPFRAME_RESTORE_TOOLTIP));
449 BuildTitlebarButton(IDR_MAXIMIZE, IDR_MAXIMIZE_P, 469 maximize_button_.reset(
450 IDR_MAXIMIZE_H, parent_box, 470 BuildTitlebarButton(IDR_MAXIMIZE, IDR_MAXIMIZE_P,
451 IDS_XPFRAME_MAXIMIZE_TOOLTIP)); 471 IDR_MAXIMIZE_H, parent_box, true,
472 IDS_XPFRAME_MAXIMIZE_TOOLTIP));
452 473
453 gtk_util::SetButtonClickableByMouseButtons(maximize_button_->widget(), 474 gtk_util::SetButtonClickableByMouseButtons(maximize_button_->widget(),
454 true, true, true); 475 true, true, true);
455 gtk_widget_size_request(restore_button_->widget(), 476 gtk_widget_size_request(restore_button_->widget(),
456 &restore_button_req_); 477 &restore_button_req_);
478 }
457 } else if (token == "close") { 479 } else if (token == "close") {
458 (left_side ? left_count : right_count)++; 480 (left_side ? left_count : right_count)++;
459 GtkWidget* parent_box = GetButtonHBox(left_side); 481 GtkWidget* parent_box = GetButtonHBox(left_side);
460 close_button_.reset( 482 close_button_.reset(
461 BuildTitlebarButton(IDR_CLOSE, IDR_CLOSE_P, 483 BuildTitlebarButton(IDR_CLOSE, IDR_CLOSE_P,
462 IDR_CLOSE_H, parent_box, 484 IDR_CLOSE_H, parent_box, true,
463 IDS_XPFRAME_CLOSE_TOOLTIP)); 485 IDS_XPFRAME_CLOSE_TOOLTIP));
464 close_button_->set_flipped(left_side); 486 close_button_->set_flipped(left_side);
465 487
466 gtk_widget_size_request(close_button_->widget(), &close_button_req_); 488 gtk_widget_size_request(close_button_->widget(), &close_button_req_);
467 } 489 }
468 // Ignore any other values like "pin" since we don't have images for 490 // Ignore any other values like "pin" since we don't have images for
469 // those. 491 // those.
470 } 492 }
471 } 493 }
472 494
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 top_padding_left_ = top_padding; 547 top_padding_left_ = top_padding;
526 } else { 548 } else {
527 titlebar_right_buttons_hbox_ = buttons_hbox; 549 titlebar_right_buttons_hbox_ = buttons_hbox;
528 top_padding_right_ = top_padding; 550 top_padding_right_ = top_padding;
529 } 551 }
530 552
531 return buttons_hbox; 553 return buttons_hbox;
532 } 554 }
533 555
534 CustomDrawButton* BrowserTitlebar::BuildTitlebarButton(int image, 556 CustomDrawButton* BrowserTitlebar::BuildTitlebarButton(int image,
535 int image_pressed, int image_hot, GtkWidget* box, int tooltip) { 557 int image_pressed, int image_hot, GtkWidget* box, bool start,
558 int tooltip) {
536 CustomDrawButton* button = new CustomDrawButton(image, image_pressed, 559 CustomDrawButton* button = new CustomDrawButton(image, image_pressed,
537 image_hot, 0); 560 image_hot, 0);
538 gtk_widget_add_events(GTK_WIDGET(button->widget()), GDK_POINTER_MOTION_MASK); 561 gtk_widget_add_events(GTK_WIDGET(button->widget()), GDK_POINTER_MOTION_MASK);
539 g_signal_connect(button->widget(), "clicked", 562 g_signal_connect(button->widget(), "clicked",
540 G_CALLBACK(OnButtonClickedThunk), this); 563 G_CALLBACK(OnButtonClickedThunk), this);
541 g_signal_connect(button->widget(), "motion-notify-event", 564 g_signal_connect(button->widget(), "motion-notify-event",
542 G_CALLBACK(OnMouseMoveEvent), browser_window_); 565 G_CALLBACK(OnMouseMoveEvent), browser_window_);
543 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip); 566 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip);
544 gtk_widget_set_tooltip_text(button->widget(), 567 gtk_widget_set_tooltip_text(button->widget(),
545 localized_tooltip.c_str()); 568 localized_tooltip.c_str());
546 gtk_box_pack_start(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); 569 if (start)
570 gtk_box_pack_start(GTK_BOX(box), button->widget(), FALSE, FALSE, 0);
571 else
572 gtk_box_pack_end(GTK_BOX(box), button->widget(), FALSE, FALSE, 0);
547 return button; 573 return button;
548 } 574 }
549 575
550 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { 576 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) {
551 using_custom_frame_ = use_custom_frame; 577 using_custom_frame_ = use_custom_frame;
552 if (!use_custom_frame || 578 if (!use_custom_frame ||
553 (browser_window_->IsMaximized() && unity::IsRunning())) { 579 (browser_window_->IsMaximized() && unity::IsRunning())) {
554 if (titlebar_left_buttons_vbox_) 580 if (titlebar_left_buttons_vbox_)
555 gtk_widget_hide(titlebar_left_buttons_vbox_); 581 gtk_widget_hide(titlebar_left_buttons_vbox_);
556 if (titlebar_right_buttons_vbox_) 582 if (titlebar_right_buttons_vbox_)
(...skipping 11 matching lines...) Expand all
568 void BrowserTitlebar::UpdateTitleAndIcon() { 594 void BrowserTitlebar::UpdateTitleAndIcon() {
569 if (!app_mode_title_) 595 if (!app_mode_title_)
570 return; 596 return;
571 597
572 // Get the page title and elide it to the available space. 598 // Get the page title and elide it to the available space.
573 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); 599 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab();
574 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); 600 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str());
575 601
576 // Note: we want to exclude the application popup window. 602 // Note: we want to exclude the application popup window.
577 if (browser_window_->browser()->is_app() && 603 if (browser_window_->browser()->is_app() &&
578 !browser_window_->browser()->is_type_popup()) { 604 browser_window_->browser()->is_type_tabbed()) {
579 // Update the system app icon. We don't need to update the icon in the top 605 // 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 606 // left of the custom frame, that will get updated when the throbber is
581 // updated. 607 // updated.
582 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); 608 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon();
583 if (icon.empty()) { 609 if (icon.empty()) {
584 gtk_util::SetWindowIcon(window_); 610 gtk_util::SetWindowIcon(window_);
585 } else { 611 } else {
586 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); 612 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(&icon);
587 gtk_window_set_icon(window_, icon_pixbuf); 613 gtk_window_set_icon(window_, icon_pixbuf);
588 g_object_unref(icon_pixbuf); 614 g_object_unref(icon_pixbuf);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 if (event->direction == GDK_SCROLL_LEFT || 821 if (event->direction == GDK_SCROLL_LEFT ||
796 event->direction == GDK_SCROLL_UP) { 822 event->direction == GDK_SCROLL_UP) {
797 if (index != 0) 823 if (index != 0)
798 tabstrip_model->SelectPreviousTab(); 824 tabstrip_model->SelectPreviousTab();
799 } else if (index + 1 < tabstrip_model->count()) { 825 } else if (index + 1 < tabstrip_model->count()) {
800 tabstrip_model->SelectNextTab(); 826 tabstrip_model->SelectNextTab();
801 } 827 }
802 return TRUE; 828 return TRUE;
803 } 829 }
804 830
831 gboolean BrowserTitlebar::OnEnterNotify(GtkWidget* widget,
832 GdkEventCrossing* event) {
833 if (window_ && panel_wrench_button_.get())
834 gtk_widget_show(panel_wrench_button_->widget());
835
836 window_has_mouse_ = TRUE;
837 return FALSE;
838 }
839
840 gboolean BrowserTitlebar::OnLeaveNotify(GtkWidget* widget,
841 GdkEventCrossing* event) {
842 if (window_ && panel_wrench_button_.get()) {
843 // leave-notify-event gets fired on window when mouse moves to a child
844 // widget inside the window. Check co-ordinates to determine whether the
845 // mouse is in the window.
846 window_has_mouse_ =
847 event->x > 0 && event->x < browser_window_->GetBounds().width() &&
Evan Stade 2011/06/21 02:58:08 did you try using event->detail ?
prasadt 2011/06/21 18:21:06 No I didn't notice that field. I tried it and see
848 event->y > 0 && event->y < browser_window_->GetBounds().height();
849 if (!window_has_mouse_ && !window_has_focus_)
850 gtk_widget_hide(panel_wrench_button_->widget());
851 }
852
853 return FALSE;
854 }
855
805 // static 856 // static
806 void BrowserTitlebar::OnButtonClicked(GtkWidget* button) { 857 void BrowserTitlebar::OnButtonClicked(GtkWidget* button) {
807 if (close_button_.get() && close_button_->widget() == button) { 858 if (close_button_.get() && close_button_->widget() == button) {
808 browser_window_->Close(); 859 browser_window_->Close();
809 } else if (restore_button_.get() && restore_button_->widget() == button) { 860 } else if (restore_button_.get() && restore_button_->widget() == button) {
810 browser_window_->UnMaximize(); 861 browser_window_->UnMaximize();
811 } else if (maximize_button_.get() && maximize_button_->widget() == button) { 862 } else if (maximize_button_.get() && maximize_button_->widget() == button) {
812 MaximizeButtonClicked(); 863 MaximizeButtonClicked();
813 } else if (minimize_button_.get() && minimize_button_->widget() == button) { 864 } else if (minimize_button_.get() && minimize_button_->widget() == button) {
814 gtk_window_iconify(window_); 865 gtk_window_iconify(window_);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 } 956 }
906 } 957 }
907 958
908 void BrowserTitlebar::ActiveWindowChanged(GdkWindow* active_window) { 959 void BrowserTitlebar::ActiveWindowChanged(GdkWindow* active_window) {
909 // Can be called during shutdown; BrowserWindowGtk will set our |window_| 960 // Can be called during shutdown; BrowserWindowGtk will set our |window_|
910 // to NULL during that time. 961 // to NULL during that time.
911 if (!window_) 962 if (!window_)
912 return; 963 return;
913 964
914 window_has_focus_ = GTK_WIDGET(window_)->window == active_window; 965 window_has_focus_ = GTK_WIDGET(window_)->window == active_window;
966 if (is_type_panel() && panel_wrench_button_.get()) {
Evan Stade 2011/06/21 02:58:08 can panel_wrench_button_ actually be null here?
prasadt 2011/06/21 18:21:06 On closer look, no. Removed the check.
967 if (window_has_focus_ || window_has_mouse_)
968 gtk_widget_show(panel_wrench_button_->widget());
969 else
970 gtk_widget_hide(panel_wrench_button_->widget());
971 }
915 UpdateTextColor(); 972 UpdateTextColor();
916 } 973 }
917 974
975 bool BrowserTitlebar::is_type_panel() {
976 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels) &&
Evan Stade 2011/06/21 02:58:08 why is the first part necessary?
prasadt 2011/06/21 18:21:06 Panel type is enabled by default (scratch pad for
977 browser_window_->browser()->is_type_panel();
978 }
979
918 /////////////////////////////////////////////////////////////////////////////// 980 ///////////////////////////////////////////////////////////////////////////////
919 // BrowserTitlebar::Throbber implementation 981 // BrowserTitlebar::Throbber implementation
920 // TODO(tc): Handle anti-clockwise spinning when waiting for a connection. 982 // TODO(tc): Handle anti-clockwise spinning when waiting for a connection.
921 983
922 // We don't bother to clean up these or the pixbufs they contain when we exit. 984 // 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; 985 static std::vector<GdkPixbuf*>* g_throbber_frames = NULL;
924 static std::vector<GdkPixbuf*>* g_throbber_waiting_frames = NULL; 986 static std::vector<GdkPixbuf*>* g_throbber_waiting_frames = NULL;
925 987
926 // Load |resource_id| from the ResourceBundle and split it into a series of 988 // Load |resource_id| from the ResourceBundle and split it into a series of
927 // square GdkPixbufs that get stored in |frames|. 989 // square GdkPixbufs that get stored in |frames|.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 ui::SimpleMenuModel::Delegate* delegate) 1037 ui::SimpleMenuModel::Delegate* delegate)
976 : SimpleMenuModel(delegate) { 1038 : SimpleMenuModel(delegate) {
977 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); 1039 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB);
978 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); 1040 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB);
979 AddSeparator(); 1041 AddSeparator();
980 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); 1042 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
981 AddSeparator(); 1043 AddSeparator();
982 AddCheckItemWithStringId(kShowWindowDecorationsCommand, 1044 AddCheckItemWithStringId(kShowWindowDecorationsCommand,
983 IDS_SHOW_WINDOW_DECORATIONS_MENU); 1045 IDS_SHOW_WINDOW_DECORATIONS_MENU);
984 } 1046 }
OLDNEW
« chrome/browser/ui/gtk/browser_titlebar.h ('K') | « chrome/browser/ui/gtk/browser_titlebar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698