OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/gtk_util.h" | 5 #include "chrome/browser/gtk/gtk_util.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 | 9 |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 GdkScreen* screen = gtk_widget_get_screen(window); | 918 GdkScreen* screen = gtk_widget_get_screen(window); |
919 GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen); | 919 GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen); |
920 if (rgba) | 920 if (rgba) |
921 gtk_widget_set_colormap(window, rgba); | 921 gtk_widget_set_colormap(window, rgba); |
922 | 922 |
923 return rgba; | 923 return rgba; |
924 } | 924 } |
925 | 925 |
926 #if defined(OS_CHROMEOS) | 926 #if defined(OS_CHROMEOS) |
927 | 927 |
| 928 GtkWindow* GetDialogTransientParent(GtkWindow* dialog) { |
| 929 GtkWindow* parent = gtk_window_get_transient_for(dialog); |
| 930 if (!parent) |
| 931 parent = chromeos::GetOptionsViewParent(); |
| 932 |
| 933 return parent; |
| 934 } |
| 935 |
928 void ShowDialog(GtkWidget* dialog) { | 936 void ShowDialog(GtkWidget* dialog) { |
929 chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(), | 937 chromeos::ShowNativeDialog(GetDialogTransientParent(GTK_WINDOW(dialog)), |
930 dialog, chromeos::DIALOG_FLAG_DEFAULT, gfx::Size(), gfx::Size()); | 938 dialog, chromeos::DIALOG_FLAG_DEFAULT, gfx::Size(), gfx::Size()); |
931 } | 939 } |
932 | 940 |
933 void ShowDialogWithLocalizedSize(GtkWidget* dialog, | 941 void ShowDialogWithLocalizedSize(GtkWidget* dialog, |
934 int width_id, | 942 int width_id, |
935 int height_id, | 943 int height_id, |
936 bool resizeable) { | 944 bool resizeable) { |
937 int width = (width_id == -1) ? 0 : | 945 int width = (width_id == -1) ? 0 : |
938 views::Window::GetLocalizedContentsWidth(width_id); | 946 views::Window::GetLocalizedContentsWidth(width_id); |
939 int height = (height_id == -1) ? 0 : | 947 int height = (height_id == -1) ? 0 : |
940 views::Window::GetLocalizedContentsHeight(height_id); | 948 views::Window::GetLocalizedContentsHeight(height_id); |
941 | 949 |
942 chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(), | 950 chromeos::ShowNativeDialog(GetDialogTransientParent(GTK_WINDOW(dialog)), |
943 dialog, | 951 dialog, |
944 resizeable ? chromeos::DIALOG_FLAG_RESIZEABLE : | 952 resizeable ? chromeos::DIALOG_FLAG_RESIZEABLE : |
945 chromeos::DIALOG_FLAG_DEFAULT, | 953 chromeos::DIALOG_FLAG_DEFAULT, |
946 gfx::Size(width, height), | 954 gfx::Size(width, height), |
947 gfx::Size()); | 955 gfx::Size()); |
948 } | 956 } |
949 | 957 |
950 void ShowModalDialogWithMinLocalizedWidth(GtkWidget* dialog, | 958 void ShowModalDialogWithMinLocalizedWidth(GtkWidget* dialog, |
951 int width_id) { | 959 int width_id) { |
952 int width = (width_id == -1) ? 0 : | 960 int width = (width_id == -1) ? 0 : |
953 views::Window::GetLocalizedContentsWidth(width_id); | 961 views::Window::GetLocalizedContentsWidth(width_id); |
954 | 962 |
955 chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(), | 963 chromeos::ShowNativeDialog(GetDialogTransientParent(GTK_WINDOW(dialog)), |
956 dialog, | 964 dialog, |
957 chromeos::DIALOG_FLAG_MODAL, | 965 chromeos::DIALOG_FLAG_MODAL, |
958 gfx::Size(), | 966 gfx::Size(), |
959 gfx::Size(width, 0)); | 967 gfx::Size(width, 0)); |
960 } | 968 } |
961 | 969 |
962 void PresentWindow(GtkWidget* window, int timestamp) { | 970 void PresentWindow(GtkWidget* window, int timestamp) { |
963 GtkWindow* host_window = chromeos::GetNativeDialogWindow(window); | 971 GtkWindow* host_window = chromeos::GetNativeDialogWindow(window); |
964 if (!host_window) | 972 if (!host_window) |
965 host_window = GTK_WINDOW(window); | 973 host_window = GTK_WINDOW(window); |
966 if (timestamp) | 974 if (timestamp) |
967 gtk_window_present_with_time(host_window, timestamp); | 975 gtk_window_present_with_time(host_window, timestamp); |
968 else | 976 else |
969 gtk_window_present(host_window); | 977 gtk_window_present(host_window); |
970 } | 978 } |
971 | 979 |
| 980 GtkWindow* GetDialogWindow(GtkWidget* dialog) { |
| 981 return chromeos::GetNativeDialogWindow(dialog); |
| 982 } |
| 983 |
972 #else | 984 #else |
973 | 985 |
974 void ShowDialog(GtkWidget* dialog) { | 986 void ShowDialog(GtkWidget* dialog) { |
975 gtk_widget_show_all(dialog); | 987 gtk_widget_show_all(dialog); |
976 } | 988 } |
977 | 989 |
978 void ShowDialogWithLocalizedSize(GtkWidget* dialog, | 990 void ShowDialogWithLocalizedSize(GtkWidget* dialog, |
979 int width_id, | 991 int width_id, |
980 int height_id, | 992 int height_id, |
981 bool resizeable) { | 993 bool resizeable) { |
(...skipping 18 matching lines...) Expand all Loading... |
1000 gtk_widget_set_size_request(dialog, width, -1); | 1012 gtk_widget_set_size_request(dialog, width, -1); |
1001 } | 1013 } |
1002 | 1014 |
1003 void PresentWindow(GtkWidget* window, int timestamp) { | 1015 void PresentWindow(GtkWidget* window, int timestamp) { |
1004 if (timestamp) | 1016 if (timestamp) |
1005 gtk_window_present_with_time(GTK_WINDOW(window), timestamp); | 1017 gtk_window_present_with_time(GTK_WINDOW(window), timestamp); |
1006 else | 1018 else |
1007 gtk_window_present(GTK_WINDOW(window)); | 1019 gtk_window_present(GTK_WINDOW(window)); |
1008 } | 1020 } |
1009 | 1021 |
| 1022 GtkWindow* GetDialogWindow(GtkWidget* dialog) { |
| 1023 return dialog; |
| 1024 } |
| 1025 |
1010 #endif | 1026 #endif |
1011 | 1027 |
1012 } // namespace gtk_util | 1028 } // namespace gtk_util |
OLD | NEW |