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

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

Issue 9371005: GTK: Do more GSEALing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/find_bar_gtk.h" 5 #include "chrome/browser/ui/gtk/find_bar_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 void FindBarGtk::SetFindBarController(FindBarController* find_bar_controller) { 320 void FindBarGtk::SetFindBarController(FindBarController* find_bar_controller) {
321 find_bar_controller_ = find_bar_controller; 321 find_bar_controller_ = find_bar_controller;
322 } 322 }
323 323
324 void FindBarGtk::Show(bool animate) { 324 void FindBarGtk::Show(bool animate) {
325 if (animate) { 325 if (animate) {
326 slide_widget_->Open(); 326 slide_widget_->Open();
327 selection_rect_ = gfx::Rect(); 327 selection_rect_ = gfx::Rect();
328 Reposition(); 328 Reposition();
329 if (container_->window) 329 GdkWindow* gdk_window = gtk_widget_get_window(container_);
330 gdk_window_raise(container_->window); 330 if (gdk_window)
331 gdk_window_raise(gdk_window);
331 } else { 332 } else {
332 slide_widget_->OpenWithoutAnimation(); 333 slide_widget_->OpenWithoutAnimation();
333 } 334 }
334 } 335 }
335 336
336 void FindBarGtk::Hide(bool animate) { 337 void FindBarGtk::Hide(bool animate) {
337 if (animate) 338 if (animate)
338 slide_widget_->Close(); 339 slide_widget_->Close();
339 else 340 else
340 slide_widget_->CloseWithoutAnimation(); 341 slide_widget_->CloseWithoutAnimation();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 gtk_widget_modify_fg(match_count_label_, GTK_STATE_NORMAL, 634 gtk_widget_modify_fg(match_count_label_, GTK_STATE_NORMAL,
634 failure ? &kEntryTextColor : &kFindSuccessTextColor); 635 failure ? &kEntryTextColor : &kFindSuccessTextColor);
635 } 636 }
636 } 637 }
637 638
638 void FindBarGtk::Reposition() { 639 void FindBarGtk::Reposition() {
639 if (!IsFindBarVisible()) 640 if (!IsFindBarVisible())
640 return; 641 return;
641 642
642 // This will trigger an allocate, which allows us to reposition. 643 // This will trigger an allocate, which allows us to reposition.
643 if (widget()->parent) 644 GtkWidget* parent = gtk_widget_get_parent(widget());
644 gtk_widget_queue_resize(widget()->parent); 645 if (parent)
646 gtk_widget_queue_resize(parent);
645 } 647 }
646 648
647 void FindBarGtk::StoreOutsideFocus() { 649 void FindBarGtk::StoreOutsideFocus() {
648 // |text_entry_| is the only widget in the find bar that can be focused, 650 // |text_entry_| is the only widget in the find bar that can be focused,
649 // so it's the only one we have to check. 651 // so it's the only one we have to check.
650 // TODO(estade): when we make the find bar buttons focusable, we'll have 652 // TODO(estade): when we make the find bar buttons focusable, we'll have
651 // to change this (same above in RestoreSavedFocus). 653 // to change this (same above in RestoreSavedFocus).
652 if (!gtk_widget_is_focus(text_entry_)) 654 if (!gtk_widget_is_focus(text_entry_))
653 focus_store_.Store(text_entry_); 655 focus_store_.Store(text_entry_);
654 } 656 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 (widget_dir == GTK_TEXT_DIR_LTR && content_dir == PANGO_DIRECTION_RTL)) { 713 (widget_dir == GTK_TEXT_DIR_LTR && content_dir == PANGO_DIRECTION_RTL)) {
712 gtk_entry_set_alignment(GTK_ENTRY(text_entry_), 1.0); 714 gtk_entry_set_alignment(GTK_ENTRY(text_entry_), 1.0);
713 } else { 715 } else {
714 gtk_entry_set_alignment(GTK_ENTRY(text_entry_), 0.0); 716 gtk_entry_set_alignment(GTK_ENTRY(text_entry_), 0.0);
715 } 717 }
716 } 718 }
717 719
718 gfx::Point FindBarGtk::GetPosition() { 720 gfx::Point FindBarGtk::GetPosition() {
719 gfx::Point point; 721 gfx::Point point;
720 722
723 GtkWidget* parent = gtk_widget_get_parent(widget());
724
721 GValue value = { 0, }; 725 GValue value = { 0, };
722 g_value_init(&value, G_TYPE_INT); 726 g_value_init(&value, G_TYPE_INT);
723 gtk_container_child_get_property(GTK_CONTAINER(widget()->parent), 727 gtk_container_child_get_property(GTK_CONTAINER(parent),
724 widget(), "x", &value); 728 widget(), "x", &value);
725 point.set_x(g_value_get_int(&value)); 729 point.set_x(g_value_get_int(&value));
726 730
727 gtk_container_child_get_property(GTK_CONTAINER(widget()->parent), 731 gtk_container_child_get_property(GTK_CONTAINER(parent),
728 widget(), "y", &value); 732 widget(), "y", &value);
729 point.set_y(g_value_get_int(&value)); 733 point.set_y(g_value_get_int(&value));
730 734
731 g_value_unset(&value); 735 g_value_unset(&value);
732 736
733 return point; 737 return point;
734 } 738 }
735 739
736 // static 740 // static
737 void FindBarGtk::OnParentSet(GtkWidget* widget, GtkObject* old_parent, 741 void FindBarGtk::OnParentSet(GtkWidget* widget, GtkObject* old_parent,
738 FindBarGtk* find_bar) { 742 FindBarGtk* find_bar) {
739 if (!widget->parent) 743 if (!gtk_widget_get_parent(widget))
740 return; 744 return;
741 745
742 g_signal_connect(gtk_widget_get_parent(widget), "set-floating-position", 746 g_signal_connect(gtk_widget_get_parent(widget), "set-floating-position",
743 G_CALLBACK(OnSetFloatingPosition), find_bar); 747 G_CALLBACK(OnSetFloatingPosition), find_bar);
744 } 748 }
745 749
746 // static 750 // static
747 void FindBarGtk::OnSetFloatingPosition(GtkFloatingContainer* floating_container, 751 void FindBarGtk::OnSetFloatingPosition(GtkFloatingContainer* floating_container,
748 GtkAllocation* allocation, 752 GtkAllocation* allocation,
749 FindBarGtk* find_bar) { 753 FindBarGtk* find_bar) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 bar->container_height_ != allocation.height) { 885 bar->container_height_ != allocation.height) {
882 // Reset the shape. 886 // Reset the shape.
883 gdk_window_shape_combine_region(gtk_widget_get_window(widget), 887 gdk_window_shape_combine_region(gtk_widget_get_window(widget),
884 NULL, 0, 0); 888 NULL, 0, 0);
885 SetDialogShape(bar->container_); 889 SetDialogShape(bar->container_);
886 890
887 bar->container_width_ = allocation.width; 891 bar->container_width_ = allocation.width;
888 bar->container_height_ = allocation.height; 892 bar->container_height_ = allocation.height;
889 } 893 }
890 894
891 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); 895 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget));
892 gdk_cairo_rectangle(cr, &e->area); 896 gdk_cairo_rectangle(cr, &e->area);
893 cairo_clip(cr); 897 cairo_clip(cr);
894 898
895 gfx::Point tabstrip_origin = 899 gfx::Point tabstrip_origin =
896 bar->window_->tabstrip()->GetTabStripOriginForWidget(widget); 900 bar->window_->tabstrip()->GetTabStripOriginForWidget(widget);
897 901
898 gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin, 902 gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin,
899 bar->theme_service_); 903 bar->theme_service_);
900 904
901 // During chrome theme mode, we need to draw the border around content_hbox 905 // During chrome theme mode, we need to draw the border around content_hbox
902 // now instead of when we render |border_bin_|. We don't use stacked event 906 // now instead of when we render |border_bin_|. We don't use stacked event
903 // boxes to simulate the effect because we need to blend them with this 907 // boxes to simulate the effect because we need to blend them with this
904 // background. 908 // background.
905 GtkAllocation border_allocation = bar->border_bin_->allocation; 909 GtkAllocation border_allocation;
910 gtk_widget_get_allocation(bar->border_bin_, &border_allocation);
906 911
907 // Blit the left part of the background image once on the left. 912 // Blit the left part of the background image once on the left.
908 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 913 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
909 gfx::CairoCachedSurface* background_left = 914 gfx::CairoCachedSurface* background_left =
910 rb.GetRTLEnabledImageNamed(IDR_FIND_BOX_BACKGROUND_LEFT).ToCairo(); 915 rb.GetRTLEnabledImageNamed(IDR_FIND_BOX_BACKGROUND_LEFT).ToCairo();
911 background_left->SetSource(cr, widget, 916 background_left->SetSource(cr, widget,
912 border_allocation.x, border_allocation.y); 917 border_allocation.x, border_allocation.y);
913 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); 918 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
914 cairo_rectangle(cr, border_allocation.x, border_allocation.y, 919 cairo_rectangle(cr, border_allocation.x, border_allocation.y,
915 background_left->Width(), background_left->Height()); 920 background_left->Width(), background_left->Height());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 return FALSE; // Continue propagation. 995 return FALSE; // Continue propagation.
991 } 996 }
992 997
993 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { 998 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) {
994 g_signal_handlers_disconnect_by_func( 999 g_signal_handlers_disconnect_by_func(
995 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), 1000 gdk_keymap_get_for_display(gtk_widget_get_display(entry)),
996 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); 1001 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this);
997 1002
998 return FALSE; // Continue propagation. 1003 return FALSE; // Continue propagation.
999 } 1004 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc ('k') | chrome/browser/ui/gtk/slide_animator_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698