| 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 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 33 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 34 #include "chrome/browser/ui/host_desktop.h" | 34 #include "chrome/browser/ui/host_desktop.h" |
| 35 #include "grit/chrome_unscaled_resources.h" | 35 #include "grit/chrome_unscaled_resources.h" |
| 36 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
| 37 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" | 37 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" |
| 38 #include "ui/base/gtk/gtk_compat.h" | 38 #include "ui/base/gtk/gtk_compat.h" |
| 39 #include "ui/base/gtk/gtk_hig_constants.h" | 39 #include "ui/base/gtk/gtk_hig_constants.h" |
| 40 #include "ui/base/gtk/gtk_screen_util.h" | 40 #include "ui/base/gtk/gtk_screen_util.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 42 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 43 #include "ui/base/text/text_elider.h" | |
| 44 #include "ui/base/x/x11_util.h" | 43 #include "ui/base/x/x11_util.h" |
| 45 #include "ui/gfx/image/cairo_cached_surface.h" | 44 #include "ui/gfx/image/cairo_cached_surface.h" |
| 46 #include "ui/gfx/image/image.h" | 45 #include "ui/gfx/image/image.h" |
| 47 #include "ui/gfx/pango_util.h" | 46 #include "ui/gfx/pango_util.h" |
| 47 #include "ui/gfx/text_elider.h" |
| 48 #include "url/gurl.h" | 48 #include "url/gurl.h" |
| 49 | 49 |
| 50 // These conflict with base/tracked_objects.h, so need to come last. | 50 // These conflict with base/tracked_objects.h, so need to come last. |
| 51 #include <gdk/gdkx.h> // NOLINT | 51 #include <gdk/gdkx.h> // NOLINT |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 #if defined(GOOGLE_CHROME_BUILD) | 55 #if defined(GOOGLE_CHROME_BUILD) |
| 56 static const char* kIconName = "google-chrome"; | 56 static const char* kIconName = "google-chrome"; |
| 57 #else | 57 #else |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 641 |
| 642 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) { | 642 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) { |
| 643 GdkPoint point = {ltr ? x : width - x, y}; | 643 GdkPoint point = {ltr ? x : width - x, y}; |
| 644 return point; | 644 return point; |
| 645 } | 645 } |
| 646 | 646 |
| 647 std::string BuildTooltipTitleFor(string16 title, const GURL& url) { | 647 std::string BuildTooltipTitleFor(string16 title, const GURL& url) { |
| 648 const std::string& url_str = url.possibly_invalid_spec(); | 648 const std::string& url_str = url.possibly_invalid_spec(); |
| 649 const std::string& title_str = UTF16ToUTF8(title); | 649 const std::string& title_str = UTF16ToUTF8(title); |
| 650 | 650 |
| 651 std::string truncated_url = UTF16ToUTF8(ui::TruncateString( | 651 std::string truncated_url = UTF16ToUTF8(gfx::TruncateString( |
| 652 UTF8ToUTF16(url_str), kMaxTooltipURLLength)); | 652 UTF8ToUTF16(url_str), kMaxTooltipURLLength)); |
| 653 gchar* escaped_url_cstr = g_markup_escape_text(truncated_url.c_str(), | 653 gchar* escaped_url_cstr = g_markup_escape_text(truncated_url.c_str(), |
| 654 truncated_url.size()); | 654 truncated_url.size()); |
| 655 std::string escaped_url(escaped_url_cstr); | 655 std::string escaped_url(escaped_url_cstr); |
| 656 g_free(escaped_url_cstr); | 656 g_free(escaped_url_cstr); |
| 657 | 657 |
| 658 if (url_str == title_str || title.empty()) { | 658 if (url_str == title_str || title.empty()) { |
| 659 return escaped_url; | 659 return escaped_url; |
| 660 } else { | 660 } else { |
| 661 std::string truncated_title = UTF16ToUTF8(ui::TruncateString( | 661 std::string truncated_title = UTF16ToUTF8(gfx::TruncateString( |
| 662 title, kMaxTooltipTitleLength)); | 662 title, kMaxTooltipTitleLength)); |
| 663 gchar* escaped_title_cstr = g_markup_escape_text(truncated_title.c_str(), | 663 gchar* escaped_title_cstr = g_markup_escape_text(truncated_title.c_str(), |
| 664 truncated_title.size()); | 664 truncated_title.size()); |
| 665 std::string escaped_title(escaped_title_cstr); | 665 std::string escaped_title(escaped_title_cstr); |
| 666 g_free(escaped_title_cstr); | 666 g_free(escaped_title_cstr); |
| 667 | 667 |
| 668 if (!escaped_url.empty()) | 668 if (!escaped_url.empty()) |
| 669 return std::string("<b>") + escaped_title + "</b>\n" + escaped_url; | 669 return std::string("<b>") + escaped_title + "</b>\n" + escaped_url; |
| 670 else | 670 else |
| 671 return std::string("<b>") + escaped_title + "</b>"; | 671 return std::string("<b>") + escaped_title + "</b>"; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 if (gtk_window_get_modal(GTK_WINDOW(dialog))) { | 992 if (gtk_window_get_modal(GTK_WINDOW(dialog))) { |
| 993 // Work around a KDE 3 window manager bug. | 993 // Work around a KDE 3 window manager bug. |
| 994 scoped_ptr<base::Environment> env(base::Environment::Create()); | 994 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 995 if (base::nix::DESKTOP_ENVIRONMENT_KDE3 == | 995 if (base::nix::DESKTOP_ENVIRONMENT_KDE3 == |
| 996 base::nix::GetDesktopEnvironment(env.get())) | 996 base::nix::GetDesktopEnvironment(env.get())) |
| 997 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); | 997 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); |
| 998 } | 998 } |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 } // namespace gtk_util | 1001 } // namespace gtk_util |
| OLD | NEW |