[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - include/LibreOfficeKit libreofficekit/qa libreofficekit/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jan 13 07:51:16 PST 2015
include/LibreOfficeKit/LibreOfficeKitGtk.h | 5 +++++
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 14 +++++++++++++-
libreofficekit/source/gtk/lokdocview.c | 14 +++++++++++++-
3 files changed, 31 insertions(+), 2 deletions(-)
New commits:
commit 66e6ca74cfe461bb2599f2e218b7e2313f16da65
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 13 16:47:23 2015 +0100
gtktiledviewer: start in viewer mode, switch to edit mode by mouse click
Change-Id: I0863ec8fb159a2e367951ba9e7d7310d250d8a1e
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 111381d..3fd0c4a 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -41,6 +41,8 @@ struct _LOKDocView
LibreOfficeKit* pOffice;
LibreOfficeKitDocument* pDocument;
+ /// View or edit mode.
+ gboolean m_bEdit;
};
struct _LOKDocViewClass
@@ -64,6 +66,9 @@ char* lok_docview_get_part_name (LOKDocView* pDocView,
int nPart);
void lok_docview_set_partmode (LOKDocView* pDocView,
LibreOfficeKitPartMode ePartMode);
+/// Sets if the viewer is actually an editor or not.
+void lok_docview_set_edit (LOKDocView* pDocView,
+ gboolean bEdit);
#ifdef __cplusplus
}
#endif
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index e1e9e4f..2be201f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -131,8 +131,11 @@ void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ )
static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/)
{
LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
-
int nCode = 0;
+
+ if (!pLOKDocView->m_bEdit)
+ return;
+
switch (pEvent->keyval)
{
case GDK_BackSpace:
@@ -154,6 +157,14 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD
pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, LOK_KEYEVENT_KEYINPUT, nCode);
}
+/// Receives a button press event.
+static void signalButton(GtkWidget* /*pWidget*/, GdkEvent* /*pEvent*/, gpointer /*pData*/)
+{
+ LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
+
+ lok_docview_set_edit(pLOKDocView, TRUE);
+}
+
// GtkComboBox requires gtk 2.24 or later
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
void populatePartSelector()
@@ -311,6 +322,7 @@ int main( int argc, char* argv[] )
// 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(pDocView, "button-press-event", G_CALLBACK(signalButton), NULL);
gtk_container_add( GTK_CONTAINER(pVBox), pDocView );
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 2e4226c..d373235 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -71,6 +71,9 @@ static void lok_docview_init( LOKDocView* pDocView )
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
pDocView->pEventBox );
+ // Allow reacting to button press events.
+ gtk_widget_set_events(pDocView->pEventBox, GDK_BUTTON_PRESS_MASK);
+
pDocView->pCanvas = gtk_image_new();
gtk_container_add( GTK_CONTAINER( pDocView->pEventBox ), pDocView->pCanvas );
@@ -84,6 +87,7 @@ static void lok_docview_init( LOKDocView* pDocView )
pDocView->pDocument = 0;
pDocView->fZoom = 1;
+ pDocView->m_bEdit = FALSE;
gtk_signal_connect( GTK_OBJECT(pDocView), "destroy",
GTK_SIGNAL_FUNC(lcl_onDestroy), NULL );
@@ -212,7 +216,6 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
{
pDocView->pDocument->pClass->initializeForRendering(pDocView->pDocument);
renderDocument( pDocView );
- pDocView->pDocument->pClass->registerCallback(pDocView->pDocument, &lok_docview_callback_worker, pDocView);
}
return TRUE;
@@ -261,4 +264,13 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_partmode( LOKDocView* pDocView,
pDocView->pDocument->pClass->setPartMode( pDocView->pDocument, ePartMode );
renderDocument( pDocView );
}
+
+SAL_DLLPUBLIC_EXPORT void lok_docview_set_edit( LOKDocView* pDocView,
+ gboolean bEdit )
+{
+ if (!pDocView->m_bEdit && bEdit)
+ pDocView->pDocument->pClass->registerCallback(pDocView->pDocument, &lok_docview_callback_worker, pDocView);
+ pDocView->m_bEdit = bEdit;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list