[Libreoffice-commits] core.git: 4 commits - libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/source
Pranav Kant
pranavk at gnome.org
Mon Jun 15 03:10:30 PDT 2015
libreofficekit/Executable_gtktiledviewer.mk | 9 +-
libreofficekit/Library_libreofficekitgtk.mk | 12 +-
libreofficekit/Module_libreofficekit.mk | 4
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 82 +++++++++-----------
libreofficekit/source/gtk/lokdocview.cxx | 79 +++++++------------
5 files changed, 90 insertions(+), 96 deletions(-)
New commits:
commit 101b616c7a2ee90b6d09eedd7a7543a63f237c97
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 22d8775..580d5f6 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++ )
{
@@ -353,22 +353,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 );
@@ -391,27 +394,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");
@@ -422,7 +436,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);
@@ -432,10 +447,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);
@@ -465,8 +483,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 0bb2ae2d00a280cef4cc0c148c7c3c0050709219
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 dc5783b..22d8775 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
@@ -153,13 +148,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;
}
@@ -265,11 +258,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.
@@ -285,8 +276,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(
@@ -344,7 +333,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[] )
{
@@ -387,8 +375,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 );
@@ -403,7 +389,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);
@@ -492,15 +477,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 028953c..ca7996f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -651,7 +651,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)
@@ -713,7 +712,6 @@ gboolean LOKDocView_Impl::renderOverlayImpl(cairo_t *pCairo)
renderGraphicHandle(pCairo, m_aGraphicSelection, m_pGraphicHandle);
}
-#endif
return FALSE;
}
@@ -1017,9 +1015,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:
@@ -1070,22 +1066,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 256a9cef8bdd89b90f0c371df8f849c567f84213
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 1f77f1b..dc5783b 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -476,6 +476,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 046852f..028953c 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.
@@ -320,21 +320,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);
@@ -374,16 +375,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)
@@ -644,16 +643,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)
@@ -715,7 +713,6 @@ gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
renderGraphicHandle(pCairo, m_aGraphicSelection, m_pGraphicHandle);
}
- cairo_destroy(pCairo);
#endif
return FALSE;
}
@@ -1154,10 +1151,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 9b3679301fe4ec4c972b68ef2cbbdd23cbc79053
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 2ce541d..1f77f1b 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>
@@ -208,13 +206,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 44398c4..046852f 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>
@@ -336,7 +334,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);
@@ -401,33 +399,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);
}
More information about the Libreoffice-commits
mailing list