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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0); | 442 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0); |
443 gtk_box_pack_start(GTK_BOX(centering_vbox), widget, TRUE, FALSE, 0); | 443 gtk_box_pack_start(GTK_BOX(centering_vbox), widget, TRUE, FALSE, 0); |
444 if (pack_at_end) | 444 if (pack_at_end) |
445 gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); | 445 gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); |
446 else | 446 else |
447 gtk_box_pack_start(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); | 447 gtk_box_pack_start(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); |
448 | 448 |
449 return centering_vbox; | 449 return centering_vbox; |
450 } | 450 } |
451 | 451 |
452 std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) { | 452 namespace { |
| 453 |
| 454 // Common implementation of ConvertAcceleratorsFromWindowsStyle() and |
| 455 // RemoveWindowsStyleAccelerators(). |
| 456 std::string ConvertAmperstandsTo(const std::string& label, |
| 457 const std::string& target) { |
453 std::string ret; | 458 std::string ret; |
454 ret.reserve(label.length() * 2); | 459 ret.reserve(label.length() * 2); |
455 for (size_t i = 0; i < label.length(); ++i) { | 460 for (size_t i = 0; i < label.length(); ++i) { |
456 if ('_' == label[i]) { | 461 if ('_' == label[i]) { |
457 ret.push_back('_'); | 462 ret.push_back('_'); |
458 ret.push_back('_'); | 463 ret.push_back('_'); |
459 } else if ('&' == label[i]) { | 464 } else if ('&' == label[i]) { |
460 if (i + 1 < label.length() && '&' == label[i + 1]) { | 465 if (i + 1 < label.length() && '&' == label[i + 1]) { |
461 ret.push_back(label[i]); | 466 ret.push_back(label[i]); |
462 ++i; | 467 ++i; |
463 } else { | 468 } else { |
464 ret.push_back('_'); | 469 ret.append(target); |
465 } | 470 } |
466 } else { | 471 } else { |
467 ret.push_back(label[i]); | 472 ret.push_back(label[i]); |
468 } | 473 } |
469 } | 474 } |
470 | 475 |
471 return ret; | 476 return ret; |
472 } | 477 } |
473 | 478 |
| 479 } // namespace |
| 480 |
| 481 std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) { |
| 482 return ConvertAmperstandsTo(label, "_"); |
| 483 } |
| 484 |
| 485 std::string RemoveWindowsStyleAccelerators(const std::string& label) { |
| 486 return ConvertAmperstandsTo(label, ""); |
| 487 } |
| 488 |
474 bool IsScreenComposited() { | 489 bool IsScreenComposited() { |
475 GdkScreen* screen = gdk_screen_get_default(); | 490 GdkScreen* screen = gdk_screen_get_default(); |
476 return gdk_screen_is_composited(screen) == TRUE; | 491 return gdk_screen_is_composited(screen) == TRUE; |
477 } | 492 } |
478 | 493 |
479 void EnumerateTopLevelWindows(x11_util::EnumerateWindowsDelegate* delegate) { | 494 void EnumerateTopLevelWindows(x11_util::EnumerateWindowsDelegate* delegate) { |
480 std::vector<XID> stack; | 495 std::vector<XID> stack; |
481 if (!x11_util::GetXWindowStack(&stack)) { | 496 if (!x11_util::GetXWindowStack(&stack)) { |
482 // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back | 497 // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back |
483 // to old school enumeration of all X windows. Some WMs parent 'top-level' | 498 // to old school enumeration of all X windows. Some WMs parent 'top-level' |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 gint x = 0, y = 0, width = 1, height = 1; | 1059 gint x = 0, y = 0, width = 1, height = 1; |
1045 gtk_window_get_position(GTK_WINDOW(dialog), &x, &y); | 1060 gtk_window_get_position(GTK_WINDOW(dialog), &x, &y); |
1046 gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); | 1061 gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); |
1047 | 1062 |
1048 return gfx::Rect(x, y, width, height); | 1063 return gfx::Rect(x, y, width, height); |
1049 } | 1064 } |
1050 | 1065 |
1051 #endif | 1066 #endif |
1052 | 1067 |
1053 } // namespace gtk_util | 1068 } // namespace gtk_util |
OLD | NEW |