[Libreoffice-commits] core.git: Branch 'feature/gsoc-tiled-rendering' - 5 commits - include/LibreOfficeKit libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/source

Pranav Kant pranavk at gnome.org
Wed Jun 10 09:06:21 PDT 2015


Rebased ref, commits from common ancestor:
commit cbd5da28e3e297ad534cf0c8fdd29036b3dfb081
Author: Pranav Kant <pranavk at gnome.org>
Date:   Wed Jun 10 20:59:18 2015 +0530

    gtktiledviewer: Replace deprecated Gtk functions
    
    Change-Id: I354aa987f8e732945fb552d855a3416c782bb508

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index b1fd637..3b3645f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -57,7 +57,7 @@ const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 };
 
 static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
 {
-    const char *sName = gtk_tool_button_get_stock_id( GTK_TOOL_BUTTON(pButton) );
+    const char *sName = gtk_tool_button_get_icon_name( GTK_TOOL_BUTTON(pButton) );
 
     float fZoom = 0;
     float fCurrentZoom = 0;
@@ -67,7 +67,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
         fCurrentZoom = lok_doc_view_get_zoom( LOK_DOC_VIEW(pDocView) );
     }
 
-    if ( strcmp(sName, "gtk-zoom-in") == 0)
+    if ( strcmp(sName, "zoom-in-symbolic") == 0)
     {
         for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
         {
@@ -78,11 +78,11 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
             }
         }
     }
-    else if ( strcmp(sName, "gtk-zoom-100") == 0)
+    else if ( strcmp(sName, "zoom-original-symbolic") == 0)
     {
         fZoom = 1;
     }
-    else if ( strcmp(sName, "gtk-zoom-out") == 0)
+    else if ( strcmp(sName, "zoom-out-symbolic") == 0)
     {
         for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
         {
@@ -351,22 +351,25 @@ int main( int argc, char* argv[] )
     gtk_window_set_default_size(GTK_WINDOW(pWindow), 1024, 768);
     g_signal_connect( pWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL );
 
-    pVBox = gtk_vbox_new( FALSE, 0 );
+    pVBox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
     gtk_container_add( GTK_CONTAINER(pWindow), pVBox );
 
     // Toolbar
     GtkWidget* pToolbar = gtk_toolbar_new();
     gtk_toolbar_set_style( GTK_TOOLBAR(pToolbar), GTK_TOOLBAR_ICONS );
 
-    GtkToolItem* pZoomIn = gtk_tool_button_new_from_stock( GTK_STOCK_ZOOM_IN );
+    GtkToolItem* pZoomIn = gtk_tool_button_new( NULL, NULL );
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoomIn), "zoom-in-symbolic");
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomIn, 0);
     g_signal_connect( G_OBJECT(pZoomIn), "clicked", G_CALLBACK(changeZoom), NULL );
 
-    GtkToolItem* pZoom1 = gtk_tool_button_new_from_stock( GTK_STOCK_ZOOM_100 );
+    GtkToolItem* pZoom1 = gtk_tool_button_new( NULL, NULL );
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoom1), "zoom-original-symbolic");
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoom1, -1);
     g_signal_connect( G_OBJECT(pZoom1), "clicked", G_CALLBACK(changeZoom), NULL );
 
-    GtkToolItem* pZoomOut = gtk_tool_button_new_from_stock( GTK_STOCK_ZOOM_OUT );
+    GtkToolItem* pZoomOut = gtk_tool_button_new( NULL, NULL );
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoomOut), "zoom-out-symbolic");
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomOut, -1);
     g_signal_connect( G_OBJECT(pZoomOut), "clicked", G_CALLBACK(changeZoom), NULL );
 
@@ -389,27 +392,38 @@ int main( int argc, char* argv[] )
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 );
 
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
-    pEnableEditing = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_EDIT);
+    pEnableEditing = gtk_toggle_tool_button_new();
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pEnableEditing), "insert-text-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pEnableEditing, -1);
     g_signal_connect(G_OBJECT(pEnableEditing), "toggled", G_CALLBACK(toggleEditing), NULL);
-    GtkToolItem* pFindButton = gtk_tool_button_new_from_stock(GTK_STOCK_FIND);
+
+    GtkToolItem* pFindButton = gtk_tool_button_new( NULL, NULL);
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindButton), "edit-find-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pFindButton, -1);
     g_signal_connect(G_OBJECT(pFindButton), "clicked", G_CALLBACK(toggleFindbar), NULL);
 
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
-    pBold = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_BOLD);
+
+    pBold = gtk_toggle_tool_button_new();
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pBold), "format-text-bold-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pBold, -1);
     g_signal_connect(G_OBJECT(pBold), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pBold, ".uno:Bold");
-    pItalic = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_ITALIC);
+
+    pItalic = gtk_toggle_tool_button_new();
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pItalic), "format-text-italic-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pItalic, -1);
     g_signal_connect(G_OBJECT(pItalic), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pItalic, ".uno:Italic");
-    pUnderline = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_UNDERLINE);
+
+    pUnderline = gtk_toggle_tool_button_new();
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pUnderline), "format-text-underline-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pUnderline, -1);
     g_signal_connect(G_OBJECT(pUnderline), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pUnderline, ".uno:Underline");
-    pStrikethrough = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_STRIKETHROUGH);
+
+    pStrikethrough = gtk_toggle_tool_button_new ();
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pStrikethrough), "format-text-strikethrough-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pStrikethrough, -1);
     g_signal_connect(G_OBJECT(pStrikethrough), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pStrikethrough, ".uno:Strikeout");
@@ -420,7 +434,8 @@ int main( int argc, char* argv[] )
     pFindbar = gtk_toolbar_new();
     gtk_toolbar_set_style(GTK_TOOLBAR(pFindbar), GTK_TOOLBAR_ICONS);
 
-    GtkToolItem* pFindbarClose = gtk_tool_button_new_from_stock(GTK_STOCK_CLOSE);
+    GtkToolItem* pFindbarClose = gtk_tool_button_new( NULL, NULL);
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindbarClose), "window-close-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarClose, -1);
     g_signal_connect(G_OBJECT(pFindbarClose), "clicked", G_CALLBACK(toggleFindbar), NULL);
 
@@ -430,10 +445,13 @@ int main( int argc, char* argv[] )
     g_signal_connect(pFindbarEntry, "key-press-event", G_CALLBACK(signalFindbar), 0);
     gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pEntryContainer, -1);
 
-    GtkToolItem* pFindbarNext = gtk_tool_button_new_from_stock(GTK_STOCK_GO_DOWN);
+    GtkToolItem* pFindbarNext = gtk_tool_button_new( NULL, NULL);
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindbarNext), "go-down-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarNext, -1);
     g_signal_connect(G_OBJECT(pFindbarNext), "clicked", G_CALLBACK(signalSearchNext), NULL);
-    GtkToolItem* pFindbarPrev = gtk_tool_button_new_from_stock(GTK_STOCK_GO_UP);
+
+    GtkToolItem* pFindbarPrev = gtk_tool_button_new( NULL, NULL);
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindbarPrev), "go-up-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarPrev, -1);
     g_signal_connect(G_OBJECT(pFindbarPrev), "clicked", G_CALLBACK(signalSearchPrev), NULL);
 
@@ -463,8 +481,7 @@ int main( int argc, char* argv[] )
     gtk_widget_set_vexpand (pScrolledWindow, TRUE);
     gtk_container_add(GTK_CONTAINER(pVBox), pScrolledWindow);
 
-    // DocView doesn't have scrolling capability, so need a viewport
-    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pScrolledWindow), pDocView);
+    gtk_container_add(GTK_CONTAINER(pScrolledWindow), pDocView);
 
     gtk_widget_show_all( pWindow );
     // Hide the findbar by default.
commit d4f19dead380f1f6b7ecdf6fb6f440effdff5825
Author: Pranav Kant <pranavk at gnome.org>
Date:   Wed Jun 10 16:57:19 2015 +0530

    lokdocview, gtktiledviewer: Remove gtk version checks
    
    We already have the global ENABLE_GTK3 guard for RHEL5 baseline.
    
    Change-Id: Id814a4063861a1e750952b44686ed24864c0394f

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index f389f7d..b1fd637 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -40,12 +40,9 @@ std::map<GtkToolItem*, std::string> g_aToolItemCommandNames;
 std::map<std::string, GtkToolItem*> g_aCommandNameToolItems;
 bool g_bToolItemBroadcast = true;
 static GtkWidget* pVBox;
-// GtkComboBox requires gtk 2.24 or later
-#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
 static GtkComboBoxText* pPartSelector;
 /// Should the part selector avoid calling lok::Document::setPart()?
 static bool g_bPartSelectorBroadcast = true;
-#endif
 GtkWidget* pFindbar;
 GtkWidget* pFindbarEntry;
 GtkWidget* pFindbarLabel;
@@ -117,7 +114,6 @@ static void toggleEditing(GtkWidget* /*pButton*/, gpointer /*pItem*/)
 /// Toggle the visibility of the findbar.
 static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
 {
-#if GTK_CHECK_VERSION(2,18,0) // we need gtk_widget_get_visible()
     if (gtk_widget_get_visible(pFindbar))
     {
         gtk_widget_hide(pFindbar);
@@ -127,7 +123,6 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
         gtk_widget_show_all(pFindbar);
         gtk_widget_grab_focus(pFindbarEntry);
     }
-#endif
 }
 
 /// Get the visible area of the scrolled window
@@ -151,13 +146,11 @@ static void getVisibleAreaTwips(GdkRectangle* pArea)
 static gboolean signalKey(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer pData)
 {
     LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
-#if GTK_CHECK_VERSION(2,18,0) // we need gtk_widget_get_visible()
     if (!gtk_widget_get_visible(pFindbar) && bool(lok_doc_view_get_edit(pLOKDocView)))
         {
             lok_doc_view_post_key(pWidget, pEvent, pData);
             return TRUE;
         }
-#endif
     return FALSE;
 }
 
@@ -263,11 +256,9 @@ static void signalSearch(LOKDocView* /*pLOKDocView*/, char* /*pPayload*/, gpoint
 
 static void signalPart(LOKDocView* /*pLOKDocView*/, int nPart, gpointer /*pData*/)
 {
-#if GTK_CHECK_VERSION(2,24,0)
     g_bPartSelectorBroadcast = false;
     gtk_combo_box_set_active(GTK_COMBO_BOX(pPartSelector), nPart);
     g_bPartSelectorBroadcast = true;
-#endif
 }
 
 /// User clicked on a cmmand button -> inform LOKDocView.
@@ -283,8 +274,6 @@ static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
     }
 }
 
-// GtkComboBox requires gtk 2.24 or later
-#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
 static void populatePartSelector()
 {
     gtk_list_store_clear( GTK_LIST_STORE(
@@ -342,7 +331,6 @@ static void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
         lok_doc_view_set_partmode( LOK_DOC_VIEW(pDocView), ePartMode );
     }
 }
-#endif
 
 int main( int argc, char* argv[] )
 {
@@ -385,8 +373,6 @@ int main( int argc, char* argv[] )
     GtkToolItem* pSeparator1 = gtk_separator_tool_item_new();
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pSeparator1, -1);
 
-// GtkComboBox requires gtk 2.24 or later
-#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
     GtkToolItem* pPartSelectorToolItem = gtk_tool_item_new();
     GtkWidget* pComboBox = gtk_combo_box_text_new();
     gtk_container_add( GTK_CONTAINER(pPartSelectorToolItem), pComboBox );
@@ -401,7 +387,6 @@ int main( int argc, char* argv[] )
     GtkWidget* pPartModeComboBox = gtk_combo_box_text_new();
     gtk_container_add( GTK_CONTAINER(pPartModeSelectorToolItem), pPartModeComboBox );
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 );
-#endif
 
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
     pEnableEditing = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_EDIT);
@@ -490,15 +475,11 @@ int main( int argc, char* argv[] )
         g_error("main: lok_doc_view_open_document() failed");
     assert(lok_doc_view_get_document(LOK_DOC_VIEW(pDocView)));
 
-    // GtkComboBox requires gtk 2.24 or later
-#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
     populatePartSelector();
     populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) );
     // Connect these signals after populating the selectors, to avoid re-rendering on setting the default part/partmode.
     g_signal_connect(G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), 0);
-
     g_signal_connect(G_OBJECT(pPartSelector), "changed", G_CALLBACK(changePart), 0);
-#endif
 
     gtk_main();
 
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 33b011a..f4f30f4 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -648,7 +648,6 @@ gboolean LOKDocView_Impl::renderOverlay(GtkWidget* /*widget*/, cairo_t *cr, gpoi
 
 gboolean LOKDocView_Impl::renderOverlayImpl(cairo_t *pCairo)
 {
-#if GTK_CHECK_VERSION(2,14,0) // we need gtk_widget_get_window()
     if (m_bEdit && m_bCursorVisible && m_bCursorOverlayVisible && !isEmptyRectangle(m_aVisibleCursor))
     {
         if (m_aVisibleCursor.width < 30)
@@ -710,7 +709,6 @@ gboolean LOKDocView_Impl::renderOverlayImpl(cairo_t *pCairo)
         renderGraphicHandle(pCairo, m_aGraphicSelection, m_pGraphicHandle);
     }
 
-#endif
     return FALSE;
 }
 
@@ -1014,9 +1012,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
     case LOK_CALLBACK_HYPERLINK_CLICKED:
     {
         GError* pError = NULL;
-#if GTK_CHECK_VERSION(2,14,0)
         gtk_show_uri(NULL, pCallback->m_aPayload.c_str(), GDK_CURRENT_TIME, &pError);
-#endif
     }
     break;
     case LOK_CALLBACK_STATE_CHANGED:
@@ -1067,22 +1063,16 @@ void LOKDocView_Impl::callbackWorkerImpl(int nType, const char* pPayload)
 {
     LOKDocView_Impl::CallbackData* pCallback = new LOKDocView_Impl::CallbackData(nType, pPayload ? pPayload : "(nil)", m_pDocView);
     g_info("lok_doc_view_callback_worker: %s, '%s'", LOKDocView_Impl::callbackTypeToString(nType), pPayload);
-#if GTK_CHECK_VERSION(2,12,0)
     gdk_threads_add_idle(LOKDocView_Impl::callback, pCallback);
-#endif
 }
 
 void LOKDocView_Impl::globalCallbackWorkerImpl(int nType, const char* pPayload)
 {
     LOKDocView_Impl::CallbackData* pCallback = new LOKDocView_Impl::CallbackData(nType, pPayload ? pPayload : "(nil)", m_pDocView);
     g_info("LOKDocView_Impl::globalCallbackWorkerImpl: %s, '%s'", LOKDocView_Impl::callbackTypeToString(nType), pPayload);
-#if GTK_CHECK_VERSION(2,12,0)
     gdk_threads_add_idle(LOKDocView_Impl::globalCallback, pCallback);
-#endif
 }
 
-
-
 void LOKDocView_Impl::commandChanged(const std::string& rString)
 {
     g_signal_emit(m_pDocView, doc_view_signals[COMMAND_CHANGED], 0, rString.c_str());
commit 4c8bf4f82dfc8630d0ec20fd07533c124f065bee
Author: Pranav Kant <pranavk at gnome.org>
Date:   Wed Jun 10 16:28:45 2015 +0530

    lokdocview: Port to gtk3; 'expose-event' -> 'draw'
    
    Change-Id: I8d2541f5cbd2b908c2b0dc52cccf9b936bbc307a

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 33d46ac..f389f7d 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -474,6 +474,8 @@ int main( int argc, char* argv[] )
 
     // Scrolled window for DocView
     pScrolledWindow = gtk_scrolled_window_new(0, 0);
+    gtk_widget_set_hexpand (pScrolledWindow, TRUE);
+    gtk_widget_set_vexpand (pScrolledWindow, TRUE);
     gtk_container_add(GTK_CONTAINER(pVBox), pScrolledWindow);
 
     // DocView doesn't have scrolling capability, so need a viewport
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index be3e424..33b011a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -116,8 +116,10 @@ struct LOKDocView_Impl
     ~LOKDocView_Impl();
     /// Connected to the destroy signal of LOKDocView, deletes its LOKDocView_Impl.
     static void destroy(LOKDocView* pDocView, gpointer pData);
-    /// Connected to the expose-event of the GtkDrawingArea
-    static void onExposed(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
+    /// Connected to the draw of the GtkDrawingArea
+    static gboolean renderDocument(GtkWidget *widget, cairo_t *cr, gpointer user_data);
+    /// Implementation of draw event handler, invoked by renderDocument().
+    gboolean renderDocumentImpl(cairo_t* cr);
     /// Receives a key press or release event.
     void signalKey(GdkEventKey* pEvent);
     /*
@@ -138,9 +140,9 @@ struct LOKDocView_Impl
     /// Implementation of motion event handler, invoked by signalMotion().
     gboolean signalMotionImpl(GdkEventButton* pEvent);
     /// Receives an expose event.
-    static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, LOKDocView* pDocView);
+    static gboolean renderOverlay(GtkWidget* pWidget, cairo_t* cr, gpointer userdata);
     /// Implementation of expose event handler (renders cursor and selection overlay), invoked by renderOverlay().
-    gboolean renderOverlayImpl(GtkWidget* pEventBox);
+    gboolean renderOverlayImpl(cairo_t *cr);
     /// Is rRectangle empty?
     static bool isEmptyRectangle(const GdkRectangle& rRectangle);
     /*
@@ -154,8 +156,6 @@ struct LOKDocView_Impl
     static gboolean handleTimeout(gpointer pData);
     /// Implementation of the timeout handler, invoked by handleTimeout().
     gboolean handleTimeoutImpl();
-    /// Implementation of expose event handler, invoked by onExposed().
-    void onExposedImpl(GdkEventExpose* event);
     /// Returns the GdkRectangle of a x,y,width,height string.
     GdkRectangle payloadToRectangle(const char* pPayload);
     /// Returns the GdkRectangles of a x1,y1,w1,h1;x2,y2,w2,h2;... string.
@@ -317,21 +317,22 @@ void LOKDocView_Impl::destroy(LOKDocView* pDocView, gpointer /*pData*/)
     delete pDocView->m_pImpl;
 }
 
-void LOKDocView_Impl::onExposed(GtkWidget* /*widget*/, GdkEventExpose* event, gpointer userdata)
+gboolean LOKDocView_Impl::renderDocument(GtkWidget* /*widget*/, cairo_t *cr, gpointer userdata)
 {
     LOKDocView *pDocView = LOK_DOC_VIEW (userdata);
-    pDocView->m_pImpl->onExposedImpl(event);
+    return pDocView->m_pImpl->renderDocumentImpl(cr);
 }
 
-void LOKDocView_Impl::onExposedImpl(GdkEventExpose* event)
+gboolean LOKDocView_Impl::renderDocumentImpl(cairo_t *pCairo)
 {
     long nDocumentWidthPixels = twipToPixel(m_nDocumentWidthTwips, m_fZoom);
     long nDocumentHeightPixels = twipToPixel(m_nDocumentHeightTwips, m_fZoom);
     // Total number of rows / columns in this document.
     guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
-    GdkRectangle aVisibleArea = event->area;
-    cairo_t *pcairo = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(m_pDocView)));
+    GdkRectangle aVisibleArea;
+
+    gdk_cairo_get_clip_rectangle (pCairo, &aVisibleArea);
 
     aVisibleArea.x = pixelToTwip (aVisibleArea.x, m_fZoom);
     aVisibleArea.y = pixelToTwip (aVisibleArea.y, m_fZoom);
@@ -371,16 +372,14 @@ void LOKDocView_Impl::onExposedImpl(GdkEventExpose* event)
             {
                 Tile& currentTile = m_aTileBuffer.getTile(nRow, nColumn, m_fZoom);
                 GdkPixbuf* pPixBuf = currentTile.getBuffer();
-
-                gdk_cairo_set_source_pixbuf (pcairo, pPixBuf,
+                gdk_cairo_set_source_pixbuf (pCairo, pPixBuf,
                                              twipToPixel(aTileRectangleTwips.x, m_fZoom),
                                              twipToPixel(aTileRectangleTwips.y, m_fZoom));
-                cairo_paint(pcairo);
+                cairo_paint(pCairo);
             }
         }
     }
-
-    cairo_destroy(pcairo);
+    return FALSE;
 }
 
 void LOKDocView_Impl::signalKey(GdkEventKey* pEvent)
@@ -641,16 +640,15 @@ gboolean LOKDocView_Impl::signalMotionImpl(GdkEventButton* pEvent)
     return FALSE;
 }
 
-gboolean LOKDocView_Impl::renderOverlay(GtkWidget* pEventBox, GdkEventExpose* /*pEvent*/, LOKDocView* pDocView)
+gboolean LOKDocView_Impl::renderOverlay(GtkWidget* /*widget*/, cairo_t *cr, gpointer userdata)
 {
-    return pDocView->m_pImpl->renderOverlayImpl(pEventBox);
+    LOKDocView *pDocView = LOK_DOC_VIEW (userdata);
+    return pDocView->m_pImpl->renderOverlayImpl(cr);
 }
 
-gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
+gboolean LOKDocView_Impl::renderOverlayImpl(cairo_t *pCairo)
 {
 #if GTK_CHECK_VERSION(2,14,0) // we need gtk_widget_get_window()
-    cairo_t* pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
-
     if (m_bEdit && m_bCursorVisible && m_bCursorOverlayVisible && !isEmptyRectangle(m_aVisibleCursor))
     {
         if (m_aVisibleCursor.width < 30)
@@ -712,7 +710,6 @@ gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
         renderGraphicHandle(pCairo, m_aGraphicSelection, m_pGraphicHandle);
     }
 
-    cairo_destroy(pCairo);
 #endif
     return FALSE;
 }
@@ -1151,10 +1148,10 @@ static void lok_doc_view_init (LOKDocView* pDocView)
     pDocView->m_pImpl = new LOKDocView_Impl(pDocView);
 
     g_signal_connect(G_OBJECT(pDocView),
-                     "expose-event",
-                     G_CALLBACK(LOKDocView_Impl::onExposed), pDocView);
+                     "draw",
+                     G_CALLBACK(LOKDocView_Impl::renderDocument), pDocView);
     g_signal_connect(G_OBJECT(pDocView),
-                     "expose-event",
+                     "draw",
                      G_CALLBACK(LOKDocView_Impl::renderOverlay), pDocView);
     gtk_widget_add_events(GTK_WIDGET(pDocView),
                            GDK_BUTTON_PRESS_MASK
commit d85dcd775b14d66a0bfecf2e416c982d62c5d8bc
Author: Pranav Kant <pranavk at gnome.org>
Date:   Wed Jun 10 16:18:06 2015 +0530

    lokdocview, gtktiledviewer: Port to gtk3
    
    Change-Id: I57f2d7b9383790e5c34fc517a905dd537519598f

diff --git a/libreofficekit/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk
index 8a52068..31028a6 100644
--- a/libreofficekit/Executable_gtktiledviewer.mk
+++ b/libreofficekit/Executable_gtktiledviewer.mk
@@ -16,7 +16,14 @@ $(eval $(call gb_Executable_set_include,gtktiledviewer,\
 
 $(eval $(call gb_Executable_use_externals,gtktiledviewer,\
     boost_headers \
-    gtk \
+))
+
+$(eval $(call gb_Executable_add_cxxflags,gtktiledviewer,\
+    $$(GTK3_CFLAGS) \
+))
+
+$(eval $(call gb_Executable_add_libs,gtktiledviewer,\
+    $(GTK3_LIBS) \
 ))
 
 $(eval $(call gb_Executable_use_libraries,gtktiledviewer,\
diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk
index 9240953..71a77e9 100644
--- a/libreofficekit/Library_libreofficekitgtk.mk
+++ b/libreofficekit/Library_libreofficekitgtk.mk
@@ -11,15 +11,19 @@ $(eval $(call gb_Library_Library,libreofficekitgtk))
 
 $(eval $(call gb_Library_use_sdk_api,libreofficekitgtk))
 
-$(eval $(call gb_Library_use_externals,libreofficekitgtk,\
-    gtk \
-))
-
 $(eval $(call gb_Library_add_exception_objects,libreofficekitgtk,\
     libreofficekit/source/gtk/lokdocview \
     libreofficekit/source/gtk/tilebuffer \
 ))
 
+$(eval $(call gb_Library_add_cxxflags,libreofficekitgtk,\
+    $$(GTK3_CFLAGS) \
+))
+
+$(eval $(call gb_Library_add_libs,libreofficekitgtk,\
+    $(GTK3_LIBS) \
+))
+
 ifeq ($(OS),LINUX)
 $(eval $(call gb_Library_add_libs,libreofficekitgtk,\
     -ldl \
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 000c2fe..217ecb2 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -15,7 +15,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,libreofficekit,\
     CppunitTest_libreofficekit_tiledrendering \
 ))
 
-ifneq ($(ENABLE_GTK),)
+ifneq ($(ENABLE_GTK3),)
 $(eval $(call gb_Module_add_targets,libreofficekit,\
     Library_libreofficekitgtk \
     Executable_gtktiledviewer \
@@ -24,7 +24,7 @@ $(eval $(call gb_Module_add_targets,libreofficekit,\
 $(eval $(call gb_Module_add_targets,libreofficekit,\
     Executable_tilebench \
 ))
-endif # ($(ENABLE_GTK),)
+endif # ($(ENABLE_GTK3),)
 
 endif # ($(OS),LINUX)
 
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 4f74583..33d46ac 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -14,9 +14,7 @@
 #include <map>
 
 #include <boost/property_tree/json_parser.hpp>
-#include <gdk/gdk.h>
 #include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
 
 #include <LibreOfficeKit/LibreOfficeKitGtk.h>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -206,13 +204,13 @@ static gboolean signalFindbar(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpoin
     gtk_label_set_text(GTK_LABEL(pFindbarLabel), "");
     switch(pEvent->keyval)
     {
-        case GDK_Return:
+        case GDK_KEY_Return:
         {
             // Search forward.
             doSearch(/*bBackwards=*/false);
             return TRUE;
         }
-        case GDK_Escape:
+        case GDK_KEY_Escape:
         {
             // Hide the findbar.
             gtk_widget_hide(pFindbar);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 8cab47e..be3e424 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -13,8 +13,6 @@
 #include <vector>
 #include <string>
 
-#include <gdk/gdkkeysyms.h>
-
 #include <com/sun/star/awt/Key.hpp>
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKit.h>
@@ -333,7 +331,7 @@ void LOKDocView_Impl::onExposedImpl(GdkEventExpose* event)
     guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
     GdkRectangle aVisibleArea = event->area;
-    cairo_t *pcairo = gdk_cairo_create(GTK_WIDGET(m_pDocView)->window);
+    cairo_t *pcairo = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(m_pDocView)));
 
     aVisibleArea.x = pixelToTwip (aVisibleArea.x, m_fZoom);
     aVisibleArea.y = pixelToTwip (aVisibleArea.y, m_fZoom);
@@ -398,33 +396,33 @@ void LOKDocView_Impl::signalKey(GdkEventKey* pEvent)
 
     switch (pEvent->keyval)
     {
-    case GDK_BackSpace:
+    case GDK_KEY_BackSpace:
         nKeyCode = com::sun::star::awt::Key::BACKSPACE;
         break;
-    case GDK_Return:
+    case GDK_KEY_Return:
         nKeyCode = com::sun::star::awt::Key::RETURN;
         break;
-    case GDK_Escape:
+    case GDK_KEY_Escape:
         nKeyCode = com::sun::star::awt::Key::ESCAPE;
         break;
-    case GDK_Tab:
+    case GDK_KEY_Tab:
         nKeyCode = com::sun::star::awt::Key::TAB;
         break;
-    case GDK_Down:
+    case GDK_KEY_Down:
         nKeyCode = com::sun::star::awt::Key::DOWN;
         break;
-    case GDK_Up:
+    case GDK_KEY_Up:
         nKeyCode = com::sun::star::awt::Key::UP;
         break;
-    case GDK_Left:
+    case GDK_KEY_Left:
         nKeyCode = com::sun::star::awt::Key::LEFT;
         break;
-    case GDK_Right:
+    case GDK_KEY_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);
+        if (pEvent->keyval >= GDK_KEY_F1 && pEvent->keyval <= GDK_KEY_F26)
+            nKeyCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_KEY_F1);
         else
             nCharCode = gdk_keyval_to_unicode(pEvent->keyval);
     }
commit ea1daef7ff0fcd7b4b59858a4276918fe94a40d3
Author: Pranav Kant <pranavk at gnome.org>
Date:   Wed Jun 10 16:10:19 2015 +0530

    lokdocview: Create LOK context inside of lok_doc_view_new
    
    Change-Id: I675192d6bd6d10e6c7974a5de6f488f9a087ac32

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 24c577e..bdd2e9a 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -46,7 +46,7 @@ struct _LOKDocViewClass
 
 GType                          lok_doc_view_get_type               (void) G_GNUC_CONST;
 
-GtkWidget*                     lok_doc_view_new                    (LibreOfficeKit* pOffice );
+GtkWidget*                     lok_doc_view_new                    (const char* pPath);
 
 gboolean                       lok_doc_view_open_document          (LOKDocView* pDocView,
                                                                     char* pPath);
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index c8b47f7..4f74583 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -19,7 +19,6 @@
 #include <gtk/gtk.h>
 
 #include <LibreOfficeKit/LibreOfficeKitGtk.h>
-#include <LibreOfficeKit/LibreOfficeKitInit.h>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #ifndef g_info
@@ -53,8 +52,6 @@ GtkWidget* pFindbar;
 GtkWidget* pFindbarEntry;
 GtkWidget* pFindbarLabel;
 
-static LibreOfficeKit* pOffice;
-
 static void lcl_registerToolItem(GtkToolItem* pItem, const std::string& rName)
 {
     g_aToolItemCommandNames[pItem] = rName;
@@ -361,10 +358,6 @@ int main( int argc, char* argv[] )
         return 1;
     }
 
-    pOffice = lok_init( argv[1] );
-    if ( pOffice == NULL )
-        return 1;
-
     gtk_init( &argc, &argv );
 
     GtkWidget *pWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
@@ -469,7 +462,9 @@ int main( int argc, char* argv[] )
     gtk_box_pack_end(GTK_BOX(pVBox), pFindbar, FALSE, FALSE, 0);
 
     // Docview
-    pDocView = lok_doc_view_new( pOffice );
+    pDocView = lok_doc_view_new(argv[1]);
+    if (pDocView == NULL)
+        g_error ("Error while creating LOKDocView widget");
     g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
     g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
     g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
@@ -492,7 +487,7 @@ int main( int argc, char* argv[] )
 
     int bOpened = lok_doc_view_open_document( LOK_DOC_VIEW(pDocView), argv[2] );
     if (!bOpened)
-        g_error("main: lok_doc_view_open_document() failed with '%s'", pOffice->pClass->getError(pOffice));
+        g_error("main: lok_doc_view_open_document() failed");
     assert(lok_doc_view_get_document(LOK_DOC_VIEW(pDocView)));
 
     // GtkComboBox requires gtk 2.24 or later
@@ -507,8 +502,6 @@ int main( int argc, char* argv[] )
 
     gtk_main();
 
-    pOffice->pClass->destroy( pOffice );
-
     return 0;
 }
 
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d3d14a2..8cab47e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/awt/Key.hpp>
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKit.h>
+#include <LibreOfficeKit/LibreOfficeKitInit.h>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <LibreOfficeKit/LibreOfficeKitGtk.h>
 #include <rsc/rsc-vcl-shared-types.hxx>
@@ -1177,14 +1178,16 @@ static void lok_doc_view_init (LOKDocView* pDocView)
 
 /**
  * lok_doc_view_new:
- * @pOffice: The LibreOfficeKit context.
+ * @pPath: The LibreOfficeKit context.
  *
  * Returns: The #LOKDocView widget instance.
  */
-SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new( LibreOfficeKit* pOffice )
+SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new(const char* pPath)
 {
-    LOKDocView* pDocView = LOK_DOC_VIEW(gtk_type_new(lok_doc_view_get_type()));
-    pDocView->m_pImpl->m_pOffice = pOffice;
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_object_new(LOK_TYPE_DOC_VIEW, NULL));
+    pDocView->m_pImpl->m_pOffice = lok_init (pPath);
+    if (pDocView->m_pImpl->m_pOffice == NULL)
+        return NULL;
     return GTK_WIDGET( pDocView );
 }
 


More information about the Libreoffice-commits mailing list