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

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

Issue 23731010: Move text_elider to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update3 Created 7 years, 3 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) 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
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/global_history_menu.cc ('k') | chrome/browser/ui/gtk/status_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698