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

Side by Side Diff: app/resource_bundle_linux.cc

Issue 1073005: Move RTL related functions from app/l10n_util to base/i18n/rtl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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
« no previous file with comments | « app/l10n_util_win.cc ('k') | app/text_elider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "app/resource_bundle.h" 5 #include "app/resource_bundle.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/app_paths.h" 9 #include "app/app_paths.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "base/base_paths.h" 12 #include "base/base_paths.h"
13 #include "base/data_pack.h" 13 #include "base/data_pack.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/path_service.h" 18 #include "base/path_service.h"
18 #include "base/string_piece.h" 19 #include "base/string_piece.h"
19 #include "base/string_util.h" 20 #include "base/string_util.h"
20 #include "gfx/gtk_util.h" 21 #include "gfx/gtk_util.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkBitmap.h"
22 23
23 namespace { 24 namespace {
24 25
25 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned 26 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned
26 // has a ref count of 1 so the caller must call g_object_unref to free the 27 // has a ref count of 1 so the caller must call g_object_unref to free the
27 // memory. 28 // memory.
28 GdkPixbuf* LoadPixbuf(RefCountedStaticMemory* data, bool rtl_enabled) { 29 GdkPixbuf* LoadPixbuf(RefCountedStaticMemory* data, bool rtl_enabled) {
29 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); 30 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new());
30 bool ok = data && gdk_pixbuf_loader_write(loader.get(), 31 bool ok = data && gdk_pixbuf_loader_write(loader.get(),
31 reinterpret_cast<const guint8*>(data->front()), data->size(), NULL); 32 reinterpret_cast<const guint8*>(data->front()), data->size(), NULL);
32 if (!ok) 33 if (!ok)
33 return NULL; 34 return NULL;
34 // Calling gdk_pixbuf_loader_close forces the data to be parsed by the 35 // Calling gdk_pixbuf_loader_close forces the data to be parsed by the
35 // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf. 36 // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf.
36 ok = gdk_pixbuf_loader_close(loader.get(), NULL); 37 ok = gdk_pixbuf_loader_close(loader.get(), NULL);
37 if (!ok) 38 if (!ok)
38 return NULL; 39 return NULL;
39 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get()); 40 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get());
40 if (!pixbuf) 41 if (!pixbuf)
41 return NULL; 42 return NULL;
42 43
43 if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && 44 if (base::i18n::IsRTL() && rtl_enabled) {
44 rtl_enabled) {
45 // |pixbuf| will get unreffed and destroyed (see below). The returned value 45 // |pixbuf| will get unreffed and destroyed (see below). The returned value
46 // has ref count 1. 46 // has ref count 1.
47 return gdk_pixbuf_flip(pixbuf, TRUE); 47 return gdk_pixbuf_flip(pixbuf, TRUE);
48 } else { 48 } else {
49 // The pixbuf is owned by the loader, so add a ref so when we delete the 49 // The pixbuf is owned by the loader, so add a ref so when we delete the
50 // loader (when the ScopedGObject goes out of scope), the pixbuf still 50 // loader (when the ScopedGObject goes out of scope), the pixbuf still
51 // exists. 51 // exists.
52 g_object_ref(pixbuf); 52 g_object_ref(pixbuf);
53 return pixbuf; 53 return pixbuf;
54 } 54 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 } 139 }
140 140
141 GdkPixbuf* ResourceBundle::GetPixbufNamed(int resource_id) { 141 GdkPixbuf* ResourceBundle::GetPixbufNamed(int resource_id) {
142 return GetPixbufImpl(resource_id, false); 142 return GetPixbufImpl(resource_id, false);
143 } 143 }
144 144
145 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) { 145 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) {
146 return GetPixbufImpl(resource_id, true); 146 return GetPixbufImpl(resource_id, true);
147 } 147 }
OLDNEW
« no previous file with comments | « app/l10n_util_win.cc ('k') | app/text_elider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698