Changeset 28386 in webkit
- Timestamp:
- Dec 4, 2007 5:14:40 AM (16 years ago)
- Location:
- trunk/WebKit/gtk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/gtk/ChangeLog
r28384 r28386 1 2007-12-04 Luca Bruno <lethalman88@gmail.com> 2 3 Reviewed by Alp Toker. 4 5 http://bugs.webkit.org/show_bug.cgi?id=15911 6 [GTK] Use GtkBindingSet to make key bindings user-configurable 7 8 This patch doesn't cover the full range of bindings, only the ones 9 that seem obviously correct and have clear public API. 10 11 * WebCoreSupport/EditorClientGtk.cpp: 12 (WebKit::EditorClient::handleKeypress): do not handle clipboard operations and select-all 13 * WebView/webkitwebview.cpp: add cut, copy, paste and select-all signals and allow binding sets (issue #15911 and #16144) 14 * WebView/webkitwebview.h: 15 1 16 2007-12-04 Xan Lopez <xan@gnome.org> 2 17 -
trunk/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
r28273 r28386 286 286 } else if (kevent->ctrlKey()) { 287 287 switch (kevent->WindowsKeyCode()) { 288 case VK_A:289 frame->editor()->execCommand("SelectAll");290 break;291 288 case VK_B: 292 289 frame->editor()->execCommand("ToggleBold"); 293 290 break; 294 case VK_C:295 frame->editor()->execCommand("Copy");296 break;297 291 case VK_I: 298 292 frame->editor()->execCommand("ToggleItalic"); 299 break;300 case VK_V:301 frame->editor()->execCommand("Paste");302 break;303 case VK_X:304 frame->editor()->execCommand("Cut");305 293 break; 306 294 case VK_Y: … … 338 326 break; 339 327 default: 340 if (kevent->ctrlKey()) { 341 switch(kevent->WindowsKeyCode()) { 342 case VK_A: 343 frame->editor()->execCommand("SelectAll"); 344 break; 345 case VK_C: case VK_X: 346 frame->editor()->execCommand("Copy"); 347 break; 348 default: 349 return; 350 } 351 } else return; 328 return; 352 329 } 353 330 } -
trunk/WebKit/gtk/WebView/webkitwebview.cpp
r28371 r28386 48 48 #include "FrameLoader.h" 49 49 #include "FrameView.h" 50 #include "Editor.h" 50 51 #include "PlatformKeyboardEvent.h" 51 52 #include "PlatformWheelEvent.h" … … 75 76 SCRIPT_CONFIRM, 76 77 SCRIPT_PROMPT, 78 SELECT_ALL, 79 COPY_CLIPBOARD, 80 PASTE_CLIPBOARD, 81 CUT_CLIPBOARD, 77 82 LAST_SIGNAL 78 83 }; … … 104 109 PlatformKeyboardEvent keyboardEvent(event); 105 110 106 if (frame->eventHandler()->keyEvent(keyboardEvent)) 107 return TRUE; 108 109 if (event->type != GDK_KEY_PRESS) 110 return FALSE; 111 112 FrameView* view = frame->view(); 113 114 /* FIXME: at the very least we should be using the same code than the 115 Windows port here, but our ScrollView file diverges enough to make 116 that impossible. A short term solution would be to unify ScrollViewWin 117 and ScrollViewGtk. Long-term ScrollView and FrameView should be 118 unified and used everywhere for scrollbars */ 119 120 switch (event->keyval) { 121 case (GDK_Down): 122 view->scrollBy(0, LINE_STEP); 123 return TRUE; 124 case (GDK_Up): 125 view->scrollBy(0, -LINE_STEP); 126 return TRUE; 127 case (GDK_Right): 128 view->scrollBy(LINE_STEP, 0); 129 return TRUE; 130 case (GDK_Left): 131 view->scrollBy(-LINE_STEP, 0); 132 return TRUE; 133 } 134 135 return FALSE; 111 if (!frame->eventHandler()->keyEvent(keyboardEvent) && event->type == GDK_KEY_PRESS) 112 { 113 FrameView* view = frame->view(); 114 115 /* FIXME: at the very least we should be using the same code than the 116 Windows port here, but our ScrollView file diverges enough to make 117 that impossible. A short term solution would be to unify ScrollViewWin 118 and ScrollViewGtk. Long-term ScrollView and FrameView should be 119 unified and used everywhere for scrollbars */ 120 121 switch (event->keyval) { 122 case GDK_Down: 123 view->scrollBy(0, LINE_STEP); 124 return TRUE; 125 case GDK_Up: 126 view->scrollBy(0, -LINE_STEP); 127 return TRUE; 128 case GDK_Right: 129 view->scrollBy(LINE_STEP, 0); 130 return TRUE; 131 case GDK_Left: 132 view->scrollBy(-LINE_STEP, 0); 133 return TRUE; 134 } 135 } 136 137 return gtk_bindings_activate_event(GTK_OBJECT(widget), event); 136 138 } 137 139 … … 361 363 } 362 364 365 static void webkit_web_view_real_select_all(WebKitWebView* webView) 366 { 367 Frame* frame = core(getFrameFromView(webView)); 368 frame->editor()->execCommand("SelectAll"); 369 } 370 371 static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView) 372 { 373 Frame* frame = core(getFrameFromView(webView)); 374 frame->editor()->execCommand("Cut"); 375 } 376 377 static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView) 378 { 379 Frame* frame = core(getFrameFromView(webView)); 380 frame->editor()->execCommand("Copy"); 381 } 382 383 static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView) 384 { 385 Frame* frame = core(getFrameFromView(webView)); 386 frame->editor()->execCommand("Paste"); 387 } 388 363 389 static void webkit_web_view_finalize(GObject* object) 364 390 { … … 376 402 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) 377 403 { 404 GtkBindingSet* binding_set; 405 378 406 g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); 379 407 … … 591 619 G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); 592 620 621 /** 622 * WebKitWebView::select-all: 623 * @web_view: the object which received the signal 624 * 625 * The ::select-all signal is a keybinding signal which gets emitted to 626 * select the complete contents of the text view. 627 * 628 * The default bindings for this signal is Ctrl-a. 629 */ 630 webkit_web_view_signals[SELECT_ALL] = g_signal_new("select_all", 631 G_TYPE_FROM_CLASS(webViewClass), 632 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 633 G_STRUCT_OFFSET(WebKitWebViewClass, select_all), 634 NULL, NULL, 635 g_cclosure_marshal_VOID__VOID, 636 G_TYPE_NONE, 0); 637 638 /** 639 * WebKitWebView::cut-clipboard: 640 * @web_view: the object which received the signal 641 * 642 * The ::cut-clipboard signal is a keybinding signal which gets emitted to 643 * cut the selection to the clipboard. 644 * 645 * The default bindings for this signal are Ctrl-x and Shift-Delete. 646 */ 647 webkit_web_view_signals[CUT_CLIPBOARD] = g_signal_new("cut_clipboard", 648 G_TYPE_FROM_CLASS(webViewClass), 649 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 650 G_STRUCT_OFFSET(WebKitWebViewClass, cut_clipboard), 651 NULL, NULL, 652 g_cclosure_marshal_VOID__VOID, 653 G_TYPE_NONE, 0); 654 655 /** 656 * WebKitWebView::copy-clipboard: 657 * @web_view: the object which received the signal 658 * 659 * The ::copy-clipboard signal is a keybinding signal which gets emitted to 660 * copy the selection to the clipboard. 661 * 662 * The default bindings for this signal are Ctrl-c and Ctrl-Insert. 663 */ 664 webkit_web_view_signals[COPY_CLIPBOARD] = g_signal_new("copy_clipboard", 665 G_TYPE_FROM_CLASS(webViewClass), 666 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 667 G_STRUCT_OFFSET(WebKitWebViewClass, copy_clipboard), 668 NULL, NULL, 669 g_cclosure_marshal_VOID__VOID, 670 G_TYPE_NONE, 0); 671 672 /** 673 * WebKitWebView::paste-clipboard: 674 * @web_view: the object which received the signal 675 * 676 * The ::paste-clipboard signal is a keybinding signal which gets emitted to 677 * paste the contents of the clipboard into the Web view. 678 * 679 * The default bindings for this signal are Ctrl-v and Shift-Insert. 680 */ 681 webkit_web_view_signals[PASTE_CLIPBOARD] = g_signal_new("paste_clipboard", 682 G_TYPE_FROM_CLASS(webViewClass), 683 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 684 G_STRUCT_OFFSET(WebKitWebViewClass, paste_clipboard), 685 NULL, NULL, 686 g_cclosure_marshal_VOID__VOID, 687 G_TYPE_NONE, 0); 593 688 594 689 /* … … 603 698 webViewClass->script_prompt = webkit_web_view_real_script_prompt; 604 699 webViewClass->console_message = webkit_web_view_real_console_message; 700 webViewClass->select_all = webkit_web_view_real_select_all; 701 webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard; 702 webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard; 703 webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard; 605 704 606 705 G_OBJECT_CLASS(webViewClass)->finalize = webkit_web_view_finalize; … … 634 733 G_TYPE_NONE, 2, 635 734 GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); 735 736 /* 737 * Key bindings 738 */ 739 740 binding_set = gtk_binding_set_by_class(webViewClass); 741 742 gtk_binding_entry_add_signal(binding_set, GDK_a, GDK_CONTROL_MASK, 743 "select_all", 0); 744 745 /* Cut/copy/paste */ 746 747 gtk_binding_entry_add_signal(binding_set, GDK_x, GDK_CONTROL_MASK, 748 "cut_clipboard", 0); 749 gtk_binding_entry_add_signal(binding_set, GDK_c, GDK_CONTROL_MASK, 750 "copy_clipboard", 0); 751 gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK, 752 "paste_clipboard", 0); 753 754 gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK, 755 "cut_clipboard", 0); 756 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_CONTROL_MASK, 757 "copy_clipboard", 0); 758 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK, 759 "paste_clipboard", 0); 636 760 } 637 761 … … 644 768 settings->setLoadsImagesAutomatically(true); 645 769 settings->setMinimumFontSize(5); 770 settings->setDOMPasteAllowed(true); 646 771 settings->setMinimumLogicalFontSize(5); 647 772 settings->setShouldPrintBackgrounds(true); -
trunk/WebKit/gtk/WebView/webkitwebview.h
r28313 r28386 79 79 gboolean (*script_prompt) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* message, const gchar* default_value, gchar** value); 80 80 gboolean (*console_message) (WebKitWebView* web_view, const gchar* message, unsigned int line_number, const gchar* source_id); 81 void (*select_all) (WebKitWebView* web_view); 82 void (*cut_clipboard) (WebKitWebView* web_view); 83 void (*copy_clipboard) (WebKitWebView* web_view); 84 void (*paste_clipboard) (WebKitWebView* web_view); 81 85 82 86 /*
Note: See TracChangeset
for help on using the changeset viewer.