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

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

Issue 6307019: Cleanup: remove unused internet and system pages for chrome os options. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove settings_page_view as well Created 9 years, 10 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) 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/ui/gtk/gtk_util.h" 5 #include "chrome/browser/ui/gtk/gtk_util.h"
6 6
7 #include <cairo/cairo.h> 7 #include <cairo/cairo.h>
8 #include <gdk/gdkx.h> 8 #include <gdk/gdkx.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include <cstdarg> 11 #include <cstdarg>
12 #include <map> 12 #include <map>
13 13
14 #include "base/environment.h" 14 #include "base/environment.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/linux_util.h" 16 #include "base/linux_util.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/nix/xdg_util.h" 18 #include "base/nix/xdg_util.h"
19 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "chrome/browser/autocomplete/autocomplete.h" 21 #include "chrome/browser/autocomplete/autocomplete.h"
22 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 22 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
23 #include "chrome/browser/autocomplete/autocomplete_match.h" 23 #include "chrome/browser/autocomplete/autocomplete_match.h"
24 #include "chrome/browser/browser_list.h" 24 #include "chrome/browser/browser_list.h"
25 #include "chrome/browser/browser_window.h" 25 #include "chrome/browser/browser_window.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/renderer_host/render_view_host.h" 27 #include "chrome/browser/renderer_host/render_view_host.h"
28 #include "chrome/browser/tab_contents/tab_contents.h" 28 #include "chrome/browser/tab_contents/tab_contents.h"
29 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
satorux1 2011/02/02 03:29:49 Do we need to add this? Otherwise, please remove i
falken 2011/02/02 04:59:34 Yes, it's still needed. I just moved it from the
29 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" 30 #include "chrome/browser/ui/gtk/cairo_cached_surface.h"
30 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" 31 #include "chrome/browser/ui/gtk/gtk_theme_provider.h"
31 #include "chrome/common/renderer_preferences.h" 32 #include "chrome/common/renderer_preferences.h"
32 #include "gfx/gtk_util.h" 33 #include "gfx/gtk_util.h"
33 #include "googleurl/src/gurl.h" 34 #include "googleurl/src/gurl.h"
34 #include "grit/theme_resources.h" 35 #include "grit/theme_resources.h"
35 #include "third_party/skia/include/core/SkBitmap.h" 36 #include "third_party/skia/include/core/SkBitmap.h"
36 #include "third_party/skia/include/core/SkColor.h" 37 #include "third_party/skia/include/core/SkColor.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/base/x/x11_util.h" 40 #include "ui/base/x/x11_util.h"
40 41
41 #if defined(OS_CHROMEOS)
42 #include "chrome/browser/chromeos/frame/browser_view.h"
43 #include "chrome/browser/chromeos/native_dialog_window.h"
44 #include "chrome/browser/chromeos/options/options_window_view.h"
45 #include "views/window/window.h"
46 #else
47 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
48 #endif
49
50 using WebKit::WebDragOperationsMask; 42 using WebKit::WebDragOperationsMask;
51 using WebKit::WebDragOperation; 43 using WebKit::WebDragOperation;
52 using WebKit::WebDragOperationNone; 44 using WebKit::WebDragOperationNone;
53 using WebKit::WebDragOperationCopy; 45 using WebKit::WebDragOperationCopy;
54 using WebKit::WebDragOperationLink; 46 using WebKit::WebDragOperationLink;
55 using WebKit::WebDragOperationMove; 47 using WebKit::WebDragOperationMove;
56 48
57 namespace { 49 namespace {
58 50
59 const char kBoldLabelMarkup[] = "<span weight='bold'>%s</span>"; 51 const char kBoldLabelMarkup[] = "<span weight='bold'>%s</span>";
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 for (GList* item = children; item; item = item->next) { 128 for (GList* item = children; item; item = item->next) {
137 gtk_container_propagate_expose(GTK_CONTAINER(widget), 129 gtk_container_propagate_expose(GTK_CONTAINER(widget),
138 GTK_WIDGET(item->data), 130 GTK_WIDGET(item->data),
139 event); 131 event);
140 } 132 }
141 g_list_free(children); 133 g_list_free(children);
142 134
143 return TRUE; 135 return TRUE;
144 } 136 }
145 137
146 #if defined(OS_CHROMEOS)
147
148 TabContents* GetBrowserWindowSelectedTabContents(BrowserWindow* window) {
149 chromeos::BrowserView* browser_view = static_cast<chromeos::BrowserView*>(
150 window);
151 return browser_view->GetSelectedTabContents();
152 }
153
154 GtkWidget* GetBrowserWindowFocusedWidget(BrowserWindow* window) {
155 gfx::NativeView widget = gtk_window_get_focus(window->GetNativeHandle());
156
157 if (widget == NULL) {
158 chromeos::BrowserView* browser_view = static_cast<chromeos::BrowserView*>(
159 window);
160 widget = browser_view->saved_focused_widget();
161 }
162
163 return widget;
164 }
165
166 #else
167
168 TabContents* GetBrowserWindowSelectedTabContents(BrowserWindow* window) { 138 TabContents* GetBrowserWindowSelectedTabContents(BrowserWindow* window) {
169 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( 139 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>(
170 window); 140 window);
171 return browser_window->browser()->GetSelectedTabContents(); 141 return browser_window->browser()->GetSelectedTabContents();
172 } 142 }
173 143
174 GtkWidget* GetBrowserWindowFocusedWidget(BrowserWindow* window) { 144 GtkWidget* GetBrowserWindowFocusedWidget(BrowserWindow* window) {
175 return gtk_window_get_focus(window->GetNativeHandle()); 145 return gtk_window_get_focus(window->GetNativeHandle());
176 } 146 }
177 147
178 #endif
179
180 } // namespace 148 } // namespace
181 149
182 namespace event_utils { 150 namespace event_utils {
183 151
184 WindowOpenDisposition DispositionFromEventFlags(guint event_flags) { 152 WindowOpenDisposition DispositionFromEventFlags(guint event_flags) {
185 if ((event_flags & GDK_BUTTON2_MASK) || (event_flags & GDK_CONTROL_MASK)) { 153 if ((event_flags & GDK_BUTTON2_MASK) || (event_flags & GDK_CONTROL_MASK)) {
186 return (event_flags & GDK_SHIFT_MASK) ? 154 return (event_flags & GDK_SHIFT_MASK) ?
187 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; 155 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
188 } 156 }
189 157
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 *selected_base = style->base[GTK_STATE_SELECTED]; 965 *selected_base = style->base[GTK_STATE_SELECTED];
998 if (normal_text) 966 if (normal_text)
999 *normal_text = style->text[GTK_STATE_NORMAL]; 967 *normal_text = style->text[GTK_STATE_NORMAL];
1000 if (selected_text) 968 if (selected_text)
1001 *selected_text = style->text[GTK_STATE_SELECTED]; 969 *selected_text = style->text[GTK_STATE_SELECTED];
1002 970
1003 g_object_ref_sink(fake_entry); 971 g_object_ref_sink(fake_entry);
1004 g_object_unref(fake_entry); 972 g_object_unref(fake_entry);
1005 } 973 }
1006 974
1007 #if defined(OS_CHROMEOS)
1008
1009 GtkWindow* GetDialogTransientParent(GtkWindow* dialog) {
1010 GtkWindow* parent = gtk_window_get_transient_for(dialog);
1011 if (!parent)
1012 parent = chromeos::GetOptionsViewParent();
1013
1014 return parent;
1015 }
1016
1017 void ShowDialog(GtkWidget* dialog) {
1018 // Make sure all controls are visible so that we get correct size.
1019 gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
1020
1021 // Get dialog window size.
1022 gint width = 0;
1023 gint height = 0;
1024 gtk_window_get_size(GTK_WINDOW(dialog), &width, &height);
1025
1026 chromeos::ShowNativeDialog(GetDialogTransientParent(GTK_WINDOW(dialog)),
1027 dialog,
1028 gtk_window_get_resizable(GTK_WINDOW(dialog)) ?
1029 chromeos::DIALOG_FLAG_RESIZEABLE :
1030 chromeos::DIALOG_FLAG_DEFAULT,
1031 gfx::Size(width, height),
1032 gfx::Size());
1033 }
1034
1035 void ShowDialogWithLocalizedSize(GtkWidget* dialog,
1036 int width_id,
1037 int height_id,
1038 bool resizeable) {
1039 int width = (width_id == -1) ? 0 :
1040 views::Window::GetLocalizedContentsWidth(width_id);
1041 int height = (height_id == -1) ? 0 :
1042 views::Window::GetLocalizedContentsHeight(height_id);
1043
1044 chromeos::ShowNativeDialog(GetDialogTransientParent(GTK_WINDOW(dialog)),
1045 dialog,
1046 resizeable ? chromeos::DIALOG_FLAG_RESIZEABLE :
1047 chromeos::DIALOG_FLAG_DEFAULT,
1048 gfx::Size(width, height),
1049 gfx::Size());
1050 }
1051
1052 void ShowModalDialogWithMinLocalizedWidth(GtkWidget* dialog,
1053 int width_id) {
1054 int width = (width_id == -1) ? 0 :
1055 views::Window::GetLocalizedContentsWidth(width_id);
1056
1057 chromeos::ShowNativeDialog(GetDialogTransientParent(GTK_WINDOW(dialog)),
1058 dialog,
1059 chromeos::DIALOG_FLAG_MODAL,
1060 gfx::Size(),
1061 gfx::Size(width, 0));
1062 }
1063
1064 void PresentWindow(GtkWidget* window, int timestamp) {
1065 GtkWindow* host_window = chromeos::GetNativeDialogWindow(window);
1066 if (!host_window)
1067 host_window = GTK_WINDOW(window);
1068 if (timestamp)
1069 gtk_window_present_with_time(host_window, timestamp);
1070 else
1071 gtk_window_present(host_window);
1072 }
1073
1074 GtkWindow* GetDialogWindow(GtkWidget* dialog) {
1075 return chromeos::GetNativeDialogWindow(dialog);
1076 }
1077
1078 gfx::Rect GetDialogBounds(GtkWidget* dialog) {
1079 return chromeos::GetNativeDialogContentsBounds(dialog);
1080 }
1081
1082 #else
1083
1084 void ShowDialog(GtkWidget* dialog) { 975 void ShowDialog(GtkWidget* dialog) {
1085 gtk_widget_show_all(dialog); 976 gtk_widget_show_all(dialog);
1086 } 977 }
1087 978
1088 void ShowDialogWithLocalizedSize(GtkWidget* dialog, 979 void ShowDialogWithLocalizedSize(GtkWidget* dialog,
1089 int width_id, 980 int width_id,
1090 int height_id, 981 int height_id,
1091 bool resizeable) { 982 bool resizeable) {
1092 gtk_widget_realize(dialog); 983 gtk_widget_realize(dialog);
1093 SetWindowSizeFromResources(GTK_WINDOW(dialog), 984 SetWindowSizeFromResources(GTK_WINDOW(dialog),
(...skipping 28 matching lines...) Expand all
1122 } 1013 }
1123 1014
1124 gfx::Rect GetDialogBounds(GtkWidget* dialog) { 1015 gfx::Rect GetDialogBounds(GtkWidget* dialog) {
1125 gint x = 0, y = 0, width = 1, height = 1; 1016 gint x = 0, y = 0, width = 1, height = 1;
1126 gtk_window_get_position(GTK_WINDOW(dialog), &x, &y); 1017 gtk_window_get_position(GTK_WINDOW(dialog), &x, &y);
1127 gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); 1018 gtk_window_get_size(GTK_WINDOW(dialog), &width, &height);
1128 1019
1129 return gfx::Rect(x, y, width, height); 1020 return gfx::Rect(x, y, width, height);
1130 } 1021 }
1131 1022
1132 #endif
1133
1134 string16 GetStockPreferencesMenuLabel() { 1023 string16 GetStockPreferencesMenuLabel() {
1135 GtkStockItem stock_item; 1024 GtkStockItem stock_item;
1136 string16 preferences; 1025 string16 preferences;
1137 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) { 1026 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) {
1138 const char16 kUnderscore[] = { '_', 0 }; 1027 const char16 kUnderscore[] = { '_', 0 };
1139 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences); 1028 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences);
1140 } 1029 }
1141 return preferences; 1030 return preferences;
1142 } 1031 }
1143 1032
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1130
1242 void DoCopy(BrowserWindow* window) { 1131 void DoCopy(BrowserWindow* window) {
1243 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); 1132 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard");
1244 } 1133 }
1245 1134
1246 void DoPaste(BrowserWindow* window) { 1135 void DoPaste(BrowserWindow* window) {
1247 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); 1136 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard");
1248 } 1137 }
1249 1138
1250 } // namespace gtk_util 1139 } // namespace gtk_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698