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

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

Issue 2449243002: Gtk3 ui: Add libgtk3ui as a separate build component (Closed)
Patch Set: Add theme_properties dep to //chrome/browser/ui Created 4 years, 2 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
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_util.h ('k') | chrome/browser/ui/libgtk2ui/libgtk2ui_export.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index 6aceaf3e6180557664e93f63db715b2f34b6d1d2..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/libgtk2ui/gtk2_util.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-// 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 <gdk/gdk.h>
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-#include <stddef.h>
-
-#include <memory>
-
-#include "base/command_line.h"
-#include "base/debug/leak_annotations.h"
-#include "base/environment.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/base/accelerators/accelerator.h"
-#include "ui/events/event_constants.h"
-#include "ui/events/keycodes/keyboard_code_conversion_x.h"
-#include "ui/gfx/geometry/size.h"
-
-namespace {
-
-const char kAuraTransientParent[] = "aura-transient-parent";
-
-void CommonInitFromCommandLine(const base::CommandLine& command_line,
- void (*init_func)(gint*, gchar***)) {
- const std::vector<std::string>& args = command_line.argv();
- int argc = args.size();
- std::unique_ptr<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();
-
- {
- // http://crbug.com/423873
- ANNOTATE_SCOPED_MEMORY_LEAK;
- init_func(&argc, &argv_pointer);
- }
- for (size_t i = 0; i < args.size(); ++i) {
- free(argv[i]);
- }
-}
-
-} // namespace
-
-namespace libgtk2ui {
-
-void GtkInitFromCommandLine(const base::CommandLine& command_line) {
- CommonInitFromCommandLine(command_line, gtk_init);
-}
-
-// TODO(erg): This method was copied out of shell_integration_linux.cc. Because
-// of how this library is structured as a stand alone .so, we can't call code
-// from browser and above.
-std::string GetDesktopName(base::Environment* env) {
-#if defined(GOOGLE_CHROME_BUILD)
- return "google-chrome.desktop";
-#else // CHROMIUM_BUILD
- // Allow $CHROME_DESKTOP to override the built-in value, so that development
- // versions can set themselves as the default without interfering with
- // non-official, packaged versions using the built-in value.
- std::string name;
- if (env->GetVar("CHROME_DESKTOP", &name) && !name.empty())
- return name;
- return "chromium-browser.desktop";
-#endif
-}
-
-guint GetGdkKeyCodeForAccelerator(const ui::Accelerator& accelerator) {
- // The second parameter is false because accelerator keys are expressed in
- // terms of the non-shift-modified key.
- return XKeysymForWindowsKeyCode(accelerator.key_code(), false);
-}
-
-GdkModifierType GetGdkModifierForAccelerator(
- const ui::Accelerator& accelerator) {
- int event_flag = accelerator.modifiers();
- int modifier = 0;
- if (event_flag & ui::EF_SHIFT_DOWN)
- modifier |= GDK_SHIFT_MASK;
- if (event_flag & ui::EF_CONTROL_DOWN)
- modifier |= GDK_CONTROL_MASK;
- if (event_flag & ui::EF_ALT_DOWN)
- modifier |= GDK_MOD1_MASK;
- return static_cast<GdkModifierType>(modifier);
-}
-
-int EventFlagsFromGdkState(guint state) {
- int flags = ui::EF_NONE;
- flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
- flags |= (state & GDK_LOCK_MASK) ? ui::EF_CAPS_LOCK_ON : ui::EF_NONE;
- flags |= (state & GDK_CONTROL_MASK) ? ui::EF_CONTROL_DOWN : ui::EF_NONE;
- flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : ui::EF_NONE;
- flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : ui::EF_NONE;
- flags |=
- (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON : ui::EF_NONE;
- flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : ui::EF_NONE;
- return flags;
-}
-
-void TurnButtonBlue(GtkWidget* button) {
-#if GTK_MAJOR_VERSION == 2
- gtk_widget_set_can_default(button, true);
-#else
- gtk_style_context_add_class(gtk_widget_get_style_context(button),
- "suggested-action");
-#endif
-}
-
-void SetGtkTransientForAura(GtkWidget* dialog, aura::Window* parent) {
- if (!parent || !parent->GetHost())
- return;
-
- gtk_widget_realize(dialog);
- GdkWindow* gdk_window = gtk_widget_get_window(dialog);
-
- // TODO(erg): Check to make sure we're using X11 if wayland or some other
- // display server ever happens. Otherwise, this will crash.
- XSetTransientForHint(GDK_WINDOW_XDISPLAY(gdk_window),
- GDK_WINDOW_XID(gdk_window),
- parent->GetHost()->GetAcceleratedWidget());
-
- // We also set the |parent| as a property of |dialog|, so that we can unlink
- // the two later.
- g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, parent);
-}
-
-aura::Window* GetAuraTransientParent(GtkWidget* dialog) {
- return reinterpret_cast<aura::Window*>(
- g_object_get_data(G_OBJECT(dialog), kAuraTransientParent));
-}
-
-void ClearAuraTransientParent(GtkWidget* dialog) {
- g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, NULL);
-}
-
-} // namespace libgtk2ui
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_util.h ('k') | chrome/browser/ui/libgtk2ui/libgtk2ui_export.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698