| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 GtkTextBuffer*); | 167 GtkTextBuffer*); |
| 168 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleMarkSet, | 168 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleMarkSet, |
| 169 GtkTextBuffer*, GtkTextIter*, GtkTextMark*); | 169 GtkTextBuffer*, GtkTextIter*, GtkTextMark*); |
| 170 // As above, but called after the default handler. | 170 // As above, but called after the default handler. |
| 171 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleMarkSetAfter, | 171 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleMarkSetAfter, |
| 172 GtkTextBuffer*, GtkTextIter*, GtkTextMark*); | 172 GtkTextBuffer*, GtkTextIter*, GtkTextMark*); |
| 173 CHROMEG_CALLBACK_3(AutocompleteEditViewGtk, void, HandleInsertText, | 173 CHROMEG_CALLBACK_3(AutocompleteEditViewGtk, void, HandleInsertText, |
| 174 GtkTextBuffer*, GtkTextIter*, const gchar*, gint); | 174 GtkTextBuffer*, GtkTextIter*, const gchar*, gint); |
| 175 CHROMEG_CALLBACK_0(AutocompleteEditViewGtk, void, | 175 CHROMEG_CALLBACK_0(AutocompleteEditViewGtk, void, |
| 176 HandleKeymapDirectionChanged, GdkKeymap*); | 176 HandleKeymapDirectionChanged, GdkKeymap*); |
| 177 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleDeleteRange, |
| 178 GtkTextBuffer*, GtkTextIter*, GtkTextIter*); |
| 179 // Unlike above HandleMarkSet and HandleMarkSetAfter, this handler will always |
| 180 // be connected to the signal. |
| 181 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleMarkSetAlways, |
| 182 GtkTextBuffer*, GtkTextIter*, GtkTextMark*); |
| 177 | 183 |
| 178 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleKeyPress, | 184 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleKeyPress, |
| 179 GdkEventKey*); | 185 GdkEventKey*); |
| 180 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleKeyRelease, | 186 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleKeyRelease, |
| 181 GdkEventKey*); | 187 GdkEventKey*); |
| 182 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleViewButtonPress, | 188 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleViewButtonPress, |
| 183 GdkEventButton*); | 189 GdkEventButton*); |
| 184 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, | 190 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, |
| 185 HandleViewButtonRelease, GdkEventButton*); | 191 HandleViewButtonRelease, GdkEventButton*); |
| 186 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleViewFocusIn, | 192 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleViewFocusIn, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 207 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleExposeEvent, | 213 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, HandleExposeEvent, |
| 208 GdkEventExpose*); | 214 GdkEventExpose*); |
| 209 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, void, | 215 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, void, |
| 210 HandleWidgetDirectionChanged, GtkTextDirection); | 216 HandleWidgetDirectionChanged, GtkTextDirection); |
| 211 CHROMEGTK_CALLBACK_2(AutocompleteEditViewGtk, void, | 217 CHROMEGTK_CALLBACK_2(AutocompleteEditViewGtk, void, |
| 212 HandleDeleteFromCursor, GtkDeleteType, gint); | 218 HandleDeleteFromCursor, GtkDeleteType, gint); |
| 213 // We connect to this so we can determine our toplevel window, so we can | 219 // We connect to this so we can determine our toplevel window, so we can |
| 214 // listen to focus change events on it. | 220 // listen to focus change events on it. |
| 215 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, void, HandleHierarchyChanged, | 221 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, void, HandleHierarchyChanged, |
| 216 GtkWidget*); | 222 GtkWidget*); |
| 217 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, gboolean, | 223 #if GTK_CHECK_VERSION(2, 20, 0) |
| 218 HandleInstantViewButtonPress, GdkEventButton*); | |
| 219 #if GTK_CHECK_VERSION(2,20,0) | |
| 220 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, void, HandlePreeditChanged, | 224 CHROMEGTK_CALLBACK_1(AutocompleteEditViewGtk, void, HandlePreeditChanged, |
| 221 const gchar*); | 225 const gchar*); |
| 222 #endif | 226 #endif |
| 227 // Undo/redo operations won't trigger "begin-user-action" and |
| 228 // "end-user-action" signals, so we need to hook into "undo" and "redo" |
| 229 // signals and call OnBeforePossibleChange()/OnAfterPossibleChange() by |
| 230 // ourselves. |
| 231 CHROMEGTK_CALLBACK_0(AutocompleteEditViewGtk, void, HandleUndoRedo); |
| 232 CHROMEGTK_CALLBACK_0(AutocompleteEditViewGtk, void, HandleUndoRedoAfter); |
| 223 | 233 |
| 224 CHROMEG_CALLBACK_1(AutocompleteEditViewGtk, void, HandleWindowSetFocus, | 234 CHROMEG_CALLBACK_1(AutocompleteEditViewGtk, void, HandleWindowSetFocus, |
| 225 GtkWindow*, GtkWidget*); | 235 GtkWindow*, GtkWidget*); |
| 226 | 236 |
| 227 // Callback for the PRIMARY selection clipboard. | 237 // Callback for the PRIMARY selection clipboard. |
| 228 static void ClipboardGetSelectionThunk(GtkClipboard* clipboard, | 238 static void ClipboardGetSelectionThunk(GtkClipboard* clipboard, |
| 229 GtkSelectionData* selection_data, | 239 GtkSelectionData* selection_data, |
| 230 guint info, | 240 guint info, |
| 231 gpointer object); | 241 gpointer object); |
| 232 void ClipboardGetSelection(GtkClipboard* clipboard, | 242 void ClipboardGetSelection(GtkClipboard* clipboard, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 262 // Get the character indices of the current selection. This honors | 272 // Get the character indices of the current selection. This honors |
| 263 // direction, cp_max is the insertion point, and cp_min is the bound. | 273 // direction, cp_max is the insertion point, and cp_min is the bound. |
| 264 CharRange GetSelection(); | 274 CharRange GetSelection(); |
| 265 | 275 |
| 266 // Translate from character positions to iterators for the current buffer. | 276 // Translate from character positions to iterators for the current buffer. |
| 267 void ItersFromCharRange(const CharRange& range, | 277 void ItersFromCharRange(const CharRange& range, |
| 268 GtkTextIter* iter_min, | 278 GtkTextIter* iter_min, |
| 269 GtkTextIter* iter_max); | 279 GtkTextIter* iter_max); |
| 270 | 280 |
| 271 // Return the number of characers in the current buffer. | 281 // Return the number of characers in the current buffer. |
| 272 int GetTextLength(); | 282 int GetTextLength() const; |
| 273 | |
| 274 // Get the string contents for the given buffer. | |
| 275 std::wstring GetTextFromBuffer(GtkTextBuffer* buffer) const; | |
| 276 | 283 |
| 277 // Try to parse the current text as a URL and colorize the components. | 284 // Try to parse the current text as a URL and colorize the components. |
| 278 void EmphasizeURLComponents(); | 285 void EmphasizeURLComponents(); |
| 279 | 286 |
| 280 // Internally invoked whenever the text changes in some way. | 287 // Internally invoked whenever the text changes in some way. |
| 281 void TextChanged(); | 288 void TextChanged(); |
| 282 | 289 |
| 283 // Save |selected_text| as the PRIMARY X selection. Unlike | 290 // Save |selected_text| as the PRIMARY X selection. Unlike |
| 284 // OwnPrimarySelection(), this won't set an owner or use callbacks. | 291 // OwnPrimarySelection(), this won't set an owner or use callbacks. |
| 285 void SavePrimarySelection(const std::string& selected_text); | 292 void SavePrimarySelection(const std::string& selected_text); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 299 // Get the text direction of |text_buffer_|'s content, by searching the first | 306 // Get the text direction of |text_buffer_|'s content, by searching the first |
| 300 // character that has a strong direction. | 307 // character that has a strong direction. |
| 301 PangoDirection GetContentDirection(); | 308 PangoDirection GetContentDirection(); |
| 302 | 309 |
| 303 // Returns the selected text. | 310 // Returns the selected text. |
| 304 std::string GetSelectedText() const; | 311 std::string GetSelectedText() const; |
| 305 | 312 |
| 306 // If the selected text parses as a URL OwnPrimarySelection is invoked. | 313 // If the selected text parses as a URL OwnPrimarySelection is invoked. |
| 307 void UpdatePrimarySelectionIfValidURL(); | 314 void UpdatePrimarySelectionIfValidURL(); |
| 308 | 315 |
| 316 // Retrieves the first and last iterators in the |text_buffer_|, but excludes |
| 317 // the anchor holding the |instant_view_| widget. |
| 318 void GetTextBufferBounds(GtkTextIter* start, GtkTextIter* end) const; |
| 319 |
| 320 // Validates an iterator in the |text_buffer_|, to make sure it doesn't go |
| 321 // beyond the anchor for holding the |instant_view_| widget. |
| 322 void ValidateTextBufferIter(GtkTextIter* iter) const; |
| 323 |
| 324 // Adjusts vertical alignment of the |instant_view_| in the |text_view_|, to |
| 325 // make sure they have the same baseline. |
| 326 void AdjustVerticalAlignmentOfInstantView(); |
| 327 |
| 309 // The widget we expose, used for vertically centering the real text edit, | 328 // The widget we expose, used for vertically centering the real text edit, |
| 310 // since the height will change based on the font / font size, etc. | 329 // since the height will change based on the font / font size, etc. |
| 311 OwnedWidgetGtk alignment_; | 330 OwnedWidgetGtk alignment_; |
| 312 | 331 |
| 313 // The actual text entry which will be owned by the alignment_. | 332 // The actual text entry which will be owned by the alignment_. |
| 314 GtkWidget* text_view_; | 333 GtkWidget* text_view_; |
| 315 | 334 |
| 316 GtkTextTagTable* tag_table_; | 335 GtkTextTagTable* tag_table_; |
| 317 GtkTextBuffer* text_buffer_; | 336 GtkTextBuffer* text_buffer_; |
| 318 GtkTextTag* faded_text_tag_; | 337 GtkTextTag* faded_text_tag_; |
| 319 GtkTextTag* secure_scheme_tag_; | 338 GtkTextTag* secure_scheme_tag_; |
| 320 GtkTextTag* security_error_scheme_tag_; | 339 GtkTextTag* security_error_scheme_tag_; |
| 321 GtkTextTag* normal_text_tag_; | 340 GtkTextTag* normal_text_tag_; |
| 322 | 341 |
| 323 // Objects for the instant suggestion text view. | 342 // Objects for the instant suggestion text view. |
| 343 GtkTextTag* instant_anchor_tag_; |
| 344 |
| 345 // A widget for displaying instant suggestion text. It'll be attached to a |
| 346 // child anchor in the |text_buffer_| object. |
| 324 GtkWidget* instant_view_; | 347 GtkWidget* instant_view_; |
| 325 GtkTextBuffer* instant_buffer_; | 348 |
| 326 GtkTextTag* instant_text_tag_; | 349 // A mark to split the content and the instant anchor. Wherever the end |
| 350 // iterator of the text buffer is required, the iterator to this mark should |
| 351 // be used. |
| 352 GtkTextMark* instant_mark_; |
| 327 | 353 |
| 328 scoped_ptr<AutocompleteEditModel> model_; | 354 scoped_ptr<AutocompleteEditModel> model_; |
| 329 scoped_ptr<AutocompletePopupView> popup_view_; | 355 scoped_ptr<AutocompletePopupView> popup_view_; |
| 330 AutocompleteEditController* controller_; | 356 AutocompleteEditController* controller_; |
| 331 ToolbarModel* toolbar_model_; | 357 ToolbarModel* toolbar_model_; |
| 332 | 358 |
| 333 // The object that handles additional command functionality exposed on the | 359 // The object that handles additional command functionality exposed on the |
| 334 // edit, such as invoking the keyword editor. | 360 // edit, such as invoking the keyword editor. |
| 335 CommandUpdater* command_updater_; | 361 CommandUpdater* command_updater_; |
| 336 | 362 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 453 |
| 428 // Indicate if the tab to search should be enabled or not. It's true by | 454 // Indicate if the tab to search should be enabled or not. It's true by |
| 429 // default and will only be set to false if the location bar view is not able | 455 // default and will only be set to false if the location bar view is not able |
| 430 // to show the tab to search hint. | 456 // to show the tab to search hint. |
| 431 bool enable_tab_to_search_; | 457 bool enable_tab_to_search_; |
| 432 | 458 |
| 433 // Indicates if the selected text is suggested text or not. If the selection | 459 // Indicates if the selected text is suggested text or not. If the selection |
| 434 // is not suggested text, that means the user manually made the selection. | 460 // is not suggested text, that means the user manually made the selection. |
| 435 bool selection_suggested_; | 461 bool selection_suggested_; |
| 436 | 462 |
| 437 #if GTK_CHECK_VERSION(2,20,0) | 463 #if GTK_CHECK_VERSION(2, 20, 0) |
| 438 // Stores the text being composed by the input method. | 464 // Stores the text being composed by the input method. |
| 439 std::wstring preedit_; | 465 std::wstring preedit_; |
| 440 #endif | 466 #endif |
| 441 | 467 |
| 442 // The view that is going to be focused next. Only valid while handling | 468 // The view that is going to be focused next. Only valid while handling |
| 443 // "focus-out" events. | 469 // "focus-out" events. |
| 444 GtkWidget* going_to_focus_; | 470 GtkWidget* going_to_focus_; |
| 445 | 471 |
| 446 GtkSignalRegistrar signals_; | 472 GtkSignalRegistrar signals_; |
| 447 | 473 |
| 448 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); | 474 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); |
| 449 }; | 475 }; |
| 450 | 476 |
| 451 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 477 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
| OLD | NEW |