OLD | NEW |
---|---|
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/web_intent_picker_gtk.h" | 5 #include "chrome/browser/ui/gtk/web_intent_picker_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 delegate_->OnInlineDispositionWebContentsCreated(web_contents); | 235 delegate_->OnInlineDispositionWebContentsCreated(web_contents); |
236 | 236 |
237 tab_contents_container_.reset(new TabContentsContainerGtk(NULL)); | 237 tab_contents_container_.reset(new TabContentsContainerGtk(NULL)); |
238 tab_contents_container_->SetTab(inline_disposition_tab_contents_.get()); | 238 tab_contents_container_->SetTab(inline_disposition_tab_contents_.get()); |
239 | 239 |
240 inline_disposition_tab_contents_->web_contents()->GetController().LoadURL( | 240 inline_disposition_tab_contents_->web_contents()->GetController().LoadURL( |
241 url, content::Referrer(), content::PAGE_TRANSITION_START_PAGE, | 241 url, content::Referrer(), content::PAGE_TRANSITION_START_PAGE, |
242 std::string()); | 242 std::string()); |
243 | 243 |
244 // Replace the picker contents with the inline disposition. | 244 // Replace the picker contents with the inline disposition. |
245 | |
246 gtk_util::RemoveAllChildren(contents_); | 245 gtk_util::RemoveAllChildren(contents_); |
Evan Stade
2012/05/18 21:16:07
try removing all children from sub_contents instea
| |
247 | 246 |
248 GtkWidget* service_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); | 247 GtkWidget* service_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); |
249 // TODO(gbillock): Eventually get the service icon button here. | 248 // TODO(gbillock): Eventually get the service icon button here. |
250 // Maybe add a title or something too? | 249 // Maybe add a title or something too? |
251 close_button_.reset( | 250 close_button_.reset( |
252 CustomDrawButton::CloseButton(GetThemeService(wrapper_))); | 251 CustomDrawButton::CloseButton(GetThemeService(wrapper_))); |
253 g_signal_connect(close_button_->widget(), | 252 g_signal_connect(close_button_->widget(), |
254 "clicked", | 253 "clicked", |
255 G_CALLBACK(OnCloseButtonClickThunk), | 254 G_CALLBACK(OnCloseButtonClickThunk), |
256 this); | 255 this); |
257 gtk_widget_set_can_focus(close_button_->widget(), FALSE); | 256 gtk_widget_set_can_focus(close_button_->widget(), FALSE); |
258 GtkWidget* close_vbox = gtk_vbox_new(FALSE, 0); | 257 GtkWidget* close_vbox = gtk_vbox_new(FALSE, 0); |
259 gtk_box_pack_start(GTK_BOX(close_vbox), close_button_->widget(), | 258 gtk_box_pack_start(GTK_BOX(close_vbox), close_button_->widget(), |
260 FALSE, FALSE, 0); | 259 FALSE, FALSE, 0); |
261 gtk_box_pack_end(GTK_BOX(service_hbox), close_vbox, FALSE, FALSE, 0); | 260 gtk_box_pack_end(GTK_BOX(service_hbox), close_vbox, FALSE, FALSE, 0); |
262 | 261 |
263 GtkWidget* vbox = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); | 262 GtkWidget* vbox = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
264 gtk_box_pack_start(GTK_BOX(vbox), service_hbox, TRUE, TRUE, 0); | 263 gtk_box_pack_start(GTK_BOX(vbox), service_hbox, TRUE, TRUE, 0); |
265 | 264 |
266 // The separator between the icon/title/close and the inline renderer. | 265 // The separator between the icon/title/close and the inline renderer. |
267 gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, TRUE, 0); | 266 gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, TRUE, 0); |
268 | 267 |
269 gtk_box_pack_end(GTK_BOX(vbox), tab_contents_container_->widget(), | 268 // hbox for the web contents, so we can have spacing on the borders. |
270 TRUE, TRUE, 0); | 269 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
271 | 270 gtk_alignment_set_padding( |
271 GTK_ALIGNMENT(alignment), 0, ui::kContentAreaBorder, | |
272 ui::kContentAreaBorder, ui::kContentAreaBorder); | |
273 gtk_container_add(GTK_CONTAINER(alignment), | |
274 tab_contents_container_->widget()); | |
275 gtk_box_pack_end(GTK_BOX(vbox), alignment, TRUE, TRUE, 0); | |
272 gtk_container_add(GTK_CONTAINER(contents_), vbox); | 276 gtk_container_add(GTK_CONTAINER(contents_), vbox); |
273 | 277 |
274 gfx::Size size = GetDefaultInlineDispositionSize(web_contents); | 278 gfx::Size size = GetMinInlineDispositionSize(); |
275 gtk_widget_set_size_request(tab_contents_container_->widget(), | 279 gtk_widget_set_size_request(tab_contents_container_->widget(), |
276 size.width(), size.height()); | 280 size.width(), size.height()); |
277 gtk_widget_show_all(contents_); | 281 gtk_widget_show_all(contents_); |
278 } | 282 } |
279 | 283 |
284 void WebIntentPickerGtk::OnInlineDispositionAutoResize(const gfx::Size& size) { | |
285 gtk_widget_set_size_request(tab_contents_container_->widget(), | |
286 size.width(), size.height()); | |
287 } | |
288 | |
280 GtkWidget* WebIntentPickerGtk::GetWidgetRoot() { | 289 GtkWidget* WebIntentPickerGtk::GetWidgetRoot() { |
281 return contents_; | 290 return contents_; |
282 } | 291 } |
283 | 292 |
284 GtkWidget* WebIntentPickerGtk::GetFocusWidget() { | 293 GtkWidget* WebIntentPickerGtk::GetFocusWidget() { |
285 return contents_; | 294 return contents_; |
286 } | 295 } |
287 | 296 |
288 void WebIntentPickerGtk::DeleteDelegate() { | 297 void WebIntentPickerGtk::DeleteDelegate() { |
289 // The delegate is deleted when the contents widget is destroyed. See | 298 // The delegate is deleted when the contents widget is destroyed. See |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 return alignment; | 608 return alignment; |
600 } | 609 } |
601 | 610 |
602 void WebIntentPickerGtk::RemoveThrobber() { | 611 void WebIntentPickerGtk::RemoveThrobber() { |
603 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget()); | 612 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget()); |
604 DCHECK(alignment); | 613 DCHECK(alignment); |
605 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget()); | 614 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget()); |
606 gtk_widget_destroy(alignment); | 615 gtk_widget_destroy(alignment); |
607 throbber_->Stop(); | 616 throbber_->Stop(); |
608 } | 617 } |
OLD | NEW |