| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UTIL_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UTIL_H_ |
| 6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UTIL_H_ | 6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UTIL_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 typedef struct _GdkPixbuf GdkPixbuf; | |
| 11 | |
| 12 class CommandLine; | 11 class CommandLine; |
| 13 class SkBitmap; | 12 class SkBitmap; |
| 14 | 13 |
| 15 namespace base { | 14 namespace base { |
| 16 class Environment; | 15 class Environment; |
| 17 } | 16 } |
| 18 | 17 |
| 18 namespace ui { |
| 19 class Accelerator; |
| 20 } |
| 21 |
| 19 namespace libgtk2ui { | 22 namespace libgtk2ui { |
| 20 | 23 |
| 21 void GtkInitFromCommandLine(const CommandLine& command_line); | 24 void GtkInitFromCommandLine(const CommandLine& command_line); |
| 22 | 25 |
| 23 // Returns the name of the ".desktop" file associated with our running process. | 26 // Returns the name of the ".desktop" file associated with our running process. |
| 24 std::string GetDesktopName(base::Environment* env); | 27 std::string GetDesktopName(base::Environment* env); |
| 25 | 28 |
| 26 const SkBitmap GdkPixbufToImageSkia(GdkPixbuf* pixbuf); | 29 const SkBitmap GdkPixbufToImageSkia(GdkPixbuf* pixbuf); |
| 27 | 30 |
| 31 // Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so |
| 32 // it is an expensive operation. The returned GdkPixbuf will have a refcount of |
| 33 // 1, and the caller is responsible for unrefing it when done. |
| 34 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap); |
| 35 |
| 36 // Show the image for the given menu item, even if the user's default is to not |
| 37 // show images. Only to be used for favicons or other menus where the image is |
| 38 // crucial to its functionality. |
| 39 void SetAlwaysShowImage(GtkWidget* image_menu_item); |
| 40 |
| 41 // Change windows accelerator style to GTK style. (GTK uses _ for |
| 42 // accelerators. Windows uses & with && as an escape for &.) |
| 43 std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label); |
| 44 |
| 45 guint GetGdkKeyCodeForAccelerator(const ui::Accelerator& accelerator); |
| 46 |
| 47 GdkModifierType GetGdkModifierForAccelerator( |
| 48 const ui::Accelerator& accelerator); |
| 49 |
| 50 // Translates event flags into plaform independent event flags. |
| 51 int EventFlagsFromGdkState(guint state); |
| 52 |
| 28 } // namespace libgtk2ui | 53 } // namespace libgtk2ui |
| 29 | 54 |
| 30 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UTIL_H_ | 55 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UTIL_H_ |
| OLD | NEW |