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

Unified Diff: gfx/gtk_util.cc

Issue 4508004: gtk: refactor copy-pasted code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gfx/gtk_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gfx/gtk_util.cc
diff --git a/gfx/gtk_util.cc b/gfx/gtk_util.cc
index c45e13344cbb7916971b42fa5489b6f9fc7ec3f3..b30b82716e9aecf02d74f68999d00e0060cd9c11 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]);
Evan Stade 2010/11/05 20:35:03 are these weird spaces necessary?
+ for (size_t i = 0; i < args.size(); ++i) {
+ // TODO(piman@google.com): can gtk_init modify argv? Just being safe
Evan Stade 2010/11/05 20:35:03 I think you can just remove the comment
+ // here.
+ argv[i] = strdup(args[i].c_str());
+ }
+ argv[argc] = NULL;
+ char **argv_pointer = argv.get();
Evan Stade 2010/11/05 20:35:03 * on left
+
+ 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;
« no previous file with comments | « gfx/gtk_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698