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/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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } else { | 329 } else { |
330 // For a non-resizable window, GTK tries to snap the window size | 330 // For a non-resizable window, GTK tries to snap the window size |
331 // to the minimum size around the content. We use the sizes in | 331 // to the minimum size around the content. We use the sizes in |
332 // the resources to set *minimum* window size to allow windows | 332 // the resources to set *minimum* window size to allow windows |
333 // with long titles to be wide enough to display their titles. | 333 // with long titles to be wide enough to display their titles. |
334 // | 334 // |
335 // But if GTK wants to make the window *wider* due to very wide | 335 // But if GTK wants to make the window *wider* due to very wide |
336 // controls, we should allow that too, so be careful to pick the | 336 // controls, we should allow that too, so be careful to pick the |
337 // wider of the resources size and the natural window size. | 337 // wider of the resources size and the natural window size. |
338 | 338 |
339 gtk_widget_show_all(GTK_BIN(window)->child); | 339 gtk_widget_show_all(gtk_bin_get_child(GTK_BIN(window))); |
340 GtkRequisition requisition; | 340 GtkRequisition requisition; |
341 gtk_widget_size_request(GTK_WIDGET(window), &requisition); | 341 gtk_widget_size_request(GTK_WIDGET(window), &requisition); |
342 gtk_widget_set_size_request( | 342 gtk_widget_set_size_request( |
343 GTK_WIDGET(window), | 343 GTK_WIDGET(window), |
344 width == -1 ? -1 : std::max(width, requisition.width), | 344 width == -1 ? -1 : std::max(width, requisition.width), |
345 height == -1 ? -1 : std::max(height, requisition.height)); | 345 height == -1 ? -1 : std::max(height, requisition.height)); |
346 } | 346 } |
347 gtk_window_set_resizable(window, resizable ? TRUE : FALSE); | 347 gtk_window_set_resizable(window, resizable ? TRUE : FALSE); |
348 } | 348 } |
349 | 349 |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) { | 1109 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) { |
1110 const char16 kUnderscore[] = { '_', 0 }; | 1110 const char16 kUnderscore[] = { '_', 0 }; |
1111 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences); | 1111 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences); |
1112 } | 1112 } |
1113 return preferences; | 1113 return preferences; |
1114 } | 1114 } |
1115 | 1115 |
1116 bool IsWidgetAncestryVisible(GtkWidget* widget) { | 1116 bool IsWidgetAncestryVisible(GtkWidget* widget) { |
1117 GtkWidget* parent = widget; | 1117 GtkWidget* parent = widget; |
1118 while (parent && gtk_widget_get_visible(parent)) | 1118 while (parent && gtk_widget_get_visible(parent)) |
1119 parent = parent->parent; | 1119 parent = gtk_widget_get_parent(parent); |
1120 return !parent; | 1120 return !parent; |
1121 } | 1121 } |
1122 | 1122 |
1123 void SetLabelWidth(GtkWidget* label, int pixel_width) { | 1123 void SetLabelWidth(GtkWidget* label, int pixel_width) { |
1124 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 1124 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
1125 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 1125 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
1126 | 1126 |
1127 // Do the simple thing in LTR because the bug only affects right-aligned | 1127 // Do the simple thing in LTR because the bug only affects right-aligned |
1128 // text. Also, when using the workaround, the label tries to maintain | 1128 // text. Also, when using the workaround, the label tries to maintain |
1129 // uniform line-length, which we don't really want. | 1129 // uniform line-length, which we don't really want. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1187 |
1188 void DoCopy(BrowserWindow* window) { | 1188 void DoCopy(BrowserWindow* window) { |
1189 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); | 1189 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); |
1190 } | 1190 } |
1191 | 1191 |
1192 void DoPaste(BrowserWindow* window) { | 1192 void DoPaste(BrowserWindow* window) { |
1193 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); | 1193 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); |
1194 } | 1194 } |
1195 | 1195 |
1196 } // namespace gtk_util | 1196 } // namespace gtk_util |
OLD | NEW |