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

Unified Diff: chrome/browser/ui/libgtk2ui/gtk2_util.cc

Issue 10545037: Aura/GTK integration: Create a small stub library that can talk to GTK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sky nits Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/libgtk2ui/gtk2_util.cc
diff --git a/chrome/browser/ui/libgtk2ui/gtk2_util.cc b/chrome/browser/ui/libgtk2ui/gtk2_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5ed3640ac4c983317604029c0667a3685c7b6634
--- /dev/null
+++ b/chrome/browser/ui/libgtk2ui/gtk2_util.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
+
+#include <gtk/gtk.h>
+
+#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace {
+
+void CommonInitFromCommandLine(const CommandLine& command_line,
+ void (*init_func)(gint*, gchar***)) {
+ 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();
+
+ init_func(&argc, &argv_pointer);
+ for (size_t i = 0; i < args.size(); ++i) {
+ free(argv[i]);
+ }
+}
+
+} // namespace
+
+namespace libgtk2ui {
+
+void GtkInitFromCommandLine(const CommandLine& command_line) {
+ CommonInitFromCommandLine(command_line, gtk_init);
+}
+
+} // namespace libgtk2ui

Powered by Google App Engine
This is Rietveld 408576698