summaryrefslogtreecommitdiffstats
path: root/gfx/gtk_util.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 20:32:22 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 20:32:22 +0000
commit0a8b97bce41cba47185d5fbee6a6850f175e9513 (patch)
tree2e774a8aac4ab7b0b52912216e04d46a2e0688b2 /gfx/gtk_util.cc
parenta43ce683b98659b5120125f04b07d8db81979f7b (diff)
downloadchromium_src-0a8b97bce41cba47185d5fbee6a6850f175e9513.zip
chromium_src-0a8b97bce41cba47185d5fbee6a6850f175e9513.tar.gz
chromium_src-0a8b97bce41cba47185d5fbee6a6850f175e9513.tar.bz2
gtk: refactor copy-pasted code
I wanted to do the same thing in a third place. TEST=compiles Review URL: http://codereview.chromium.org/4508004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/gtk_util.cc')
-rw-r--r--gfx/gtk_util.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/gfx/gtk_util.cc b/gfx/gtk_util.cc
index c45e133..b30b827 100644
--- a/gfx/gtk_util.cc
+++ b/gfx/gtk_util.cc
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "base/linux_util.h"
#include "gfx/rect.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -52,6 +53,24 @@ std::string ConvertAmperstandsTo(const std::string& label,
namespace gfx {
+void GtkInitFromCommandLine(const CommandLine& command_line) {
+ const std::vector<std::string>& args = command_line.argv();
+ int argc = args.size();
+ scoped_array<char *> argv(new char *[argc + 1]);
+ for (size_t i = 0; i < args.size(); ++i) {
+ // TODO(piman@google.com): can gtk_init modify argv? Just being safe
+ // here.
+ argv[i] = strdup(args[i].c_str());
+ }
+ argv[argc] = NULL;
+ char **argv_pointer = argv.get();
+
+ gtk_init(&argc, &argv_pointer);
+ for (size_t i = 0; i < args.size(); ++i) {
+ free(argv[i]);
+ }
+}
+
GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) {
if (bitmap->isNull())
return NULL;