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

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: sync changes 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();
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(web_contents_); 78 ConstrainedWindowTabHelper::FromWebContents(web_contents_);
84 constrained_window_tab_helper->AddConstrainedDialog(this); 79 constrained_window_tab_helper->AddConstrainedDialog(this);
85 } 80 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 115 ConstrainedWindowTabHelper::FromWebContents(web_contents_);
121 if ((!helper->delegate() || 116 if ((!helper->delegate() ||
122 helper->delegate()->ShouldFocusConstrainedWindow()) && 117 helper->delegate()->ShouldFocusConstrainedWindow()) &&
123 gtk_util::IsWidgetAncestryVisible(focus_widget)) { 118 gtk_util::IsWidgetAncestryVisible(focus_widget)) {
124 gtk_widget_grab_focus(focus_widget); 119 gtk_widget_grab_focus(focus_widget);
125 } else { 120 } else {
126 ContainingView()->focus_store()->SetWidget(focus_widget); 121 ContainingView()->focus_store()->SetWidget(focus_widget);
127 } 122 }
128 } 123 }
129 124
125 void ConstrainedWindowGtk::BackgroundColorChanged() {
126 GdkColor background;
127 if (delegate_->GetBackgroundColor(&background)) {
128 gtk_widget_modify_base(border_.get(), GTK_STATE_NORMAL, &background);
129 gtk_widget_modify_fg(border_.get(), GTK_STATE_NORMAL, &background);
130 gtk_widget_modify_bg(border_.get(), GTK_STATE_NORMAL, &background);
131 }
132 }
133
130 ConstrainedWindowGtk::TabContentsViewType* 134 ConstrainedWindowGtk::TabContentsViewType*
131 ConstrainedWindowGtk::ContainingView() { 135 ConstrainedWindowGtk::ContainingView() {
132 return ChromeWebContentsViewDelegateGtk::GetFor(web_contents_); 136 return ChromeWebContentsViewDelegateGtk::GetFor(web_contents_);
133 } 137 }
134 138
135 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, 139 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender,
136 GdkEventKey* key) { 140 GdkEventKey* key) {
137 if (key->keyval == GDK_Escape) { 141 if (key->keyval == GDK_Escape) {
138 // Let the stack unwind so the event handler can release its ref 142 // Let the stack unwind so the event handler can release its ref
139 // on widget(). 143 // on widget().
140 MessageLoop::current()->PostTask( 144 MessageLoop::current()->PostTask(
141 FROM_HERE, 145 FROM_HERE,
142 base::Bind(&ConstrainedWindowGtk::CloseConstrainedWindow, 146 base::Bind(&ConstrainedWindowGtk::CloseConstrainedWindow,
143 weak_factory_.GetWeakPtr())); 147 weak_factory_.GetWeakPtr()));
144 return TRUE; 148 return TRUE;
145 } 149 }
146 150
147 return FALSE; 151 return FALSE;
148 } 152 }
149 153
150 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender, 154 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender,
151 GtkWidget* previous_toplevel) { 155 GtkWidget* previous_toplevel) {
152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
153 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget()))) 157 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget())))
154 return; 158 return;
155 159
156 FocusConstrainedWindow(); 160 FocusConstrainedWindow();
157 } 161 }
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