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_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_toolbar_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/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 GtkWidget* left = NULL; | 539 GtkWidget* left = NULL; |
540 GtkWidget* right = NULL; | 540 GtkWidget* right = NULL; |
541 if (gtk_widget_get_direction(star) == GTK_TEXT_DIR_LTR) { | 541 if (gtk_widget_get_direction(star) == GTK_TEXT_DIR_LTR) { |
542 left = toolbar->star_->widget(); | 542 left = toolbar->star_->widget(); |
543 right = toolbar->go_->widget(); | 543 right = toolbar->go_->widget(); |
544 } else { | 544 } else { |
545 left = toolbar->go_->widget(); | 545 left = toolbar->go_->widget(); |
546 right = toolbar->star_->widget(); | 546 right = toolbar->star_->widget(); |
547 } | 547 } |
548 | 548 |
549 gint x = left->allocation.x; | 549 GdkRectangle rec = { |
550 gint y = left->allocation.y; | 550 left->allocation.x, |
551 gint width = (right->allocation.x - left->allocation.x) + | 551 left->allocation.y, |
552 right->allocation.width; | 552 (right->allocation.x - left->allocation.x) + right->allocation.width, |
553 gint height = (right->allocation.y - left->allocation.y) + | 553 (right->allocation.y - left->allocation.y) + right->allocation.height |
554 right->allocation.height; | 554 }; |
555 | 555 |
556 // Make sure our off screen entry has the correct base color if we're in | 556 // Make sure our off screen entry has the correct base color if we're in |
557 // secure mode. | 557 // secure mode. |
558 gtk_widget_modify_base( | 558 gtk_widget_modify_base( |
559 toolbar->offscreen_entry_.get(), GTK_STATE_NORMAL, | 559 toolbar->offscreen_entry_.get(), GTK_STATE_NORMAL, |
560 (toolbar->browser_->toolbar_model()->GetSchemeSecurityLevel() == | 560 (toolbar->browser_->toolbar_model()->GetSchemeSecurityLevel() == |
561 ToolbarModel::SECURE) ? | 561 ToolbarModel::SECURE) ? |
562 &kSecureColor : NULL); | 562 &kSecureColor : NULL); |
563 | 563 |
564 GtkStyle* gtk_owned_style = | 564 GtkStyle* gtk_owned_style = |
565 gtk_rc_get_style(toolbar->offscreen_entry_.get()); | 565 gtk_rc_get_style(toolbar->offscreen_entry_.get()); |
566 // GTK owns the above and we're going to have to make our own copy of it | 566 // GTK owns the above and we're going to have to make our own copy of it |
567 // that we can edit. | 567 // that we can edit. |
568 GtkStyle* our_style = gtk_style_copy(gtk_owned_style); | 568 GtkStyle* our_style = gtk_style_copy(gtk_owned_style); |
569 our_style = gtk_style_attach(our_style, location_hbox->window); | 569 our_style = gtk_style_attach(our_style, location_hbox->window); |
570 | 570 |
571 // TODO(erg): Draw the focus ring if appropriate... | 571 // TODO(erg): Draw the focus ring if appropriate... |
572 | 572 |
573 // We're using GTK rendering; draw a GTK entry widget onto the background. | 573 // We're using GTK rendering; draw a GTK entry widget onto the background. |
574 gtk_paint_shadow(our_style, location_hbox->window, | 574 gtk_paint_shadow(our_style, location_hbox->window, |
575 GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL, | 575 GTK_STATE_NORMAL, GTK_SHADOW_IN, &rec, |
576 location_hbox, "entry", | 576 location_hbox, "entry", |
577 x, y, width, height); | 577 rec.x, rec.y, rec.width, rec.height); |
578 | 578 |
579 // Draw the interior background (not all themes draw the entry background | 579 // Draw the interior background (not all themes draw the entry background |
580 // above; this is a noop on themes that do). | 580 // above; this is a noop on themes that do). |
581 gint xborder = our_style->xthickness; | 581 gint xborder = our_style->xthickness; |
582 gint yborder = our_style->ythickness; | 582 gint yborder = our_style->ythickness; |
583 gtk_paint_flat_box(our_style, location_hbox->window, | 583 gtk_paint_flat_box(our_style, location_hbox->window, |
584 GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, | 584 GTK_STATE_NORMAL, GTK_SHADOW_NONE, &rec, |
585 location_hbox, "entry_bg", | 585 location_hbox, "entry_bg", |
586 x + xborder, y + yborder, | 586 rec.x + xborder, rec.y + yborder, |
587 width - 2 * xborder, | 587 rec.width - 2 * xborder, |
588 height - 2 * yborder); | 588 rec.height - 2 * yborder); |
589 | 589 |
590 g_object_unref(our_style); | 590 g_object_unref(our_style); |
591 } | 591 } |
592 | 592 |
593 return FALSE; | 593 return FALSE; |
594 } | 594 } |
595 | 595 |
596 // static | 596 // static |
597 void BrowserToolbarGtk::OnButtonClick(GtkWidget* button, | 597 void BrowserToolbarGtk::OnButtonClick(GtkWidget* button, |
598 BrowserToolbarGtk* toolbar) { | 598 BrowserToolbarGtk* toolbar) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 g_signal_stop_emission_by_name(menu, "move-current"); | 700 g_signal_stop_emission_by_name(menu, "move-current"); |
701 default: | 701 default: |
702 break; | 702 break; |
703 } | 703 } |
704 } | 704 } |
705 | 705 |
706 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { | 706 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { |
707 // If we're a popup window, only show the location bar (omnibox). | 707 // If we're a popup window, only show the location bar (omnibox). |
708 return browser_->type() != Browser::TYPE_NORMAL; | 708 return browser_->type() != Browser::TYPE_NORMAL; |
709 } | 709 } |
OLD | NEW |