| 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_LIBGTKUI_GTK2_KEY_BINDINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTKUI_GTK_KEY_BINDINGS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_LIBGTKUI_GTK2_KEY_BINDINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_LIBGTKUI_GTK_KEY_BINDINGS_HANDLER_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/event_types.h" | 13 #include "base/event_types.h" |
| 14 #include "ui/base/ime/linux/text_edit_command_auralinux.h" | 14 #include "ui/base/ime/linux/text_edit_command_auralinux.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // returned if the key event doesn't correspond to a predefined key binding. | 51 // returned if the key event doesn't correspond to a predefined key binding. |
| 52 // Edit commands matched with |event| will be stored in |edit_commands|, if | 52 // Edit commands matched with |event| will be stored in |edit_commands|, if |
| 53 // non-NULL. | 53 // non-NULL. |
| 54 bool MatchEvent(const ui::Event& event, | 54 bool MatchEvent(const ui::Event& event, |
| 55 std::vector<ui::TextEditCommandAuraLinux>* commands); | 55 std::vector<ui::TextEditCommandAuraLinux>* commands); |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 // Object structure of Handler class, which is derived from GtkTextView. | 58 // Object structure of Handler class, which is derived from GtkTextView. |
| 59 struct Handler { | 59 struct Handler { |
| 60 GtkTextView parent_object; | 60 GtkTextView parent_object; |
| 61 Gtk2KeyBindingsHandler *owner; | 61 Gtk2KeyBindingsHandler* owner; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // Class structure of Handler class. | 64 // Class structure of Handler class. |
| 65 struct HandlerClass { | 65 struct HandlerClass { |
| 66 GtkTextViewClass parent_class; | 66 GtkTextViewClass parent_class; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Creates a new instance of Handler class. | 69 // Creates a new instance of Handler class. |
| 70 GtkWidget* CreateNewHandler(); | 70 GtkWidget* CreateNewHandler(); |
| 71 | 71 |
| 72 // Adds an edit command to the key event. | 72 // Adds an edit command to the key event. |
| 73 void EditCommandMatched(ui::TextEditCommand command, | 73 void EditCommandMatched(ui::TextEditCommand command, |
| 74 const std::string& value); | 74 const std::string& value); |
| 75 | 75 |
| 76 // Builds a fake GdkEventKey from an XEvent. | 76 // Builds a fake GdkEventKey from an XEvent. |
| 77 void BuildGdkEventKeyFromXEvent(const base::NativeEvent& xevent, | 77 void BuildGdkEventKeyFromXEvent(const base::NativeEvent& xevent, |
| 78 GdkEventKey* gdk_event); | 78 GdkEventKey* gdk_event); |
| 79 | 79 |
| 80 // Initializes Handler structure. | 80 // Initializes Handler structure. |
| 81 static void HandlerInit(Handler *self); | 81 static void HandlerInit(Handler* self); |
| 82 | 82 |
| 83 // Initializes HandlerClass structure. | 83 // Initializes HandlerClass structure. |
| 84 static void HandlerClassInit(HandlerClass *klass); | 84 static void HandlerClassInit(HandlerClass* klass); |
| 85 | 85 |
| 86 // Registeres Handler class to GObject type system and return its type id. | 86 // Registeres Handler class to GObject type system and return its type id. |
| 87 static GType HandlerGetType(); | 87 static GType HandlerGetType(); |
| 88 | 88 |
| 89 // Gets the Gtk2KeyBindingsHandler object which owns the Handler object. | 89 // Gets the Gtk2KeyBindingsHandler object which owns the Handler object. |
| 90 static Gtk2KeyBindingsHandler* GetHandlerOwner(GtkTextView* text_view); | 90 static Gtk2KeyBindingsHandler* GetHandlerOwner(GtkTextView* text_view); |
| 91 | 91 |
| 92 // Handler of "backspace" signal. | 92 // Handler of "backspace" signal. |
| 93 static void BackSpace(GtkTextView* text_view); | 93 static void BackSpace(GtkTextView* text_view); |
| 94 | 94 |
| 95 // Handler of "copy-clipboard" signal. | 95 // Handler of "copy-clipboard" signal. |
| 96 static void CopyClipboard(GtkTextView* text_view); | 96 static void CopyClipboard(GtkTextView* text_view); |
| 97 | 97 |
| 98 // Handler of "cut-clipboard" signal. | 98 // Handler of "cut-clipboard" signal. |
| 99 static void CutClipboard(GtkTextView* text_view); | 99 static void CutClipboard(GtkTextView* text_view); |
| 100 | 100 |
| 101 // Handler of "delete-from-cursor" signal. | 101 // Handler of "delete-from-cursor" signal. |
| 102 static void DeleteFromCursor(GtkTextView* text_view, GtkDeleteType type, | 102 static void DeleteFromCursor(GtkTextView* text_view, |
| 103 GtkDeleteType type, |
| 103 gint count); | 104 gint count); |
| 104 | 105 |
| 105 // Handler of "insert-at-cursor" signal. | 106 // Handler of "insert-at-cursor" signal. |
| 106 static void InsertAtCursor(GtkTextView* text_view, const gchar* str); | 107 static void InsertAtCursor(GtkTextView* text_view, const gchar* str); |
| 107 | 108 |
| 108 // Handler of "move-cursor" signal. | 109 // Handler of "move-cursor" signal. |
| 109 static void MoveCursor(GtkTextView* text_view, GtkMovementStep step, | 110 static void MoveCursor(GtkTextView* text_view, |
| 110 gint count, gboolean extend_selection); | 111 GtkMovementStep step, |
| 112 gint count, |
| 113 gboolean extend_selection); |
| 111 | 114 |
| 112 // Handler of "move-viewport" signal. | 115 // Handler of "move-viewport" signal. |
| 113 static void MoveViewport(GtkTextView* text_view, GtkScrollStep step, | 116 static void MoveViewport(GtkTextView* text_view, |
| 117 GtkScrollStep step, |
| 114 gint count); | 118 gint count); |
| 115 | 119 |
| 116 // Handler of "paste-clipboard" signal. | 120 // Handler of "paste-clipboard" signal. |
| 117 static void PasteClipboard(GtkTextView* text_view); | 121 static void PasteClipboard(GtkTextView* text_view); |
| 118 | 122 |
| 119 // Handler of "select-all" signal. | 123 // Handler of "select-all" signal. |
| 120 static void SelectAll(GtkTextView* text_view, gboolean select); | 124 static void SelectAll(GtkTextView* text_view, gboolean select); |
| 121 | 125 |
| 122 // Handler of "set-anchor" signal. | 126 // Handler of "set-anchor" signal. |
| 123 static void SetAnchor(GtkTextView* text_view); | 127 static void SetAnchor(GtkTextView* text_view); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 139 | 143 |
| 140 // Buffer to store the match results. | 144 // Buffer to store the match results. |
| 141 std::vector<ui::TextEditCommandAuraLinux> edit_commands_; | 145 std::vector<ui::TextEditCommandAuraLinux> edit_commands_; |
| 142 | 146 |
| 143 // Whether the current X server has the XKeyboard extension. | 147 // Whether the current X server has the XKeyboard extension. |
| 144 bool has_xkb_; | 148 bool has_xkb_; |
| 145 }; | 149 }; |
| 146 | 150 |
| 147 } // namespace libgtkui | 151 } // namespace libgtkui |
| 148 | 152 |
| 149 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK2_KEY_BINDINGS_HANDLER_H_ | 153 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_KEY_BINDINGS_HANDLER_H_ |
| OLD | NEW |