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

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

Issue 11040053: retry 160232 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 2 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/constrained_window_gtk.h" 5 #include "chrome/browser/ui/gtk/constrained_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 GtkWidget* frame = gtk_frame_new(NULL); 50 GtkWidget* frame = gtk_frame_new(NULL);
51 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); 51 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
52 52
53 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 53 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
54 if (delegate->ShouldHaveBorderPadding()) { 54 if (delegate->ShouldHaveBorderPadding()) {
55 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 55 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
56 ui::kContentAreaBorder, ui::kContentAreaBorder, 56 ui::kContentAreaBorder, ui::kContentAreaBorder,
57 ui::kContentAreaBorder, ui::kContentAreaBorder); 57 ui::kContentAreaBorder, ui::kContentAreaBorder);
58 } 58 }
59 59
60 GdkColor background;
61 if (delegate->GetBackgroundColor(&background)) {
62 gtk_widget_modify_base(ebox, GTK_STATE_NORMAL, &background);
63 gtk_widget_modify_fg(ebox, GTK_STATE_NORMAL, &background);
64 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, &background);
65 }
66
67 if (gtk_widget_get_parent(dialog)) 60 if (gtk_widget_get_parent(dialog))
68 gtk_widget_reparent(dialog, alignment); 61 gtk_widget_reparent(dialog, alignment);
69 else 62 else
70 gtk_container_add(GTK_CONTAINER(alignment), dialog); 63 gtk_container_add(GTK_CONTAINER(alignment), dialog);
71 64
72 gtk_container_add(GTK_CONTAINER(frame), alignment); 65 gtk_container_add(GTK_CONTAINER(frame), alignment);
73 gtk_container_add(GTK_CONTAINER(ebox), frame); 66 gtk_container_add(GTK_CONTAINER(ebox), frame);
74 border_.Own(ebox); 67 border_.Own(ebox);
75 68
69 BackgroundColorChanged();
Evan Stade 2012/10/05 09:04:51 the fix was moving this below L67.
70
76 gtk_widget_add_events(widget(), GDK_KEY_PRESS_MASK); 71 gtk_widget_add_events(widget(), GDK_KEY_PRESS_MASK);
77 g_signal_connect(widget(), "key-press-event", G_CALLBACK(OnKeyPressThunk), 72 g_signal_connect(widget(), "key-press-event", G_CALLBACK(OnKeyPressThunk),
78 this); 73 this);
79 g_signal_connect(widget(), "hierarchy-changed", 74 g_signal_connect(widget(), "hierarchy-changed",
80 G_CALLBACK(OnHierarchyChangedThunk), this); 75 G_CALLBACK(OnHierarchyChangedThunk), this);
81 76
82 ConstrainedWindowTabHelper* constrained_window_tab_helper = 77 ConstrainedWindowTabHelper* constrained_window_tab_helper =
83 ConstrainedWindowTabHelper::FromWebContents( 78 ConstrainedWindowTabHelper::FromWebContents(
84 tab_contents_->web_contents()); 79 tab_contents_->web_contents());
85 constrained_window_tab_helper->AddConstrainedDialog(this); 80 constrained_window_tab_helper->AddConstrainedDialog(this);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 tab_contents_->web_contents()); 118 tab_contents_->web_contents());
124 if ((!helper->delegate() || 119 if ((!helper->delegate() ||
125 helper->delegate()->ShouldFocusConstrainedWindow()) && 120 helper->delegate()->ShouldFocusConstrainedWindow()) &&
126 gtk_util::IsWidgetAncestryVisible(focus_widget)) { 121 gtk_util::IsWidgetAncestryVisible(focus_widget)) {
127 gtk_widget_grab_focus(focus_widget); 122 gtk_widget_grab_focus(focus_widget);
128 } else { 123 } else {
129 ContainingView()->focus_store()->SetWidget(focus_widget); 124 ContainingView()->focus_store()->SetWidget(focus_widget);
130 } 125 }
131 } 126 }
132 127
128 void ConstrainedWindowGtk::BackgroundColorChanged() {
129 GdkColor background;
130 if (delegate_->GetBackgroundColor(&background)) {
131 gtk_widget_modify_base(border_.get(), GTK_STATE_NORMAL, &background);
132 gtk_widget_modify_fg(border_.get(), GTK_STATE_NORMAL, &background);
133 gtk_widget_modify_bg(border_.get(), GTK_STATE_NORMAL, &background);
134 }
135 }
136
133 ConstrainedWindowGtk::TabContentsViewType* 137 ConstrainedWindowGtk::TabContentsViewType*
134 ConstrainedWindowGtk::ContainingView() { 138 ConstrainedWindowGtk::ContainingView() {
135 return 139 return
136 ChromeWebContentsViewDelegateGtk::GetFor(tab_contents_->web_contents()); 140 ChromeWebContentsViewDelegateGtk::GetFor(tab_contents_->web_contents());
137 } 141 }
138 142
139 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, 143 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender,
140 GdkEventKey* key) { 144 GdkEventKey* key) {
141 if (key->keyval == GDK_Escape) { 145 if (key->keyval == GDK_Escape) {
142 // Let the stack unwind so the event handler can release its ref 146 // Let the stack unwind so the event handler can release its ref
143 // on widget(). 147 // on widget().
144 MessageLoop::current()->PostTask( 148 MessageLoop::current()->PostTask(
145 FROM_HERE, 149 FROM_HERE,
146 base::Bind(&ConstrainedWindowGtk::CloseConstrainedWindow, 150 base::Bind(&ConstrainedWindowGtk::CloseConstrainedWindow,
147 weak_factory_.GetWeakPtr())); 151 weak_factory_.GetWeakPtr()));
148 return TRUE; 152 return TRUE;
149 } 153 }
150 154
151 return FALSE; 155 return FALSE;
152 } 156 }
153 157
154 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender, 158 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender,
155 GtkWidget* previous_toplevel) { 159 GtkWidget* previous_toplevel) {
156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
157 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget()))) 161 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget())))
158 return; 162 return;
159 163
160 FocusConstrainedWindow(); 164 FocusConstrainedWindow();
161 } 165 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/constrained_window_gtk.h ('k') | chrome/browser/ui/gtk/web_intent_picker_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698