diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-03-25 17:54:11 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-03-30 09:23:48 +0200 |
commit | ffd4b87966a69ede188a5e15151c95f199558f27 (patch) | |
tree | b164fe1a33a77dd2307877890e8f7ec85d02f900 /libreofficekit/qa | |
parent | 5e43b9a9a05f1146c71fbce46a2ddce44c59c77b (diff) |
lokdocview: move keyboard handling to LOKDocView_Impl
Change-Id: I1117ec42bdf0f2cb19f77723b87597d301d20ddb
Diffstat (limited to 'libreofficekit/qa')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 67 |
1 files changed, 2 insertions, 65 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 194ee41c3c8f..9c1c7ed6ce38 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -12,16 +12,12 @@ #include <string.h> #include <gdk/gdk.h> -#include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> #include <LibreOfficeKit/LibreOfficeKitGtk.h> #include <LibreOfficeKit/LibreOfficeKitInit.h> #include <LibreOfficeKit/LibreOfficeKitEnums.h> -#include <com/sun/star/awt/Key.hpp> -#include <rsc/rsc-vcl-shared-types.hxx> - #ifndef g_info #define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__) #endif @@ -119,65 +115,6 @@ void toggleBold(GtkWidget* /*pButton*/, gpointer /*pItem*/) lok_docview_post_command(pLOKDocView, ".uno:Bold"); } -/// Receives a key press or release event. -static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/) -{ - LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView); - int nCharCode = 0; - int nKeyCode = 0; - - if (!lok_docview_get_edit(pLOKDocView)) - { - g_info("signalKey: not in edit mode, ignore"); - return; - } - - switch (pEvent->keyval) - { - case GDK_BackSpace: - nKeyCode = com::sun::star::awt::Key::BACKSPACE; - break; - case GDK_Return: - nKeyCode = com::sun::star::awt::Key::RETURN; - break; - case GDK_Escape: - nKeyCode = com::sun::star::awt::Key::ESCAPE; - break; - case GDK_Tab: - nKeyCode = com::sun::star::awt::Key::TAB; - break; - case GDK_Down: - nKeyCode = com::sun::star::awt::Key::DOWN; - break; - case GDK_Up: - nKeyCode = com::sun::star::awt::Key::UP; - break; - case GDK_Left: - nKeyCode = com::sun::star::awt::Key::LEFT; - break; - case GDK_Right: - nKeyCode = com::sun::star::awt::Key::RIGHT; - break; - default: - if (pEvent->keyval >= GDK_F1 && pEvent->keyval <= GDK_F26) - nKeyCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_F1); - else - nCharCode = gdk_keyval_to_unicode(pEvent->keyval); - } - - // rsc is not public API, but should be good enough for debugging purposes. - // If this is needed for real, then probably a new param of type - // css::awt::KeyModifier is needed in postKeyEvent(). - if (pEvent->state & GDK_SHIFT_MASK) - nKeyCode |= KEY_SHIFT; - - LibreOfficeKitDocument* pDocument = lok_docview_get_document(pLOKDocView); - if (pEvent->type == GDK_KEY_RELEASE) - pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode); - else - pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode); -} - // GtkComboBox requires gtk 2.24 or later #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 void populatePartSelector() @@ -330,8 +267,8 @@ int main( int argc, char* argv[] ) g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL); // Input handling. - g_signal_connect(pWindow, "key-press-event", G_CALLBACK(signalKey), NULL); - g_signal_connect(pWindow, "key-release-event", G_CALLBACK(signalKey), NULL); + g_signal_connect(pWindow, "key-press-event", G_CALLBACK(lok_docview_post_key), pDocView); + g_signal_connect(pWindow, "key-release-event", G_CALLBACK(lok_docview_post_key), pDocView); gtk_container_add( GTK_CONTAINER(pVBox), pDocView ); |