OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/native_dialog_window.h" | 5 #include "chrome/browser/chromeos/native_dialog_window.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // Get focus widget of the dialog. | 218 // Get focus widget of the dialog. |
219 GtkWidget* focus_widget = gtk_window_get_focus(GTK_WINDOW(dialog_)); | 219 GtkWidget* focus_widget = gtk_window_get_focus(GTK_WINDOW(dialog_)); |
220 | 220 |
221 // Create a GtkAlignment as dialog contents container. | 221 // Create a GtkAlignment as dialog contents container. |
222 GtkWidget* contents = gtk_alignment_new(0.5, 0.5, 1.0, 1.0); | 222 GtkWidget* contents = gtk_alignment_new(0.5, 0.5, 1.0, 1.0); |
223 gtk_alignment_set_padding(GTK_ALIGNMENT(contents), | 223 gtk_alignment_set_padding(GTK_ALIGNMENT(contents), |
224 kDialogPadding, kDialogPadding, | 224 kDialogPadding, kDialogPadding, |
225 kDialogPadding, kDialogPadding); | 225 kDialogPadding, kDialogPadding); |
226 | 226 |
227 // Move dialog contents into our container. | 227 // Move dialog contents into our container. |
228 GtkWidget* dialog_contents = GTK_DIALOG(dialog_)->vbox; | 228 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); |
229 g_object_ref(dialog_contents); | 229 g_object_ref(content_area); |
230 gtk_container_remove(GTK_CONTAINER(dialog_), dialog_contents); | 230 gtk_container_remove(GTK_CONTAINER(dialog_), content_area); |
231 gtk_container_add(GTK_CONTAINER(contents), dialog_contents); | 231 gtk_container_add(GTK_CONTAINER(contents), content_area); |
232 g_object_unref(dialog_contents); | 232 g_object_unref(content_area); |
233 gtk_widget_hide(dialog_); | 233 gtk_widget_hide(dialog_); |
234 | 234 |
235 g_object_set_data(G_OBJECT(dialog_), kNativeDialogHost, | 235 g_object_set_data(G_OBJECT(dialog_), kNativeDialogHost, |
236 reinterpret_cast<gpointer>(this)); | 236 reinterpret_cast<gpointer>(this)); |
237 | 237 |
238 gtk_widget_show_all(contents); | 238 gtk_widget_show_all(contents); |
239 | 239 |
240 contents_view_ = new views::NativeViewHost(); | 240 contents_view_ = new views::NativeViewHost(); |
241 // TODO(xiyuan): Find a better way to get proper background. | 241 // TODO(xiyuan): Find a better way to get proper background. |
242 contents_view_->set_background(views::Background::CreateSolidBackground( | 242 contents_view_->set_background(views::Background::CreateSolidBackground( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 return host ? host->GetWidget()->GetNativeWindow() : NULL; | 339 return host ? host->GetWidget()->GetNativeWindow() : NULL; |
340 } | 340 } |
341 | 341 |
342 gfx::Rect GetNativeDialogContentsBounds(gfx::NativeView native_dialog) { | 342 gfx::Rect GetNativeDialogContentsBounds(gfx::NativeView native_dialog) { |
343 NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( | 343 NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( |
344 g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); | 344 g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); |
345 return host ? host->bounds() : gfx::Rect(); | 345 return host ? host->bounds() : gfx::Rect(); |
346 } | 346 } |
347 | 347 |
348 } // namespace chromeos | 348 } // namespace chromeos |
OLD | NEW |