Rebased ref, commits from common ancestor: commit c0aca9496957c50fad48c6d007810b9a2fbb3926 Author: Pranav Kant <pran...@gnome.org> Date: Sat Aug 15 18:48:53 2015 +0530
Widget registration Change-Id: I1749b5b02018cfe6f85a13aed8de4b31a09788e3 diff --git a/configure.ac b/configure.ac index 7b0f031..fe9e070 100644 --- a/configure.ac +++ b/configure.ac @@ -201,6 +201,11 @@ SRC_ROOT=`pwd` cd $BUILDDIR x_Cygwin=[\#] +dnl ====================================== +dnl Required GObject introspection version +dnl ====================================== +INTROSPECTION_REQUIRED_VERSION=1.32.0 + dnl =================================================================== dnl Search all the common names for GNU Make dnl =================================================================== @@ -9992,6 +9997,7 @@ if test "x$enable_gtk3" = "xyes"; then PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.2 gtk+-unix-print-3.0 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo, ENABLE_GTK3="TRUE", ENABLE_GTK3="") if test "x$ENABLE_GTK3" = "xTRUE"; then R="gtk3" + GOBJECT_INTROSPECTION_CHECK(INTROSPECTION_REQUIRED_VERSION) else AC_MSG_ERROR([gtk3 or dependent libraries of the correct versions, not found]) fi diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..aa7b3b4 --- /dev/null +++ b/m4/introspection.m4 @@ -0,0 +1,96 @@ +dnl -*- mode: autoconf -*- +dnl Copyright 2009 Johan Dahlin +dnl +dnl This file is free software; the author(s) gives unlimited +dnl permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl + +# serial 1 + +m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], +[ + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([LT_INIT],[$0])dnl setup libtool first + + dnl enable/disable introspection + m4_if([$2], [require], + [dnl + enable_introspection=yes + ],[dnl + AC_ARG_ENABLE(introspection, + AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], + [Enable introspection for this build]),, + [enable_introspection=auto]) + ])dnl + + AC_MSG_CHECKING([for gobject-introspection]) + + dnl presence/version checking + AS_CASE([$enable_introspection], + [no], [dnl + found_introspection="no (disabled, use --enable-introspection to enable)" + ],dnl + [yes],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0],, + AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], + found_introspection=yes, + AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) + ],dnl + [auto],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) + dnl Canonicalize enable_introspection + enable_introspection=$found_introspection + ],dnl + [dnl + AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) + ])dnl + + AC_MSG_RESULT([$found_introspection]) + + INTROSPECTION_SCANNER= + INTROSPECTION_COMPILER= + INTROSPECTION_GENERATE= + INTROSPECTION_GIRDIR= + INTROSPECTION_TYPELIBDIR= + if test "x$found_introspection" = "xyes"; then + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` + INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` + INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` + INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` + INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection + fi + AC_SUBST(INTROSPECTION_SCANNER) + AC_SUBST(INTROSPECTION_COMPILER) + AC_SUBST(INTROSPECTION_GENERATE) + AC_SUBST(INTROSPECTION_GIRDIR) + AC_SUBST(INTROSPECTION_TYPELIBDIR) + AC_SUBST(INTROSPECTION_CFLAGS) + AC_SUBST(INTROSPECTION_LIBS) + AC_SUBST(INTROSPECTION_MAKEFILE) + + AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +]) + + +dnl Usage: +dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) + +AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) +]) + +dnl Usage: +dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) + + +AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) +]) diff --git a/sysui/desktop/share/create_tree.sh b/sysui/desktop/share/create_tree.sh index c6be0bb..04b5202 100755 --- a/sysui/desktop/share/create_tree.sh +++ b/sysui/desktop/share/create_tree.sh @@ -87,3 +87,15 @@ for i in base calc draw impress writer; do cp "${APPDATA_SOURCE_DIR}/libreoffice-${i}.appdata.xml" "${DESTDIR}/${PREFIXDIR}/share/appdata/${PREFIX}-${i}.appdata.xml" done +# Generate gobject-introspection files +mkdir -p "${DESTDIR}/${PREFIXDIR}/share/gir-1.0" +"${INTROSPECTION_SCANNER}" "${SRCDIR}/include/LibreOfficeKit/LibreOfficeKitGtk.h" "${SRCDIR}/libreofficekit/source/gtk/lokdocview.cxx" \ + "${INTROSPECTION_CFLAGS}" -I"${SRCDIR}/include/" --include=GLib-2.0 --include=GObject-2.0 --include=Gio-2.0 \ + --library=libreofficekitgtk --library-path="${INSTALLDIR}/program/libreofficekitgtk" \ + --include=Gdk-3.0 --include=GdkPixbuf-2.0 --include=Gtk-3.0 \ + --namespace=LOKDocView --nsversion=0.1 --identifier-prefix=LOKDoc --symbol-prefix=lok_doc \ + --output="${DESTDIR}/${PREFIXDIR}/share/gir-1.0/LOKDocView-0.1.gir" --warn-all --no-libtool + +mkdir -p "${DESTDIR}/${PREFIXDIR}/${LIBDIR}/girepository-1.0" +"${INTROSPECTION_COMPILER}" "${DESTDIR}/${PREFIXDIR}/share/gir-1.0/LOKDocView-0.1.gir" \ + --output="${DESTDIR}/${PREFIXDIR}/${LIBDIR}/girepository-1.0/LOKDocView-0.1.typelib" commit 69c2fce42bca9f0ff50e99bf05a141b1d24492b2 Author: Pranav Kant <pran...@gnome.org> Date: Sat Aug 15 18:48:11 2015 +0530 gtktiledviewer: Jump to cursor position when it changes Change-Id: If50ac0bd21e59b0e0639aa353513451e88ae2a9f diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 73db976..8de7110 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -57,6 +57,25 @@ static void lcl_registerToolItem(GtkToolItem* pItem, const std::string& rName) const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 }; + +/// Get the visible area of the scrolled window +static void getVisibleAreaTwips(GdkRectangle* pArea) +{ +#if GTK_CHECK_VERSION(2,14,0) // we need gtk_adjustment_get_page_size() + GtkAdjustment* pHAdjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow)); + GtkAdjustment* pVAdjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow)); + + pArea->x = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), + gtk_adjustment_get_value(pHAdjustment)); + pArea->y = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), + gtk_adjustment_get_value(pVAdjustment)); + pArea->width = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), + gtk_adjustment_get_page_size(pHAdjustment)); + pArea->height = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), + gtk_adjustment_get_page_size(pVAdjustment)); +#endif +} + static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ) { const char *sName = gtk_tool_button_get_icon_name( GTK_TOOL_BUTTON(pButton) ); @@ -175,23 +194,6 @@ static void doCopy(GtkWidget* /*pButton*/, gpointer /*pItem*/) free(pUsedFormat); } -/// Get the visible area of the scrolled window -static void getVisibleAreaTwips(GdkRectangle* pArea) -{ -#if GTK_CHECK_VERSION(2,14,0) // we need gtk_adjustment_get_page_size() - GtkAdjustment* pHAdjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow)); - GtkAdjustment* pVAdjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow)); - - pArea->x = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), - gtk_adjustment_get_value(pHAdjustment)); - pArea->y = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), - gtk_adjustment_get_value(pVAdjustment)); - pArea->width = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), - gtk_adjustment_get_page_size(pHAdjustment)); - pArea->height = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), - gtk_adjustment_get_page_size(pVAdjustment)); -#endif -} /// Searches for the next or previous text of pFindbarEntry. static void doSearch(bool bBackwards) @@ -319,6 +321,54 @@ static void signalHyperlink(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointe } } +/// Cursor position changed +static void cursorChanged(LOKDocView* /*pDocView*/, gint nX, gint nY, + gint /*nWidth*/, gint /*nHeight*/, gpointer /*pData*/) +{ + GtkAdjustment* vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow)); + GtkAdjustment* hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(pScrolledWindow)); + GdkRectangle visArea; + gdouble upper; + gint x = -1, y = -1; + + getVisibleAreaTwips(&visArea); + + // check vertically + if (nY < visArea.y) + { + y = nY - visArea.height/2; + if (y < 0) + y = gtk_adjustment_get_lower(vadj); + } + else if (nY > visArea.y + visArea.height) + { + y = nY - visArea.height/2; + upper = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), gtk_adjustment_get_upper(vadj)); + if (y > upper) + y = upper; + + } + + if (nX < visArea.x) + { + x = nX - visArea.width/2; + if (x < 0) + x = gtk_adjustment_get_lower(hadj); + } + else if (nX > visArea.x + visArea.width) + { + x = nX - visArea.width/2; + upper = lok_doc_view_pixel_to_twip(LOK_DOC_VIEW(pDocView), gtk_adjustment_get_upper(hadj)); + if (x > upper) + x = upper; + } + + if (y!=-1) + gtk_adjustment_set_value(vadj, lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), y)); + if (x!=-1) + gtk_adjustment_set_value(hadj, lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), x)); +} + static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/) { if (g_bToolItemBroadcast) @@ -576,6 +626,7 @@ int main( int argc, char* argv[] ) g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL); g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL); g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL); + g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), NULL); // Scrolled window for DocView diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 8a2e4a2..7f2dc73 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -117,6 +117,7 @@ enum PART_CHANGED, SIZE_CHANGED, HYPERLINK_CLICKED, + CURSOR_CHANGED, LAST_SIGNAL }; @@ -518,6 +519,11 @@ callback (gpointer pData) { priv->m_aVisibleCursor = payloadToRectangle(pDocView, pCallback->m_aPayload.c_str()); priv->m_bCursorOverlayVisible = true; + g_signal_emit(pDocView, doc_view_signals[CURSOR_CHANGED], 0, + priv->m_aVisibleCursor.x, + priv->m_aVisibleCursor.y, + priv->m_aVisibleCursor.width, + priv->m_aVisibleCursor.height); gtk_widget_queue_draw(GTK_WIDGET(pDocView)); } break; @@ -1743,6 +1749,25 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + + /** + * LOKDocView::cursor-changed: + * @pDocView: the #LOKDocView on which the signal is emitted + * @nX: The new cursor position (X coordinate) in pixels + * @nY: The new cursor position (Y coordinate) in pixels + * @nWidth: The width of new cursor + * @nHeight: The height of new cursor + */ + doc_view_signals[CURSOR_CHANGED] = + g_signal_new("cursor-changed", + G_TYPE_FROM_CLASS(pGObjectClass), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_generic, + G_TYPE_NONE, 4, + G_TYPE_INT, G_TYPE_INT, + G_TYPE_INT, G_TYPE_INT); } /** _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits