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/find_bar_gtk.h" | 5 #include "chrome/browser/gtk/find_bar_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/gfx/gtk_util.h" | 10 #include "base/gfx/gtk_util.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 : browser_(browser), | 144 : browser_(browser), |
145 window_(static_cast<BrowserWindowGtk*>(browser->window())), | 145 window_(static_cast<BrowserWindowGtk*>(browser->window())), |
146 theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), | 146 theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), |
147 container_width_(-1), | 147 container_width_(-1), |
148 container_height_(-1), | 148 container_height_(-1), |
149 ignore_changed_signal_(false), | 149 ignore_changed_signal_(false), |
150 current_fixed_width_(-1) { | 150 current_fixed_width_(-1) { |
151 InitWidgets(); | 151 InitWidgets(); |
152 ViewIDUtil::SetID(text_entry_, VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 152 ViewIDUtil::SetID(text_entry_, VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); |
153 | 153 |
154 dialog_background_.reset(new NineBox(browser->profile()->GetThemeProvider(), | |
155 0, IDR_THEME_TOOLBAR, 0, | |
156 0, 0, 0, 0, 0, 0)); | |
157 | |
158 // Insert the widget into the browser gtk hierarchy. | 154 // Insert the widget into the browser gtk hierarchy. |
159 window_->AddFindBar(this); | 155 window_->AddFindBar(this); |
160 | 156 |
161 // Hook up signals after the widget has been added to the hierarchy so the | 157 // Hook up signals after the widget has been added to the hierarchy so the |
162 // widget will be realized. | 158 // widget will be realized. |
163 g_signal_connect(text_entry_, "changed", | 159 g_signal_connect(text_entry_, "changed", |
164 G_CALLBACK(OnChanged), this); | 160 G_CALLBACK(OnChanged), this); |
165 g_signal_connect(text_entry_, "key-press-event", | 161 g_signal_connect(text_entry_, "key-press-event", |
166 G_CALLBACK(OnKeyPressEvent), this); | 162 G_CALLBACK(OnKeyPressEvent), this); |
167 g_signal_connect(text_entry_, "key-release-event", | 163 g_signal_connect(text_entry_, "key-release-event", |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 bar->container_width_ = widget->allocation.width; | 658 bar->container_width_ = widget->allocation.width; |
663 bar->container_height_ = widget->allocation.height; | 659 bar->container_height_ = widget->allocation.height; |
664 } | 660 } |
665 | 661 |
666 // Draw the background theme image. | 662 // Draw the background theme image. |
667 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 663 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
668 cairo_rectangle(cr, e->area.x, e->area.y, e->area.width, e->area.height); | 664 cairo_rectangle(cr, e->area.x, e->area.y, e->area.width, e->area.height); |
669 cairo_clip(cr); | 665 cairo_clip(cr); |
670 gfx::Point tabstrip_origin = | 666 gfx::Point tabstrip_origin = |
671 bar->window_->tabstrip()->GetTabStripOriginForWidget(widget); | 667 bar->window_->tabstrip()->GetTabStripOriginForWidget(widget); |
672 bar->dialog_background_->RenderTopCenterStrip( | 668 GdkPixbuf* background = bar->browser_->profile()->GetThemeProvider()-> |
673 cr, tabstrip_origin.x(), tabstrip_origin.y(), | 669 GetPixbufNamed(IDR_THEME_TOOLBAR); |
674 e->area.x + e->area.width - tabstrip_origin.x()); | 670 gdk_cairo_set_source_pixbuf(cr, background, |
| 671 tabstrip_origin.x(), tabstrip_origin.y()); |
| 672 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
| 673 cairo_rectangle(cr, tabstrip_origin.x(), tabstrip_origin.y(), |
| 674 e->area.x + e->area.width - tabstrip_origin.x(), |
| 675 gdk_pixbuf_get_height(background)); |
| 676 cairo_fill(cr); |
675 cairo_destroy(cr); | 677 cairo_destroy(cr); |
676 | 678 |
677 // Draw the border. | 679 // Draw the border. |
678 GetDialogBorder()->RenderToWidget(widget); | 680 GetDialogBorder()->RenderToWidget(widget); |
679 } | 681 } |
680 | 682 |
681 // Propagate to the container's child. | 683 // Propagate to the container's child. |
682 GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget)); | 684 GtkWidget* child = gtk_bin_get_child(GTK_BIN(widget)); |
683 if (child) | 685 if (child) |
684 gtk_container_propagate_expose(GTK_CONTAINER(widget), child, e); | 686 gtk_container_propagate_expose(GTK_CONTAINER(widget), child, e); |
(...skipping 10 matching lines...) Expand all Loading... |
695 } | 697 } |
696 | 698 |
697 // static | 699 // static |
698 gboolean FindBarGtk::OnButtonPress(GtkWidget* text_entry, GdkEventButton* e, | 700 gboolean FindBarGtk::OnButtonPress(GtkWidget* text_entry, GdkEventButton* e, |
699 FindBarGtk* find_bar) { | 701 FindBarGtk* find_bar) { |
700 find_bar->StoreOutsideFocus(); | 702 find_bar->StoreOutsideFocus(); |
701 | 703 |
702 // Continue propagating the event. | 704 // Continue propagating the event. |
703 return FALSE; | 705 return FALSE; |
704 } | 706 } |
OLD | NEW |