[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - include/LibreOfficeKit libreofficekit/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jan 27 05:38:04 PST 2015
include/LibreOfficeKit/LibreOfficeKitGtk.h | 2 ++
libreofficekit/source/gtk/lokdocview.c | 25 +++++++++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
New commits:
commit ba5011bcffc83bcf9e6e55f96b6d56e60d81c676
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 27 14:36:12 2015 +0100
lokdocview: let the cursor blink
Change-Id: I935fe7f09a5a6efcbfd246b0f24eba5226f61fb2
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 75278e7..ea9c9de 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -45,6 +45,8 @@ struct _LOKDocView
gboolean m_bEdit;
/// Position and size of the visible cursor.
GdkRectangle m_aVisibleCursor;
+ /// Cursor is visible or hidden (for blinking).
+ gboolean m_bCursorVisible;
};
struct _LOKDocViewClass
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index e9a440e..40fe474 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -16,8 +16,9 @@
#include <LibreOfficeKit/LibreOfficeKitGtk.h>
-#ifndef G_SOURCE_REMOVE
+#if !GLIB_CHECK_VERSION(2,32,0)
#define G_SOURCE_REMOVE FALSE
+#define G_SOURCE_CONTINUE TRUE
#endif
static void lok_docview_class_init( LOKDocViewClass* pClass );
@@ -111,6 +112,7 @@ static void lok_docview_init( LOKDocView* pDocView )
pDocView->fZoom = 1;
pDocView->m_bEdit = FALSE;
memset(&pDocView->m_aVisibleCursor, 0, sizeof(pDocView->m_aVisibleCursor));
+ pDocView->m_bCursorVisible = FALSE;
gtk_signal_connect( GTK_OBJECT(pDocView), "destroy",
GTK_SIGNAL_FUNC(lcl_onDestroy), NULL );
@@ -145,6 +147,23 @@ static gboolean lcl_isEmptyRectangle(GdkRectangle* pRectangle)
return pRectangle->x == 0 && pRectangle->y == 0 && pRectangle->width == 0 && pRectangle->height == 0;
}
+/// Takes care of the blinking cursor.
+static gboolean lcl_handleTimeout(gpointer pData)
+{
+ LOKDocView* pDocView = pData;
+
+ if (pDocView->m_bEdit)
+ {
+ if (pDocView->m_bCursorVisible)
+ pDocView->m_bCursorVisible = FALSE;
+ else
+ pDocView->m_bCursorVisible = TRUE;
+ gtk_widget_queue_draw(GTK_WIDGET(pDocView->pEventBox));
+ }
+
+ return G_SOURCE_CONTINUE;
+}
+
static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpointer pData)
{
LOKDocView* pDocView = pData;
@@ -153,7 +172,7 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
(void)pEvent;
pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
- if (!lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
+ if (pDocView->m_bCursorVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
{
if (pDocView->m_aVisibleCursor.width == 0)
// Set a minimal width if it would be 0.
@@ -331,6 +350,7 @@ static gboolean lok_docview_callback(gpointer pData)
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
pCallback->m_pDocView->m_aVisibleCursor = lcl_payloadToRectangle(pCallback->m_pPayload);
+ pCallback->m_pDocView->m_bCursorVisible = TRUE;
gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->pEventBox));
}
break;
@@ -437,6 +457,7 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_edit( LOKDocView* pDocView,
{
g_info("lok_docview_set_edit: entering edit mode, registering callback");
pDocView->pDocument->pClass->registerCallback(pDocView->pDocument, &lok_docview_callback_worker, pDocView);
+ g_timeout_add(600, &lcl_handleTimeout, pDocView);
}
pDocView->m_bEdit = bEdit;
}
More information about the Libreoffice-commits
mailing list